Skip to content

LibraryImport with custom StringMarshalling type causes the source generator to keep the Compilation object alive #78242

@jkoritzinsky

Description

@jkoritzinsky

Description

When using the StringMarshallingCustomType property on a LibraryImport attribute, the generator caches a symbol object, causing the compilation to be kept alive across runs of the generator.

Reproduction Steps

I've included a test case (commented out) in this commit 32f856c (#77130)

Expected behavior

The test should pass.

Actual behavior

The test fails.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

The problem is that the LibraryImportData record type contains a property for the StringMarshallingCustomType property from LibraryImportAttribute and we put that property into our "data model" type IncrementalStubGenerationContext:

We need to change how we pass the attribute data between the "compute the model" stage and the "generate code" stage such that the information we need is available, but the symbols are not passed while still having a decently understandable API.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions