How does one use the "Value cannot be null" attribute feature?
Under Resharper 3.0 there are options for ["Value cannot be null" attribute type name] and ["Value can be null" attribute type name] . I cannot find any documentation on what these are for or how to use them. Searching via Google, and these forums has been fruitless. Help?
Please sign in to leave a comment.
Hmmm. I think I figured it out myself. Define some attributes:
public class NonNullableAttribute : Attribute {}
public class NullableAttribute : Attribute { }
private static object SomeMethod( string someText)
{
return null; // do stuff
}
And then set the options in Resharper and it highlights stuff. Cool! But what if I have multiple attributes? For example, if my project utilizes a 3rd party library that defines nonnullable/nullable attributes and my project also defines such attributes. Can I specify multiple attributes using a delimiter?
Hello Jim,
This is a known issue with nullable (and all other) attributes which we are
going to address in ReSharper vNext
You can use existing attributes from the 3rd party library meanwhile. Yes,
I know that if you have 2 libraries with different attributes, this doesn't
work, but stil...
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
JB> Hmmm. I think I figured it out myself. Define some attributes:
JB>
JB> public class NonNullableAttribute : Attribute {}
JB> public class NullableAttribute : Attribute { }
JB>
JB> private static object SomeMethod( string someText)
JB> {
JB> return null; // do stuff
JB> }
JB> And then set the options in Resharper and it highlights stuff. Cool!
JB> But what if I have multiple attributes? For example, if my project
JB> utilizes a 3rd party library that defines nonnullable/nullable
JB> attributes and my project also defines such attributes. Can I
JB> specify multiple attributes using a delimiter?
JB>