-
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
110
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
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.
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
… test case for where there is a metadata scenario
Added special handling for KeyValuePair<,> types in the TypeMarshaller to ensure the correct runtime class name is used for marshalling. Updated comments to clarify logic and removed outdated TODO.
…to user/kythant/TypeHandling
…to user/kythant/TypeHandling
Replaces Debug.Assert with a NotSupportedException when the WindowsRuntimeMappedTypeAttribute is missing on the metadata provider type in both WindowsRuntimeMarshallingInfo and WindowsRuntimeMetadataInfo. This provides clearer error reporting and guidance for unexpected code generation issues.
Deleted outdated TODO comments regarding type map entries for non-generic interfaces, value types, and delegate types in TypeMarshaller. No functional code changes were made.
Introduces methods and references to handle TypeMap and TypeMapAssociation attributes for WindowsRuntimeMetadataTypeMapGroup in InteropCustomAttributeFactory and InteropReferences. This enables generation and referencing of custom attributes using the new type map group.
Reorganized conditional checks for nullable and projected types in TypeMarshaller. Ensures special handling for types that cannot be used in Nullable<T> and improves clarity by nesting projected and metadata info lookups under a single nullable check.
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.
31c9fb6 to
1c5e5b4
Compare
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.
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.