Version Used:
Works with (maybe a few more versions aftewards as well):
Compiler version: 4.12.0-3.24631.1
Language version: 12.0
breaks around:
Compiler version: 5.5.0-2.26080.10
Language version: 12.0
Steps to Reproduce:
using System.ComponentModel.DataAnnotations.Schema;
public class Test
{
[ForeignKey(nameof(this.Nav))]
public int NavId { get; set; }
public object Nav { get; set; }
}
nameof(this.Member) previously compiled (Roslyn 4.12, C# 12) and only showed "this" as unnecessary. In Roslyn 5.5 it now produces a compiler error, even with the same language version. This appears to be a regression.
Expected Behavior:
The "this." prefix is shown as unnecessary but no syntax highlighting/errors/etc.
Actual Behavior:
Compilation fails with error: msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0027)
Use case:
If property Nav is removed from the class then [ForeignKey(nameof(this.Nav))] errors which ensures that the Entity Framework Navigational Attribute exists as a property of the class. [ForeignKey(nameof("Nav"))] is undesirable because the property doesn't have to exist. [ForeignKey(nameof(Nav))] is also undesirable because if I have a class called Nav this doesn't error and doesn't ensure the navigational attribute exists, it just now points to the Class outside of this file.