@@ -20,7 +20,7 @@ class WebApiClientHtttApi
2020 /// <summary>
2121 /// 接口声明
2222 /// </summary>
23- private readonly InterfaceDeclarationSyntax interfaceDeclaration ;
23+ private readonly InterfaceDeclarationSyntax httpApiInterfaceSyntax ;
2424
2525 /// <summary>
2626 /// webApiClient上下文
@@ -39,7 +39,7 @@ class WebApiClientHtttApi
3939 public WebApiClientHtttApi ( SyntaxNodeAnalysisContext syntaxNodeContext )
4040 {
4141 this . syntaxNodeContext = syntaxNodeContext ;
42- this . interfaceDeclaration = syntaxNodeContext . Node as InterfaceDeclarationSyntax ;
42+ this . httpApiInterfaceSyntax = syntaxNodeContext . Node as InterfaceDeclarationSyntax ;
4343 this . webApiClientContext = new WebApiClientContext ( syntaxNodeContext . Compilation ) ;
4444 this . IsHtttApiInterface = this . GetIsHtttApiInterface ( ) ;
4545 }
@@ -50,12 +50,12 @@ public WebApiClientHtttApi(SyntaxNodeAnalysisContext syntaxNodeContext)
5050 /// <returns></returns>
5151 private bool GetIsHtttApiInterface ( )
5252 {
53- if ( this . interfaceDeclaration == null || this . interfaceDeclaration . BaseList == null )
53+ if ( this . httpApiInterfaceSyntax == null || this . httpApiInterfaceSyntax . BaseList == null )
5454 {
5555 return false ;
5656 }
5757
58- foreach ( var baseType in this . interfaceDeclaration . BaseList . Types )
58+ foreach ( var baseType in this . httpApiInterfaceSyntax . BaseList . Types )
5959 {
6060 var type = this . syntaxNodeContext . SemanticModel . GetTypeInfo ( baseType . Type ) . Type ;
6161 if ( type . Equals ( this . webApiClientContext . IHttpApiType ) == true )
@@ -75,6 +75,7 @@ public void ReportDiagnostic()
7575 this . ReportDiagnosticOfAttributes ( ) ;
7676 this . ReportDiagnosticOfReturnTypes ( ) ;
7777 this . ReportDiagnosticOfRefParameters ( ) ;
78+ this . ReportDiagnosticOfNotMethodDefinds ( ) ;
7879 }
7980
8081 /// <summary>
@@ -87,7 +88,7 @@ public void ReportDiagnosticOfAttributes()
8788 return ;
8889 }
8990
90- var interfaceSymbol = this . syntaxNodeContext . SemanticModel . GetDeclaredSymbol ( this . interfaceDeclaration ) ;
91+ var interfaceSymbol = this . syntaxNodeContext . SemanticModel . GetDeclaredSymbol ( this . httpApiInterfaceSyntax ) ;
9192 if ( interfaceSymbol == null )
9293 {
9394 return ;
@@ -155,13 +156,34 @@ public void ReportDiagnosticOfRefParameters()
155156 }
156157 }
157158
159+ /// <summary>
160+ /// 报告非方法声明诊断
161+ /// </summary>
162+ public void ReportDiagnosticOfNotMethodDefinds ( )
163+ {
164+ if ( this . IsHtttApiInterface == false )
165+ {
166+ return ;
167+ }
168+
169+ foreach ( var member in this . httpApiInterfaceSyntax . Members )
170+ {
171+ if ( member . Kind ( ) != SyntaxKind . MethodDeclaration )
172+ {
173+ var location = member . GetLocation ( ) ;
174+ var diagnostic = DiagnosticDescriptors . NotMethodDefindDescriptor . ToDiagnostic ( location ) ;
175+ this . syntaxNodeContext . ReportDiagnostic ( diagnostic ) ;
176+ }
177+ }
178+ }
179+
158180 /// <summary>
159181 /// 获取HttpApi方法
160182 /// </summary>
161183 /// <returns></returns>
162184 private IEnumerable < IMethodSymbol > GetHttpApiMethodSymbols ( )
163185 {
164- foreach ( var member in this . interfaceDeclaration . Members )
186+ foreach ( var member in this . httpApiInterfaceSyntax . Members )
165187 {
166188 if ( member . Kind ( ) != SyntaxKind . MethodDeclaration )
167189 {
0 commit comments