Marshalling source generation code could pass TypePositionInfo and StubCodeContext only to constructors and have parameterless generation methods #89033
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
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.
The text was updated successfully, but these errors were encountered: