-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything featureQuestionResolution-AnsweredThe question has been answeredThe question has been answered
Description
Version Used: VS 17.14.21 .NET 9.0.11 Preview language features (Also VS 18, .NET 10)
I have a custom error type where I use null to indicate success.
public static bool IsSuccess([NotNullWhen(false)] this MyErrorClass? info)
{
return info is null;
}
With the new C# 14 features, I wanted to change this to a property.
extension(MyErrorClass? info)
{
public bool IsSuccess
{
[NotNullWhen(false)] // CS0592 error here
get => info is null;
}
}
With the new extension properties, it is now possible to write a property that runs on a null object. So, null analysis should be updated to support this.
Expected Behavior:
Some way to tell the null analysis that the extended class is not null given some property return value.
Actual Behavior:
It is not possible to change from an extension method to an extension property while preserving the null analysis.
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything featureQuestionResolution-AnsweredThe question has been answeredThe question has been answered