Skip to content

Add [OverloadResolution] to methods to resolve new() ambiguity - #248

Merged
andrewlock merged 9 commits into
mainfrom
overload-resolution
Apr 14, 2026
Merged

Add [OverloadResolution] to methods to resolve new() ambiguity#248
andrewlock merged 9 commits into
mainfrom
overload-resolution

Conversation

@andrewlock

Copy link
Copy Markdown
Owner

No description provided.

andrewlock and others added 9 commits March 16, 2026 20:13
…lyfill

Instead of conditionally emitting the [OverloadResolutionPriority(1)] attribute
based on a C# version check, always emit it gated behind preprocessor symbols:
#if NET9_0_OR_GREATER || NETESCAPADES_ENUMGENERATORS_OVERLOAD_PRIORITY

This simplifies the generator by removing the useOverloadPriority flag and
removes the generated polyfill attribute — users who define
NETESCAPADES_ENUMGENERATORS_OVERLOAD_PRIORITY must provide their own polyfill.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gration tests

The overload priority tests only work on .NET 9+ where
OverloadResolutionPriorityAttribute exists in the BCL. On older TFMs,
the preprocessor symbol is not defined, so the #if-gated attribute
and associated tests are skipped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ymbol

Document how to resolve CS0121 overload ambiguity when using target-typed
new() with generated Parse/TryParse/ToStringFast option overloads.
On .NET 9+ this works automatically; on older TFMs users can define the
preprocessor symbol and provide a polyfill (e.g. via SimonCropp/Polyfill).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Define NETESCAPADES_ENUMGENERATORS_OVERLOAD_PRIORITY and add a conditional
polyfill of OverloadResolutionPriorityAttribute (gated with
#if !NET9_0_OR_GREATER) to all integration test projects, including the
netstandard2.0 library projects where the generator emits code.

The overload priority tests are unguarded and run on all TFMs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

    216 files  ±  0      216 suites  ±0   5h 20m 53s ⏱️ - 1h 5m 18s
 29 041 tests + 11   29 037 ✅ + 11   4 💤 ±0  0 ❌ ±0 
512 731 runs  +504  512 659 ✅ +504  72 💤 ±0  0 ❌ ±0 

Results for commit d91a3ea. ± Comparison against base commit a6bb7b2.

@andrewlock
andrewlock merged commit d3995b8 into main Apr 14, 2026
5 checks passed
@andrewlock
andrewlock deleted the overload-resolution branch April 14, 2026 20:07
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.

1 participant