dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.71k stars 3.98k forks source link

Source generators: unique files names #42628

Open chsienki opened 4 years ago

chsienki commented 4 years ago

We currently set the filename of an added syntax tree to the provided hintName, which is only ensured to be unique per-generator.

We should make the names some combination of generator name and hint name to ensure global uniqueness.

Nirmal4G commented 2 years ago

I'm hitting "The hintName of the added source file must be unique within a generator" error message. This happens only when MSBuild's NodeReuse is set to true. I might be wrong but the error disappeared when I set it to false. In a similar project, when the output paths change to a global location (although separated by ProjectName), this error occurs again.