ReSharper says “Check if ‘UserHostAddress’ is not null” when I’m accessing HttpContext.Current.Request.UserHostAddress (it is in a try/catch block).
Within another method get the following property from the request object:
HttpContext.Current.Request.RawUrl
How does ReSharper determine or “know” that Request cannot be null? Or Current? Or HttpContext?
Maybe it is a bad example with this framework object chain but I think you get the point.
R# uses its included External Annotations to provide these code annotations for types within the .NET Framework (like your mentioned ASP.NET classes).
The reason, why Jetbrains annotated for example
HttpContext.Currentas nullable is that in an console application (an application without HTTP context)HttpContext.Currentreturnsnull.