From 63e579b1fa3bf354463c574562987f2fada8b3c8 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Thu, 10 Nov 2022 21:48:11 +0200 Subject: [PATCH 1/2] Support `Microsoft.Data.SqlClient` in S2857. --- .../SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs index 21a937bfc94..5035b42e6f2 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs @@ -54,6 +54,7 @@ public sealed class SqlKeywordsDelimitedBySpace : SonarDiagnosticAnalyzer CSharpSyntaxHelper.BuildQualifiedNameSyntax("System", "Data", "Odbc"), CSharpSyntaxHelper.BuildQualifiedNameSyntax("System", "Data", "OracleClient"), CSharpSyntaxHelper.BuildQualifiedNameSyntax("Microsoft", "Data", "Sqlite"), + CSharpSyntaxHelper.BuildQualifiedNameSyntax("Microsoft", "Data", "SqlClient"), SyntaxFactory.IdentifierName("Dapper"), SyntaxFactory.IdentifierName("NHibernate"), SyntaxFactory.IdentifierName("PetaPoco") From fc34664e0958c46433d5eda7d3212aa62134c4a8 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Sat, 28 Jan 2023 17:27:26 +0200 Subject: [PATCH 2/2] Update tests. --- .../SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs | 2 +- .../MetadataReferences/NuGetMetadataReference.cs | 1 + .../Rules/SqlKeywordsDelimitedBySpaceTest.cs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs index 5035b42e6f2..7d106c15b4e 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/SqlKeywordsDelimitedBySpace.cs @@ -53,8 +53,8 @@ public sealed class SqlKeywordsDelimitedBySpace : SonarDiagnosticAnalyzer CSharpSyntaxHelper.BuildQualifiedNameSyntax("System", "Data", "Entity"), CSharpSyntaxHelper.BuildQualifiedNameSyntax("System", "Data", "Odbc"), CSharpSyntaxHelper.BuildQualifiedNameSyntax("System", "Data", "OracleClient"), - CSharpSyntaxHelper.BuildQualifiedNameSyntax("Microsoft", "Data", "Sqlite"), CSharpSyntaxHelper.BuildQualifiedNameSyntax("Microsoft", "Data", "SqlClient"), + CSharpSyntaxHelper.BuildQualifiedNameSyntax("Microsoft", "Data", "Sqlite"), SyntaxFactory.IdentifierName("Dapper"), SyntaxFactory.IdentifierName("NHibernate"), SyntaxFactory.IdentifierName("PetaPoco") diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/MetadataReferences/NuGetMetadataReference.cs b/analyzers/tests/SonarAnalyzer.UnitTest/MetadataReferences/NuGetMetadataReference.cs index 8bbc4a17602..cfbf60a773c 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/MetadataReferences/NuGetMetadataReference.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/MetadataReferences/NuGetMetadataReference.cs @@ -77,6 +77,7 @@ internal static class NuGetMetadataReference public static References MicrosoftAzureWebJobsExtensionsDurableTask(string packageVersion = Constants.NuGetLatestVersion) => Create("Microsoft.Azure.WebJobs.Extensions.DurableTask", packageVersion); public static References MicrosoftAzureWebJobsExtensionsHttp(string packageVersion = Constants.NuGetLatestVersion) => Create("Microsoft.Azure.WebJobs.Extensions.Http", packageVersion); public static References MicrosoftBuildNoTargets(string packageVersion = "3.1.0") => Create("Microsoft.Build.NoTargets", packageVersion); + public static References MicrosoftDataSqlClient(string packageVersion = "5.1.0") => Create("Microsoft.Data.SqlClient", packageVersion); public static References MicrosoftDataSqliteCore(string packageVersion = "2.0.0") => Create("Microsoft.Data.Sqlite.Core", packageVersion); public static References MicrosoftEntityFrameworkCore(string packageVersion) => Create("Microsoft.EntityFrameworkCore", packageVersion); public static References MicrosoftEntityFrameworkCoreSqliteCore(string packageVersion) => Create("Microsoft.EntityFrameworkCore.Sqlite.Core", packageVersion); diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/SqlKeywordsDelimitedBySpaceTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/SqlKeywordsDelimitedBySpaceTest.cs index af068a9225b..0f03a3169fd 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/SqlKeywordsDelimitedBySpaceTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/SqlKeywordsDelimitedBySpaceTest.cs @@ -82,6 +82,7 @@ public class SqlKeywordsDelimitedBySpaceTest [DataRow("System.Data.Entity")] [DataRow("System.Data.Odbc")] [DataRow("Dapper")] + [DataRow("Microsoft.Data.SqlClient")] [DataRow("Microsoft.Data.Sqlite")] [DataRow("NHibernate")] [DataRow("PetaPoco")] @@ -91,6 +92,7 @@ public class SqlKeywordsDelimitedBySpaceTest .AddReferences(MetadataReferenceFacade.SystemData) .AddReferences(NuGetMetadataReference.Dapper()) .AddReferences(NuGetMetadataReference.EntityFramework()) + .AddReferences(NuGetMetadataReference.MicrosoftDataSqlClient()) .AddReferences(NuGetMetadataReference.MicrosoftDataSqliteCore()) .AddReferences(NuGetMetadataReference.MicrosoftSqlServerCompact()) .AddReferences(NuGetMetadataReference.NHibernate())