Extension methods not taken into account during analysis
Hi,
Is there a way to configure ReSharper to take into account my extension methods while analyzing the code?
I created this extension method:
public static bool IsNullOrEmpty<T>( this List<T> source )
{
return source == null || source.Count == 0;
}
When I use it (see below), I get a warning (Possible NullReferenceException) that is irrelevant.
public void DoSomething(IEnumerable<int> collection)
{
var list = collection?.ToList();
if (!list.IsNullOrEmpty())
{
foreach (var item in list) // warning here
{
// Do something
}
}
}
I'm using ReSharper 10.0.2
Thanks!
Please sign in to leave a comment.
Use the ContractAnnotation attribute:
[ContractAnnotation("null => true")]public static bool IsNullOrEmpty<T>( this List<T> source )