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
OptionsValidatorGenerator emits ambiguous System.Diagnostics reference — should use global::System.Diagnostics #118476
The OptionsValidatorGenerator from Microsoft.Extensions.Options.SourceGeneration emits attributes like this:
namespace XXX { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Options.SourceGeneration", "9.0.12.31616")] internal sealed partial class __AppSettingsValidator__ { /// <summary> /// Validates a specific named options instance (or all when <paramref name="name"/> is <see langword="null" />). /// </summary> /// <param name="name">The name of the options instance being validated.</param> /// <param name="options">The options instance.</param> /// <returns>Validation result.</returns> [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Extensions.Options.SourceGeneration", "9.0.12.31616")] [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026:RequiresUnreferencedCode", Justification = "The created ValidationContext object is used in a way that never call reflection")]
Reproduction Steps
If the consuming project has a namespace like XXX.System, the generated code fails to compile The type or namespace name 'Diagnostics' does not exist in the namespace 'XXX.System' (are you missing an assembly reference?)
Activity
dotnet-policy-service commentedon Aug 7, 2025
Tagging subscribers to this area: @dotnet/area-extensions-options
See info in area-owners.md if you want to be subscribed.
rosebyte commentedon Mar 17, 2026
Triage: we will fix it when we have capacity.
Add global:: qualifier to UnconditionalSuppressMessage in OptionsVali…
Add global:: qualifier to System namespaces in OptionsValidatorGenera…