You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning CS8785 Generator 'OneOfGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'ConsoleApp1_Result.g.cs' of the added source file must be unique within a generator.
Parameter name: hintName' ConsoleApp1 C:\Users\...\ConsoleApp1.csproj 1 Active Generator threw the following exception:
'System.ArgumentException: The hintName 'ConsoleApp1_Result.g.cs' of the added source file must be unique within a generator.
Parameter name: hintName
at Microsoft.CodeAnalysis.AdditionalSourcesCollection.Add(String hintName, SourceText source)
at OneOf.SourceGenerator.OneOfGenerator.Execute(SourceProductionContext context, ImmutableArray`1 symbols)
at Microsoft.CodeAnalysis.UserFunctionExtensions.<>c__DisplayClass3_0`2.<WrapUserAction>b__0(TInput1 input1, TInput2 input2, CancellationToken token)'.
we can do one of the following:
Put ALL the generated source code into one file
Change file name generation to something like typeof(Result<,,>).ToString() which should generate ~ "Result`3[T1,T2,T3]" (we can replace "`[,]" characters with underscores
Add number of generic arguments to file name (ConsoleApp1_Result_3.g.cs, ConsoleApp1_Result_2.g.cs)
side note:
source generator also fails when we put the type into global namespace:
Using this code, the source generator does not generate anything:
If I rename or remove one of the classes, it does work as expected.
The text was updated successfully, but these errors were encountered: