Why does "Conditional access qualifier expression is known to be not null" trigger?

I have this code where I attempt to get the remote endpoint IP address from a WCF Service for debugging/logging:

var endpoint = (RemoteEndpointMessageProperty)OperationContext.Current?.IncomingMessageProperties?[RemoteEndpointMessageProperty.Name];

The ?[] conditional element access triggers the above mentioned rule:

 

However, looking at the reference sources, it seems that IncomingMessageProperties could very well be null:

        public MessageProperties IncomingMessageProperties
        {
            get
            {
                Message message = this.clientReply ?? this.request;
                if (message != null)
                    return message.Properties;
                else
                    return null;
            }
        }

 

https://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/OperationContext.cs,c1b61824747e04f0

 

Is this a bug or am I missing something?

 

1 comment
Comment actions Permalink
Official comment

Hello Andreas,

 

thank you for the feedback.

We've fixed the issue as part of External Annotation package.

Thank you.

Please sign in to leave a comment.