-
Notifications
You must be signed in to change notification settings - Fork 337
Defer customization filtering in EnsureBuilt to allow visitor transformations #9665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… method suppression Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
…ansformations Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
| /// <summary> | ||
| /// Mutable override for BuildMethods. When set, BuildMethods returns this instead of the constructor-provided methods. | ||
| /// </summary> | ||
| internal MethodProvider[]? MethodsOverride { get; set; } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; } = []; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
Line 230 in 942d808
| public IReadOnlyList<PropertyProvider> Properties => _properties ??= FilterCustomizedMembers ? FilterCustomizedProperties(BuildProperties()) : BuildProperties(); |
There was a problem hiding this comment.
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.
EnsureBuilt(), butEnsureBuilt()triggersMethodslazy init which applies customization filtering prematurely, removing methods before visitors can transform themEnsureBuilt()to build members without applying customization filtering, deferring it toCSharpGen.ExecuteAsyncafter visitors runMethodIsNotFilteredWhenVisitorChangesSignaturethat verifies a method matching custom code is preserved throughEnsureBuilt()so visitors can transform itMethodsOverridefromTestTypeProviderand replaced with a localMutableMethodsTypeProviderclass private to the test fileMethods_toMethodProvidersfollowing existing convention fromClientCustomizationTests💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.