Version Used:
Compiler version: '4.0.1-1.21568.1 (6ab66011)'.
Language version: latest (10.0).
Visual Studio version: 17.0.4
Steps to Reproduce:
- Declare a base class with an auto-implemented property:
public class Base {
public virtual int Member { get; private set; }
}
- Attempt to override the property in a derived class:
public class Derived : Base {
public override int Member { get; } // CS8080
}
- Same behavior and error occur whether or not
Base is abstract. Declaring Derived.Member with { get; private set; } instead results in "CS0115 'Derived.Member.set': no suitable method found to override". Also, if Base.Member is declared abstract then that line fails to compile with "CS0442 'Base.Member.set': abstract properties cannot have private accessors". These latter two errors make sense but the CS8080 one seems wrong.
I am reporting this as a bug, rather than a language feature request, b/c the resulting CS8080 error seems to be almost completely undocumented. The VS link goes to the "Sorry, we don't have specifics on this C# error" page of the MS docs, a quick google turned up basically zero meaningful results, and the only mention of it in this entire repo is this unit test and this open issue from four years ago: dotnet/roslyn#23326. The code I provided in the repro steps seems like it should be valid C# to me, but if its not, then at least the documentation should be fixed.
Expected Behavior:
I am able to override auto-implemented properties declared with private set using an auto-implemented property without set.
Actual Behavior:
Overring an auto-implemented property declared with private set using an auto-implemented property without set results in undocumented CS8080 compiler error.
Version Used:
Compiler version: '4.0.1-1.21568.1 (6ab66011)'.
Language version: latest (10.0).
Visual Studio version: 17.0.4
Steps to Reproduce:
Baseisabstract. DeclaringDerived.Memberwith{ get; private set; }instead results in "CS0115 'Derived.Member.set': no suitable method found to override". Also, ifBase.Memberis declaredabstractthen that line fails to compile with "CS0442 'Base.Member.set': abstract properties cannot have private accessors". These latter two errors make sense but the CS8080 one seems wrong.I am reporting this as a bug, rather than a language feature request, b/c the resulting CS8080 error seems to be almost completely undocumented. The VS link goes to the "Sorry, we don't have specifics on this C# error" page of the MS docs, a quick google turned up basically zero meaningful results, and the only mention of it in this entire repo is this unit test and this open issue from four years ago: dotnet/roslyn#23326. The code I provided in the repro steps seems like it should be valid C# to me, but if its not, then at least the documentation should be fixed.
Expected Behavior:
I am able to override auto-implemented properties declared with
private setusing an auto-implemented property withoutset.Actual Behavior:
Overring an auto-implemented property declared with
private setusing an auto-implemented property withoutsetresults in undocumented CS8080 compiler error.