-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add support for custom types in arrays and custom collections #201
Conversation
3.0 Release
3.0.1 Release
3.1.0 Release
@@ -45,7 +45,7 @@ public JsonStringConfigProvider(string json) : base(new JsonConfigurationSource | |||
|
|||
public override void Load() | |||
{ | |||
Load(StringToStream(_json)); | |||
Load(StringToStream(_json.Fix())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
netcore3.0 System.Text.Json issue
@@ -63,13 +63,20 @@ public static LoggerConfiguration WithDummyThreadId(this LoggerEnrichmentConfigu | |||
|
|||
public static LoggerConfiguration DummyRollingFile( | |||
this LoggerSinkConfiguration loggerSinkConfiguration, | |||
List<string> objectBinding, | |||
List<Binding> objectBinding, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nblumhardt In fact, a test using this method should have failed because it sets json incorrectly:
var json = @"{
""Serilog"": {
""Using"": [""TestDummies""],
""WriteTo"": [{
""Name"": ""DummyRollingFile"",
""Args"": {""pathFormat"" : ""C:\\"",
""objectBinding"" : [ { ""foo"" : ""bar"" }, { ""abc"" : ""xyz"" } ] }
}]
}
}";
objectBinding
is not a array of strings, it is array of objects. I came across this error when adding support for arrays of custom types. objectBinding
parameter was initialized incorrectly.
@@ -262,6 +237,31 @@ string GetSectionName(IConfigurationSection s) | |||
} | |||
} | |||
|
|||
internal static IConfigurationArgumentValue GetArgumentValue(IConfigurationSection argumentSection, IReadOnlyCollection<Assembly> configurationAssemblies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it began to be used in another place
return result; | ||
} | ||
|
||
bool TryCreateContainer(out object result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If false fallbacks to ms config binding implementation.
@nblumhardt Could you please find the time to see this PR? |
@@ -8,5 +8,15 @@ public static object LiteralValue(this LogEventPropertyValue @this) | |||
{ | |||
return ((ScalarValue)@this).Value; | |||
} | |||
|
|||
// netcore3.0 error: | |||
// Could not parse the JSON file. System.Text.Json.JsonReaderException : ''' is an invalid start of a property name. Expected a '"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do these come from? (Would be better to fix the source JSON if possible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source json does not need to be changed. There are many tests that test the simplified syntax. The problem is not in the tests, but in the fact that the new serializer, in principle, does not support the simplified syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Perhaps ToValidJson()
would be more descriptive here? Since it's exploiting some fairly questionable JSON parsing on the earlier platform, we could get rid of the conditional and just use the same method on all platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I'm aware of; the code is in the test project (so the changes are on the .NET Core side)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand. The simplified syntax should continue to work. Tests for it should remain, it makes no sense to rewrite them.
just use the same method on all platforms?
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in #203
Thanks for the nudge @sungam3r - I'm maxed out currently but will try to get back to this shortly, unless another of the maintainers of this repo gets here first :-) Changes seem good. Just for context, is there a sink we fail to configure currently because of this? |
I needed this in my own project. I wanted to configure destructuring policy (not a sink) accepting a list of types (restrictions). |
<AssemblyName>Serilog.Settings.Configuration.Tests</AssemblyName> | ||
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile> | ||
<SignAssembly>true</SignAssembly> | ||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(TargetFramework)' == 'net452'"> | ||
<PropertyGroup Condition="'$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net452'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net451
isn't in <TargetFrameworks>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in #203
<Authors>Serilog Contributors</Authors> | ||
<TargetFrameworks>netstandard2.0;net451;net461</TargetFrameworks> | ||
<TargetFrameworks>netstandard2.0;net451;net452;net461</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for the additional target framework here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this target because I saw references to it in the conditions.
add new test platforms and unify msbuild conditional properties minor code cleanup PackageIcon instead of PackageIconUrl fix for simplified syntax on netcore3.0 fix SinkWithConfigurationBindingArgument test (wrong argument type)
e632d77
to
63efc49
Compare
I accidentally made a rebase on the wrong branch. So I created a new PR - #203 |
Also: