Skip to content
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

Marshalling source generation code could pass TypePositionInfo and StubCodeContext only to constructors and have parameterless generation methods #89033

Closed
jtschuster opened this issue Jul 17, 2023 · 1 comment · Fixed by #105597
Labels
area-System.Runtime.InteropServices in-pr There is an active PR which will close this issue when it is merged source-generator Indicates an issue with a source generator feature
Milestone

Comments

@jtschuster
Copy link
Member

The marshalling generator types in Microsoft.Interop.SourceGeneration pass a StubCodeContext to a method that builds an IMarshallingGenerator, which takes a TypePositionInfo and StubCodeContext each time it generates a method, and has different behavior depending on those.

If instead, a constructor method composed an object based on the StubCodeContext and TypePositionInfo, and the methods on the object took no parameters, the generator could be much easier to debug and unit test, as the composition of the object would be the only thing that impacts the generated code. This would also make it easy to unit test, since tests could compose an object and test the behavior of the generator without need to create a TypePositionInfo and StubCodeContext.

@jtschuster jtschuster added area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature labels Jul 17, 2023
@jtschuster jtschuster self-assigned this Jul 17, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 17, 2023
@ghost
Copy link

ghost commented Jul 17, 2023

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

Issue Details

The marshalling generator types in Microsoft.Interop.SourceGeneration pass a StubCodeContext to a method that builds an IMarshallingGenerator, which takes a TypePositionInfo and StubCodeContext each time it generates a method, and has different behavior depending on those.

If instead, a constructor method composed an object based on the StubCodeContext and TypePositionInfo, and the methods on the object took no parameters, the generator could be much easier to debug and unit test, as the composition of the object would be the only thing that impacts the generated code. This would also make it easy to unit test, since tests could compose an object and test the behavior of the generator without need to create a TypePositionInfo and StubCodeContext.

Author: jtschuster
Assignees: jtschuster
Labels:

area-System.Runtime.InteropServices, source-generator

Milestone: -

@jkoritzinsky jkoritzinsky added this to the 9.0.0 milestone Jul 20, 2023
@jkoritzinsky jkoritzinsky removed the untriaged New issue has not been triaged by the area owner label Jul 20, 2023
@jtschuster jtschuster removed their assignment Jul 25, 2023
@jkoritzinsky jkoritzinsky added the in-pr There is an active PR which will close this issue when it is merged label Jul 27, 2024
@jkoritzinsky jkoritzinsky modified the milestones: 9.0.0, 10.0.0 Aug 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices in-pr There is an active PR which will close this issue when it is merged source-generator Indicates an issue with a source generator feature
Projects
Archived in project
2 participants