#16: add first implementation of tableEntry analyzer

pull/26/head
Simon Gockner 6 years ago
parent a27d344bbb
commit 9c1b890959
  1. 38
      GBase/Diagnosis/GBaseTableEntryAnalyzer.cs
  2. 1
      GBase/GBase.csproj

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace GBase.Diagnosis
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class GBaseTableEntryAnalyzer : DiagnosticAnalyzer
{
private const string DIAGNOSTIC_ID = "GBaseTableEntryAnalyzer";
private const string CATEGORY = "GBaseTableEntryAnalyzer Category";
private static readonly LocalizableString _title = "Missing GBaseEntries for this GBaseTable";
private static readonly LocalizableString _messageFormat = "Type '{0}' is marked as GBaseTable but doesn't contain any GBase entries.";
private static readonly DiagnosticDescriptor _rule = new DiagnosticDescriptor(DIAGNOSTIC_ID, _title, _messageFormat, CATEGORY, DiagnosticSeverity.Warning, true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(_rule); } }
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.Attribute);
}
private void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
AttributeSyntax attribute = (AttributeSyntax) context.Node;
}
}
}

@ -23,6 +23,7 @@
<ItemGroup>
<PackageReference Include="LightweightIocContainer" Version="2.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.5.0-beta2-final" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save