You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Static data-source properties on private nested types produce CS0122 in generated code #7461
A public static property with a data-source attribute inside a private nested type causes generated initialization code to fail with CS0122. The generator checks the property's accessibility but emits references to its inaccessible containing type, so adding an otherwise unused private helper can break the project build.
Reproduction
Add this to a test project referencing TUnit and build with source generation enabled:
The emitted StaticPropertyInitializer.g.cs refers to ExampleTests.Helper outside its containing class and reports CS0122. Changing the helper to internal allows compilation.
Expected and actual
Expected: either supported initialization or an actionable diagnostic on the user's property. Actual: compiler errors in generated code referencing an inaccessible type. Please handle containing-type accessibility when generating static-property initialization.
Environment
.NET SDK 10.0.403, macOS arm64, net10.0. Reproduced using repository source; the same accessibility check remains on main at d9e9e6638e. No matching issue was found in open or closed issue searches, and there is no unreleased changelog in the checkout.
Found while adding regression fixtures for TUnit PR #7459.
Activity
Align inaccessible static-property diagnostics with discovery (#7461)
Preserve per-file settings for inaccessible property diagnostics (#7461)
Fix diagnostic tree identity for duplicate source paths (#7461)
Test diagnostic identity across compilation tree changes (#7461)
Diagnose static data-source properties in inaccessible containing typ…