Isolated Analyzers and Relay projects
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Discord.Net.Tests")]
|
||||
@@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
|
||||
namespace RegexAnalyzer
|
||||
{
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public class ConfigureAwaitAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
public const string DiagnosticId = "ConfigureAwait";
|
||||
internal const string Title = "ConfigureAwait was not specified";
|
||||
internal const string MessageFormat = "ConfigureAwait error {0}";
|
||||
internal const string Description = "ConfigureAwait(false) should be used.";
|
||||
internal const string Category = "Usage";
|
||||
internal static DiagnosticDescriptor Rule =
|
||||
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat,
|
||||
Category, DiagnosticSeverity.Error, isEnabledByDefault: true, description: Description);
|
||||
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
|
||||
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.InvocationExpression);
|
||||
}
|
||||
|
||||
private void AnalyzeNode(SyntaxNodeAnalysisContext context)
|
||||
{
|
||||
/*var invocationExpr = (InvocationExpressionSyntax)context.Node;
|
||||
var memberAccessExpr = invocationExpr.Expression as MemberAccessExpressionSyntax;
|
||||
if (memberAccessExpr?.Name.ToString() != "Match") return;
|
||||
var memberSymbol = context.SemanticModel.GetSymbolInfo(memberAccessExpr).Symbol as IMethodSymbol;
|
||||
if (!memberSymbol?.ToString().StartsWith("System.Text.RegularExpressions.Regex.Match") ?? true) return;
|
||||
var argumentList = invocationExpr.ArgumentList as ArgumentListSyntax;
|
||||
if ((argumentList?.Arguments.Count ?? 0) < 2) return;
|
||||
var regexLiteral = argumentList.Arguments[1].Expression as LiteralExpressionSyntax;
|
||||
if (regexLiteral == null) return;
|
||||
var regexOpt = context.SemanticModel.GetConstantValue(regexLiteral);
|
||||
if (!regexOpt.HasValue) return;
|
||||
var regex = regexOpt.Value as string;
|
||||
if (regex == null) return;
|
||||
try
|
||||
{
|
||||
System.Text.RegularExpressions.Regex.Match("", regex);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
var diagnostic = Diagnostic.Create(Rule, regexLiteral.GetLocation(), e.Message);
|
||||
context.ReportDiagnostic(diagnostic);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="../../Discord.Net.targets" />
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Discord.Net.Analyzers</AssemblyName>
|
||||
<RootNamespace>Discord.Analyzers</RootNamespace>
|
||||
<Description>A Discord.Net extension adding compile-time analysis.</Description>
|
||||
<TargetFrameworks>netstandard1.3</TargetFrameworks>
|
||||
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win81</PackageTargetFallback>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.0.0-rc2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user