-
Notifications
You must be signed in to change notification settings - Fork 121
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
85
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
+1,677
−347
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.
Introduced TypeMapAssociation attributes for WindowsRuntimeMetadataTypeMapGroup in ABI types including IDisposable, IServiceProvider, AsyncActionCompletedHandler, IVectorChangedEventArgs, IAsyncAction, and IAsyncInfo to improve type mapping and metadata handling.
…oft/CsWinRT into user/kythant/TypeHandling
Replaces WindowsRuntimeComWrappersTypeMapGroup with WindowsRuntimeMetadataTypeMapGroup in Matrix3x2, Matrix4x4, Plane, Quaternion, and Vector2 type map attributes for improved metadata handling.
Deleted the [WindowsRuntimeMetadataTypeName("Object")] attribute from the Object class as it was unnecessary. This helps clean up the code and avoid redundant metadata.
Added TypeMapAssemblyTarget attributes for WindowsRuntimeMetadataTypeMapGroup and DynamicInterfaceCastableImplementationTypeMapGroup to support additional type mapping scenarios in generated assemblies.
Refactored ABI.System.ComponentModel.INotifyDataErrorInfo to consistently use fully qualified type names for global::System.ComponentModel.INotifyDataErrorInfo throughout the file. Added new TypeMap and TypeMapAssociation attributes for WindowsRuntimeMetadataTypeMapGroup, and improved documentation comments for clarity. This enhances type safety and interoperability with Windows Runtime metadata.
Replaces PlaceholderWindowsRuntimeComWrappersMarshallerAttribute with WindowsRuntimeComWrappersMarshallerAttributePlaceholder in a new file and updates all references. Removes the old placeholder and related reference type attribute from WindowsRuntimeMarshallingInfo.cs for improved clarity and maintainability.
Replaces PlaceholderDynamicInterfaceCastableImplementationForwarderAttribute with DynamicInterfaceCastableImplementationForwarderAttributePlaceholder and moves its implementation to a new file. Updates all references to use the new class name, improving clarity and organization.
Refactors ContextAwareObjectReference to use NullPlaceholder.Instance instead of PlaceholderNullAgileReference.Instance. Removes the now-unused PlaceholderNullAgileReference class.
Added [WindowsRuntimeMappedType] attributes to various ABI types in the WinRT.Runtime2 project. This change improves type mapping between .NET types and their Windows Runtime counterparts, enhancing interop and metadata clarity.
Introduces the WindowsRuntimeMappedMetadataAttribute for annotating custom-mapped types with their source Windows Runtime metadata file. The attribute is marked obsolete and is intended for internal use.
Replaces the check for WindowsRuntimeMetadataAttribute with WindowsRuntimeMappedMetadataAttribute for proxy types, ensuring correct identification of custom-mapped types. Adds a Debug.Assert to verify the code path is only triggered for proxy types. Also updates a comment for clarity and removes the unused isMetadataType argument in one constructor call.
Updated all ABI type files to use the [WindowsRuntimeMappedMetadata] attribute instead of [WindowsRuntimeMetadata] for contract mapping. This change standardizes the attribute usage across all relevant types in the WinRT.Runtime2 ABI layer.
Refactored the static ConditionalWeakTable field to improve naming consistency and clarity. Updated all references to use the new name, reflecting its purpose of mapping types to metadata info rather than marshalling info.
Added WindowsRuntimeMetadataTypeName and WindowsRuntimeReferenceType attributes to the EventRegistrationToken struct to enhance metadata and type information for interop scenarios.
Updated ABI files for IVectorChangedEventArgs, IAsyncAction, and IAsyncInfo to use direct type references instead of global::Windows.Foundation.* type names. Removed redundant TypeMapAssociation attributes and adjusted marshaller and interface implementation code accordingly. Also removed an unused attribute from EventRegistrationToken. These changes improve code clarity and maintainability by reducing reliance on global type names and streamlining type mapping.
…oft/CsWinRT into user/kythant/TypeHandling
Introduced GetAnonymousInspectableMarshallingInfo to centralize logic for retrieving marshalling info for anonymous objects, including special cases for Exception and Type. This improves code clarity and maintainability by removing repeated logic and handling custom exception and Type instances more explicitly.
Added special handling for projected types, exceptions, and System.Type in TypeMarshaller. Improved logic for mapping metadata types to CLR types, including handling for KeyValuePair and delegate types. These changes improve accuracy and round-tripping of type information during marshalling.
Enhanced TypeMarshaller to better handle value types and delegates without explicit metadata names, and to properly bypass marshalling for Nullable<KeyValuePair<,>> types. Removed redundant [WindowsRuntimeMetadataTypeName] attributes from Point, Rect, and Size to align with updated marshalling logic.
…oft/CsWinRT into user/kythant/TypeHandling
Replaces usage of _metadataTypeName with _runtimeClassName when retrieving the cached runtime class name, ensuring the correct value is returned.
…oft/CsWinRT into user/kythant/TypeHandling
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.