R# 4.0.739 Incorrect "possible null reference" warning

Apologies; jira won't let me in.

I have the following code;

ServicesSection servicesSection =
ConfigurationManager.GetSection("system.serviceModel/services")
as ServicesSection;

if (null == servicesSection ||
null == servicesSection.ElementInformation ||
!servicesSection.ElementInformation.IsPresent ||
null == servicesSection.ElementInformation.Properties ||
servicesSection.ElementInformation.Properties.Count == 0 ||
null ==
servicesSection.ElementInformation.Properties[string.Empty])
throw new ConfigurationErrorsException("cannot find valid
services configuration section");

ServiceElementCollection servicesCollection =
servicesSection.ElementInformation.Properties[string.Empty].Value
as ServiceElementCollection;

servicesSection.ElementInformation.Properties[string.Empty].Value is flagged
as a possible null reference exception when I believe I've performed all the
checks I can. It's complaining about the possible of ElementInformation
being null, which as you can see from the checks I am specifically looking
for.

Please sign in to leave a comment.