Skip to content

Conversation

@Sergio0694
Copy link
Member

Title.
Also added some missing conv.u instructions and did some minor refactoring.

Examples of codegen:

image

Note

Draft because there's some commits to move and this branch also needs to be rebased.

Renamed the 'currentMethod' variable to 'get_KeyMethod' in the IMapChangedEventArgs1Impl factory to better reflect its purpose and improve code clarity.
Inserted the Conv_U opcode in the IL instruction sequence within InteropTypeDefinitionBuilder.IEnumerator1. This change likely ensures correct type conversion for native interop scenarios.
Replaced inline method signature definitions for IMapChangedEventArgs`1 with calls to dedicated factory methods in WellKnownTypeSignatureFactory. This improves maintainability and centralizes signature creation logic.
Moved the generation of the 'Key' method for IMapChangedEventArgs1 to a new InteropMethodDefinitionFactory.IMapChangedEventArgs1Methods class. The new implementation provides a complete method body and integrates with emit state for return value rewriting. Updated all call sites to use the new factory method and pass the emit state.
Updated IAsyncInfoMethods to use get_UntypedRetVal instead of get_TypedRetVal for calli signatures. Removed the unused get_TypedRetVal method from WellKnownTypeSignatureFactory to simplify the code and avoid unnecessary type specificity.
Inserted the Conv_U opcode in the IL instruction sequence for KeyValuePair methods to ensure correct type conversion. This change improves the accuracy of the generated interop method definitions.
Split HasCurrentOrMoveNext into get_HasCurrent and MoveNext methods for clarity and maintainability. Updated call sites to use the new methods and restructured method bodies for GetMany and HasCurrentOrMoveNext to better match their intended signatures and logic.
Copy link

Copilot AI left a 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 enhances the code generation for IMapChangedEventArgs<K> interfaces in cswinrtgen by emitting full method types instead of incomplete implementations. The changes include refactoring method signature creation, adding missing conv.u IL instructions for pointer conversions, and improving method organization.

Key Changes:

  • Implemented complete code generation for IMapChangedEventArgs<K>.Key method with proper marshaling and exception handling
  • Refactored method signature factories to eliminate duplicate code and improve reusability
  • Added missing conv.u instructions for address-to-native integer pointer conversions

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
InteropGenerator.Emit.cs Added emitState parameter to DefineIMapChangedEventArgsTypes call
WellKnownTypeSignatureFactory.cs Removed duplicate get_TypedRetVal method and added specialized IMapChangedEventArgs1get_CollectionChangeImpl method
WellKnownTypeDefinitionFactory.cs Refactored to use new factory methods instead of inline signature creation
InteropMethodDefinitionFactory.KeyValuePairMethods.cs Added missing conv.u instruction for pointer conversion
InteropMethodDefinitionFactory.IMapChangedEventArgs1Methods.cs New file implementing complete Key method with proper IL generation
InteropMethodDefinitionFactory.IMapChangedEventArgs1Impl.cs Renamed variables and updated comments for consistency
InteropMethodDefinitionFactory.IEnumerator1Impl.cs Reorganized methods, added explicit get_HasCurrent and MoveNext methods, and removed unused import
InteropMethodDefinitionFactory.IAsyncInfoMethods.cs Replaced specialized signature call with generic get_UntypedRetVal
InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs Replaced placeholder implementation with factory method call
InteropTypeDefinitionBuilder.IEnumerator1.cs Updated method calls to use new explicit factory methods and added missing conv.u

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Updated the HasCurrentOrMoveNext method to take an explicit adapterMethod parameter instead of determining it internally. This change clarifies method usage and improves code maintainability by making dependencies explicit.
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/map-changed-event-args-methods branch from 1e2158a to e0a14ec Compare December 23, 2025 05:24
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.

2 participants