Skip to content

Fix DoNotPublicize on types with nested types - #236

Merged
krafs merged 2 commits into
mainfrom
fix-denied-type-walkup
Aug 3, 2026
Merged

Fix DoNotPublicize on types with nested types#236
krafs merged 2 commits into
mainfrom
fix-denied-type-walkup

Conversation

@krafs

@krafs krafs commented Aug 3, 2026

Copy link
Copy Markdown
Owner

A DoNotPublicize naming 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/CS0121 errors, one per type it excludes, and builds clean with this fix.

@krafs krafs changed the title Stop the type walk-up at an excluded enclosing type Fix DoNotPublicize on types with nested types Aug 3, 2026
@krafs
krafs force-pushed the fix-denied-type-walkup branch from a218a8c to 5804b96 Compare August 3, 2026 17:53
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
krafs force-pushed the fix-denied-type-walkup branch from 5804b96 to bda65de Compare August 3, 2026 17:54
@krafs krafs self-assigned this Aug 3, 2026
@krafs
krafs marked this pull request as ready for review August 3, 2026 18:15
@krafs
krafs merged commit 784b85b into main Aug 3, 2026
10 checks passed
@krafs
krafs deleted the fix-denied-type-walkup branch August 3, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant