GetMarshalAsFromOperation checks the value argument for a constant value. Because the runtime type of the represented value in this method is always MarshalAsAttribute or MarshalAsAttribute[], the only possible constant value is null. The marshalAsStrings argument should have a null element added if the value argument has a constant value (null).
Proposed solution
When value has a constant value (null), a null element should be added to marshalAsStrings:
if (value.ConstantValue.HasValue) // value is null
{
marshalAsStrings.Add(null); // <--- add this line
return;
}
Additional considerations
Work on #1 is already underway and the definition of GetMarshalAsFromOperation has moved to a different file. Because git does not track this refactoring, implementing this change will wait until work on #1 is completed and merged into the incremental-generator branch.
Describe the issue
GetMarshalAsFromOperation
checks thevalue
argument for a constant value. Because the runtime type of the represented value in this method is alwaysMarshalAsAttribute
orMarshalAsAttribute[]
, the only possible constant value isnull
. ThemarshalAsStrings
argument should have anull
element added if thevalue
argument has a constant value (null
).Proposed solution
When
value
has a constant value (null
), anull
element should be added tomarshalAsStrings
:Additional considerations
Work on #1 is already underway and the definition of
GetMarshalAsFromOperation
has moved to a different file. Because git does not track this refactoring, implementing this change will wait until work on #1 is completed and merged into theincremental-generator
branch.