You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stringGet(IResponse<string>s){if(s.IsSuccess)returns.Content;// warning CS8603: Possible null reference return.return"default";}interfaceIResponse{boolIsSuccess{get;}}interfaceIResponse<T>:IResponse{[MemberNotNullWhen(true,nameof(Content))]abstractboolIResponse.IsSuccess{get;}T?Content{get;}}
Diagnostic Id:
warning CS8603: Possible null reference return.
Expected Behavior:
Should not trigger warning.
Actual Behavior:
As far I understand MemberNotNullWhen can reference only properties/methods from same class. Like in the example. But in this case, it ignores the attribute on IsSuccess override.
The text was updated successfully, but these errors were encountered:
I think when the IsSuccess declaration is an explicit interface implementation, that member is not "seen" at the use site. Only the signature of the implemented member is seen. So if you want attributes and such to have an effect at the use site you may want to do something like this: SharpLab
Version Used:
SDK 9.0.101
Steps to Reproduce:
sharplab
Diagnostic Id:
warning CS8603: Possible null reference return.
Expected Behavior:
Should not trigger warning.
Actual Behavior:
As far I understand MemberNotNullWhen can reference only properties/methods from same class. Like in the example. But in this case, it ignores the attribute on IsSuccess override.
The text was updated successfully, but these errors were encountered: