Search code examples
c#annotationsresharperrider

How set condition Jetbrains.Annotations for Task<TType>


I want to give to analyzer information about nullable or not item inside of Task.

For example:

[NotNull]
[CoolAttributeForTask]
public Task<object> DoHardWordAsync()
{
    return Task.FromResult(null);
}

In this case, I want to say to analyzer: "I know that item inside task can be null, analyze it, please".

How I can do this?


Solution

  • You can use [ItemCanBeNull]/[ItemNotNull] attributes for collection-like types (e.g. List<T>, IEnumerable<T>), task-like types (Task<T>, ValueTask<T>) and Lazy<T>.