Open
docs: Document CS8080 private accessor override limitation#55014
Conversation
Copilot
AI
changed the title
[WIP] Fix override of property with private set in derived class
docs: Document CS8080 private accessor override limitation
Jul 24, 2026
adegeo
reviewed
Jul 24, 2026
wadepickett
reviewed
Jul 27, 2026
| - Override only the accessors that exist in the base class property declaration (**CS0545**, **CS0546**). You can't override a property accessor that isn't present or accessible in the base class because there's no virtual method to override. If the base class property has only a `get` accessor, you can't add a `set` accessor through an override. Either add the missing accessor to the base class and mark it `virtual`, or use `new` to hide the base class property with a new property definition. | ||
| - Match the type of the overriding property to the type of the overridden member (**CS1715**). Read-only (`get`-only) properties support covariant return types beginning with C# 9, so the override can return a more derived type. However, properties that have a `set` or `init` accessor require an exact type match because the setter accepts values of the declared type. If you need a different type on a property with a setter, change the property type in the derived class to match the base class declaration, or remove the setter and use a covariant return type instead. | ||
| - Include all accessors from the base property when overriding with an auto-implemented property (**CS8080**). Auto-implemented properties generate both storage and accessor implementations, so they must override all accessors present in the base class. If the base property has both `get` and `set`, the auto-implemented override must also have both. To override only specific accessors, implement the property with explicit accessor bodies and an explicit backing field instead of using auto-implementation. | ||
| - Include all accessors from the base property when overriding with an auto-implemented property (**CS8080**). Auto-implemented properties generate both storage and accessor implementations, so they must override all accessors present in the base class. If the base property has both `get` and `set`, the auto-implemented override must also have both. To override only specific accessors, implement the property with explicit accessor bodies and an explicit backing field instead of using auto-implementation. If the base class property has a `private` accessor, you can't override the property with an auto-implemented property—use explicit accessor bodies instead. |
Contributor
There was a problem hiding this comment.
Suggested change
| - Include all accessors from the base property when overriding with an auto-implemented property (**CS8080**). Auto-implemented properties generate both storage and accessor implementations, so they must override all accessors present in the base class. If the base property has both `get` and `set`, the auto-implemented override must also have both. To override only specific accessors, implement the property with explicit accessor bodies and an explicit backing field instead of using auto-implementation. If the base class property has a `private` accessor, you can't override the property with an auto-implemented property—use explicit accessor bodies instead. | |
| - Include all accessors from the base property when overriding with an auto-implemented property (**CS8080**). Auto-implemented properties generate both storage and accessor implementations, so they must override all accessors present in the base class. If the base property has both `get` and `set`, the auto-implemented override must also have both. To override only specific accessors, implement the property with explicit accessor bodies and an explicit backing field instead of using auto-implementation. If the base class property has a `private` accessor, you can't override the property with an auto-implemented property. Use explicit accessor bodies instead. |
Very minor, removing the em dash that had no spaces around it and breaking into two sentances.
wadepickett
approved these changes
Jul 27, 2026
Contributor
There was a problem hiding this comment.
@adegeo : LGTM. I am not up on the technical aspect of this item. Good to have someone review that is. I"m not spotting a technical issue. I did see your note on your tests.
Approved, but see very minor suggestion. Watching for any need for a re-approve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CS8080 was nearly undocumented—the VS error link led to a "no specifics" page, and the existing docs entry didn't cover the common case that triggers it: a base property with a
privateaccessor.Changes
property-declaration-errors.md— CS8080 bullet: Expanded the existing entry to explain that when the base class property has aprivateaccessor (e.g.,private set), an auto-implemented override is impossible becauseprivatemembers aren't accessible in derived classes. Adds explicit guidance to use explicit accessor bodies instead:Internal previews