You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for IFormatProvider used to convert string to other types
Also introduce a new `ConfigurationReaderOptions` class to avoid `ReadFrom.Configuration()` methods exponential growth when adding new options.
All _older_ `Configuration()` methods go through the newly introduced `Configuration(LoggerSettingsConfiguration, IConfiguration, ConfigurationReaderOptions)` method that takes an `ConfigurationReaderOptions` instance.
Older methods explicitly set the `FormatProvider` option to `null` in order to preserve backward compatibility.
By using the new `Configuration()` method, users opt into the new default of having the invariant culture as the format provider.
Note: the `= null` default value in the `Configuration()` method taking a `DependencyContext` has been removed in order to make sure the CS0121 compilation does not occur:
> [CS0121] The call is ambiguous between the following methods or properties: 'ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration, IConfiguration, DependencyContext)' and 'ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration, IConfiguration, ConfigurationReaderOptions)'
Fixes#325
@@ -282,6 +285,8 @@ Some Serilog packages require a reference to a logger configuration object. The
282
285
283
286
When the configuration specifies a discrete value for a parameter (such as a string literal), the package will attempt to convert that value to the target method's declared CLR type of the parameter. Additional explicit handling is provided for parsing strings to `Uri`, `TimeSpan`, `enum`, arrays and custom collections.
284
287
288
+
Since version 4.0.0, conversion will use the invariant culture (`CultureInfo.InvariantCulture`) as long as the `ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptions options)` method is used. Obsolete methods use the current culture to preserve backward compatibility.
289
+
285
290
### Static member support
286
291
287
292
Static member access can be used for passing to the configuration argument via [special](https://github.com/serilog/serilog-settings-configuration/blob/dev/test/Serilog.Settings.Configuration.Tests/StringArgumentValueTests.cs#L35) syntax:
@@ -377,8 +382,9 @@ public class Startup : FunctionsStartup
thrownewArgumentException("The assemblies array must not be empty.",nameof(assemblies));
23
+
}
24
+
25
+
/// <summary>
26
+
/// Initialize a new instance of the <see cref="ConfigurationReaderOptions"/> class.
27
+
/// </summary>
28
+
/// <remarks>Prefer the constructor taking explicit assemblies: <see cref="ConfigurationReaderOptions(System.Reflection.Assembly[])"/>. It's the only one supporting single-file publishing.</remarks>
/// Initialize a new instance of the <see cref="ConfigurationReaderOptions"/> class.
35
+
/// </summary>
36
+
/// <param name="dependencyContext">
37
+
/// The dependency context from which sink/enricher packages can be located. If <see langword="null"/>, the platform default will be used.
38
+
/// </param>
39
+
/// <remarks>Prefer the constructor taking explicit assemblies: <see cref="ConfigurationReaderOptions(System.Reflection.Assembly[])"/>. It's the only one supporting single-file publishing.</remarks>
/// Initialize a new instance of the <see cref="ConfigurationReaderOptions"/> class.
44
+
/// </summary>
45
+
/// <param name="configurationAssemblySource">Defines how the package identifies assemblies to scan for sinks and other types.</param>
46
+
/// <remarks>Prefer the constructor taking explicit assemblies: <see cref="ConfigurationReaderOptions(System.Reflection.Assembly[])"/>. It's the only one supporting single-file publishing.</remarks>
0 commit comments