Consider the following C#.Net code:
using System.Xml;
internal class MyXmlReaderClass : XmlReader
{
private readonly XmlReader _innerReader;
public MyXmlReaderClass(...other_parameters... , XmlReader innerReader)
{
_innerReader = innerReader;
}
//... lots of code has been left out, here ...
public override string LocalName
{
get { return _innerReader.LocalName; }
}
//... lots more code has been left out, here ...
}
In the property, LocalName
, ReSharper places an underline under the type, string
, with the warning, 'string' is (explicitly or implicitly) [NotNull].
I thought that I understood the concept in play regarding nullable objects. I have been able to refactor most of these issues out of my code, except in this case.
If I understand my world correctly, the base class (XmlReader) is what ReSharper identifies as [NotNull]
. That means that ReSharper believes that my override of the property could possibly return a null while the base never returns a null.
I am having a difficult time wrapping my mind around how I could override the base class property LocalName
with some sort of override, such that there is no conflict in the property between the base class and the derived class.
My question is a multiple-part, "What exactly is ReSharper identifying, and how do I fix the inconsistency?"
Yes, I have searched high and low through StackOverflow and used Google yet cannot find this specific example.
Thank you.