Home > Blockchain >  CA1062 is thrown after updating to !! parameter null checking
CA1062 is thrown after updating to !! parameter null checking

Time:05-30

According to CA1062 null checks are required in externally visible methods like this:

public static double GetLongitude(this Location location)
{
    if(location is null)
    {
        throw new ArgumentNullException(nameof(location));
    }

    return location.Longitude;
}

I have now updated to .net 6.0 and tried to use the parameter null check "!!":

public static double GetLongitude(this Location location!!) => location.Longitude;

But this thrown CA1062 again.

Hope you guys can help me :-)

CodePudding user response:

There's no such operator in C# 10/.NET 6. Parameter null checking is a proposal for the upcoming C# 11 that was eventually postponed due to developer objections in April 2022.

  • Related