From ef83da978863098c811ab665e3a9cc48e567792c Mon Sep 17 00:00:00 2001 From: Piotr Stenke Date: Sat, 4 Jan 2025 14:17:46 +0100 Subject: [PATCH] Fix code style warnings --- .editorconfig | 6 ++++++ internal/GenerateModuleRepository/Program.cs | 5 +++-- src/Durian.AnalysisServices/Extensions/SymbolFacts.cs | 5 +---- .../Extensions/SyntaxNodeExtensions.cs | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index 57995199..ad48383b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,9 @@ dotnet_diagnostic.IDE0150.severity = none # IDE0074: Use compound assignment dotnet_diagnostic.IDE0074.severity = none + +# IDE0290: Use primary constructor +csharp_style_prefer_primary_constructors = false + +# IDE0305: Simplify collection initialization +dotnet_style_prefer_collection_expression = false diff --git a/internal/GenerateModuleRepository/Program.cs b/internal/GenerateModuleRepository/Program.cs index 77e7c89d..69d2be4d 100644 --- a/internal/GenerateModuleRepository/Program.cs +++ b/internal/GenerateModuleRepository/Program.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Text.RegularExpressions; using Newtonsoft.Json; @@ -133,7 +134,7 @@ private static void SetDiagnostics(ModuleConfiguration module, Dictionary()) { DiagnosticData data = GetDiagnosticData(match, module.Module.Name!, file); @@ -518,7 +519,7 @@ private static void WriteDiagnosticData(in DiagnosticData diag, ModuleData modul builder.Append( $@" new DiagnosticData( title: ""{diag.Title}"", - id: {diag.Id!.Substring(5, 2)}, + id: {diag.Id!.AsSpan(5, 2)}, docsPath: ""{module.Documentation}/{diag.Id}.md"", fatal: {diag.Fatal.ToString().ToLower()}, hasLocation: {diag.HasLocation.ToString().ToLower()}"); diff --git a/src/Durian.AnalysisServices/Extensions/SymbolFacts.cs b/src/Durian.AnalysisServices/Extensions/SymbolFacts.cs index 020c0feb..87832354 100644 --- a/src/Durian.AnalysisServices/Extensions/SymbolFacts.cs +++ b/src/Durian.AnalysisServices/Extensions/SymbolFacts.cs @@ -2082,10 +2082,7 @@ static bool HasObsoleteAttribute(ISymbol symbol) return symbol.GetAttributes().Any(attr => attr.AttributeClass is { MetadataName: nameof(ObsoleteAttribute), - ContainingNamespace: - { - Name: nameof(System) - } + ContainingNamespace.Name: nameof(System) }); } } diff --git a/src/Durian.AnalysisServices/Extensions/SyntaxNodeExtensions.cs b/src/Durian.AnalysisServices/Extensions/SyntaxNodeExtensions.cs index a7896e27..a86e3a37 100644 --- a/src/Durian.AnalysisServices/Extensions/SyntaxNodeExtensions.cs +++ b/src/Durian.AnalysisServices/Extensions/SyntaxNodeExtensions.cs @@ -2721,7 +2721,7 @@ public static bool IsDisable(this PragmaWarningDirectiveTriviaSyntax node) /// to determine whether represents the keyword. public static bool IsDynamic(this TypeSyntax node) { - return (node as IdentifierNameSyntax)?.Identifier.ValueText == "dynamic"; + return node is IdentifierNameSyntax { Identifier.ValueText: "dynamic" }; } ///