net_automatic_interface icon indicating copy to clipboard operation
net_automatic_interface copied to clipboard

Random crashes

Open skarllot opened this issue 1 year ago • 3 comments

The generator is randomly crashing with the error below:

Generator 'AutomaticInterfaceGenerator' 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 '<redacted>.IFileDiscovery.cs' of the added source file must be unique within a generator. (Parameter 'hintName')'.
System.ArgumentException: The hintName '<redacted>.IFileDiscovery.cs' of the added source file must be unique within a generator. (Parameter 'hintName')
at Microsoft.CodeAnalysis.AdditionalSourcesCollection.Add(String hintName, SourceText source) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\SourceGeneration\AdditionalSourcesCollection.cs:line 78
at AutomaticInterface.AutomaticInterfaceGenerator.GenerateCode(SourceProductionContext context, ImmutableArray`1 enumerations)
at Microsoft.CodeAnalysis.UserFunctionExtensions.c__DisplayClass3_0`2. b__0(TInput1 input1, TInput2 input2, CancellationToken token) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\SourceGeneration\UserFunction.cs:line 101

-----

System.ArgumentException: The hintName '<redacted>.IFileDiscovery.cs' of the added source file must be unique within a generator. (Parameter 'hintName')
at Microsoft.CodeAnalysis.AdditionalSourcesCollection.Add(String hintName, SourceText source) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\SourceGeneration\AdditionalSourcesCollection.cs:line 78
at AutomaticInterface.AutomaticInterfaceGenerator.GenerateCode(SourceProductionContext context, ImmutableArray`1 enumerations)
at Microsoft.CodeAnalysis.UserFunctionExtensions.c__DisplayClass3_0`2. b__0(TInput1 input1, TInput2 input2, CancellationToken token) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\SourceGeneration\UserFunction.cs:line 101

skarllot avatar Apr 13 '24 23:04 skarllot

I've encountered this Problem before. The problem is that the created name must be unique, but the API of an interface Generator does not allow to check for that. To solve this: Can you make sure that only one interface with the name FileDiscovery exists?

ChristianSauer avatar Apr 15 '24 12:04 ChristianSauer

Yes, there's only one

skarllot avatar Apr 15 '24 13:04 skarllot

OK, can you produce a minimal sample?

ChristianSauer avatar Apr 15 '24 13:04 ChristianSauer

I couldn't replay the problem anymore

skarllot avatar Aug 28 '24 01:08 skarllot