diff --git a/Serilog.sln.DotSettings b/Serilog.sln.DotSettings
index a84b8ae38..5fe3d28ac 100644
--- a/Serilog.sln.DotSettings
+++ b/Serilog.sln.DotSettings
@@ -50,6 +50,7 @@
WARNING
HINT
ERROR
+ SUGGESTION
ERROR
ERROR
ERROR
diff --git a/src/Serilog/Capturing/PropertyValueConverter.cs b/src/Serilog/Capturing/PropertyValueConverter.cs
index d244271c9..3744b50e8 100644
--- a/src/Serilog/Capturing/PropertyValueConverter.cs
+++ b/src/Serilog/Capturing/PropertyValueConverter.cs
@@ -247,6 +247,7 @@ bool TryConvertValueTuple(object value, Destructuring destructuring, Type valueT
definition == typeof(ValueTuple<,,,,>) || definition == typeof(ValueTuple<,,,,,>) ||
definition == typeof(ValueTuple<,,,,,,>))
#else
+ // ReSharper disable once PossibleNullReferenceException
var defn = definition.FullName;
if (defn == "System.ValueTuple`1" || defn == "System.ValueTuple`2" ||
defn == "System.ValueTuple`3" || defn == "System.ValueTuple`4" ||
diff --git a/src/Serilog/Context/LogContext.cs b/src/Serilog/Context/LogContext.cs
index 7baaa9038..1be79e705 100644
--- a/src/Serilog/Context/LogContext.cs
+++ b/src/Serilog/Context/LogContext.cs
@@ -254,6 +254,8 @@ public DisposableObjectHandle(object o) : base(o)
public override object InitializeLifetimeService()
{
var lease = (ILease)base.InitializeLifetimeService();
+ // ReSharper disable once PossibleNullReferenceException
+ // not 100% sure this will never occur ...
lease.Register(LifeTimeSponsor);
return lease;
}
diff --git a/src/Serilog/Core/Pipeline/MessageTemplateCache.cs b/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
index 459a224a5..225ce0e73 100644
--- a/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
+++ b/src/Serilog/Core/Pipeline/MessageTemplateCache.cs
@@ -51,6 +51,8 @@ public MessageTemplate Parse(string messageTemplate)
return _innerParser.Parse(messageTemplate);
#if HASHTABLE
+ // ReSharper disable once InconsistentlySynchronizedField
+ // ignored warning because this is by design
var result = (MessageTemplate)_templates[messageTemplate];
if (result != null)
return result;
diff --git a/src/Serilog/Settings/KeyValuePairs/KeyValuePairSettings.cs b/src/Serilog/Settings/KeyValuePairs/KeyValuePairSettings.cs
index b9ec1f059..69c619efd 100644
--- a/src/Serilog/Settings/KeyValuePairs/KeyValuePairSettings.cs
+++ b/src/Serilog/Settings/KeyValuePairs/KeyValuePairSettings.cs
@@ -148,7 +148,7 @@ where matchCallables.IsMatch(wt.Key)
if (callableDirectives.Any())
{
- var configurationAssemblies = LoadConfigurationAssemblies(directives);
+ var configurationAssemblies = LoadConfigurationAssemblies(directives).ToList();
foreach (var receiverGroup in callableDirectives.GroupBy(d => d.ReceiverType))
{
diff --git a/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs b/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
index 6534a35ef..bea70a67b 100644
--- a/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
+++ b/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
@@ -24,7 +24,7 @@ public class PropertyValueConverterTests
[Fact]
public async Task MaximumDepthIsEffectiveAndThreadSafe()
{
- var _converter = new PropertyValueConverter(3, 1000, 1000, Enumerable.Empty(), Enumerable.Empty(), false);
+ var converter = new PropertyValueConverter(3, 1000, 1000, Enumerable.Empty(), Enumerable.Empty(), false);
var barrier = new Barrier(participantCount: 3);
@@ -63,7 +63,7 @@ void DoThreadTest(object logObject, Action assertAction)
{
barrier.SignalAndWait();
- var propValue = _converter.CreatePropertyValue(logObject, true);
+ var propValue = converter.CreatePropertyValue(logObject, true);
Assert.IsType(propValue);
diff --git a/test/Serilog.Tests/Context/LogContextTests.cs b/test/Serilog.Tests/Context/LogContextTests.cs
index 7fc0b62df..3e46c1f00 100644
--- a/test/Serilog.Tests/Context/LogContextTests.cs
+++ b/test/Serilog.Tests/Context/LogContextTests.cs
@@ -31,7 +31,9 @@ static LogContextTests()
public LogContextTests()
{
#if REMOTING
+ // ReSharper disable AssignNullToNotNullAttribute
CallContext.LogicalSetData(typeof(LogContext).FullName, null);
+ // ReSharper restore AssignNullToNotNullAttribute
#endif
}
@@ -266,7 +268,9 @@ public void DoesNotPreventCrossDomainCalls()
{
domain = AppDomain.CreateDomain("LogContextTests", null, AppDomain.CurrentDomain.SetupInformation);
+ // ReSharper disable AssignNullToNotNullAttribute
var callable = (RemotelyCallable)domain.CreateInstanceAndUnwrap(typeof(RemotelyCallable).Assembly.FullName, typeof(RemotelyCallable).FullName);
+ // ReSharper restore AssignNullToNotNullAttribute
using (LogContext.PushProperty("Anything", 1001))
Assert.True(callable.IsCallable());
@@ -381,4 +385,4 @@ public bool IsCallable()
}
}
#endif
-}
\ No newline at end of file
+}
diff --git a/test/Serilog.Tests/MethodOverloadConventionTests.cs b/test/Serilog.Tests/MethodOverloadConventionTests.cs
index 1c03f55f6..523ec05ba 100644
--- a/test/Serilog.Tests/MethodOverloadConventionTests.cs
+++ b/test/Serilog.Tests/MethodOverloadConventionTests.cs
@@ -305,9 +305,7 @@ public void ValidateIsEnabledMethods(Type loggerType)
Assert.Equal(parameter.Name, "level");
Assert.Equal(parameter.ParameterType, typeof(LogEventLevel));
- CollectingSink sink;
-
- var logger = GetLogger(loggerType, out sink, LogEventLevel.Information);
+ var logger = GetLogger(loggerType, out _, LogEventLevel.Information);
var falseResult = InvokeMethod(method, logger, new object[] { LogEventLevel.Verbose });
@@ -503,6 +501,7 @@ void ForContextMethod4(MethodInfo method)
TestForContextResult(method, logger, normalResult: enrichedLogger);
}
+ // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
void TestForContextResult(MethodInfo method, ILogger logger, object normalResult)
{
Assert.NotNull(normalResult);
@@ -761,10 +760,7 @@ static void InvokeConventionMethod(
static void InvokeConventionMethod(MethodInfo method, Type[] typeArgs, object[] parameters)
{
- CollectingSink sink;
- LogEventLevel level;
-
- InvokeConventionMethod(method, typeArgs, parameters, out level, out sink);
+ InvokeConventionMethod(method, typeArgs, parameters, out _, out _);
}
static void InvokeConventionMethodAndTest(MethodInfo method, Type[] typeArgs, object[] parameters)
@@ -889,6 +885,7 @@ static object InvokeMethod(
return method.Invoke(instance, parameters);
}
+ // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
static void EvaluateSingleResult(LogEventLevel level, CollectingSink results)
{
//evaluate single log event
@@ -901,9 +898,7 @@ static void EvaluateSingleResult(LogEventLevel level, CollectingSink results)
static ILogger GetLogger(Type loggerType)
{
- CollectingSink sink;
-
- return GetLogger(loggerType, out sink);
+ return GetLogger(loggerType, out _);
}
static ILogger GetLogger(Type loggerType, out CollectingSink sink, LogEventLevel level = LogEventLevel.Verbose)
@@ -940,4 +935,4 @@ static ILogger GetLogger(Type loggerType, out CollectingSink sink, LogEventLevel
throw new ArgumentException($"Logger Type of {loggerType} is not supported");
}
}
-}
\ No newline at end of file
+}
diff --git a/test/Serilog.Tests/Parsing/MessageTemplateParserTests.cs b/test/Serilog.Tests/Parsing/MessageTemplateParserTests.cs
index fdbe8de05..9e68fd29c 100644
--- a/test/Serilog.Tests/Parsing/MessageTemplateParserTests.cs
+++ b/test/Serilog.Tests/Parsing/MessageTemplateParserTests.cs
@@ -11,6 +11,7 @@ static MessageTemplateToken[] Parse(string messsageTemplate)
return new MessageTemplateParser().Parse(messsageTemplate).Tokens.ToArray();
}
+ // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
static void AssertParsedAs(string message, params MessageTemplateToken[] messageTemplateTokens)
{
var parsed = Parse(message);
diff --git a/test/Serilog.Tests/Settings/KeyValuePairSettingsTests.cs b/test/Serilog.Tests/Settings/KeyValuePairSettingsTests.cs
index 91c1da789..9b7e7f9fd 100644
--- a/test/Serilog.Tests/Settings/KeyValuePairSettingsTests.cs
+++ b/test/Serilog.Tests/Settings/KeyValuePairSettingsTests.cs
@@ -313,12 +313,14 @@ public void LoggingLevelSwitchCanBeUsedForMinimumLevelOverrides()
systemLogger.Write(Some.WarningEvent());
Assert.False(evt is null, "LoggingLevelSwitch initial level was Warning for logger System.*. It should log Warning messages for SourceContext System.Bar");
+ // ReSharper disable HeuristicUnreachableCode
evt = null;
var controlSwitch = DummyWithLevelSwitchSink.ControlLevelSwitch;
controlSwitch.MinimumLevel = LogEventLevel.Information;
systemLogger.Write(Some.InformationEvent());
Assert.False(evt is null, "LoggingLevelSwitch level was changed to Information for logger System.*. It should now log Information events for SourceContext System.Bar.");
+ // ReSharper restore HeuristicUnreachableCode
}
}
diff --git a/test/Serilog.Tests/Settings/SettingValueConversionsTests.cs b/test/Serilog.Tests/Settings/SettingValueConversionsTests.cs
index 9dacbe050..17d2cfcfc 100644
--- a/test/Serilog.Tests/Settings/SettingValueConversionsTests.cs
+++ b/test/Serilog.Tests/Settings/SettingValueConversionsTests.cs
@@ -33,8 +33,8 @@ public void EmptyStringValuesConvertToNullIfTargetIsNullable()
[Fact]
public void ValuesConvertToNullableTimeSpan()
{
- var result = (System.TimeSpan?)SettingValueConversions.ConvertToType("00:01:00", typeof(System.TimeSpan?));
- Assert.Equal(System.TimeSpan.FromMinutes(1), result);
+ var result = (TimeSpan?)SettingValueConversions.ConvertToType("00:01:00", typeof(TimeSpan?));
+ Assert.Equal(TimeSpan.FromMinutes(1), result);
}
[Fact]
diff --git a/test/TestDummies/DummyRollingFileAuditSink.cs b/test/TestDummies/DummyRollingFileAuditSink.cs
index 3a8355a8d..e8618d026 100644
--- a/test/TestDummies/DummyRollingFileAuditSink.cs
+++ b/test/TestDummies/DummyRollingFileAuditSink.cs
@@ -8,7 +8,9 @@ namespace TestDummies
public class DummyRollingFileAuditSink : ILogEventSink
{
[ThreadStatic]
+ // ReSharper disable ThreadStaticFieldHasInitializer
public static List Emitted = new List();
+ // ReSharper restore ThreadStaticFieldHasInitializer
public void Emit(LogEvent logEvent)
{
diff --git a/test/TestDummies/DummyRollingFileSink.cs b/test/TestDummies/DummyRollingFileSink.cs
index 5e6bde88b..bc98ed219 100644
--- a/test/TestDummies/DummyRollingFileSink.cs
+++ b/test/TestDummies/DummyRollingFileSink.cs
@@ -8,7 +8,9 @@ namespace TestDummies
public class DummyRollingFileSink : ILogEventSink
{
[ThreadStatic]
+ // ReSharper disable ThreadStaticFieldHasInitializer
public static List Emitted = new List();
+ // ReSharper restore ThreadStaticFieldHasInitializer
public void Emit(LogEvent logEvent)
{
diff --git a/test/TestDummies/DummyWithLevelSwitchSink.cs b/test/TestDummies/DummyWithLevelSwitchSink.cs
index 707574ce1..4e1d76fc3 100644
--- a/test/TestDummies/DummyWithLevelSwitchSink.cs
+++ b/test/TestDummies/DummyWithLevelSwitchSink.cs
@@ -16,7 +16,9 @@ public DummyWithLevelSwitchSink(LoggingLevelSwitch loggingControlLevelSwitch)
public static LoggingLevelSwitch ControlLevelSwitch;
[ThreadStatic]
+ // ReSharper disable ThreadStaticFieldHasInitializer
public static List Emitted = new List();
+ // ReSharper restore ThreadStaticFieldHasInitializer
public void Emit(LogEvent logEvent)
{
diff --git a/test/TestDummies/DummyWrappingSink.cs b/test/TestDummies/DummyWrappingSink.cs
index 9d7f96681..cd15d8c33 100644
--- a/test/TestDummies/DummyWrappingSink.cs
+++ b/test/TestDummies/DummyWrappingSink.cs
@@ -8,7 +8,9 @@ namespace TestDummies
public class DummyWrappingSink : ILogEventSink
{
[ThreadStatic]
+ // ReSharper disable ThreadStaticFieldHasInitializer
public static List Emitted = new List();
+ // ReSharper restore ThreadStaticFieldHasInitializer
private readonly ILogEventSink _sink;
@@ -23,4 +25,4 @@ public void Emit(LogEvent logEvent)
_sink.Emit(logEvent);
}
}
-}
\ No newline at end of file
+}