I have the following code in my C# application.
DateTimeFormatInfo.CurrentInfo.DayNames
ReSharper 7.1.1 is highlighting the fact that the DateTimeFormatInfo.CurrentInfo could cause a null reference exception.
Under what circumstances would this occur? Or is this just a mistake on ReSharper's part believing that any object whose property you access should be null checked?
ReSharper is most probably just doing lexical analysis here and nothing deeper.
Since
DateTimeFormatInfois a class, a variable of this type can benull. Which means that the instance returned byDateTimeFormatInfo.CurrentInfocan be anullreference.That's the error you are getting.
ReSharper doesn't understand that the method was coded such that it will not return a
nullreference, so it gives a warning.Don't take the messages from ReSharper as scripture...