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 }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Missing warnings for compiler-generated code in types with RUC #2806
The interaction between RUC-on-type and compiler-generated code gets a little subtle.
classProgram{staticvoidMain(){// IL2026: Using member 'RUCType.RUCType()' ...// This should also warn about the state machine constructor.RequireAll(typeof(RUCType));}staticvoidRequireAll([DAM(DAMT.All)]Typet){}}[RequiresUnreferencedCode("RUCType")]classRUCType{publicIEnumerable<int>M(){yieldreturn0;}}
This isn't super high priority because there is an existing warning about the RUC type's constructor. Technically though, I think we should also warn about the state machine's constructor, since that could be accessed via reflection independently of the RUC type. We decided that RUC on type doesn't also apply to nested types, but I think it should for compiler-generated nested types, which are effectively a representation of the outer type's members.
Looking at this again, I don't think this is necessary because:
This will already warn for the reference to IEnumerable<int> M which conceptually is what represents the state machine ctor. The analyzer warning should be the same without having to understand what this compiles to.
Our intrinsic handling for GetNestedTypes doesn't seem to propagate the annotations anyway, so I don't think there's a way to reflect on the constructor without getting a warning.
Activity
sbomer commentedon Jan 6, 2026
Looking at this again, I don't think this is necessary because:
IEnumerable<int> Mwhich conceptually is what represents the state machine ctor. The analyzer warning should be the same without having to understand what this compiles to.GetNestedTypesdoesn't seem to propagate the annotations anyway, so I don't think there's a way to reflect on the constructor without getting a warning.