Skip to content

Conversation

@kythant
Copy link

@kythant kythant commented Nov 25, 2025

No description provided.

@kythant kythant closed this Nov 25, 2025
@kythant kythant reopened this Nov 26, 2025
@kythant kythant closed this Nov 27, 2025
@kythant kythant reopened this Dec 1, 2025
kythant and others added 17 commits December 1, 2025 15:59
Simplifies and clarifies the handling of TypeReference creation, including improved comments and restructuring for primitive and proxy types. Ensures more consistent reporting of TypeKind and streamlines marshalling info usage.
Changed the TypeReference.Name field from string? to ReadOnlySpan<char> for improved memory safety and performance. Updated marshalling logic and related references to accommodate the new type.
Added [WindowsRuntimeMetadata] attributes to ABI type classes in WinRT.Runtime2 to specify their associated Windows contracts. This improves metadata clarity and contract mapping for types such as Boolean, Byte, Char, DateTimeOffset, Double, EventHandler, Exception, Guid, Int16, Int32, Int64, Numerics types, Object, Single, String, TimeSpan, Type, UInt16, UInt32, UInt64, and Uri.
Introduces TypeMapAssociation attributes for DynamicInterfaceCastableImplementationTypeMapGroup to INotifyDataErrorInfo, IDisposable, and IServiceProvider ABI interfaces. Also adds WindowsRuntimeMetadata and WindowsRuntimeClassName attributes to their respective interface implementations for improved WinRT interop.
Added logic to TypeMarshaller to support round-tripping C# primitive types (e.g., System.SByte) that are not Windows Runtime types. This ensures such types can be resolved even if not found in the WindowsRuntimeMarshallingInfo lookup.
Introduces handling for the WindowsRuntimeMetadataTypeNameAttribute in InteropTypeDefinitionBuilder and InteropReferences. This allows proxy types to optionally emit the metadata type name attribute and reference the original managed type when required.
@Sergio0694 Sergio0694 force-pushed the user/kythant/TypeHandling branch from 31c9fb6 to 1c5e5b4 Compare January 27, 2026 03:26
Introduces handling for the WindowsRuntimeMappedMetadataAttribute in proxy type generation. Updates relevant builders and references to allow optional inclusion of mapped metadata information when generating interop types.
Introduces a static Proxy method to InteropTypeDefinitionBuilder.KeyValuePair for creating proxy types for KeyValuePair<TKey, TValue>. Updates InteropGenerator.Emit to use the new method, improving clarity and encapsulation for KeyValuePair proxy generation.
Introduces the IsGenericType property to determine if a TypeSignature represents a constructed generic type.
Introduces MetadataTypeNameGenerator to handle Windows Runtime metadata type name generation, including generic and array types. Refactors RuntimeClassNameGenerator to delegate type name formatting to the new helper, improving code reuse and maintainability. Adds error handling for unresolved types and clarifies logic for IReference wrapping.
Updated TypeMapAttributes methods in Delegate and KeyValuePair builders to accept TypeSignature instead of GenericInstanceTypeSignature. Added a static Proxy method to InteropTypeDefinitionBuilder.Delegate for delegate proxy type creation, and updated usage in InteropGenerator.Emit to use the new method.
Expanded the comment to mention that generic delegate types are also handled by using '[WindowsRuntimeMetadataTypeName]'. No code changes were made.
Corrected 'GetMetadataTyoeName' and 'AppendMetadataTyoeName' to 'GetMetadataTypeName' and 'AppendMetadataTypeName' in MetadataTypeNameGenerator and updated all references. This improves code clarity and consistency.
Introduces a new metadataTypeName parameter to TypeMapAttributes and updates all relevant builder calls to include it, defaulting to null where not required. This enables emitting additional type map attributes for metadata type mapping, supporting improved marshalling scenarios such as Windows Runtime delegate types.
Replaces the use of runtimeClassName with metadataTypeName when setting the WindowsRuntimeMetadataTypeNameAttribute. This ensures the correct type name is used in the custom attribute.
Renames proxyTypeMap* parameters to marshallingTypeMap* and adds metadataTypeMap* parameters across InteropTypeDefinitionBuilder and related builders. Updates attribute emission logic to support both marshalling and metadata type map associations, improving clarity and future extensibility.
Clarified the summary to specify proxy types are for interfaces or SZ array types. Added comments and set 'referenceMappedType' to true to ensure the '[WindowsRuntimeMappedType]' attribute is emitted, enabling 'TypeName' marshalling to retrieve the runtime class name.
Set metadataTypeMapSourceType and metadataTypeMapProxyType to appropriate values in IList, IReadOnlyList, and interface type builder methods. This ensures correct type mapping for metadata generation.
Introduces a dedicated Proxy method for SZ array types in InteropTypeDefinitionBuilder.SzArray, separating it from the interface proxy logic. Updates all call sites to use the new method for arrays and renames the parameter for interface proxies to improve clarity.
Updated the XML documentation for the proxyType parameter to reference only Proxy, removing the method signature for clarity and maintainability.
Emit '[WindowsRuntimeMetadataTypeName]' instead of a runtime class name when generating proxies for interface types. This supports mapping generic interface names during 'TypeName' marshalling, as runtime class names are not needed for interfaces.
Reorganizes the logic for handling value types in TypeMarshaller. Now, KeyValuePair<,> is explicitly checked before falling back to marshalling info for other value types, improving clarity and correctness in type selection.
Replaces global::System.Collections type references with direct type usage (e.g., IEnumerable, IEnumerator, IList) in ABI marshaller and implementation files. Refactors and exposes ComWrappersMarshallerAttribute classes as public, adds missing attributes, and introduces a new Interface helper in DynamicCustomMappedTypeMapEntriesBuilder to streamline interface mapping logic.
Annotated DataErrorsChangedEventArgs ABI type with WindowsRuntimeMappedMetadata and WindowsRuntimeMappedType attributes to improve metadata mapping and type resolution.
Extracted marshaller attribute type resolution into GetMarshallerAttributeType to reduce code duplication. Replaced ManagedOnlyTypeOrInterface with ManagedOnlyType, simplifying parameters and usage. Updated method calls and removed redundant marshaller attribute resolution logic from multiple locations.
Renamed internal builder methods for clarity, distinguishing between interface and delegate type mappings. Updated NotifyCollectionChangedEventArgs and PropertyChangedEventArgs ABI files to remove unnecessary TypeMapAssociation attributes, simplify type references, and improve marshaller and attribute declarations for consistency and maintainability.
Replaces calls to ManagedOnlyDelegateType with DelegateType for delegate type mappings, and updates related method signatures and invocations for consistency. This change streamlines delegate type handling and unifies the mapping logic.
Introduces a new private ClassType method to handle custom-mapped class types, mirroring the existing DelegateType logic. Updates relevant calls to use ClassType instead of DelegateType for class types, improving clarity and separation of concerns in type mapping.
* Add WindowsRuntimeReadOnlyList implementation

Introduces WindowsRuntimeReadOnlyList, a sealed class implementing projected Windows Runtime readonly IList types. This class provides optimized enumeration support and interface projection for Windows Runtime objects, improving performance and integration with .NET.

* Add IReadOnlyListComWrappersMarshallerAttribute

Introduces a custom marshaller attribute for IReadOnlyList in the WinRT.Runtime2 ABI. This enables proper marshalling of IReadOnlyList types, aligning with .NET naming conventions and supporting XAML configurations.

* Handle IBindableVectorView in TypeMarshaller

Return null for 'IBindableVectorView' in TypeMarshaller to avoid resolving a marshalling info instance for which there is no .NET equivalent. This prevents failures when the type map contains an entry but no public type exists.

* Make mappedType parameter nullable in Proxy method

Updated the Proxy method in InteropTypeDefinitionBuilder to accept a nullable TypeSignature for mappedType, and adjusted its usage accordingly. This change allows for cases where a mapped type may not be provided, improving flexibility in interop type generation.

* Refactor IBindableVectorView type mapping logic

Replaces WindowsRuntimeExposedType with IBindableVectorViewType to clarify and specialize the handling of IBindableVectorView type mapping. Updates logic to generate proxy types and type map attributes for both CCW and RCW scenarios, improving maintainability and correctness for Windows.UI.Xaml and Microsoft.UI.Xaml projections.

* Refactor Proxy method to remove referenceMappedType param

Removed the 'referenceMappedType' parameter from InteropTypeDefinitionBuilder.Proxy and updated all call sites to use only the 'mappedType' parameter. The logic now adds the WindowsRuntimeMappedType attribute if 'mappedType' is not null, simplifying the method signature and usage.

* Fix typo in comment in DynamicCustomMappedTypeMapEntriesBuilder

Corrected 'tye' to 'type' in a comment to improve code documentation clarity.

* Remove 'sealed' from override members in bindable classes

Removed the 'sealed' modifier from HasUnwrappableNativeObjectReference and IsOverridableInterface overrides in WindowsRuntimeEnumerable, WindowsRuntimeList, and WindowsRuntimeReadOnlyList. This change allows further overriding in derived classes if needed.

* Rename WindowsRuntimeIterator to WindowsRuntimeEnumerator

Renamed the WindowsRuntimeIterator class and related references to WindowsRuntimeEnumerator for improved clarity and consistency with .NET naming conventions.
Use Resolve(module) directly when resolving ComWrappers marshaller attribute types and update related error handling. Change CustomMappedTypeComWrappersMarshallerAttributeTypeResolveError to take a TypeSignature, add a new NonProjectedTypeComWrappersMarshallerAttributeTypeResolveError(TypeReference, string) for non-projected WinRT types (used for IBindableVectorView), and update the thrown exceptions to provide the correct context (passing the custom-mapped type where appropriate). These changes improve diagnostics and fix the type-resolution call sites.
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.

4 participants