-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Describe the issue
The methods in the MarshalInfo class in the incremental-generator branch are responsible for parsing user-supplied MarshalAsAttributes. It is supported for this attribute to be supplied by a reference to a readonly field, but previously this was not properly implemented. The correct Roslyn APIs necessary were not understood. See GetOperation returning null for VariableDeclaratorSyntax, VariableDeclarationSyntax, and FieldDeclarationSyntax - Stack Overflow for more information.
Proposed solution
The above referenced Stack Overflow question has an answer posted which includes details about the solution to this issue. The IFieldInitializerOperation can be obtained by discovering the EqualsValueClauseSyntax child node of the FieldDeclarationSyntax for inline field initializers. The manual parsing of the MarshalAsAttribute(s) provided by the referenced readonly field should be abandoned in favor of the much more powerful IOperation APIs.
Additional considerations
This issue depends on #15 as it refers to the same areas of the code.
Also, the Stack Overflow answer provides details about parsing values assigned to the readonly field inside of a constructor. This is currently not supported at all, and will be added as a new issue which will depend on this one.