Visitar URL original
Fix CS8669 warning in generated MessagePack.GeneratedMessagePackResolver.g.cs by Copilot · Pull Request #2279 · MessagePack-CSharp/MessagePack-CSharp · GitHub
Skip to content

Fix CS8669 warning in generated MessagePack.GeneratedMessagePackResolver.g.cs - #2279

Merged
AArnott merged 4 commits into
masterfrom
copilot/fix-warn-cs8669-issue
Jul 8, 2026
Merged

AArnott merged 4 commits into
masterfrom
copilot/fix-warn-cs8669-issue

Conversation

Copilot AI commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

The generated MessagePack.GeneratedMessagePackResolver.g.cs emits CS8669 warnings when user types contain nullable reference type annotations in generic arguments (e.g., List<SomeClass?>), because the resolver template was missing the #pragma warning disable CS8669 already present in all formatter-generated files.

The resolver generates expressions like:

{ typeof(global::System.Collections.Generic.List<global::TempProject.SomeClass?>), 0 },

Without a nullable context or suppression, this triggers CS8669.

Changes

  • ResolverTemplate.tt / ResolverTemplate.cs — Added #pragma warning disable CS8669 // We may leak nullable annotations into generated code. matching the pattern already used in FormatterTemplate.tt
  • Resource files — Updated all 86+ MessagePack.GeneratedMessagePackResolver.g.cs test resource files to include the new pragma line
  • New test — NullableReferenceTypeInListFormatter reproduces the exact scenario from the issue: a [MessagePackObject] with a required List<SomeClass?> Values property, verifying no diagnostics are emitted and the generated resolver contains the pragma

Copilot AI changed the title [WIP] Fix CS8669 warning in auto-generated MessagePack code Fix CS8669 warning in generated MessagePack.GeneratedMessagePackResolver.g.cs Jul 8, 2026
Copilot AI requested a review from AArnott July 8, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected warning CS8669: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.

2 participants