graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Types.Analyzer generates invalid class names when assembly contains certain characters

Open Keyslam opened this issue 1 year ago • 1 comments

Product

Hot Chocolate

Version

13.9.0

Link to minimal reproduction

https://github.com/Keyslam/HotChocolate-SourceGeneratorAssemblyName

Steps to reproduce

  1. Create an assembly with an invalid character for a class in its same (For example HotChocolate-Test)
  2. Add the HotChocolate and HotChocolate.Types.Analyzers packages
  3. Define a class that inherits from ObjectType

What is expected?

The source generator should generate a valid ...TypesRequestExecutorBuilderExtensions file

What is actually happening?

The ...TypesRequestExecutorBuilderExtensions class name includes the invalid characters, causing compile issues.

Relevant log output

No response

Additional context

I think modifying Types.Analyzers.Helpers.GeneratorUtils.CreateModuleName to strip out invalid characters would be a good solution. If that is acceptable I can submit a PR for it. https://github.com/ChilliCream/graphql-platform/blob/1af5a4775e4f77e0757b739ee0081fd962ac6901/src/HotChocolate/Core/src/Types.Analyzers/Helpers/GeneratorUtils.cs#L40

Keyslam avatar Feb 20 '24 13:02 Keyslam

As a workaround you can override the module name with the ModuleInfo ....

michaelstaib avatar Feb 29 '24 22:02 michaelstaib