Skip to content

fix(codegen): suppress warnings in generated source - #10854

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-generator-warning-suppressions
Aug 27, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-generator-warning-suppressions

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

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 disable and #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

Copilot AI lite review requested due to automatic review settings August 27, 2026 21:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Code coverage

78.54% line coverage - 99,056 / 126,115 lines

Coverage details

@ReubenBond
ReubenBond merged commit 00d1a22 into dotnet:main Aug 27, 2026
76 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-generator-warning-suppressions branch August 27, 2026 21:45
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incremental source generator emits CS0618 for obsolete grain methods

2 participants