messagetemplates / messagetemplates-csharp

A C# implementation of Message Templates

Home Page:http://messagetemplates.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support net40

adamchester opened this issue · comments

This implementation was recently re-extracted from Serilog, and an unfortunate side effect was that we dropped support for net40. Serilog is typically used in apps where newer runtime versions are easier to target, and dropping net40 made sense there. However, Message templates can be used in libraries where support for a wider range of framework versions are more important.

Examples of existing libraries that may target older net frameworks and could benefit from message templates are: web servers (eg. suave), actor frameworks (eg. Akka.net), libLog, build tools (eg. Fake).

The main issues for supporting net40 is use of System.Reflection and collections (eg. IReadOnlyDictionary<T>), which were solved previously by a few well-placed #if directives.

A pain in serilog (1.5.x) was the lack of binary compatibility between net40 and net45. For example, the use of IReadOnlyDictionary<T> (only available in net45+) in the public interface makes it impossible for net40 targets to execute against net45 binaries. Message templates C# inherited this problem from Serilog, but we are pre 1.0 and can avoid that mistake by changing the public API types to only use types available in all supported targets.

/cc @nblumhardt thoughts?

I copied src from an old version that did support net40 and made PR #5.

I don't want to pull #5 because it's a mess with multiple unrelated changes and whitespace everywhere, but at least it shows how net40 could be done relatively easily.

Fixed via #6