@@ -110,28 +110,7 @@ public async Task<string> GenerateTypesAsync(GraphQLTypeGeneratorOptions options
110110
111111 private class Context
112112 {
113- public class DotNetTypeWithMembers
114- {
115- public string TypeName { get ; init ; }
116- private HashSet < string > MemberNames { get ; } = new ( ) ;
117- public void AddMember ( string memberName )
118- {
119- MemberNames . Add ( memberName ) ;
120- }
121-
122- public IEnumerable < string > GetMembers ( ) => MemberNames ;
123- }
124-
125113 public readonly StringBuilder StrBuilder = new ( ) ;
126- private readonly List < DotNetTypeWithMembers > _dotNetTypes = new ( ) ;
127- public IEnumerable < DotNetTypeWithMembers > DotNetTypes => _dotNetTypes ;
128-
129- public DotNetTypeWithMembers AddDotNetType ( string typeName )
130- {
131- var dotNetType = new DotNetTypeWithMembers { TypeName = typeName } ;
132- _dotNetTypes . Add ( dotNetType ) ;
133- return dotNetType ;
134- }
135114 }
136115
137116 public string GenerateTypes ( GraphQLTypeGeneratorOptions options , JsonDocument introspectionQueryResponse )
@@ -259,9 +238,8 @@ private void GenerateUnion(Context ctx, GraphQLType type, Dictionary<string, Gra
259238 f => ( GenerateTypeName ( f . type , options ) , f . name ) ) ;
260239 }
261240
262- var dotNetType = ctx . AddDotNetType ( interfaceName ) ;
263241 commonFields
264- . ForEach ( f => GenerateField ( ctx , dotNetType , type , f , options ) ) ;
242+ . ForEach ( f => GenerateField ( ctx , type , f , options ) ) ;
265243
266244 str . AppendLine ( "}" ) ;
267245 }
@@ -298,11 +276,10 @@ private void GenerateInterface(Context ctx, GraphQLType type, Dictionary<string,
298276 }
299277 }
300278
301- var dotNetType = ctx . AddDotNetType ( interfaceName ) ;
302279 type . fields
303280 //interface shouldn't redeclare fields already declare in parent interfaces
304281 . Where ( f => ( type . interfaces ?? [ ] ) . SelectMany ( i => i . fields ) . Where ( f2 => f2 . name == f . name ) . IsEmpty ( ) )
305- . ForEach ( f => GenerateField ( ctx , dotNetType , type , f , options ) ) ;
282+ . ForEach ( f => GenerateField ( ctx , type , f , options ) ) ;
306283
307284 str . AppendLine ( "}" ) ;
308285 }
@@ -369,14 +346,13 @@ private void GenerateClass(Context ctx, GraphQLType type, Dictionary<string, Gra
369346 str . AppendLine ( ) ;
370347 str . AppendLine ( "{" ) ;
371348
372- var dotNetType = ctx . AddDotNetType ( className ) ;
373349 type . fields
374- . ForEach ( f => GenerateField ( ctx , dotNetType , type , f , options ) ) ;
350+ . ForEach ( f => GenerateField ( ctx , type , f , options ) ) ;
375351
376352 str . AppendLine ( "}" ) ;
377353 }
378354
379- private void GenerateField ( Context ctx , Context . DotNetTypeWithMembers containingDotNetType , GraphQLType containingType , GraphQLField f , GraphQLTypeGeneratorOptions options )
355+ private void GenerateField ( Context ctx , GraphQLType containingType , GraphQLField f , GraphQLTypeGeneratorOptions options )
380356 {
381357 var str = ctx . StrBuilder
382358 . AppendLine ( GenerateDescriptionCommentAndAttribute ( f . description ) ) ;
@@ -393,7 +369,6 @@ private void GenerateField(Context ctx, Context.DotNetTypeWithMembers containing
393369 string typeName = GenerateTypeName ( f . type , options , f . name , containingType ) ;
394370 str . AppendLine ( $ "public { typeName } ? { EscapeCSharpKeyword ( f . name ) } {{ { ( containingType . kind == GraphQLTypeKind . INTERFACE ? "get;" : "get;set;" ) } }}")
395371 . AppendLine ( ) ;
396- containingDotNetType . AddMember ( f . name ) ;
397372 }
398373
399374 private bool TryGetTypeNameOverride ( GraphQLType containingType , string fieldName , GraphQLTypeGeneratorOptions options , out string typeName )
0 commit comments