Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying the Serilog assembly is needed when passing the name of an interface implementation #81

Closed
tsimbalar opened this issue Jan 18, 2018 · 1 comment

Comments

@tsimbalar
Copy link
Member

tsimbalar commented Jan 18, 2018

When a sink/enrichment/filtering method accepts a parameter which is an interface, the different settings providers accept as a value "the qualified name of an implementation".

For instance, to specify an implementation of Serilog.Formatting.ITextFormatter such as Serilog.Formatting.Json.JsonFormatter, the following value can be passed : "Serilog.Formatting.Json.JsonFormatter, Serilog" , for instance :

{
  "Serilog": {
    "Using": [ "TestDummies" ],
    "WriteTo": [
      {
        "Name": "DummyWithFormatter",
        "Args": {
          "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
        }
      }
    ]
  }
}

It turns out that the AppSettings provider does not require the assembly name for methods coming from the Serilog assembly, and this can be used :

  <appSettings>
    <add key="serilog:using:TestDummies" value="TestDummies" />
    <add key="serilog:write-to:DummyWithFormatter.formatter" value="Serilog.Formatting.Json.JsonFormatter" />
  </appSettings>

For consistency it would be nice if Serilog.Settings.Configuration behaved the same and did not require to specify the assembly name Serilog for types that come from that assembly.

(I have found this edge case whil working on serilog/serilog#1053 and have a failing test case here :
https://github.com/tsimbalar/serilog-settings-comparison/blob/b547207ebace1dc3e7283d1dba231132e7de0a3b/test/Serilog.Settings.Comparison.Tests/3-Advanced%20settings%20formats/331_ImplementationDefaultConstructor.cs#L21-L36
)

It looks lik serilog/serilog#1065 may be similar.

@MV10
Copy link
Contributor

MV10 commented May 6, 2018

Tagging into this issue, I may do something about it shortly. My recent little Roslyn adventure led me to look more closely at a variety of ways to resolve various relationships between assemblies, types, and namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants