-
Notifications
You must be signed in to change notification settings - Fork 123
System.Type Marshaling #2129
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
Open
kythant
wants to merge
168
commits into
staging/3.0
Choose a base branch
from
user/kythant/TypeHandling
base: staging/3.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
System.Type Marshaling #2129
+3,173
−757
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit ff83e55.
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.
…oft/CsWinRT into user/kythant/TypeHandling
…icrosoft/CsWinRT into user/kythant/TypeHandling
Add assembly-level TypeMapAssociation attributes to associate INotifyPropertyChanged and INotifyCollectionChanged with their respective ABI proxy implementation types (INotifyPropertyChangedInterfaceImpl and INotifyCollectionChangedInterfaceImpl). This enables the DynamicInterfaceCastableImplementationTypeMapGroup to locate the proxy types for interop/ComWrappers scenarios. Changes applied to the corresponding ABI files for ComponentModel and Collections.Specialized.
Replace fully-qualified "global::System.Collections.IEnumerator" with the simpler "IEnumerator" in IEnumerable-related marshaller and implementation methods (GetEnumerator implementations and return types) in src/WinRT.Runtime2/ABI/System/Collections/IEnumerable.cs for consistency and readability. No behavioral changes intended.
Add InterfaceType calls to emit dynamic custom mapped type map entries for INotifyPropertyChanged and INotifyCollectionChanged. Each entry supplies Windows and Microsoft XAML metadata, the trim target (using the respective reference type signature), interopReferences, module, and useWindowsUIXamlProjections. Keeps TODO notes to also emit the IDIC interface.
Make the WindowsRuntimeComWrappersMarshaller attribute optional when generating interop proxy types. Add a new useComWrappersMarshallerAttribute flag to InterfaceType call sites and its signature; only look up and pass the marshaller attribute TypeDefinition when requested. Update InteropTypeDefinitionBuilder to accept a nullable attribute type and only emit the custom attribute if it's non-null. This avoids unnecessary lookups/emission for interfaces that don't require a ComWrappers marshaller (e.g. INotifyPropertyChanged) while still enabling it for types that do (e.g. IEnumerable). Files changed: DynamicCustomMappedTypeMapEntriesBuilder.cs, InteropTypeDefinitionBuilder.cs.
Add the [WindowsRuntimeClassName("Microsoft.UI.Xaml.Data.DataErrorsChangedEventArgs")] attribute to the ABI.System.ComponentModel.DataErrorsChangedEventArgs declaration so the ABI type is associated with the correct WinRT class name. This clarifies runtime metadata for WinRT interop and mapping to Microsoft.UI.Xaml.Data.DataErrorsChangedEventArgs.
Remove the [WindowsRuntimeMappedMetadata("Windows.Foundation.FoundationContract")] attribute from ABI.System.EventHandler and add a clarifying comment. This prevents automatic Windows Runtime mapping for EventHandler so that marshalling typeof(EventHandler) remains a custom type and aligns with existing special-case marshalling behavior.
Remove the WindowsRuntimeMappedMetadata and WindowsRuntimeClassName attributes from the DynamicInterfaceCastable implementation of global::System.IDisposable (IDisposableInterfaceImpl in ABI/System/IDisposable.cs). This change strips unnecessary WinRT annotations from the interface implementation; no other code modifications were made.
manodasanW
reviewed
Feb 4, 2026
| } | ||
|
|
||
| void write_struct_winrt_classname_attribute(writer& w, TypeDef const& type) | ||
| void write_winrt_classname_attribute(writer& w, TypeDef const& type) |
Member
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.
Suggested change
| void write_winrt_classname_attribute(writer& w, TypeDef const& type) | |
| void write_value_type_winrt_classname_attribute(writer& w, TypeDef const& type) |
550bc58 to
5b9ef4e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.