Skip to content

[http-client-csharp] Consolidate duplicate MethodSignature comparison logic#9692

Merged
JonathanCrd merged 5 commits intomicrosoft:mainfrom
JonathanCrd:bug-IsMatch-MethodSignature
Feb 14, 2026
Merged

[http-client-csharp] Consolidate duplicate MethodSignature comparison logic#9692
JonathanCrd merged 5 commits intomicrosoft:mainfrom
JonathanCrd:bug-IsMatch-MethodSignature

Conversation

@JonathanCrd
Copy link
Member

Fixes #9658

This PR removes duplicated method signature comparison logic by using a consolidated MethodSignatureEqualityComparer


Used AI to generate the following text based on the commit history

Changes

🔧 Created Unified Comparer

  • Added MethodSignatureBaseEqualityComparer to MethodSignatureBase class
  • Consolidated all comparison logic including special operator handling (explicit vs implicit)
  • Exposed via public static readonly IEqualityComparer<MethodSignatureBase> SignatureComparer

🧹 Eliminated Duplication in TypeProvider

  • Replaced ~40 lines of custom IsMatch() logic with single line delegation to base comparer
  • Removed duplicate helper methods (IsNameMatch, GetFullMethodName)

🚀 Simplified MethodSignature Comparer

  • Removed redundant MethodSignatureEqualityComparer wrapper class
  • Changed to clean property: MethodSignatureComparer => SignatureComparer

📝 Updated References

  • Updated 4 references in ClientProvider.cs and ModelFactoryProvider.cs to maintain existing API

Benefits

Single source of truth - All method signature equality logic unified
Extended to constructors - Base comparer now works for both methods and constructors
Eliminated ~50 lines of duplicate code
Backward compatible - No breaking changes to existing APIs
All tests pass - Verified with full test suite (3,235 tests, 0 failures)

Testing

  • All existing tests pass
  • Constructor signature matching scenarios validated
  • Method signature comparison behavior unchanged

@JonathanCrd JonathanCrd self-assigned this Feb 11, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Feb 11, 2026
@github-actions
Copy link
Contributor

No changes needing a change description found.

Copy link
Contributor

@jorgerangel-msft jorgerangel-msft left a comment

Choose a reason for hiding this comment

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

Can we please add a few unit tests exercising the new comparer?

@JoshLove-msft
Copy link
Contributor

Can we verify the fix in Search before merging?

@JonathanCrd JonathanCrd added this pull request to the merge queue Feb 14, 2026
Merged via the queue into microsoft:main with commit 91f56d2 Feb 14, 2026
23 checks passed
@JonathanCrd JonathanCrd deleted the bug-IsMatch-MethodSignature branch February 14, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeProvider.IsMatch should use the MethodSIgnatureEqualityComparer

3 participants