Fix DoNotPublicize on types with nested types - #236
Merged
Conversation
krafs
force-pushed
the
fix-denied-type-walkup
branch
from
August 3, 2026 17:53
a218a8c to
5804b96
Compare
Publicizing a nested type walks up and publicizes its enclosers, which silently undid a DoNotPublicize naming one of them: the exclusion does not reach nested types, so the sweep publicized them and the walk-up dragged the excluded type public again. Regression since #200, in 2.3.1. The walk-up is the engine's own inference, so it now yields to a type the user excluded by name. Reaching a denied type directly still publicizes it, which keeps an explicitly named member usable.
krafs
force-pushed
the
fix-denied-type-walkup
branch
from
August 3, 2026 17:54
5804b96 to
bda65de
Compare
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.
A
DoNotPublicizenaming a type was silently undone whenever that type had nested types — including compiler-generated ones, so it hits consumers who do not think they have any. The exclusion does not reach nested types, so an assembly-wide sweep publicized them, and the declaring-type walk-up dragged the excluded type public again. Regression since #200, shipped in 2.3.1.The walk-up is the engine's own inference, so it yields to a type the user excluded by name rather than widening the exclusion to nested types — which would invert documented behavior and break anyone relying on it. Reaching a denied type directly still publicizes it, so an explicitly named member stays usable.
Found by building real consumers against a locally packed Publicizer: SharpIDE fails to compile on 2.3.1 and on main with 18
CS0433/CS0121errors, one per type it excludes, and builds clean with this fix.