Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 900 Bytes

RCS1210.md

File metadata and controls

62 lines (47 loc) · 900 Bytes

RCS1210: Return completed task instead of returning null

Property Value
Id RCS1210
Category Usage
Severity Warning

Examples

Code with Diagnostic

Task<object> GetAsync()
{
    return null; // RCS1210
}

Code with Fix

Task<object> GetAsync()
{
    return Task.FromResult<object>(null);
}

Code with Diagnostic

Task<object> GetAsync()
{
    return _foo?.GetAsync(); // RCS1210
}

Code with Fix

Task<object> GetAsync()
{
    Foo x = _foo;
    if (x != null)
    {
        return _foo.GetAsync();
    }
    else
    {
        return Task.FromResult<object>(null);
    }
}

See Also

(Generated with DotMarkdown)