diff --git a/.github/workflows/dotnet-library.yml b/.github/workflows/dotnet-library.yml index e5b4621..d1658f6 100644 --- a/.github/workflows/dotnet-library.yml +++ b/.github/workflows/dotnet-library.yml @@ -22,7 +22,7 @@ jobs: - name: Setup .Net uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Build run: dotnet build --configuration Release - name: Test diff --git a/Source/CodeAnalysis/AnalyzerReleases.Shipped.md b/Source/CodeAnalysis/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000..e69de29 diff --git a/Source/CodeAnalysis/AnalyzerReleases.Unshipped.md b/Source/CodeAnalysis/AnalyzerReleases.Unshipped.md new file mode 100644 index 0000000..d9c58ad --- /dev/null +++ b/Source/CodeAnalysis/AnalyzerReleases.Unshipped.md @@ -0,0 +1,12 @@ +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +DL0001 | Legacy | Error | Analyzer +DL0002 | Style | Error | Analyzer +DL0003 | Openness | Error | Analyzer +DL0004 | Naming | Error | Analyzer +DL0005 | Exceptions | Error | Analyzer +DL0006 | Exceptions | Error | Analyzer +DL0007 | Naming | Error | Analyzer +DL0008 | Exceptions | Error | Analyzer \ No newline at end of file diff --git a/Source/CodeAnalysis/CodeAnalysis.csproj b/Source/CodeAnalysis/CodeAnalysis.csproj index d15fbd0..799eae5 100644 --- a/Source/CodeAnalysis/CodeAnalysis.csproj +++ b/Source/CodeAnalysis/CodeAnalysis.csproj @@ -1,9 +1,10 @@ - + - net5 + netstandard2.0 false + false Dolittle.CodeAnalysis Dolittle.CodeAnalysis @@ -14,18 +15,21 @@ Dolittle.CodeAnalysis 1.0.0.0 - einari - https://github.com/dolittle-tools/DotNET.Common + Dolittle + https://github.com/dolittle/DotNET.Common MIT logo.png - https://github.com/dolittle-tools/DotNET.Common + https://github.com/dolittle/DotNET.Common false Dolittle CodeAnalysis Rules Copyright Dolittle, Code, Analyzers true - + + + + @@ -36,19 +40,19 @@ - - - - - - + + + + + + - + - + diff --git a/Source/CodeAnalysis/ExceptionConstructorParametersShouldNotContainMessage/Analyzer.cs b/Source/CodeAnalysis/ExceptionConstructorParametersShouldNotContainMessage/Analyzer.cs index a8b4516..476c861 100644 --- a/Source/CodeAnalysis/ExceptionConstructorParametersShouldNotContainMessage/Analyzer.cs +++ b/Source/CodeAnalysis/ExceptionConstructorParametersShouldNotContainMessage/Analyzer.cs @@ -23,12 +23,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0006", title: "ExceptionConstructorParametersShouldNotContainMessage", - messageFormat: "An argument of an exception with the name 'message' in it indicates its a generic exception and output string ownership is wrong.", + messageFormat: "An argument of an exception with the name 'message' in it indicates its a generic exception and output string ownership is wrong", category: "Exceptions", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// diff --git a/Source/CodeAnalysis/ExceptionDescriptionShouldFollowStandard/Analyzer.cs b/Source/CodeAnalysis/ExceptionDescriptionShouldFollowStandard/Analyzer.cs index f948efa..d6861dc 100644 --- a/Source/CodeAnalysis/ExceptionDescriptionShouldFollowStandard/Analyzer.cs +++ b/Source/CodeAnalysis/ExceptionDescriptionShouldFollowStandard/Analyzer.cs @@ -28,12 +28,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0007", title: "ExceptionDescriptionShouldFollowStandard", - messageFormat: $"Exception description for API documentation should start with '{Phrase}'.", + messageFormat: $"Exception description for API documentation should start with '{Phrase}'", category: "Naming", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -50,38 +50,52 @@ public override void Initialize(AnalysisContext context) SyntaxKind.ClassDeclaration)); } - void HandleClassDeclaration(SyntaxNodeAnalysisContext context) + static void HandleClassDeclaration(SyntaxNodeAnalysisContext context) { var classDeclaration = context.Node as ClassDeclarationSyntax; - if (classDeclaration?.BaseList == null || classDeclaration?.BaseList?.Types == null) return; + if (classDeclaration?.BaseList?.Types == null) + { + return; + } - if (classDeclaration.InheritsASystemException(context.SemanticModel)) + if (!classDeclaration.InheritsASystemException(context.SemanticModel)) { - foreach (var trivia in classDeclaration.GetLeadingTrivia()) + return; + } + + foreach (var trivia in classDeclaration.GetLeadingTrivia()) + { + if (!trivia.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia) && !trivia.IsKind(SyntaxKind.MultiLineDocumentationCommentTrivia)) { - if (trivia.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia) || - trivia.IsKind(SyntaxKind.MultiLineDocumentationCommentTrivia)) - { - var descendants = trivia.GetStructure().DescendantTokens(); - var summaryTokenAndIndex = descendants - .Select((token, index) => new { Token = token, Index = index }) - .FirstOrDefault(_ => _.Token.IsKind(SyntaxKind.IdentifierToken) && _.Token.Text.Equals("summary", StringComparison.InvariantCulture)); + continue; + } - if (summaryTokenAndIndex == default) return; + var descendants = trivia.GetStructure()?.DescendantTokens().ToArray(); + var summaryTokenAndIndex = descendants + .Select((token, index) => new { Token = token, Index = index }) + .FirstOrDefault(_ => _.Token.IsKind(SyntaxKind.IdentifierToken) && _.Token.Text.Equals("summary", StringComparison.InvariantCulture)); - var xmlTextLiteralToken = descendants - .Skip(summaryTokenAndIndex.Index) - .FirstOrDefault(_ => _.IsKind(SyntaxKind.XmlTextLiteralToken)); + if (summaryTokenAndIndex == default) + { + return; + } + + var xmlTextLiteralToken = descendants + .Skip(summaryTokenAndIndex.Index) + .FirstOrDefault(_ => _.IsKind(SyntaxKind.XmlTextLiteralToken)); - if (xmlTextLiteralToken == default) return; + if (xmlTextLiteralToken == default) + { + return; + } - if (!xmlTextLiteralToken.Text.Trim().StartsWith(Phrase, StringComparison.InvariantCulture)) - { - var diagnostic = Diagnostic.Create(Rule, xmlTextLiteralToken.GetLocation()); - context.ReportDiagnostic(diagnostic); - } - } + if (xmlTextLiteralToken.Text.Trim().StartsWith(Phrase, StringComparison.InvariantCulture)) + { + continue; } + + var diagnostic = Diagnostic.Create(Rule, xmlTextLiteralToken.GetLocation()); + context.ReportDiagnostic(diagnostic); } } } diff --git a/Source/CodeAnalysis/ExceptionShouldBeSpecific/Analyzer.cs b/Source/CodeAnalysis/ExceptionShouldBeSpecific/Analyzer.cs index 4858dcb..dfdecac 100644 --- a/Source/CodeAnalysis/ExceptionShouldBeSpecific/Analyzer.cs +++ b/Source/CodeAnalysis/ExceptionShouldBeSpecific/Analyzer.cs @@ -21,12 +21,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0008", title: "ExceptionShouldBeSpecific", - messageFormat: "Throwing a generic system exception is not a allowed - you should create a specific exception.", + messageFormat: "Throwing a generic system exception is not a allowed - you should create a specific exception", category: "Exceptions", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -42,23 +42,26 @@ public override void Initialize(AnalysisContext context) OperationKind.Throw)); } - void HandleThrow(OperationAnalysisContext context) + static void HandleThrow(OperationAnalysisContext context) { - if (context.Operation is IThrowOperation throwOperation) + if (context.Operation is not IThrowOperation throwOperation) { - var exceptionOperation = throwOperation.Exception; - if (exceptionOperation is IConversionOperation conversionOperation) - { - exceptionOperation = conversionOperation.Operand; - } + return; + } + + var exceptionOperation = throwOperation.Exception; + if (exceptionOperation is IConversionOperation conversionOperation) + { + exceptionOperation = conversionOperation.Operand; + } - if (exceptionOperation is IObjectCreationOperation exception && - exception.Constructor.ContainingNamespace.Name.StartsWith("System", StringComparison.InvariantCulture)) - { - var diagnostic = Diagnostic.Create(Rule, throwOperation.Syntax.GetLocation()); - context.ReportDiagnostic(diagnostic); - } + if (exceptionOperation is not IObjectCreationOperation exception || !exception.Constructor.ContainingNamespace.Name.StartsWith("System", StringComparison.InvariantCulture)) + { + return; } + + var diagnostic = Diagnostic.Create(Rule, throwOperation.Syntax.GetLocation()); + context.ReportDiagnostic(diagnostic); } } } diff --git a/Source/CodeAnalysis/ExceptionShouldNotBeSuffixed/Analyzer.cs b/Source/CodeAnalysis/ExceptionShouldNotBeSuffixed/Analyzer.cs index f34a6e6..3e864bc 100644 --- a/Source/CodeAnalysis/ExceptionShouldNotBeSuffixed/Analyzer.cs +++ b/Source/CodeAnalysis/ExceptionShouldNotBeSuffixed/Analyzer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Immutable; -using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -23,12 +22,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0004", title: "ExceptionShouldNotBeSuffixed", - messageFormat: "The use of the word 'Exception' should not be added as a suffix - create a well understood and self explanatory name for the exception.", + messageFormat: "The use of the word 'Exception' should not be added as a suffix - create a well understood and self explanatory name for the exception", category: "Naming", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -45,19 +44,26 @@ public override void Initialize(AnalysisContext context) SyntaxKind.ClassDeclaration)); } - void HandleClassDeclaration(SyntaxNodeAnalysisContext context) + static void HandleClassDeclaration(SyntaxNodeAnalysisContext context) { var classDeclaration = context.Node as ClassDeclarationSyntax; - if (classDeclaration?.BaseList == null || classDeclaration?.BaseList?.Types == null) return; + if (classDeclaration?.BaseList == null || classDeclaration?.BaseList?.Types == null) + { + return; + } + + if (!classDeclaration.InheritsASystemException(context.SemanticModel)) + { + return; + } - if (classDeclaration.InheritsASystemException(context.SemanticModel)) + if (!classDeclaration.Identifier.Text.EndsWith("Exception", StringComparison.InvariantCulture)) { - if (classDeclaration.Identifier.Text.EndsWith("Exception", StringComparison.InvariantCulture)) - { - var diagnostic = Diagnostic.Create(Rule, classDeclaration.Identifier.GetLocation()); - context.ReportDiagnostic(diagnostic); - } + return; } + + var diagnostic = Diagnostic.Create(Rule, classDeclaration.Identifier.GetLocation()); + context.ReportDiagnostic(diagnostic); } } } diff --git a/Source/CodeAnalysis/ExceptionShouldOnlyHaveOneConstructor/Analyzer.cs b/Source/CodeAnalysis/ExceptionShouldOnlyHaveOneConstructor/Analyzer.cs index 1a70d94..290fe4e 100644 --- a/Source/CodeAnalysis/ExceptionShouldOnlyHaveOneConstructor/Analyzer.cs +++ b/Source/CodeAnalysis/ExceptionShouldOnlyHaveOneConstructor/Analyzer.cs @@ -23,12 +23,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0005", title: "ExceptionShouldOnlyHaveOneConstructor", - messageFormat: "An exception should not have more than one constructor and typically not a generic one taking a message.", + messageFormat: "An exception should not have more than one constructor and typically not a generic one taking a message", category: "Exceptions", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -45,22 +45,29 @@ public override void Initialize(AnalysisContext context) SyntaxKind.ClassDeclaration)); } - void HandleClassDeclaration(SyntaxNodeAnalysisContext context) + static void HandleClassDeclaration(SyntaxNodeAnalysisContext context) { var classDeclaration = context.Node as ClassDeclarationSyntax; - if (classDeclaration?.BaseList == null || classDeclaration?.BaseList?.Types == null) return; + if (classDeclaration?.BaseList?.Types is null) + { + return; + } + + if (!classDeclaration.InheritsASystemException(context.SemanticModel)) + { + return; + } + + var constructors = classDeclaration.Members.Where(_ => _.IsKind(SyntaxKind.ConstructorDeclaration)).ToArray(); + if (constructors.Length <= 1) + { + return; + } - if (classDeclaration.InheritsASystemException(context.SemanticModel)) + foreach (var constructor in constructors) { - var constructors = classDeclaration.Members.Where(_ => _.IsKind(SyntaxKind.ConstructorDeclaration)).ToArray(); - if (constructors.Length > 1) - { - foreach (var constructor in constructors) - { - var diagnostic = Diagnostic.Create(Rule, constructor.GetLocation()); - context.ReportDiagnostic(diagnostic); - } - } + var diagnostic = Diagnostic.Create(Rule, constructor.GetLocation()); + context.ReportDiagnostic(diagnostic); } } } diff --git a/Source/CodeAnalysis/PrivateNotAllowed/Analyzer.cs b/Source/CodeAnalysis/PrivateNotAllowed/Analyzer.cs index 8e0ed96..d4cfba0 100644 --- a/Source/CodeAnalysis/PrivateNotAllowed/Analyzer.cs +++ b/Source/CodeAnalysis/PrivateNotAllowed/Analyzer.cs @@ -24,12 +24,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0002", title: "PrivateNotAllowed", - messageFormat: "Private is implicit in C# and is not needed.", + messageFormat: "Private is implicit in C# and is not needed", category: "Style", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -56,29 +56,36 @@ public override void Initialize(AnalysisContext context) ImmutableArray.Create(SyntaxKind.PropertyDeclaration)); } - void HandleDeclarations(SyntaxNodeAnalysisContext context) + static void HandleDeclarations(SyntaxNodeAnalysisContext context) { - var childTokens = context.Node?.ChildTokens(); - if (childTokens == null) return; + var childTokens = context.Node.ChildTokens(); + if (childTokens is null) + { + return; + } + ReportErrorIfModifierIsPrivate(context, childTokens); } - void HandleEventDeclaration(SyntaxNodeAnalysisContext context) + static void HandleEventDeclaration(SyntaxNodeAnalysisContext context) { var eventDeclaration = context.Node as EventDeclarationSyntax; ReportErrorIfModifierIsPrivate(context, eventDeclaration.Modifiers); } - void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context) + static void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context) { var propertyDeclaration = context.Node as PropertyDeclarationSyntax; ReportErrorIfModifierIsPrivate(context, propertyDeclaration.Modifiers); } - void ReportErrorIfModifierIsPrivate(SyntaxNodeAnalysisContext context, IEnumerable tokens) + static void ReportErrorIfModifierIsPrivate(SyntaxNodeAnalysisContext context, IEnumerable tokens) { var privateKeyword = tokens.SingleOrDefault(_ => _.IsKind(SyntaxKind.PrivateKeyword)); - if (privateKeyword == default) return; + if (privateKeyword == default) + { + return; + } var diagnostic = Diagnostic.Create(Rule, privateKeyword.GetLocation()); context.ReportDiagnostic(diagnostic); diff --git a/Source/CodeAnalysis/RemoveUnnecessaryImports/Analyzer.cs b/Source/CodeAnalysis/RemoveUnnecessaryImports/Analyzer.cs deleted file mode 100644 index 094d7f8..0000000 --- a/Source/CodeAnalysis/RemoveUnnecessaryImports/Analyzer.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; - -#pragma warning disable RS1025, RS1026 - -namespace Dolittle.CodeAnalysis.RemoveUnnecessaryImports -{ - /// - /// Represents a that does not allow the unnecessary import statements. - /// - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public class Analyzer : DiagnosticAnalyzer - { - /// - /// Represents the rule for the analyzer. - /// - public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( - id: "CS8019", - title: "RemoveUnnecessaryImports", - messageFormat: $"Unnecessary using directive.", - category: "Style", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - description: null, - helpLinkUri: $"", - customTags: Array.Empty()); - - /// - public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(Rule); - - /// - public override void Initialize(AnalysisContext context) - { - context.EnableConcurrentExecution(); - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); - - context.RegisterSemanticModelAction(AnalyzeSemanticModel); - } - - void AnalyzeSemanticModel(SemanticModelAnalysisContext context) - { - var cancellationToken = context.CancellationToken; - var model = context.SemanticModel; - var root = model.SyntaxTree.GetRoot(cancellationToken); - - var diagnostics = model.GetDiagnostics(cancellationToken: cancellationToken); - if (!diagnostics.Any()) return; - - foreach (var diagnostic in diagnostics) - { - if (diagnostic.Id == "CS8019") - { - if (root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node) - { - var diagnosticWrapper = Diagnostic.Create(Rule, node.GetLocation()); - context.ReportDiagnostic(diagnosticWrapper); - } - } - } - } - } -} \ No newline at end of file diff --git a/Source/CodeAnalysis/SealedNotAllowed/Analyzer.cs b/Source/CodeAnalysis/SealedNotAllowed/Analyzer.cs index bb7143a..d3830d9 100644 --- a/Source/CodeAnalysis/SealedNotAllowed/Analyzer.cs +++ b/Source/CodeAnalysis/SealedNotAllowed/Analyzer.cs @@ -23,12 +23,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0003", title: "SealedNotAllowed", - messageFormat: "The keyword 'sealed' unnecessarily locks down code from inheritance - very rare occasions is this a problem.", + messageFormat: "The keyword 'sealed' unnecessarily locks down code from inheritance - very rare occasions is this a problem", category: "Openness", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -45,11 +45,14 @@ public override void Initialize(AnalysisContext context) SyntaxKind.ClassDeclaration)); } - void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context) + static void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context) { var classDeclaration = context.Node as ClassDeclarationSyntax; var sealedKeyword = classDeclaration.Modifiers.SingleOrDefault(_ => _.IsKind(SyntaxKind.SealedKeyword)); - if (sealedKeyword == default) return; + if (sealedKeyword == default) + { + return; + } var diagnostic = Diagnostic.Create(Rule, sealedKeyword.GetLocation()); context.ReportDiagnostic(diagnostic); diff --git a/Source/CodeAnalysis/SerializableNotAllowed/Analyzer.cs b/Source/CodeAnalysis/SerializableNotAllowed/Analyzer.cs index 8d0eb51..a89592c 100644 --- a/Source/CodeAnalysis/SerializableNotAllowed/Analyzer.cs +++ b/Source/CodeAnalysis/SerializableNotAllowed/Analyzer.cs @@ -22,12 +22,12 @@ public class Analyzer : DiagnosticAnalyzer public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( id: "DL0001", title: "SerializableNotAllowed", - messageFormat: "The use of the [Serializable] attribute is considered an old .NET desktop framework practice for interop/marshalling between AppDomains and is not necessary.", + messageFormat: "The use of the [Serializable] attribute is considered an old .NET desktop framework practice for interop/marshalling between AppDomains and is not necessary", category: "Legacy", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, description: null, - helpLinkUri: $"", + helpLinkUri: string.Empty, customTags: Array.Empty()); /// @@ -41,14 +41,16 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(AnalyzeSyntaxNode, SyntaxKind.Attribute); } - void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context) + static void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context) { var attribute = context.Node as AttributeSyntax; - if (attribute.Name.ToString() == "Serializable") + if (attribute.Name.ToString() != "Serializable") { - var diagnostic = Diagnostic.Create(Rule, context.Node.GetLocation()); - context.ReportDiagnostic(diagnostic); + return; } + + var diagnostic = Diagnostic.Create(Rule, context.Node.GetLocation()); + context.ReportDiagnostic(diagnostic); } } } diff --git a/Source/Common/Dolittle.Common.csproj b/Source/Common/Dolittle.Common.csproj index 3421e07..308a51e 100644 --- a/Source/Common/Dolittle.Common.csproj +++ b/Source/Common/Dolittle.Common.csproj @@ -6,7 +6,7 @@ https://github.com/dolittle/Home MIT - net5 + netstandard2.0 Dolittle.Common true logo.png @@ -23,7 +23,7 @@ - + diff --git a/Specifications/CodeAnalysis/CodeAnalysis.csproj b/Specifications/CodeAnalysis/CodeAnalysis.csproj index 12a234e..7cdee5d 100644 --- a/Specifications/CodeAnalysis/CodeAnalysis.csproj +++ b/Specifications/CodeAnalysis/CodeAnalysis.csproj @@ -1,5 +1,5 @@ - + Dolittle.CodeAnalysis.Specs @@ -7,7 +7,7 @@ - + diff --git a/Specifications/CodeAnalysis/RemoveUnnecessaryImports/UnitTests.cs b/Specifications/CodeAnalysis/RemoveUnnecessaryImports/UnitTests.cs deleted file mode 100644 index 53e438b..0000000 --- a/Specifications/CodeAnalysis/RemoveUnnecessaryImports/UnitTests.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Dolittle.CodeAnalysis.RemoveUnnecessaryImports -{ - [TestClass] - public class UnitTests : CodeFixVerifier - { - [TestMethod] - public void NotUsingAllImports() - { - const string content = @" - using System; - - namespace MyNamespace - { - public class MyClass - { - } - } - "; - - var expected = new DiagnosticResult - { - Id = Analyzer.Rule.Id, - Message = (string)Analyzer.Rule.MessageFormat, - Severity = Analyzer.Rule.DefaultSeverity, - Locations = new[] - { - new DiagnosticResultLocation("Test0.cs", 2, 17) - } - }; - - VerifyCSharpDiagnostic(content, expected); - } - - protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer() - { - return new Analyzer(); - } - } -} \ No newline at end of file diff --git a/specs.props b/specs.props index c5989f8..2a3954b 100644 --- a/specs.props +++ b/specs.props @@ -2,14 +2,14 @@ - net5 + net6 true $(NoWarn);SA1600;CA1307;CA1305;CS1591;CA1819;SA1122;SA1615;SA1514 - +