Husqvik / GraphQlClientGenerator

GraphQL C# client generator
MIT License
213 stars 49 forks source link

Error CS0542: 'Text': member names cannot be the same as their enclosing type (CS0542) #106

Closed dori4n closed 2 years ago

dori4n commented 2 years ago

The generator generates illegal classes with fields that have the same name as the class, if an object type in the GraphQL schema has a member with a similar name, such that after Pascal case conversion, it ends up being the same. Example: Text object type with member/field name text, or ClassObject type with field name class_object.

It would be good to detect this type of name collision and to pick a different name. 🙂

Husqvik commented 2 years ago

the GraphQlGeneratorConfiguration class contains CustomClassNameMapping where you can define remapping of colliding names or if you just want to call the classes differently than their original GraphQL name. I will consider to generate a surrogate suffix to a class automatically if the name collides to not explicitly require this option.