fix(codegen): suppress warnings in generated source - #10854
Merged
ReubenBond merged 1 commit intoAug 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: None
What changed in this PR
Updates Orleans’ source generator output to suppress all warnings within generated compilation units (via #pragma warning disable/restore without a fixed ID list), preventing user projects with “warnings as errors” from failing due to newly introduced diagnostics (e.g., obsolete-member warnings) while keeping user-authored call sites diagnostic-active.
Changes:
- Change generated source wrapping from a fixed diagnostic ID suppression list to blanket warning suppression within generated files.
- Add/strengthen regression coverage to ensure obsolete warnings are suppressed in generated proxy code but still surface (as errors under strict settings) in user-authored call sites.
- Update generator snapshot baselines to reflect the new pragma form.
| File | Description |
|---|---|
| src/Orleans.CodeGenerator/GeneratedSourceOutput.cs | Switch generated file pragma directives to blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/GeneratedWarningSuppressionTests.cs | Add obsolete-warning regression test and make “strict diagnostics” truly warnings-as-errors. |
| test/Orleans.CodeGenerator.Tests/OrleansSourceGeneratorTests.cs | Update snapshot concatenation to match new pragma restore text. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestAlias.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClass.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithAnnotatedFields.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithDifferentAccessModifiers.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithFields.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithInheritance.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithInitOnlyProperty.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicClassWithoutNamespace.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicGrain.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestBasicStruct.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassNestedTypes.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassPrimitiveTypes.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassPrimitiveTypesUsingFullName.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassReferenceProperties.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithConstructorParameters.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithFieldAndNoSetters.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithGenerateMethodSerializersAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithGenerateSerializerAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithInterfaceConstructorParameter.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithNoPublicConstructors.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithOptionalConstructorParameters.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassWithParameterizedConstructor.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestClassesWithGeneratedActivatorConstructorAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestCompoundTypeAlias.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGenericClass.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGenericClassWithConstructorParameters.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainComplexGrain.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainMethodAnnotatedWithInvokableBaseType.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainMethodAnnotatedWithResponseTimeout.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainWithDifferentKeyTypes.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestGrainWithMultipleInterfaces.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestRecords.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestRecordsWithParameterIdAttributes.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestWithOmitDefaultMemberValuesAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestWithSerializerTransparentAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestWithSuppressReferenceTrackingAttribute.verified.cs | Snapshot update for blanket warning disable/restore. |
| test/Orleans.CodeGenerator.Tests/snapshots/OrleansSourceGeneratorTests.TestWithUseActivatorAnnotation.verified.cs | Snapshot update for blanket warning disable/restore. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Code coverage78.54% line coverage - 99,056 / 126,115 lines Coverage details
|
This was referenced Aug 29, 2026
Merged
This was referenced Sep 7, 2026
This was referenced Sep 9, 2026
This was referenced Sep 14, 2026
Closed
Closed
Open
This was referenced Sep 21, 2026
Merged
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Generated Orleans source can reference obsolete members or trigger compiler and analyzer warnings that user projects promote to errors. Maintaining a fixed warning list leaves generated code vulnerable to new diagnostics.
This wraps each generated compilation unit in
#pragma warning disableand#pragma warning restore, suppressing warning-severity diagnostics only within generated source while preserving compiler errors and diagnostics in user-authored code. Regression coverage promotes all warnings to errors and verifies that obsolete user calls remain errors.Closes #10851
Microsoft Reviewers: Open in CodeFlow