|
@@ -1,4 +1,5 @@
|
|
|
using System.Collections.Immutable;
|
|
using System.Collections.Immutable;
|
|
|
|
|
+using System.Linq;
|
|
|
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis;
|
|
|
using Microsoft.CodeAnalysis.Diagnostics;
|
|
using Microsoft.CodeAnalysis.Diagnostics;
|
|
|
|
|
|
|
@@ -8,7 +9,7 @@ namespace ET.Analyzer
|
|
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
|
public class EntityClassDeclarationAnalyzer: DiagnosticAnalyzer
|
|
public class EntityClassDeclarationAnalyzer: DiagnosticAnalyzer
|
|
|
{
|
|
{
|
|
|
- public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(EntityClassDeclarationAnalyzerRule.Rule);
|
|
|
|
|
|
|
+ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(EntityClassDeclarationAnalyzerRule.Rule,EntityCannotDeclareGenericTypeRule.Rule);
|
|
|
|
|
|
|
|
public override void Initialize(AnalysisContext context)
|
|
public override void Initialize(AnalysisContext context)
|
|
|
{
|
|
{
|
|
@@ -50,6 +51,19 @@ namespace ET.Analyzer
|
|
|
Diagnostic diagnostic = Diagnostic.Create(EntityClassDeclarationAnalyzerRule.Rule, classSyntax.GetLocation(), namedTypeSymbol.Name,Definition.EntityType);
|
|
Diagnostic diagnostic = Diagnostic.Create(EntityClassDeclarationAnalyzerRule.Rule, classSyntax.GetLocation(), namedTypeSymbol.Name,Definition.EntityType);
|
|
|
context.ReportDiagnostic(diagnostic);
|
|
context.ReportDiagnostic(diagnostic);
|
|
|
}
|
|
}
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var baseType = namedTypeSymbol.BaseType?.ToString();
|
|
|
|
|
+ if (baseType == Definition.EntityType || baseType == Definition.LSEntityType)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (namedTypeSymbol.IsGenericType)
|
|
|
|
|
+ {
|
|
|
|
|
+ var entitySyntax = namedTypeSymbol.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax();
|
|
|
|
|
+ Diagnostic diagnostic = Diagnostic.Create(EntityCannotDeclareGenericTypeRule.Rule, entitySyntax?.GetLocation(),
|
|
|
|
|
+ namedTypeSymbol.Name);
|
|
|
|
|
+ context.ReportDiagnostic(diagnostic);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|