This issue has been moved from a ticket on Developer Community.
[severity:It bothers me. A fix would be nice]
Given a method like this:
[MemberNotNull(nameof(this.Name))]
public MyShape SetName(string name)
{
this.Name = name;
return this;
}
CS0027 will (sometimes) be emitted as an error in VS2026, with the location referring to this. as it appears in the attribute argument. Yet the compilation succeeds anyway.
CS8618 also is emitted as a false warning in this case.
Removing this. resolves both diagnostics:
[MemberNotNull(nameof(Name))]
public MyShape SetName(string name)
{
this.Name = name;
return this;
}
This looks like a bug in the compiler / language service.
Repro steps
git clone https://github.com/AArnott/Nerdbank.MessagePack.git
cd Nerdbank.MessagePack
git checkout b1e27e7a3e5954056e4f2db72d2fc1d8ce1f2053
.\Nerdbank.MessagePack.slnx
Look at the error list. You may have to open MyShape.cs in order to see it populate with these two false diagnostics.
Original Comments
Feedback Bot on 12/22/2025, 03:14 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 1/30/2026, 09:10 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
This issue has been moved from a ticket on Developer Community.
[severity:It bothers me. A fix would be nice]
Given a method like this:
CS0027 will (sometimes) be emitted as an error in VS2026, with the location referring to
this.as it appears in the attribute argument. Yet the compilation succeeds anyway.CS8618 also is emitted as a false warning in this case.
Removing
this.resolves both diagnostics:This looks like a bug in the compiler / language service.
Repro steps
Look at the error list. You may have to open
MyShape.csin order to see it populate with these two false diagnostics.Original Comments
Feedback Bot on 12/22/2025, 03:14 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 1/30/2026, 09:10 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.