简体   繁体   中英

CA1062 is thrown after updating to !! parameter null checking

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:-)

C# 10/.NET 6 中没有这样的运算符。 参数空值检查是对即将到来的 C# 11 的提议,由于开发人员在 2022 年 4 月的反对,该提议最终被推迟

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM