Skip to content

fix issue 378#380

Open
Bezarius wants to merge 2 commits intoCysharp:mainfrom
Bezarius:main
Open

fix issue 378#380
Bezarius wants to merge 2 commits intoCysharp:mainfrom
Bezarius:main

Conversation

@Bezarius
Copy link
Copy Markdown

issue description: #378

@neuecc
Copy link
Copy Markdown
Member

neuecc commented Feb 18, 2025

Thank you.
I was planning to overhaul the Source Generator, but that ended up making me come to a standstill.
I will accept ongoing improvements and release them in the near future.

Copilot AI review requested due to automatic review settings January 26, 2026 13:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the source generator to consistently gate use of the C# 11 scoped modifier on both the target framework and language version, preventing mismatches with base formatter signatures as described in issue #378.

Changes:

  • Update all generator scopedRef decisions to require both context.IsNet7OrGreater and context.IsCSharp11OrGreater(), ensuring scoped ref is only emitted when compatible with the runtime and language.
  • Simplify the fixedSize detection logic by replacing a manual loop-and-flag pattern with a single Members.All(...) boolean expression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

var fixedSizeInterface = "";
var fixedSizeMethod = "";
scopedRef = (context.IsCSharp11OrGreater())
scopedRef = context.IsNet7OrGreater && context.IsCSharp11OrGreater()
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The new scopedRef condition (context.IsNet7OrGreater && context.IsCSharp11OrGreater()) fixes the reported mismatch between generated scoped parameters and the base formatter signatures, but there doesn't appear to be a regression test that covers this specific matrix (C# 11 language version with IsNet7OrGreater == false). It would be helpful to add a generator test that simulates this environment and asserts that the generated formatter methods use plain ref, so future changes to IsNet7OrGreater/language-version logic don't reintroduce this compiler error.

Copilot uses AI. Check for mistakes.
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.

3 participants