I have the following code:
private static LogLevel? _logLevel = null; public static LogLevel LogLevel { get { if (!_logLevel.HasValue) { _logLevel = readLogLevelFromFile(); } return _logLevel.Value; } } private static LogLevel readLogLevelFromFile() { ... }
I get a ReSharper warning in the return about a possible System.InvalidOperationException , and I suggest checking _logLevel to see if it is null first. However, readLogLevelFromFile returns LogLevel , not LogLevel? so the return cannot be reached when _logLevel is null . Is this just a ReSharper oversight, or am I missing something?
null c # nullable resharper
Sarah vessels
source share