Skip to content

Conversation

@jkoritzinsky
Copy link
Member

One class will handle the raw parsing of the MarshalAs attribute.

The other class handles resolving a MarshalAs attribute into the custom marshaller type that will provide the marshalling based on our generator's rules.

This split makes it easier for other generator models to reuse our parsing logic without having to also reuse our custom marshaller resolution logic. In particular, a hypothetical IDispatch-focused generator would want to marshal all values into VARIANT values, so they may want to reuse the marshaller attribute parsing logic, but not the custom marshallers directly.

One class will handle the raw parsing of the MarshalAs attribute.

The other class handles resolving a MarshalAs attribute into the custom marshaller type that will provide the marshalling based on our generator's rules.

This split makes it easier for other generator models to reuse our parsing logic without having to also reuse our custom marshaller resolution logic. In particular, a hypothetical IDispatch-focused generator would want to marshal all values into `VARIANT` values, so they may want to reuse the marshaller attribute parsing logic, but not the custom marshallers directly.
@jkoritzinsky jkoritzinsky added area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature labels Oct 4, 2023
@jkoritzinsky jkoritzinsky added this to the 9.0.0 milestone Oct 4, 2023
@ghost ghost assigned jkoritzinsky Oct 4, 2023
@ghost
Copy link

ghost commented Oct 4, 2023

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Issue Details

One class will handle the raw parsing of the MarshalAs attribute.

The other class handles resolving a MarshalAs attribute into the custom marshaller type that will provide the marshalling based on our generator's rules.

This split makes it easier for other generator models to reuse our parsing logic without having to also reuse our custom marshaller resolution logic. In particular, a hypothetical IDispatch-focused generator would want to marshal all values into VARIANT values, so they may want to reuse the marshaller attribute parsing logic, but not the custom marshallers directly.

Author: jkoritzinsky
Assignees: -
Labels:

area-System.Runtime.InteropServices, source-generator

Milestone: 9.0.0

/// This class suppports parsing a System.Runtime.InteropServices.MarshalAsAttribute.
/// This class suppports parsing a System.Runtime.InteropServices.MarshalAsAttribute into a <see cref="MarshalAsInfo"/>.
/// </summary>
public sealed class MarshalAsAttributeParser : IMarshallingInfoAttributeParser, IUseSiteAttributeParser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still used as a IMarshallingInfoAttributeParser now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intended to optionally be used that way. We don't use it in the same way currently, but we delegate to this implementation from the other one through the interface.

@jkoritzinsky jkoritzinsky merged commit 55be11c into dotnet:main Oct 5, 2023
@jkoritzinsky jkoritzinsky deleted the marshalas-parser-split branch October 5, 2023 02:54
@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants