-
Notifications
You must be signed in to change notification settings - Fork 121
Emit full 'IVectorMethods' types for lists in 'cswinrtgen' #2166
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: user/sergiopedri/map-methods
Are you sure you want to change the base?
Emit full 'IVectorMethods' types for lists in 'cswinrtgen' #2166
Conversation
Moved the SetAt method logic for IList<T> to InteropMethodDefinitionFactory.IVectorMethods, replacing the previous placeholder implementation. This centralizes method creation and provides a complete method body for SetAt, improving maintainability and consistency.
Introduces a shared SetAtOrInsertAt helper to generate both SetAt and InsertAt methods for IVector<T> interfaces, reducing code duplication and improving maintainability. Updates method body construction to use the new helper and parameterize method name and signature.
Moves InsertAt method definition logic from InteropTypeDefinitionBuilder.IList1 to InteropMethodDefinitionFactory.IVectorMethods. This centralizes method creation and reduces duplication, improving maintainability.
Moved the construction of the IList<T>.Append method to InteropMethodDefinitionFactory.IVectorMethods.Append, providing a full method body and parameter marshaling logic. This improves maintainability and consistency with other interop method definitions.
Refactored IList<T> interop builder to use a new InteropMethodDefinitionFactory.IVectorMethods.IndexOf method, which now provides a full implementation for the IndexOf method, including method body and parameter marshaling. This improves maintainability and consistency with other IVector methods.
Updated the XML documentation for CilOutParameterIndices to clarify that parameter indices are 1-based, with index 0 representing the implicit 'this' parameter.
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.
Pull request overview
This PR implements full code generation for IVectorMethods types in the cswinrtgen tool. Previously, these methods had placeholder implementations that threw exceptions; now they generate complete CIL method bodies with proper marshalling, exception handling, and resource cleanup.
Key changes:
- Adds factory methods for generating
SetAt,InsertAt,Append, andIndexOfimplementations - Implements proper try/finally blocks for resource cleanup
- Handles parameter marshalling with native type conversion
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
InteropMethodDefinitionFactory.IVectorMethods.cs |
New file containing factory methods for generating complete IVector<T> method implementations with CIL bodies |
MethodDefinitionExtensions.cs |
Added documentation clarifying that CilOutParameterIndices uses 1-based indexing |
InteropTypeDefinitionBuilder.IList1.cs |
Replaced placeholder method stubs with calls to the new factory methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Track rewriting the 'value' parameter for this method | ||
| emitState.TrackNativeParameterMethodRewrite( | ||
| paraneterType: elementType, |
Copilot
AI
Dec 22, 2025
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.
Corrected spelling of 'paraneterType' to 'parameterType'.
| paraneterType: elementType, | |
| parameterType: elementType, |
|
|
||
| // Track rewriting the 'value' parameter for this method | ||
| emitState.TrackNativeParameterMethodRewrite( | ||
| paraneterType: elementType, |
Copilot
AI
Dec 22, 2025
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.
Corrected spelling of 'paraneterType' to 'parameterType'.
| paraneterType: elementType, | |
| parameterType: elementType, |
|
|
||
| // Track rewriting the 'value' parameter for this method | ||
| emitState.TrackNativeParameterMethodRewrite( | ||
| paraneterType: elementType, |
Copilot
AI
Dec 22, 2025
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.
Corrected spelling of 'paraneterType' to 'parameterType'.
| paraneterType: elementType, | |
| parameterType: elementType, |
Title.
Examples of codegen:
Note
Draft because there's some commits to move and this branch also needs to be rebased.