@@ -53,11 +53,13 @@ is not ClassDeclarationSyntax classSyntax
5353 return string . Empty ;
5454 }
5555 var generationAttribute = GetGenerationAttribute ( typeSymbol ) ;
56- var namespaceName = GetNameSpace ( typeSymbol , generationAttribute ) ;
5756 var asInternal = GetAsInternal ( generationAttribute ) ;
58- var interfaceName = $ "I{ classSyntax . GetClassName ( ) } ";
59-
60- var interfaceGenerator = new InterfaceBuilder ( namespaceName , interfaceName , asInternal ) ;
57+ var symbolDetails = GetSymbolDetails ( typeSymbol , classSyntax ) ;
58+ var interfaceGenerator = new InterfaceBuilder (
59+ symbolDetails . NamespaceName ,
60+ symbolDetails . InterfaceName ,
61+ asInternal
62+ ) ;
6163
6264 interfaceGenerator . AddClassDocumentation ( GetDocumentationForClass ( classSyntax ) ) ;
6365 interfaceGenerator . AddGeneric ( GetGeneric ( classSyntax , namedTypeSymbol ) ) ;
@@ -78,14 +80,14 @@ is not ClassDeclarationSyntax classSyntax
7880 return generatedCode ;
7981 }
8082
81- private static AttributeData ? GetGenerationAttribute ( ISymbol typeSymbol )
82- {
83- return typeSymbol
84- . GetAttributes ( )
85- . FirstOrDefault ( x =>
86- x . AttributeClass != null
87- && x . AttributeClass . Name . Contains ( AutomaticInterfaceGenerator . DefaultAttributeName )
88- ) ;
83+ private static AttributeData ? GetGenerationAttribute ( ISymbol typeSymbol )
84+ {
85+ return typeSymbol
86+ . GetAttributes ( )
87+ . FirstOrDefault ( x =>
88+ x . AttributeClass != null
89+ && x . AttributeClass . Name . Contains ( AutomaticInterfaceGenerator . DefaultAttributeName )
90+ ) ;
8991 }
9092
9193 private static string GetNameSpace ( ISymbol typeSymbol , AttributeData ? generationAttribute )
@@ -100,20 +102,36 @@ private static string GetNameSpace(ISymbol typeSymbol, AttributeData? generation
100102 return string . IsNullOrWhiteSpace ( customNs )
101103 ? typeSymbol . ContainingNamespace . ToDisplayString ( )
102104 : customNs ! ;
103- }
104-
105+ }
106+
105107 private static bool GetAsInternal ( AttributeData ? generationAttribute )
106108 {
107109 if ( generationAttribute == null )
108110 {
109111 return false ;
110112 }
111113
112- var asInternal = ( bool ? ) generationAttribute . ConstructorArguments . Skip ( 1 ) . FirstOrDefault ( ) . Value ;
114+ var asInternal = ( bool ? )
115+ generationAttribute . ConstructorArguments . Skip ( 2 ) . FirstOrDefault ( ) . Value ;
113116
114117 return asInternal . GetValueOrDefault ( ) ;
115118 }
116119
120+ private static GeneratedSymbolDetails GetSymbolDetails (
121+ ITypeSymbol typeSymbol ,
122+ ClassDeclarationSyntax classSyntax
123+ )
124+ {
125+ var generationAttribute = typeSymbol
126+ . GetAttributes ( )
127+ . FirstOrDefault ( x =>
128+ x . AttributeClass != null
129+ && x . AttributeClass . Name . Contains ( AutomaticInterfaceGenerator . DefaultAttributeName )
130+ ) ;
131+
132+ return new GeneratedSymbolDetails ( generationAttribute , typeSymbol , classSyntax ) ;
133+ }
134+
117135 private static void AddMethodsToInterface ( List < ISymbol > members , InterfaceBuilder codeGenerator )
118136 {
119137 members
0 commit comments