diff --git a/src/MongoDB.Analyzer.Package/MongoDB.Analyzer.Package.csproj b/src/MongoDB.Analyzer.Package/MongoDB.Analyzer.Package.csproj index 47cb5413..ab67dc1a 100644 --- a/src/MongoDB.Analyzer.Package/MongoDB.Analyzer.Package.csproj +++ b/src/MongoDB.Analyzer.Package/MongoDB.Analyzer.Package.csproj @@ -10,14 +10,14 @@ MongoDB.Analyzer - 1.2.0 + 1.3.0 MongoDB Inc. MongoDB.Analyzer packageIcon.png LICENSE.md https://www.mongodb.com/docs/mongodb-analyzer/current/ https://github.com/mongodb/mongo-csharp-analyzer - https://github.com/mongodb/mongo-csharp-analyzer/releases/tag/v1.2.0 + https://github.com/mongodb/mongo-csharp-analyzer/releases/tag/v1.3.0 false MongoDB Roslyn analyzer for MongoDB .Net driver. Copyright © 2010-present MongoDB Inc. diff --git a/src/MongoDB.Analyzer/AnalyzerReleases.Shipped.md b/src/MongoDB.Analyzer/AnalyzerReleases.Shipped.md index a21c2b7d..e8b88c64 100644 --- a/src/MongoDB.Analyzer/AnalyzerReleases.Shipped.md +++ b/src/MongoDB.Analyzer/AnalyzerReleases.Shipped.md @@ -1,14 +1,20 @@ -; Shipped analyzer releases -; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md +## Release 1.0.0 -## Release 1.0.0 +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|-------------------- +MABuilders1001 | MongoDB.Analyzer.Builders | Info | Builders expression to MQL [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MABuilders1001) +MABuilders2001 | MongoDB.Analyzer.Builders | Warning | Unsupported builders expression [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MABuilders2001) +MALinq1001 | MongoDB.Analyzer.LINQ | Info | LINQ expression to MQL [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MALinq1001) +MALinq2001 | MongoDB.Analyzer.LINQ | Warning | Unsupported LINQ expression [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MALinq2001) +MALinq2002 | MongoDB.Analyzer.LINQ | Warning | Supported only in LINQ3 expression [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MALinq2002) + +## Release 1.3.0 ### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|-------------------- -MABuilders1001 | MongoDB.Analyzer.Builders | Info | Builders expression to MQL [Documentation](http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-builders-2-mql-v-1-0) -MABuilders2001 | MongoDB.Analyzer.Builders | Warning | Unsupported builders expression [Documentation](http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-builders-expression-v-1-0) -MALinq1001 | MongoDB.Analyzer.LINQ | Info | LINQ expression to MQL [Documentation](http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-linq-2-mql-v-1-0) -MALinq2001 | MongoDB.Analyzer.LINQ | Warning | Unsupported LINQ expression [Documentation](http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-linq-expression-v-1-0) -MALinq2002 | MongoDB.Analyzer.LINQ | Warning | Supported only in LINQ3 expression [Documentation](http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-linq-2-expression-v-1-0) +MAPoco1001 | MongoDB.Analyzer.Poco | Info | Poco to Json [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MAPoco1001) +MAPoco2001 | MongoDB.Analyzer.Poco | Warning | Unsupported POCO [Documentation](https://www.mongodb.com/docs/mongodb-analyzer/current/rules/#MAPoco2001) diff --git a/src/MongoDB.Analyzer/Core/Builders/BuidersDiagnosticsRules.cs b/src/MongoDB.Analyzer/Core/Builders/BuidersDiagnosticsRules.cs deleted file mode 100644 index 4c68f305..00000000 --- a/src/MongoDB.Analyzer/Core/Builders/BuidersDiagnosticsRules.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace MongoDB.Analyzer.Core.Builders; - -public static class BuidersDiagnosticsRules -{ - private const string DiagnosticIdBuilders2MQL = "MABuilders1001"; - private const string DiagnosticIdNotSupportedBuilderExpression = "MABuilders2001"; - private const string Category = "MongoDB.Analyzer.Builders"; - - public static readonly DiagnosticDescriptor DiagnosticRuleBuilder2MQL = new( - id: DiagnosticIdBuilders2MQL, - title: "Builders to MQL", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Info, - isEnabledByDefault: true, - helpLinkUri: "http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-builders-2-mql-v-1-0"); - - public static readonly DiagnosticDescriptor DiagnosticRuleNotSupportedBuilderExpression = new( - id: DiagnosticIdNotSupportedBuilderExpression, - title: "Not supported builders expression", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true, - helpLinkUri: "http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-builders-expression-v-1-0"); - - public static DiagnosticDescriptor[] DiagnosticsRules { get; } = new[] - { - DiagnosticRuleBuilder2MQL, - DiagnosticRuleNotSupportedBuilderExpression - }; -} diff --git a/src/MongoDB.Analyzer/Core/Builders/BuildersAnalyzer.cs b/src/MongoDB.Analyzer/Core/Builders/BuildersAnalyzer.cs index 2501589d..d75ebdb0 100644 --- a/src/MongoDB.Analyzer/Core/Builders/BuildersAnalyzer.cs +++ b/src/MongoDB.Analyzer/Core/Builders/BuildersAnalyzer.cs @@ -80,7 +80,7 @@ private static AnalysisStats ReportMqlOrInvalidExpressions(MongoAnalysisContext if (mqlResult.Mql != null) { var mql = analysisContext.Node.ConstantsRemapper.RemapConstants(mqlResult.Mql); - var diagnosticDescriptor = BuidersDiagnosticsRules.DiagnosticRuleBuilder2MQL; + var diagnosticDescriptor = DiagnosticsRules.DiagnosticRuleBuilder2MQL; var decoratedMessage = AnalysisUtilities.DecorateMessage(mql, driverVersion, context.Settings); semanticContext.ReportDiagnostics(diagnosticDescriptor, decoratedMessage, locations); mqlCount++; @@ -91,7 +91,7 @@ private static AnalysisStats ReportMqlOrInvalidExpressions(MongoAnalysisContext if (isDriverOrBsonException || settings.OutputInternalExceptions) { - var diagnosticDescriptor = BuidersDiagnosticsRules.DiagnosticRuleNotSupportedBuilderExpression; + var diagnosticDescriptor = DiagnosticsRules.DiagnosticRuleNotSupportedBuilderExpression; var message = AnalysisUtilities.GetExceptionMessage(mqlResult.Exception, typesMapper, AnalysisType.Builders); var decoratedMessage = AnalysisUtilities.DecorateMessage(message, driverVersion, context.Settings); diff --git a/src/MongoDB.Analyzer/Core/Linq/LinqAnalyzer.cs b/src/MongoDB.Analyzer/Core/Linq/LinqAnalyzer.cs index 352dc089..f53d91b0 100644 --- a/src/MongoDB.Analyzer/Core/Linq/LinqAnalyzer.cs +++ b/src/MongoDB.Analyzer/Core/Linq/LinqAnalyzer.cs @@ -67,7 +67,7 @@ private static void ReportInvalidExpressions(MongoAnalysisContext context, Expre foreach (var invalidLinqNode in linqExpressionAnalysis.InvalidExpressionNodes) { var diagnostics = Diagnostic.Create( - LinqDiagnosticsRules.DiagnosticRuleNotSupportedLinqExpression, + DiagnosticsRules.DiagnosticRuleNotSupportedLinqExpression, invalidLinqNode.OriginalExpression.GetLocation(), AnalysisUtilities.DecorateMessage(invalidLinqNode.Errors.FirstOrDefault(), driverVersionString, context.Settings)); @@ -105,7 +105,7 @@ private static AnalysisStats ReportMqlOrInvalidExpressions(MongoAnalysisContext if (mqlResult.Mql != null) { var mql = analysisContext.Node.ConstantsRemapper.RemapConstants(mqlResult.Mql); - var diagnosticDescriptor = mqlResult.Linq3Only ? LinqDiagnosticsRules.DiagnosticRuleNotSupportedLinq2Expression : LinqDiagnosticsRules.DiagnosticRuleLinq2MQL; + var diagnosticDescriptor = mqlResult.Linq3Only ? DiagnosticsRules.DiagnosticRuleNotSupportedLinq2Expression : DiagnosticsRules.DiagnosticRuleLinq2MQL; var decoratedMessage = AnalysisUtilities.DecorateMessage(mql, driverVersion, settings); semanticContext.ReportDiagnostics(diagnosticDescriptor, decoratedMessage, locations); mqlCount++; @@ -116,7 +116,7 @@ private static AnalysisStats ReportMqlOrInvalidExpressions(MongoAnalysisContext if (isDriverOrLinqException || settings.OutputInternalExceptions) { - var diagnosticDescriptor = LinqDiagnosticsRules.DiagnosticRuleNotSupportedLinqExpression; + var diagnosticDescriptor = DiagnosticsRules.DiagnosticRuleNotSupportedLinqExpression; var message = AnalysisUtilities.GetExceptionMessage(mqlResult.Exception, typesMapper, AnalysisType.Linq); var decoratedMessage = AnalysisUtilities.DecorateMessage(message, driverVersion, context.Settings); diff --git a/src/MongoDB.Analyzer/Core/Linq/LinqDiagnosticsRules.cs b/src/MongoDB.Analyzer/Core/Linq/LinqDiagnosticsRules.cs deleted file mode 100644 index 481ae4e3..00000000 --- a/src/MongoDB.Analyzer/Core/Linq/LinqDiagnosticsRules.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2021-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace MongoDB.Analyzer.Core.Linq; - -public static class LinqDiagnosticsRules -{ - private const string DiagnosticIdLinq2MQL = "MALinq1001"; - private const string DiagnosticIdNotSupportedLinqExpression = "MALinq2001"; - private const string DiagnosticIdNotSupportedLinq2Expression = "MALinq2002"; - private const string Category = "MongoDB.Analyzer.LINQ"; - - public static readonly DiagnosticDescriptor DiagnosticRuleLinq2MQL = new( - id: DiagnosticIdLinq2MQL, - title: "LINQ to MQL", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Info, - isEnabledByDefault: true, - helpLinkUri: "http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-linq-2-mql-v-1-0"); - - public static readonly DiagnosticDescriptor DiagnosticRuleNotSupportedLinqExpression = new( - id: DiagnosticIdNotSupportedLinqExpression, - title: "Not supported LINQ expression", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true, - helpLinkUri: "http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-linq-expression-v-1-0"); - - public static readonly DiagnosticDescriptor DiagnosticRuleNotSupportedLinq2Expression = new( - id: DiagnosticIdNotSupportedLinq2Expression, - title: "Not supported LINQ2 expression", - messageFormat: "Supported in LINQ3 only: {0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true, - helpLinkUri: "http://dochub.mongodb.org/core/mongodb-analyzer-diagnostic-rule-not-supported-linq-2-expression-v-1-0"); - - public static DiagnosticDescriptor[] DiagnosticsRules { get; } = new[] - { - DiagnosticRuleLinq2MQL, - DiagnosticRuleNotSupportedLinqExpression, - DiagnosticRuleNotSupportedLinq2Expression, - }; -} diff --git a/src/MongoDB.Analyzer/Core/Poco/PocoAnalyzer.cs b/src/MongoDB.Analyzer/Core/Poco/PocoAnalyzer.cs index bcd1bdfa..e62ec4d5 100644 --- a/src/MongoDB.Analyzer/Core/Poco/PocoAnalyzer.cs +++ b/src/MongoDB.Analyzer/Core/Poco/PocoAnalyzer.cs @@ -79,7 +79,7 @@ private static AnalysisStats ReportJsonOrInvalidExpressions(MongoAnalysisContext if (jsonResult.Json != null) { var decoratedMessage = AnalysisUtilities.DecorateMessage(jsonResult.Json, driverVersion, context.Settings); - semanticContext.ReportDiagnostics(PocoDiagnosticRules.DiagnosticRulePoco2Json, decoratedMessage, locations); + semanticContext.ReportDiagnostics(DiagnosticsRules.DiagnosticRulePoco2Json, decoratedMessage, locations); jsonCount++; } else if (jsonResult.Exception != null) @@ -88,11 +88,10 @@ private static AnalysisStats ReportJsonOrInvalidExpressions(MongoAnalysisContext if (isDriverOrBsonException || settings.OutputInternalExceptions) { - var diagnosticDescriptor = PocoDiagnosticRules.DiagnosticRuleNotSupportedPoco; var message = AnalysisUtilities.GetExceptionMessage(jsonResult.Exception, typesMapper, AnalysisType.Poco); var decoratedMessage = AnalysisUtilities.DecorateMessage(message, driverVersion, context.Settings); - semanticContext.ReportDiagnostics(diagnosticDescriptor, decoratedMessage, locations); + semanticContext.ReportDiagnostics(DiagnosticsRules.DiagnosticRuleNotSupportedPoco, decoratedMessage, locations); } if (!isDriverOrBsonException) diff --git a/src/MongoDB.Analyzer/Core/Poco/PocoDiagnosticsRules.cs b/src/MongoDB.Analyzer/Core/Poco/PocoDiagnosticsRules.cs deleted file mode 100644 index 3ba6db2e..00000000 --- a/src/MongoDB.Analyzer/Core/Poco/PocoDiagnosticsRules.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License") -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace MongoDB.Analyzer.Core.Poco; - -public static class PocoDiagnosticRules -{ - private const string DiagnosticIdPoco2Json = "MAPoco1001"; - private const string DiagnosticIdNotSupportedPoco = "MAPoco2001"; - private const string Category = "MongoDB.Analyzer.Poco"; - - public static readonly DiagnosticDescriptor DiagnosticRulePoco2Json = new( - id: DiagnosticIdPoco2Json, - title: "Poco to Json", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Info, - isEnabledByDefault: true, - helpLinkUri: ""); - - public static readonly DiagnosticDescriptor DiagnosticRuleNotSupportedPoco = new( - id: DiagnosticIdNotSupportedPoco, - title: "Not supported Poco", - messageFormat: "{0}", - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true, - helpLinkUri: ""); - - public static DiagnosticDescriptor[] DiagnosticsRules { get; } = new[] - { - DiagnosticRulePoco2Json, - DiagnosticRuleNotSupportedPoco - }; -} \ No newline at end of file diff --git a/src/MongoDB.Analyzer/Core/Telemetry/AnalysisTelemetry.cs b/src/MongoDB.Analyzer/Core/Telemetry/AnalysisTelemetry.cs index 71792e20..52a8c265 100644 --- a/src/MongoDB.Analyzer/Core/Telemetry/AnalysisTelemetry.cs +++ b/src/MongoDB.Analyzer/Core/Telemetry/AnalysisTelemetry.cs @@ -29,7 +29,7 @@ internal record AnalysisTelemetry( public static AnalysisTelemetry Empty = new(0, 0, null, null, -1, -1, -1, -1, -1); public (string, object)[] ToKeyValues() => new (string, object)[] - { + { ("expressions_found_count", ExpressionsFound), ("data_types_count", DataTypesCount), ("driver_version", DriverVersion), @@ -38,5 +38,5 @@ internal record AnalysisTelemetry( ("driver_exception_count", DriverExceptionCount), ("internal_exception_count", InternalExceptionCount), ("duration_ms", DurationMS) - }; + }; } diff --git a/src/MongoDB.Analyzer/Core/Telemetry/ITelemetryServiceExtensions.cs b/src/MongoDB.Analyzer/Core/Telemetry/ITelemetryServiceExtensions.cs index d182a601..8d516b58 100644 --- a/src/MongoDB.Analyzer/Core/Telemetry/ITelemetryServiceExtensions.cs +++ b/src/MongoDB.Analyzer/Core/Telemetry/ITelemetryServiceExtensions.cs @@ -39,7 +39,7 @@ public static void AnalysisStarted( var csharpOptions = csharpCompilation.Options; var data = new (string, object)[] - { + { ("output_kind", (csharpOptions?.OutputKind)?.ToString() ?? "Unknown"), ("output_platform", (csharpOptions?.Platform)?.ToString() ?? "Unknown"), ("lang_version", (csharpCompilation?.LanguageVersion)?.ToString() ?? "Unknown"), @@ -49,7 +49,7 @@ public static void AnalysisStarted( ("poco_limit", settings.PocoLimit.ToString()), ("logs_enabled", settings.OutputInternalLogsToFile), ("analyzer_version", s_version) - }; + }; telemetryService.Event("Analysis Started", data); } @@ -61,5 +61,5 @@ public static void BuildersAnalysisResult(this ITelemetryService telemetryServic telemetryService.Event("Builders analyzed", analysisStatistics.ToKeyValues()); public static void PocoAnalysisResult(this ITelemetryService telemetryService, AnalysisTelemetry analysisStatistics) => - telemetryService.Event("Pocos analyzed", analysisStatistics.ToKeyValues()); + telemetryService.Event("POCOs analyzed", analysisStatistics.ToKeyValues()); } diff --git a/src/MongoDB.Analyzer/DiagnosticsRules.cs b/src/MongoDB.Analyzer/DiagnosticsRules.cs new file mode 100644 index 00000000..c65620f1 --- /dev/null +++ b/src/MongoDB.Analyzer/DiagnosticsRules.cs @@ -0,0 +1,122 @@ +// Copyright 2021-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Analyzer.Core; + +namespace MongoDB.Analyzer; + +internal static class DiagnosticsRules +{ + private const string DocumentationRulesBaseLink = "https://www.mongodb.com/docs/mongodb-analyzer/current/rules"; + + // Builders + private const string DiagnosticIdBuilders2MQL = "MABuilders1001"; + private const string DiagnosticIdNotSupportedBuilderExpression = "MABuilders2001"; + private const string BuilderCategory = "MongoDB.Analyzer.Builders"; + + // LINQ + private const string DiagnosticIdLinq2MQL = "MALinq1001"; + private const string DiagnosticIdNotSupportedLinqExpression = "MALinq2001"; + private const string DiagnosticIdNotSupportedLinq2Expression = "MALinq2002"; + private const string LinqCategory = "MongoDB.Analyzer.LINQ"; + + // POCO + private const string DiagnosticIdPoco2Json = "MAPoco1001"; + private const string DiagnosticIdNotSupportedPoco = "MAPoco2001"; + private const string PocoCategory = "MongoDB.Analyzer.Poco"; + + // Builders + public static DiagnosticDescriptor DiagnosticRuleBuilder2MQL { get; } = new DiagnosticDescriptor( + id: DiagnosticIdBuilders2MQL, + title: "Builders to MQL", + messageFormat: "{0}", + category: BuilderCategory, + defaultSeverity: DiagnosticSeverity.Info, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdBuilders2MQL)); + + public static DiagnosticDescriptor DiagnosticRuleNotSupportedBuilderExpression { get; } = new DiagnosticDescriptor( + id: DiagnosticIdNotSupportedBuilderExpression, + title: "Not supported builders expression", + messageFormat: "{0}", + category: BuilderCategory, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdNotSupportedBuilderExpression)); + + // LINQ + public static DiagnosticDescriptor DiagnosticRuleLinq2MQL { get; } = new DiagnosticDescriptor( + id: DiagnosticIdLinq2MQL, + title: "LINQ to MQL", + messageFormat: "{0}", + category: LinqCategory, + defaultSeverity: DiagnosticSeverity.Info, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdLinq2MQL)); + + public static DiagnosticDescriptor DiagnosticRuleNotSupportedLinqExpression { get; } = new DiagnosticDescriptor( + id: DiagnosticIdNotSupportedLinqExpression, + title: "Not supported LINQ expression", + messageFormat: "{0}", + category: LinqCategory, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdNotSupportedLinqExpression)); + + public static DiagnosticDescriptor DiagnosticRuleNotSupportedLinq2Expression { get; } = new DiagnosticDescriptor( + id: DiagnosticIdNotSupportedLinq2Expression, + title: "Not supported LINQ2 expression", + messageFormat: "Supported in LINQ3 only: {0}", + category: LinqCategory, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdNotSupportedLinq2Expression)); + + // POCO + public static DiagnosticDescriptor DiagnosticRulePoco2Json { get; } = new DiagnosticDescriptor( + id: DiagnosticIdPoco2Json, + title: "POCO to Json", + messageFormat: "{0}", + category: PocoCategory, + defaultSeverity: DiagnosticSeverity.Info, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdPoco2Json)); + + public static DiagnosticDescriptor DiagnosticRuleNotSupportedPoco { get; } = new DiagnosticDescriptor( + id: DiagnosticIdNotSupportedPoco, + title: "Not supported POCO", + messageFormat: "{0}", + category: PocoCategory, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true, + helpLinkUri: GetRuleUrl(DiagnosticIdNotSupportedPoco)); + + public static ImmutableArray Rules { get; } = CollectionExtensions.CreateImmutableArray(new[] + { + // Builders + DiagnosticRuleBuilder2MQL, + DiagnosticRuleNotSupportedBuilderExpression, + + // LINQ + DiagnosticRuleLinq2MQL, + DiagnosticRuleNotSupportedLinqExpression, + DiagnosticRuleNotSupportedLinq2Expression, + + // POCO + DiagnosticRulePoco2Json, + DiagnosticRuleNotSupportedPoco + }); + + private static string GetRuleUrl(string ruleId) => $"{DocumentationRulesBaseLink}/#{ruleId}"; +} diff --git a/src/MongoDB.Analyzer/MongoDB.Analyzer.csproj b/src/MongoDB.Analyzer/MongoDB.Analyzer.csproj index 563a2e9f..31319b0a 100644 --- a/src/MongoDB.Analyzer/MongoDB.Analyzer.csproj +++ b/src/MongoDB.Analyzer/MongoDB.Analyzer.csproj @@ -7,11 +7,11 @@ MongoDBAnalyzerCore - 1.2.0.0 + 1.3.0.0 MongoDB Inc. Copyright © 2010-present MongoDB Inc. MongoDB Roslyn analyzer for MongoDB .Net driver. - 1.2.0 + 1.3.0 MongoDB.Analyzer enable diff --git a/src/MongoDB.Analyzer/MongoDBDiagnosticAnalyzer.cs b/src/MongoDB.Analyzer/MongoDBDiagnosticAnalyzer.cs index 3ca77d0f..7400e8e2 100644 --- a/src/MongoDB.Analyzer/MongoDBDiagnosticAnalyzer.cs +++ b/src/MongoDB.Analyzer/MongoDBDiagnosticAnalyzer.cs @@ -22,10 +22,7 @@ namespace MongoDB.Analyzer; [DiagnosticAnalyzer(LanguageNames.CSharp)] public sealed class MongoDBDiagnosticAnalyzer : DiagnosticAnalyzer { - public override ImmutableArray SupportedDiagnostics => CollectionExtensions.CreateImmutableArray( - BuidersDiagnosticsRules.DiagnosticsRules, - LinqDiagnosticsRules.DiagnosticsRules, - PocoDiagnosticRules.DiagnosticsRules); + public override ImmutableArray SupportedDiagnostics => DiagnosticsRules.Rules; public override void Initialize(AnalysisContext context) {