Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

  • Understand the problem: Visitors that transform method parameters (e.g., merging IfMatch/IfNoneMatch into MatchConditions) run AFTER EnsureBuilt(), but EnsureBuilt() triggers Methods lazy init which applies customization filtering prematurely, removing methods before visitors can transform them
  • Revert the incorrect generic type argument fix from IsNameMatch
  • Remove incorrect generic type test and test data
  • Fix: Change EnsureBuilt() to build members without applying customization filtering, deferring it to CSharpGen.ExecuteAsync after visitors run
  • Add test MethodIsNotFilteredWhenVisitorChangesSignature that verifies a method matching custom code is preserved through EnsureBuilt() so visitors can transform it
  • Verify the test fails without the fix and passes with it
  • Run all existing tests to ensure no regressions (1237 Generator + 1073 ClientModel tests pass)
  • Run code review (minor style comments, consistent with existing patterns)
  • Address review feedback: Removed MethodsOverride from TestTypeProvider and replaced with a local MutableMethodsTypeProvider class private to the test file
  • Address review feedback: Renamed Methods_ to MethodProviders following existing convention from ClientCustomizationTests

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

… method suppression

Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
@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 10, 2026
Copilot AI changed the title [WIP] Fix bug in CreateOrUpdate method parameter merging Fix IsNameMatch to compare generic type arguments when matching custom methods Feb 10, 2026
Copilot AI requested a review from ArthurMa1978 February 10, 2026 04:27
…ansformations

Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Copilot AI changed the title Fix IsNameMatch to compare generic type arguments when matching custom methods Defer customization filtering in EnsureBuilt to allow visitor transformations Feb 10, 2026
/// <summary>
/// Mutable override for BuildMethods. When set, BuildMethods returns this instead of the constructor-provided methods.
/// </summary>
internal MethodProvider[]? MethodsOverride { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot we should come up with another approach that doesn't involve adding this property solely for testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed MethodsOverride from TestTypeProvider and restored it to its original state. The test now uses a local MutableMethodsTypeProvider class private to OutputLibraryVisitorTests.cs instead. Commit: 0c3ba9d

…modifying TestTypeProvider

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
/// </summary>
private class MutableMethodsTypeProvider : TypeProvider
{
public MethodProvider[] Methods_ { get; set; } = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot rename this to something less silly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to MethodProviders to match the existing convention from ClientCustomizationTests.ClientTypeProvider. Commit: 701260d

…ntion

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
// Filtering is deferred to CSharpGen.ExecuteAsync after visitors have had a chance
// to transform members (e.g., merging parameters). This ensures visitors see the
// full set of members before customization filtering is applied.
_methods ??= BuildMethods();
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need the filtering that is done on the TypeProvider's property's accessors? ie.

public IReadOnlyList<PropertyProvider> Properties => _properties ??= FilterCustomizedMembers ? FilterCustomizedProperties(BuildProperties()) : BuildProperties();

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think so, at least we do if we don't want to update hundreds of tests.

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.

4 participants