Skip to content

GCop628 false alarm #300

@sungam3r

Description

@sungam3r
public Task DoSome(int? value) // GCop628: Maybe define this method on 'Nullable' class as it's using 1 of its members (compared to 0 from this type)
{
    if (value.HasValue)
      return Task.CompletedTask;
    return null;
}

Obviously, we cannot move the method inside System.Nullable<T>. The rule should take into account the system types. Also note if you make the method static, then there is no warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions