c# - Resharper ContractAnnotation for null-check not eliminating NRE warning -
i'm having problem extension method, annotated contractannotation tell r# null-ness of object doesn't result in nre warning going away. here's how projects laid out:
project1: jetbrainsextensions has r# annotations class defines contractannotation
project2: mybaselibrary references project1 , has extension method this:
[contractannotation("null => true; notnull => false")] public static bool isnull(this object aobject) { return referenceequals(null, aobject); }
project3: mybusinesslogic using mybaselibrary project , wants this:
if (myvariable.isnull()) return; myvariable.dostuff();
the line: myvariable.dostuff(); warning there's possible null reference exception.
i've followed advice listed in many/all of related stackoverflow posts regarding how annotation should written. i've tried:
[contractannotation("aobject:null => true; aobject:notnull => false")]
and
[contractannotation("aobject:null => true")]
i've tried:
if (myvariable.isnull()) return; else myvariable.dosomething();
thinking if/else construct save it. no dice.
i'm suspecting issue multi-project/assembly way i'm packaging it, i'm not entirely sure. idea do?
update: i'm using reshaper 8.2. i've tried putting r# annotation inside businesslogic project , i've put new extension method inside project well. neither of have worked remove nre.
Comments
Post a Comment