diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json new file mode 100644 index 0000000000..66a041f018 --- /dev/null +++ b/.config/tsaoptions.json @@ -0,0 +1,10 @@ +{ + "instanceUrl": "https://devdiv.visualstudio.com/", + "template": "TFSDEVDIV", + "projectName": "DEVDIV", + "areaPath": "DevDiv\\NET Developer Experience\\Productivity", + "iterationPath": "DevDiv", + "notificationAliases": [ "mlinfraswat@microsoft.com" ], + "repositoryName":"roslyn-analyzers", + "codebaseName": "roslyn-analyzers" +} \ No newline at end of file diff --git a/azure-pipelines-microbuild.yml b/azure-pipelines-microbuild.yml index 324a28d68a..6c7b3e3f95 100644 --- a/azure-pipelines-microbuild.yml +++ b/azure-pipelines-microbuild.yml @@ -1,3 +1,10 @@ +parameters: + # Optionally do not publish to TSA. Useful for e.g. verifying fixes before PR. +- name: TSAEnabled + displayName: Publish results to TSA + type: boolean + default: true + # Branches that trigger a build on commit trigger: - main @@ -81,7 +88,40 @@ stages: PathtoPublish: 'artifacts\VSSetup\$(_BuildConfig)' ArtifactName: 'VSIXes' condition: succeeded() - +- stage: analysis + displayName: Code analysis + pool: + name: NetCore1ESPool-Internal + demands: ImageOverride -equals windows.vs2022preview.amd64 + jobs: + - job: codeql + displayName: CodeQL + timeoutInMinutes: 120 + variables: + # CG is handled in the primary CI pipeline + - name: skipComponentGovernanceDetection + value: true + # Force CodeQL enabled so it may be run on any branch + - name: Codeql.Enabled + value: true + # Do not let CodeQL 3000 Extension gate scan frequency + - name: Codeql.Cadence + value: 0 + - name: Codeql.TSAEnabled + value: true + steps: + - task: UseDotNet@2 + inputs: + useGlobalJson: true + - task: CodeQL3000Init@0 + displayName: CodeQL Initialize + - script: eng\common\cibuild.cmd + -configuration Release + -prepareMachine + /p:Test=false + displayName: Windows Build + - task: CodeQL3000Finalize@0 + displayName: CodeQL Finalize - template: eng\common\templates\post-build\post-build.yml parameters: publishingInfraVersion: 3 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f469068f4..a58e277d24 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -103,7 +103,7 @@ jobs: - job: Markdownlint pool: - vmImage: ubuntu-18.04 + vmImage: ubuntu-22.04 steps: - script: sudo npm install -g markdownlint-cli@0.31.1 displayName: Install markdownlint-cli diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a9ec0c7ddf..aaa606b0cc 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 6f93ec8da69a42fbe9a702a33e104f94773c3f03 + 5be556106f26f171f32187951b9a141f9580d03a diff --git a/eng/Versions.props b/eng/Versions.props index 25071613d8..4b4a782426 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -16,7 +16,7 @@ 3.3.4 beta1 - 7.0.0 + 8.0.0 preview1 $(VersionPrefix) + + + + PreserveNewest + AnalyzerReleases\$(AssemblyName)\AnalyzerReleases.Unshipped.md + diff --git a/src/Microsoft.CodeAnalysis.Analyzers/CSharp/CSharpImmutableObjectMethodAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/CSharp/CSharpImmutableObjectMethodAnalyzer.cs index efebc83fe4..da96c09977 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/CSharp/CSharpImmutableObjectMethodAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/CSharp/CSharpImmutableObjectMethodAnalyzer.cs @@ -13,6 +13,9 @@ namespace Microsoft.CodeAnalysis.CSharp.Analyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1014: + /// [DiagnosticAnalyzer(LanguageNames.CSharp)] public class CSharpImmutableObjectMethodAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/FixAnalyzers/FixerWithFixAllAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/FixAnalyzers/FixerWithFixAllAnalyzer.cs index 8cac63a6c7..00c8fcbc6a 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/FixAnalyzers/FixerWithFixAllAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/FixAnalyzers/FixerWithFixAllAnalyzer.cs @@ -14,6 +14,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.FixAnalyzers using static CodeAnalysisDiagnosticsResources; /// + /// RS1010: + /// RS1011: + /// RS1016: /// A that intends to support fix all occurrences must classify the registered code actions into equivalence classes by assigning it an explicit, non-null equivalence key which is unique across all registered code actions by this fixer. /// This enables the to fix all diagnostics in the required scope by applying code actions from this fixer that are in the equivalence class of the trigger code action. /// This analyzer catches violations of this requirement in the code actions registered by a that supports . diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/InternalImplementationOnlyAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/InternalImplementationOnlyAnalyzer.cs index fc563b5f83..661adf7d49 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/InternalImplementationOnlyAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/InternalImplementationOnlyAnalyzer.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeAnalysis.Analyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1009: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class InternalImplementationOnlyAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ClassIsNotDiagnosticAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ClassIsNotDiagnosticAnalyzer.cs index f942173685..b6b8251032 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ClassIsNotDiagnosticAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ClassIsNotDiagnosticAnalyzer.cs @@ -9,6 +9,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1027: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ClassIsNotDiagnosticAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs index c80b4d170c..7798b48e0c 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs @@ -13,6 +13,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1024: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class CompareSymbolsCorrectlyAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ConfigureGeneratedCodeAnalysisAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ConfigureGeneratedCodeAnalysisAnalyzer.cs index 5618f05afa..c1c0afd751 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ConfigureGeneratedCodeAnalysisAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/ConfigureGeneratedCodeAnalysisAnalyzer.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1025: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class ConfigureGeneratedCodeAnalysisAnalyzer : DiagnosticAnalyzerCorrectnessAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs index f4242c82b7..ffbc827f19 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs @@ -17,6 +17,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1022: + /// public abstract class DiagnosticAnalyzerApiUsageAnalyzer : DiagnosticAnalyzer where TTypeSyntax : SyntaxNode { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAttributeAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAttributeAnalyzer.cs index 72413a48c2..ddf317fc0a 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAttributeAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAttributeAnalyzer.cs @@ -10,6 +10,10 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1001: + /// RS1004: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DiagnosticAnalyzerAttributeAnalyzer : DiagnosticAnalyzerCorrectnessAnalyzer { @@ -24,14 +28,14 @@ public sealed class DiagnosticAnalyzerAttributeAnalyzer : DiagnosticAnalyzerCorr customTags: WellKnownDiagnosticTagsExtensions.Telemetry); public static readonly DiagnosticDescriptor AddLanguageSupportToAnalyzerRule = new( - DiagnosticIds.AddLanguageSupportToAnalyzerRuleId, - CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerTitle)), - CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerMessage)), - DiagnosticCategory.MicrosoftCodeAnalysisCorrectness, - DiagnosticSeverity.Warning, - isEnabledByDefault: true, - description: CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerDescription)), - customTags: WellKnownDiagnosticTagsExtensions.Telemetry); + DiagnosticIds.AddLanguageSupportToAnalyzerRuleId, + CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerTitle)), + CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerMessage)), + DiagnosticCategory.MicrosoftCodeAnalysisCorrectness, + DiagnosticSeverity.Warning, + isEnabledByDefault: true, + description: CreateLocalizableResourceString(nameof(AddLanguageSupportToAnalyzerDescription)), + customTags: WellKnownDiagnosticTagsExtensions.Telemetry); public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(MissingDiagnosticAnalyzerAttributeRule, AddLanguageSupportToAnalyzerRule); diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer.cs index 0704987206..f72ad8f129 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer.cs @@ -24,6 +24,17 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers using PooledResourcesDataValueConcurrentDictionary = PooledConcurrentDictionary>; using PooledFieldToResourceNameAndFileNameConcurrentDictionary = PooledConcurrentDictionary; + /// + /// RS1007 + /// RS1015 + /// RS1017 + /// RS1019 + /// RS1028 + /// RS1029 + /// RS1031 + /// RS1032 + /// RS1033 + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAnalyzer { @@ -58,9 +69,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna "Text.CSharp.Analyzers", "Text.VisualBasic.Analyzers"); - /// - /// RS1007 () - /// public static readonly DiagnosticDescriptor UseLocalizableStringsInDescriptorRule = new( DiagnosticIds.UseLocalizableStringsInDescriptorRuleId, CreateLocalizableResourceString(nameof(UseLocalizableStringsInDescriptorTitle)), @@ -71,9 +79,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(UseLocalizableStringsInDescriptorDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1015 () - /// public static readonly DiagnosticDescriptor ProvideHelpUriInDescriptorRule = new( DiagnosticIds.ProvideHelpUriInDescriptorRuleId, CreateLocalizableResourceString(nameof(ProvideHelpUriInDescriptorTitle)), @@ -84,9 +89,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(ProvideHelpUriInDescriptorDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1017 () - /// public static readonly DiagnosticDescriptor DiagnosticIdMustBeAConstantRule = new( DiagnosticIds.DiagnosticIdMustBeAConstantRuleId, CreateLocalizableResourceString(nameof(DiagnosticIdMustBeAConstantTitle)), @@ -97,9 +99,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(DiagnosticIdMustBeAConstantDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1019 () - /// public static readonly DiagnosticDescriptor UseUniqueDiagnosticIdRule = new( DiagnosticIds.UseUniqueDiagnosticIdRuleId, CreateLocalizableResourceString(nameof(UseUniqueDiagnosticIdTitle)), @@ -110,9 +109,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(UseUniqueDiagnosticIdDescription)), customTags: WellKnownDiagnosticTagsExtensions.CompilationEndAndTelemetry); - /// - /// RS1028 () - /// public static readonly DiagnosticDescriptor ProvideCustomTagsInDescriptorRule = new( DiagnosticIds.ProvideCustomTagsInDescriptorRuleId, CreateLocalizableResourceString(nameof(ProvideCustomTagsInDescriptorTitle)), @@ -123,9 +119,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(ProvideCustomTagsInDescriptorDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1029 () - /// public static readonly DiagnosticDescriptor DoNotUseReservedDiagnosticIdRule = new( DiagnosticIds.DoNotUseReservedDiagnosticIdRuleId, CreateLocalizableResourceString(nameof(DoNotUseReservedDiagnosticIdTitle)), @@ -136,9 +129,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna description: CreateLocalizableResourceString(nameof(DoNotUseReservedDiagnosticIdDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1031 () - /// public static readonly DiagnosticDescriptor DefineDiagnosticTitleCorrectlyRule = new( DiagnosticIds.DefineDiagnosticTitleCorrectlyRuleId, CreateLocalizableResourceString(nameof(DefineDiagnosticTitleCorrectlyTitle)), @@ -148,9 +138,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna isEnabledByDefault: true, customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1032 () - /// public static readonly DiagnosticDescriptor DefineDiagnosticMessageCorrectlyRule = new( DiagnosticIds.DefineDiagnosticMessageCorrectlyRuleId, CreateLocalizableResourceString(nameof(DefineDiagnosticMessageCorrectlyTitle)), @@ -160,9 +147,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna isEnabledByDefault: true, customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1033 () - /// public static readonly DiagnosticDescriptor DefineDiagnosticDescriptionCorrectlyRule = new( DiagnosticIds.DefineDiagnosticDescriptionCorrectlyRuleId, CreateLocalizableResourceString(nameof(DefineDiagnosticDescriptionCorrectlyTitle)), diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer_IdRangeAndCategoryValidation.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer_IdRangeAndCategoryValidation.cs index e2d1510b0a..5a6b37d64a 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer_IdRangeAndCategoryValidation.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticDescriptorCreationAnalyzer_IdRangeAndCategoryValidation.cs @@ -19,14 +19,16 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1018 + /// RS1020 + /// RS1021 + /// public sealed partial class DiagnosticDescriptorCreationAnalyzer { private const string DiagnosticCategoryAndIdRangeFile = "DiagnosticCategoryAndIdRanges.txt"; private static readonly (string? prefix, int start, int end) s_defaultAllowedIdsInfo = (null, -1, -1); - /// - /// RS1018 () - /// public static readonly DiagnosticDescriptor DiagnosticIdMustBeInSpecifiedFormatRule = new( DiagnosticIds.DiagnosticIdMustBeInSpecifiedFormatRuleId, CreateLocalizableResourceString(nameof(DiagnosticIdMustBeInSpecifiedFormatTitle)), @@ -37,9 +39,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer description: CreateLocalizableResourceString(nameof(DiagnosticIdMustBeInSpecifiedFormatDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1020 () - /// public static readonly DiagnosticDescriptor UseCategoriesFromSpecifiedRangeRule = new( DiagnosticIds.UseCategoriesFromSpecifiedRangeRuleId, CreateLocalizableResourceString(nameof(UseCategoriesFromSpecifiedRangeTitle)), @@ -50,9 +49,6 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer description: CreateLocalizableResourceString(nameof(UseCategoriesFromSpecifiedRangeDescription)), customTags: WellKnownDiagnosticTagsExtensions.Telemetry); - /// - /// RS1021 () - /// public static readonly DiagnosticDescriptor AnalyzerCategoryAndIdRangeFileInvalidRule = new( DiagnosticIds.AnalyzerCategoryAndIdRangeFileInvalidRuleId, CreateLocalizableResourceString(nameof(AnalyzerCategoryAndIdRangeFileInvalidTitle)), diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DoNotUseCompilationGetSemanticModelAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DoNotUseCompilationGetSemanticModelAnalyzer.cs index 85c5400395..9910368d25 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DoNotUseCompilationGetSemanticModelAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DoNotUseCompilationGetSemanticModelAnalyzer.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1030: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseCompilationGetSemanticModelAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/EnableConcurrentExecutionAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/EnableConcurrentExecutionAnalyzer.cs index 6245fb0a18..7099d2f5a4 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/EnableConcurrentExecutionAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/EnableConcurrentExecutionAnalyzer.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1026: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class EnableConcurrentExecutionAnalyzer : DiagnosticAnalyzerCorrectnessAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/PreferIsKindAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/PreferIsKindAnalyzer.cs index 531c6ea243..2ee2789e1f 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/PreferIsKindAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/PreferIsKindAnalyzer.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1034: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferIsKindAnalyzer : DiagnosticAnalyzer { diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/RegisterActionAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/RegisterActionAnalyzer.cs index fcb89fa498..cd8844655a 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/RegisterActionAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/RegisterActionAnalyzer.cs @@ -16,6 +16,13 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1002: + /// RS1003: + /// RS1006: + /// RS1012: + /// RS1013: + /// public abstract class RegisterActionAnalyzer : DiagnosticAnalyzerCorrectnessAnalyzer where TInvocationExpressionSyntax : SyntaxNode where TArgumentSyntax : SyntaxNode diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/UpgradeMSBuildWorkspaceAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/UpgradeMSBuildWorkspaceAnalyzer.cs index 61e20fa656..e39d57fd99 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/UpgradeMSBuildWorkspaceAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/UpgradeMSBuildWorkspaceAnalyzer.cs @@ -9,6 +9,9 @@ namespace Microsoft.CodeAnalysis.Analyzers { using static CodeAnalysisDiagnosticsResources; + /// + /// RS1023: + /// public abstract class UpgradeMSBuildWorkspaceAnalyzer : DiagnosticAnalyzer { private const string WorkspacesDesktop = "Microsoft.CodeAnalysis.Workspaces.Desktop"; diff --git a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs index 587fd3b42a..fb6717d120 100644 --- a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs @@ -16,6 +16,9 @@ namespace Microsoft.CodeAnalysis.BannedApiAnalyzers { using static BannedApiAnalyzerResources; + /// + /// RS0035: + /// public abstract class RestrictedInternalsVisibleToAnalyzer : DiagnosticAnalyzer where TNameSyntax : SyntaxNode where TSyntaxKind : struct diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Performance/CSharpConstantExpectedAnalyzer.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Performance/CSharpConstantExpectedAnalyzer.cs new file mode 100644 index 0000000000..ae87caec60 --- /dev/null +++ b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Performance/CSharpConstantExpectedAnalyzer.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.NetCore.Analyzers.Performance; + +namespace Microsoft.NetCore.CSharp.Analyzers.Performance +{ + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public sealed class CSharpConstantExpectedAnalyzer : ConstantExpectedAnalyzer + { + private static readonly CSharpDiagnosticHelper s_diagnosticHelper = new(); + private static readonly IdentifierNameSyntax s_constantExpectedIdentifier = (IdentifierNameSyntax)SyntaxFactory.ParseName(ConstantExpected); + private static readonly IdentifierNameSyntax s_constantExpectedAttributeIdentifier = (IdentifierNameSyntax)SyntaxFactory.ParseName(ConstantExpectedAttribute); + + protected override DiagnosticHelper Helper => s_diagnosticHelper; + + protected override void RegisterAttributeSyntax(CompilationStartAnalysisContext context, ConstantExpectedContext constantExpectedContext) + { + context.RegisterSyntaxNodeAction(context => OnAttributeNode(context, constantExpectedContext), SyntaxKind.Attribute); + } + + private void OnAttributeNode(SyntaxNodeAnalysisContext context, ConstantExpectedContext constantExpectedContext) + { + var attributeSyntax = (AttributeSyntax)context.Node; + var attributeName = attributeSyntax.Name; + if (!attributeName.IsEquivalentTo(s_constantExpectedIdentifier) && !attributeName.IsEquivalentTo(s_constantExpectedAttributeIdentifier)) + { + return; + } + + if (attributeSyntax.Parent.Parent is ParameterSyntax parameter) + { + var parameterSymbol = context.SemanticModel.GetDeclaredSymbol(parameter); + OnParameterWithConstantExpectedAttribute(parameterSymbol, constantExpectedContext, context.ReportDiagnostic); + } + } + + private sealed class CSharpDiagnosticHelper : DiagnosticHelper + { + private readonly IdentifierNameSyntax _constantExpectedMinIdentifier = (IdentifierNameSyntax)SyntaxFactory.ParseName(ConstantExpectedMin); + private readonly IdentifierNameSyntax _constantExpectedMaxIdentifier = (IdentifierNameSyntax)SyntaxFactory.ParseName(ConstantExpectedMax); + + public override Location? GetMaxLocation(SyntaxNode attributeNode) => GetArgumentLocation(attributeNode, _constantExpectedMaxIdentifier); + + public override Location? GetMinLocation(SyntaxNode attributeNode) => GetArgumentLocation(attributeNode, _constantExpectedMinIdentifier); + + private static Location? GetArgumentLocation(SyntaxNode attributeNode, IdentifierNameSyntax targetNameSyntax) + { + var attributeSyntax = (AttributeSyntax)attributeNode; + if (attributeSyntax.ArgumentList is null) + { + return null; + } + var targetArg = attributeSyntax.ArgumentList.Arguments.FirstOrDefault(arg => arg.NameEquals.Name.IsEquivalentTo(targetNameSyntax, true)); + return targetArg?.GetLocation(); + } + } + } +} +; \ No newline at end of file diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpDoNotUseStackallocInLoops.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpDoNotUseStackallocInLoops.cs index 22a2a694f2..e5eeac01f4 100644 --- a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpDoNotUseStackallocInLoops.cs +++ b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpDoNotUseStackallocInLoops.cs @@ -38,7 +38,8 @@ public sealed override void Initialize(AnalysisContext context) // foreach loops are special, in that as with other loops we don't want stackallocs // in the body of the loop, but in the expression of a foreach is ok. case SyntaxKind.ForEachStatement: - ForEachStatementSyntax foreachStatement = (ForEachStatementSyntax)node; + case SyntaxKind.ForEachVariableStatement: + var foreachStatement = (CommonForEachStatementSyntax)node; if (foreachStatement.Expression.Contains(ctx.Node)) { continue; @@ -71,7 +72,7 @@ static bool ShouldWarn(IOperation? op, SyntaxNode node) foreach (IOperation child in block.Operations) { if (child.Syntax.SpanStart > node.SpanStart && - (child is IReturnOperation || (child is IBranchOperation branch && branch.BranchKind == BranchKind.Break))) + (child is IReturnOperation or IBranchOperation { BranchKind: BranchKind.Break })) { // Err on the side of false negatives / caution and say this stackalloc is ok. // Note, too, it's possible we're breaking out of a nested loop, and the outer loop @@ -88,7 +89,7 @@ static bool ShouldWarn(IOperation? op, SyntaxNode node) } // Warn as needed. - if (ShouldWarn(ctx.SemanticModel.GetOperationWalkingUpParentChain(ctx.Node, default), ctx.Node)) + if (ShouldWarn(ctx.SemanticModel.GetOperationWalkingUpParentChain(ctx.Node, ctx.CancellationToken), ctx.Node)) { ctx.ReportDiagnostic(ctx.Node.CreateDiagnostic(Rule)); } diff --git a/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md b/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md index e5586b2214..0f56a95458 100644 --- a/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md +++ b/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md @@ -287,3 +287,27 @@ Rule ID | Category | Severity | Notes CA1801 | Usage | Disabled | ReviewUnusedParametersAnalyzer, [Documentation](https://learn.microsoft.com/visualstudio/code-quality/ca1801) IL3000 | Publish | Disabled | Moved analyzer to mono/linker IL3001 | Publish | Disabled | Moved analyzer to mono/linker + +## Release 7.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +CA1311 | Globalization | Hidden | SpecifyCultureForToLowerAndToUpper, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1311) +CA1420 | Interoperability | Warning | FeatureUnsupportedWhenRuntimeMarshallingDisabled, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1420) +CA1421 | Interoperability | Info | MethodUsesRuntimeMarshallingEvenWhenMarshallingDisabled, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1421) +CA1422 | Interoperability | Warning | PlatformCompatibilityAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422) +CA1849 | Performance | Disabled | UseAsyncMethodInAsyncContext, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1849) +CA1850 | Performance | Info | PreferHashDataOverComputeHashAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1850) +CA1851 | Performance | Disabled | AvoidMultipleEnumerations, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1851) +CA1852 | Performance | Hidden | SealInternalTypes, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1852) +CA1853 | Performance | Info | DoNotGuardDictionaryRemoveByContainsKey, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1853) +CA1854 | Performance | Info | PreferDictionaryTryGetValueAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1854) +CA1855 | Performance | Info | UseSpanClearInsteadOfFillAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1855) +CA2019 | Reliability | Info | UseThreadStaticCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2019) +CA2020 | Reliability | Info | PreventNumericIntPtrUIntPtrBehavioralChanges, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2020) +CA2259 | Usage | Warning | UseThreadStaticCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2259) +CA2260 | Usage | Warning | ImplementGenericMathInterfacesCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2260) +CA5404 | Security | Disabled | DoNotDisableTokenValidationChecks, [Documentation](https://learn.microsoft.com/visualstudio/code-quality/ca5404) +CA5405 | Security | Disabled | DoNotAlwaysSkipTokenValidationInDelegates, [Documentation](https://learn.microsoft.com/visualstudio/code-quality/ca5405) diff --git a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md index 43032124eb..4cb7d58e49 100644 --- a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md +++ b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md @@ -4,20 +4,5 @@ Rule ID | Category | Severity | Notes --------|----------|----------|------- -CA1311 | Globalization | Hidden | SpecifyCultureForToLowerAndToUpper, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1311) -CA1420 | Interoperability | Warning | FeatureUnsupportedWhenRuntimeMarshallingDisabled, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1420) -CA1421 | Interoperability | Info | MethodUsesRuntimeMarshallingEvenWhenMarshallingDisabled, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1421) -CA1422 | Interoperability | Warning | PlatformCompatibilityAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422) -CA1849 | Performance | Disabled | UseAsyncMethodInAsyncContext, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1849) -CA1850 | Performance | Info | PreferHashDataOverComputeHashAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1850) -CA1851 | Performance | Disabled | AvoidMultipleEnumerations, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1851) -CA1852 | Performance | Hidden | SealInternalTypes, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1852) -CA1853 | Performance | Info | DoNotGuardDictionaryRemoveByContainsKey, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1853) -CA1854 | Performance | Info | PreferDictionaryTryGetValueAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1854) -CA1855 | Performance | Info | UseSpanClearInsteadOfFillAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1855) -CA2019 | Reliability | Info | UseThreadStaticCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2019) -CA2020 | Reliability | Info | PreventNumericIntPtrUIntPtrBehavioralChanges, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2020) -CA2259 | Usage | Warning | UseThreadStaticCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2259) -CA2260 | Usage | Warning | ImplementGenericMathInterfacesCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2260) -CA5404 | Security | Disabled | DoNotDisableTokenValidationChecks, [Documentation](https://learn.microsoft.com/visualstudio/code-quality/ca5404) -CA5405 | Security | Disabled | DoNotAlwaysSkipTokenValidationInDelegates, [Documentation](https://learn.microsoft.com/visualstudio/code-quality/ca5405) +CA1856 | Performance | Error | ConstantExpectedAnalyzer, [Documentation](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1856) +CA1857 | Performance | Warning | ConstantExpectedAnalyzer, [Documentation](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1857) diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructors.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructors.cs index db11e37084..e26c3b37b0 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructors.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AbstractTypesShouldNotHaveConstructors.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1012: Abstract classes should not have public constructors + /// CA1012: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AbstractTypesShouldNotHaveConstructorsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidEmptyInterfaces.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidEmptyInterfaces.cs index b26dc5030b..ca9cec4328 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidEmptyInterfaces.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidEmptyInterfaces.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1040: Avoid empty interfaces + /// CA1040: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidEmptyInterfacesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidExcessiveParametersOnGenericTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidExcessiveParametersOnGenericTypes.cs index 7a99916a01..cc69c0ecc3 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidExcessiveParametersOnGenericTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidExcessiveParametersOnGenericTypes.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1005: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidExcessiveParametersOnGenericTypes : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidOutParameters.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidOutParameters.cs index ea979867ac..6a24023fde 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidOutParameters.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/AvoidOutParameters.cs @@ -12,6 +12,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1021: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidOutParameters : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CancellationTokenParametersMustComeLast.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CancellationTokenParametersMustComeLast.cs index a1279286a7..bd388898bb 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CancellationTokenParametersMustComeLast.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CancellationTokenParametersMustComeLast.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1068: CancellationToken parameters must come last. + /// CA1068: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class CancellationTokenParametersMustComeLastAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnly.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnly.cs index cba5a8c72b..22c8dd32c7 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnly.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionPropertiesShouldBeReadOnly.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2227: Collection properties should be read only + /// CA2227: /// /// Cause: /// An externally visible writable property is a type that implements System.Collections.ICollection. diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionsShouldImplementGenericInterface.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionsShouldImplementGenericInterface.cs index ce85b77af6..2507a39a43 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionsShouldImplementGenericInterface.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/CollectionsShouldImplementGenericInterface.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1010: Collections should implement generic interface + /// CA1010: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class CollectionsShouldImplementGenericInterfaceAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DeclareTypesInNamespaces.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DeclareTypesInNamespaces.cs index bd530ce03f..f013dc8d37 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DeclareTypesInNamespaces.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DeclareTypesInNamespaces.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1050: Declare types in namespaces + /// CA1050: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DeclareTypesInNamespacesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DefineAccessorsForAttributeArguments.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DefineAccessorsForAttributeArguments.cs index 9aae01ef86..d88211eee4 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DefineAccessorsForAttributeArguments.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DefineAccessorsForAttributeArguments.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1019: Define accessors for attribute arguments + /// CA1019: /// /// Cause: /// In its constructor, an attribute defines arguments that do not have corresponding properties. diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareProtectedMembersInSealedTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareProtectedMembersInSealedTypes.cs index 91315728f1..c87be4436d 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareProtectedMembersInSealedTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareProtectedMembersInSealedTypes.cs @@ -11,6 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// + /// CA1047: /// This rule is not implemented for C# as the compiler warning CS0628 already covers this part. /// #pragma warning disable RS1004 // Recommend adding language support to diagnostic analyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareStaticMembersOnGenericTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareStaticMembersOnGenericTypes.cs index 6941428409..1ed4d01824 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareStaticMembersOnGenericTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareStaticMembersOnGenericTypes.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1000: Do not declare static members on generic types + /// CA1000: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDeclareStaticMembersOnGenericTypesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFields.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFields.cs index 2ededa9507..14e1514fc0 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFields.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDeclareVisibleInstanceFields.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1051: Do not declare visible instance fields + /// CA1051: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDeclareVisibleInstanceFieldsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.cs index 3a634619b2..16900225d1 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotDirectlyAwaitATask.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2007: Do not directly await a Task in libraries. Append ConfigureAwait(false) to the task. + /// CA2007: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDirectlyAwaitATaskAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotExposeGenericLists.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotExposeGenericLists.cs index baff44419c..16da9400ab 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotExposeGenericLists.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotExposeGenericLists.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1002: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotExposeGenericLists : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotHideBaseClassMethods.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotHideBaseClassMethods.cs index 2193acf5d2..a2e0ccdf62 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotHideBaseClassMethods.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotHideBaseClassMethods.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1061: Do not hide base class methods + /// CA1061: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotHideBaseClassMethodsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotNameEnumValuesReserved.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotNameEnumValuesReserved.cs index 5b5f4e2511..2bdb0e29b4 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotNameEnumValuesReserved.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotNameEnumValuesReserved.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1700: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotNameEnumValuesReserved : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotOverloadOperatorEqualsOnReferenceTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotOverloadOperatorEqualsOnReferenceTypes.cs index b76cbf1017..b367787796 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotOverloadOperatorEqualsOnReferenceTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotOverloadOperatorEqualsOnReferenceTypes.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1046: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotOverloadOperatorEqualsOnReferenceTypes : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPassTypesByReference.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPassTypesByReference.cs index 0aacf71dde..690e51b02c 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPassTypesByReference.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPassTypesByReference.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1045: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotPassTypesByReference : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPrefixEnumValuesWithTypeName.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPrefixEnumValuesWithTypeName.cs index 4a5aa38691..e98022e083 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPrefixEnumValuesWithTypeName.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotPrefixEnumValuesWithTypeName.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1712: Do not prefix enum values with type name + /// CA1712: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotPrefixEnumValuesWithTypeNameAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocations.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocations.cs index 7d31db6212..36b38ea1c4 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocations.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/DoNotRaiseExceptionsInUnexpectedLocations.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1065: Do not raise exceptions in unexpected locations + /// CA1065: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotRaiseExceptionsInUnexpectedLocationsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumShouldNotHaveDuplicatedValues.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumShouldNotHaveDuplicatedValues.cs index 2cad74e4d1..864757d526 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumShouldNotHaveDuplicatedValues.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumShouldNotHaveDuplicatedValues.cs @@ -13,6 +13,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1069: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class EnumShouldNotHaveDuplicatedValues : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumStorageShouldBeInt32.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumStorageShouldBeInt32.cs index d8711ab0c4..d859e3adba 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumStorageShouldBeInt32.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumStorageShouldBeInt32.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1028: Enum Storage should be Int32 + /// CA1028: /// Implementation slightly modified from original FxCop after discussing with Nick Guerrera /// FxCop implementation used 2 distinct diagnostic messages depending on the underlying type of the enum /// In this implementation, we have only 1 diagnostic message - "If possible, make the underlying type of '{0}' System.Int32 instead of {1}." diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumWithFlagsAttribute.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumWithFlagsAttribute.cs index d4cfd0477e..3a000641f4 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumWithFlagsAttribute.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumWithFlagsAttribute.cs @@ -16,16 +16,14 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// Implements CA1027 and CA2217 - /// - /// 1) CA1027: Mark enums with FlagsAttribute + /// CA1027: /// /// Cause: /// The values of a public enumeration are powers of two or are combinations of other values that are defined in the enumeration, /// and the System.FlagsAttribute attribute is not present. /// To reduce false positives, this rule does not report a violation for enumerations that have contiguous values. /// - /// 2) CA2217: Do not mark enums with FlagsAttribute + /// CA2217: /// /// Cause: /// An externally visible enumeration is marked with FlagsAttribute and it has one or more values that are not powers of two or diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumsShouldHaveZeroValue.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumsShouldHaveZeroValue.cs index 4cdb05ed45..d71e6a5cba 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumsShouldHaveZeroValue.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EnumsShouldHaveZeroValue.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1008: Enums should have zero value + /// CA1008: /// /// Cause: /// An enumeration without an applied System.FlagsAttribute does not define a member that has a value of zero; diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EquatableAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EquatableAnalyzer.cs index a736646794..2a5b8d7b8f 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EquatableAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EquatableAnalyzer.cs @@ -11,6 +11,10 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1066: + /// CA1067: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class EquatableAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EventsShouldNotHaveBeforeOrAfterPrefix.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EventsShouldNotHaveBeforeOrAfterPrefix.cs index 9617c82cf8..4299aed807 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EventsShouldNotHaveBeforeOrAfterPrefix.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/EventsShouldNotHaveBeforeOrAfterPrefix.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1713: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class EventsShouldNotHaveBeforeOrAfterPrefix : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ExceptionsShouldBePublic.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ExceptionsShouldBePublic.cs index 230e3a008e..82465d9ef2 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ExceptionsShouldBePublic.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ExceptionsShouldBePublic.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1064: Exceptions should be public + /// CA1064: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ExceptionsShouldBePublicAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCase.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCase.cs index 6d62df7743..7207c93a46 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCase.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldDifferByMoreThanCase.cs @@ -14,6 +14,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1708: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldDifferByMoreThanCaseAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefix.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefix.cs index 5742d456d6..a7808571a0 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefix.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectPrefix.cs @@ -12,6 +12,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1715: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldHaveCorrectPrefixAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffix.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffix.cs index c4546e17fd..eb54c44fa9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffix.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldHaveCorrectSuffix.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1710: Identifiers should have correct suffix + /// CA1710: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldHaveCorrectSuffixAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNames.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNames.cs index 5840a87b7c..be173d2857 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNames.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainTypeNames.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1720-redefined: Identifiers should not contain type names + /// CA1720: /// Cause: /// The name of a parameter or a member contains a language-specific data type name. /// diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscores.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscores.cs index 19f666616f..3279307bc9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscores.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscores.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1707: Identifiers should not contain underscores + /// CA1707: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldNotContainUnderscoresAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotHaveIncorrectSuffix.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotHaveIncorrectSuffix.cs index d64bebce6b..0755ca16ce 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotHaveIncorrectSuffix.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotHaveIncorrectSuffix.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1711: Identifiers should not have incorrect suffix + /// CA1711: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldNotHaveIncorrectSuffixAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywords.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywords.cs index 1f1a997ed1..ed45319efb 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywords.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/IdentifiersShouldNotMatchKeywords.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1716: Identifiers should not match keywords + /// CA1716: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldNotMatchKeywordsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementIDisposableCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementIDisposableCorrectly.cs index eeb9e88ee1..6e6aff04f0 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementIDisposableCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementIDisposableCorrectly.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1063: Implement IDisposable Correctly + /// CA1063: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ImplementIDisposableCorrectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs index 7eac9d1e55..d1fbfe702a 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1032 - redefined: Implement standard exception constructors + /// CA1032: /// Cause: A type extends System.Exception and does not declare all the required constructors. /// Description: Exception types must implement the following constructors. Failure to provide the full set of constructors can make it difficult to correctly handle exceptions /// For CSharp, example when type name is GoodException diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.cs index 8cb9418dfa..96b221cfc6 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1033: Interface methods should be callable by child types + /// CA1033: /// /// Consider a base type that explicitly implements a public interface method. /// A type that derives from the base type can access the inherited interface method only through a reference to the current instance ('this' in C#) that is cast to the interface. diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithAttributesDiagnosticAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithAttributesDiagnosticAnalyzer.cs index 62e1d6d43c..50b4d09d20 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithAttributesDiagnosticAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithAttributesDiagnosticAnalyzer.cs @@ -10,6 +10,10 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1016: + /// CA1014: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class MarkAssembliesWithAttributesDiagnosticAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithComVisible.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithComVisible.cs index 459a4608d5..29dc33cb00 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithComVisible.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAssembliesWithComVisible.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1017: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class MarkAssembliesWithComVisibleAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAttributesWithAttributeUsage.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAttributesWithAttributeUsage.cs index 06f5b82213..e5243685bd 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAttributesWithAttributeUsage.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAttributesWithAttributeUsage.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1018: Custom attributes should have AttributeUsage attribute defined. + /// CA1018: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class MarkAttributesWithAttributeUsageAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MovePInvokesToNativeMethodsClass.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MovePInvokesToNativeMethodsClass.cs index efc03645a9..ac1104acc9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MovePInvokesToNativeMethodsClass.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MovePInvokesToNativeMethodsClass.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1060 - Move P/Invokes to native methods class + /// CA1060: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class MovePInvokesToNativeMethodsClassAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NestedTypesShouldNotBeVisible.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NestedTypesShouldNotBeVisible.cs index 1d274aa909..55e53fff08 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NestedTypesShouldNotBeVisible.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NestedTypesShouldNotBeVisible.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1034: Nested types should not be visible + /// CA1034: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class NestedTypesShouldNotBeVisibleAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NonConstantFieldsShouldNotBeVisible.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NonConstantFieldsShouldNotBeVisible.cs index 245080c86e..bbecf90b41 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NonConstantFieldsShouldNotBeVisible.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/NonConstantFieldsShouldNotBeVisible.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2211: Non-constant fields should not be visible + /// CA2211: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class NonConstantFieldsShouldNotBeVisibleAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs index 0a729fbb05..02f409ef06 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorOverloadsHaveNamedAlternates.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2225: Operator overloads have named alternates + /// CA2225: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class OperatorOverloadsHaveNamedAlternatesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.cs index 272ac051c9..d39689ae5c 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2226: Operators should have symmetrical overloads + /// CA2226: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class OperatorsShouldHaveSymmetricalOverloadsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.cs index 3c1d5a0d68..37a5fbab60 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2231: A value type overrides Equals but does not implement the equality operator. + /// CA2231: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class OverloadOperatorEqualsOnOverridingValueTypeEqualsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypes.cs index 30edabe538..9c45a485c5 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideEqualsAndOperatorEqualsOnValueTypes.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1815: Override equals and operator equals on value types + /// CA1815: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class OverrideEqualsAndOperatorEqualsOnValueTypesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.cs index 0c19c3b745..924b925059 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.cs @@ -13,7 +13,8 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1036: A public or protected type implements the System.IComparable interface and + /// CA1036: + /// A public or protected type implements the System.IComparable interface and /// does not override Object.Equals or does not overload the language-specific operator /// for equality, inequality, less than, less than or equal, greater than or /// greater than or equal. The rule does not report a violation if the type inherits diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclaration.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclaration.cs index 19b0db36af..86dd43e857 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclaration.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ParameterNamesShouldMatchBaseDeclaration.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1725: Parameter names should match base declaration + /// CA1725: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ParameterNamesShouldMatchBaseDeclarationAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStrings.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStrings.cs index 10eaaf3846..f981ebdd37 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStrings.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PassSystemUriObjectsInsteadOfStrings.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2234: Pass system uri objects instead of strings + /// CA2234: /// public abstract class PassSystemUriObjectsInsteadOfStringsAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnly.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnly.cs index 0810d61132..d3befba4f9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnly.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotBeWriteOnly.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1044: Properties should not be write only + /// CA1044: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PropertiesShouldNotBeWriteOnlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotReturnArrays.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotReturnArrays.cs index 6ed389647c..b12d761df7 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotReturnArrays.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertiesShouldNotReturnArrays.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1819: Properties should not return arrays + /// CA1819: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PropertiesShouldNotReturnArraysAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethods.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethods.cs index 4f55cb76c8..5e85917a8f 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethods.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/PropertyNamesShouldNotMatchGetMethods.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1721: Property names should not match get methods + /// CA1721: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PropertyNamesShouldNotMatchGetMethodsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ProvideObsoleteAttributeMessage.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ProvideObsoleteAttributeMessage.cs index 28a28e9876..65d58e793d 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ProvideObsoleteAttributeMessage.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/ProvideObsoleteAttributeMessage.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1041: Provide ObsoleteAttribute message + /// CA1041: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ProvideObsoleteAttributeMessageAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/StaticHolderTypes.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/StaticHolderTypes.cs index a693c3c3de..75386e44b2 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/StaticHolderTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/StaticHolderTypes.cs @@ -11,8 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1052: Static holder classes should be marked static, and should not have default - /// constructors. + /// CA1052: /// /// /// diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespaces.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespaces.cs index a6368bbbbd..c4d515a7d8 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespaces.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypeNamesShouldNotMatchNamespaces.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1724: Type names should not match namespaces + /// CA1724: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class TypeNamesShouldNotMatchNamespacesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposable.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposable.cs index 2af0c99091..0808ef0590 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposable.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/TypesThatOwnDisposableFieldsShouldBeDisposable.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1001: Types that own disposable fields should be disposable + /// CA1001: /// public abstract class TypesThatOwnDisposableFieldsShouldBeDisposableAnalyzer : DiagnosticAnalyzer where TTypeDeclarationSyntax : SyntaxNode diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriParametersShouldNotBeStrings.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriParametersShouldNotBeStrings.cs index 1cc9d1215c..9d66b410eb 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriParametersShouldNotBeStrings.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriParametersShouldNotBeStrings.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1054: Uri parameters should not be strings + /// CA1054: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class UriParametersShouldNotBeStringsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriPropertiesShouldNotBeStrings.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriPropertiesShouldNotBeStrings.cs index 3a9caf722c..28e9badd96 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriPropertiesShouldNotBeStrings.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriPropertiesShouldNotBeStrings.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1056: Uri properties should not be strings + /// CA1056: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class UriPropertiesShouldNotBeStringsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriReturnValuesShouldNotBeStrings.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriReturnValuesShouldNotBeStrings.cs index 021362761c..d2dea5e8f2 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriReturnValuesShouldNotBeStrings.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UriReturnValuesShouldNotBeStrings.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1055: Uri return values should not be strings + /// CA1055: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class UriReturnValuesShouldNotBeStringsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseEventsWhereAppropriate.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseEventsWhereAppropriate.cs index 47b5538215..1888c6596c 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseEventsWhereAppropriate.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseEventsWhereAppropriate.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1030: Use events where appropriate + /// CA1030: /// /// This rule detects methods that have names that ordinarily would be used for events. /// Events follow the Observer or Publish-Subscribe design pattern; they are used when a state change in one object must be communicated to other objects. diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs index 7ef5871e62..5cc4f7cab4 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs @@ -11,8 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1003: Use generic event handler instances - /// CA1009: A delegate that handles a public or protected event does not have the correct signature, return type, or parameter names. + /// CA1003: /// /// Recommends that event handlers use /// diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexers.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexers.cs index aaff9f8ea3..9c60be6615 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexers.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UseIntegralOrStringArgumentForIndexers.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1043: Use Integral Or String Argument For Indexers + /// CA1043: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseIntegralOrStringArgumentForIndexersAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UsePropertiesWhereAppropriate.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UsePropertiesWhereAppropriate.cs index 72f80191c3..4329a0dbdc 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UsePropertiesWhereAppropriate.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/UsePropertiesWhereAppropriate.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1024: Use properties where appropriate + /// CA1024: /// /// Cause: /// A public or protected method has a name that starts with Get, takes no parameters, and returns a value that is not an array. diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Documentation/AvoidUsingCrefTagsWithAPrefix.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Documentation/AvoidUsingCrefTagsWithAPrefix.cs index 4ac338b8fe..40b658a49d 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Documentation/AvoidUsingCrefTagsWithAPrefix.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Documentation/AvoidUsingCrefTagsWithAPrefix.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeQuality.Analyzers.Documentation using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1200: Avoid using cref tags with a prefix + /// CA1200: /// public abstract class AvoidUsingCrefTagsWithAPrefixAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidDeadConditionalCode.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidDeadConditionalCode.cs index daa42f0553..9c4fffe4e8 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidDeadConditionalCode.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidDeadConditionalCode.cs @@ -18,7 +18,9 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1508: Flags conditional expressions which are always true/false and null checks for operations that are always null/non-null based on predicate analysis. + /// CA1508: + /// + /// Flags conditional expressions which are always true/false and null checks for operations that are always null/non-null based on predicate analysis. /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidDeadConditionalCode : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUninstantiatedInternalClasses.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUninstantiatedInternalClasses.cs index 98ccc0f003..614889bd70 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUninstantiatedInternalClasses.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUninstantiatedInternalClasses.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1812: Avoid uninstantiated internal classes + /// CA1812: /// public abstract class AvoidUninstantiatedInternalClassesAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUnusedPrivateFields.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUnusedPrivateFields.cs index 41eaa4820a..e6f86c14db 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUnusedPrivateFields.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUnusedPrivateFields.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1823: Avoid unused private fields + /// CA1823: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidUnusedPrivateFieldsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/CodeMetricsAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/CodeMetricsAnalyzer.cs index 50963fdcff..993b7d1108 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/CodeMetricsAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/CodeMetricsAnalyzer.cs @@ -19,11 +19,11 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability.CodeMetrics using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1501: Avoid excessive inheritance - /// CA1502: Avoid excessive complexity - /// CA1505: Avoid unmaintainable code - /// CA1506: Avoid excessive class coupling - /// CA1509: Invalid entry in code metrics rule specification file + /// CA1501: + /// CA1502: + /// CA1505: + /// CA1506: + /// CA1509: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class CodeMetricsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/DoNotIgnoreMethodResults.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/DoNotIgnoreMethodResults.cs index 6be3c385e8..66575322a9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/DoNotIgnoreMethodResults.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/DoNotIgnoreMethodResults.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1806: Do not ignore method results + /// CA1806: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotIgnoreMethodResultsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/UseNameofInPlaceOfString.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/UseNameofInPlaceOfString.cs index 9ae0f20e33..b85d070d2f 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/UseNameofInPlaceOfString.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/UseNameofInPlaceOfString.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1507 Use nameof to express symbol names + /// CA1507: /// public abstract class UseNameofInPlaceOfStringAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs index 5b986db100..2e6b6abcb3 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2246: Prevent objects from being referenced in statements where they are reassigned + /// CA2246: /// #pragma warning disable RS1004 // Recommend adding language support to diagnostic analyzer - Construct not valid in VB.NET [DiagnosticAnalyzer(LanguageNames.CSharp)] diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidDuplicateElementInitialization.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidDuplicateElementInitialization.cs index 31e230b2cd..0c2a3617b9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidDuplicateElementInitialization.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidDuplicateElementInitialization.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2244: Do not duplicate indexed element initializations + /// CA2244: /// #pragma warning disable RS1004 // Recommend adding language support to diagnostic analyzer - Construct impossible in VB.NET [DiagnosticAnalyzer(LanguageNames.CSharp)] diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidInfiniteRecursion.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidInfiniteRecursion.cs index 630ba80349..dda557c0ea 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidInfiniteRecursion.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidInfiniteRecursion.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA2011: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidInfiniteRecursion : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidMultipleEnumerations/AvoidMultipleEnumerations.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidMultipleEnumerations/AvoidMultipleEnumerations.cs index 04c4c3cd6a..8249d79550 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidMultipleEnumerations/AvoidMultipleEnumerations.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidMultipleEnumerations/AvoidMultipleEnumerations.cs @@ -14,6 +14,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines.AvoidMultipleEnumerations { + /// + /// CA1851: + /// internal abstract partial class AvoidMultipleEnumerations : DiagnosticAnalyzer { private const string RuleId = "CA1851"; diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidPropertySelfAssignment.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidPropertySelfAssignment.cs index f036e12e19..40972e9afd 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidPropertySelfAssignment.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidPropertySelfAssignment.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2245: Prevent properties from being assigned to themselves + /// CA2245: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotCallOverridableMethodsInConstructors.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotCallOverridableMethodsInConstructors.cs index 011421cc8a..3865bb5eeb 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotCallOverridableMethodsInConstructors.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotCallOverridableMethodsInConstructors.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2214: Do not call overridable methods in constructors + /// CA2214: /// /// Cause: The constructor of an unsealed type calls a virtual method defined in its class. /// diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotDeclareEventFieldsAsVirtual.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotDeclareEventFieldsAsVirtual.cs index 58a32bf350..60dffad215 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotDeclareEventFieldsAsVirtual.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotDeclareEventFieldsAsVirtual.cs @@ -10,6 +10,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1070: + /// #pragma warning disable RS1004 // Recommend adding language support to diagnostic analyzer - Construct is invalid in VB.NET [DiagnosticAnalyzer(LanguageNames.CSharp)] #pragma warning restore RS1004 // Recommend adding language support to diagnostic analyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotInitializeUnnecessarily.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotInitializeUnnecessarily.cs index 57a747931e..695f202a0d 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotInitializeUnnecessarily.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotInitializeUnnecessarily.cs @@ -12,7 +12,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; - /// CA1805: Do not initialize unnecessarily. + /// + /// CA1805: + /// public abstract class DoNotInitializeUnnecessarilyAnalyzer : DiagnosticAnalyzer { internal const string RuleId = "CA1805"; diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotRaiseExceptionsInExceptionClauses.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotRaiseExceptionsInExceptionClauses.cs index 93ae425c64..89e57ce8d9 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotRaiseExceptionsInExceptionClauses.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotRaiseExceptionsInExceptionClauses.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2219: Do not raise exceptions in exception clauses + /// CA2219: /// /// /// The original FxCop implementation of this rule finds violations of this rule inside diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/MarkMembersAsStatic.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/MarkMembersAsStatic.cs index ea6b4018ae..02498839ba 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/MarkMembersAsStatic.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/MarkMembersAsStatic.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1822: Mark members as static + /// CA1822: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class MarkMembersAsStaticAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/PreferJaggedArraysOverMultidimensional.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/PreferJaggedArraysOverMultidimensional.cs index 3cb183293e..ca686bd9c5 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/PreferJaggedArraysOverMultidimensional.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/PreferJaggedArraysOverMultidimensional.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1814: Prefer jagged arrays over multidimensional + /// CA1814: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferJaggedArraysOverMultidimensionalAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RemoveEmptyFinalizers.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RemoveEmptyFinalizers.cs index f096f2bcba..f195e9d57a 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RemoveEmptyFinalizers.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RemoveEmptyFinalizers.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1821: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class RemoveEmptyFinalizersAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs index 337cdde6e3..190ed881f3 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs @@ -11,6 +11,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA2200: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class RethrowToPreserveStackDetailsAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ReviewVisibleEventHandlers.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ReviewVisibleEventHandlers.cs index 3dcfb15392..b234fcbdde 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ReviewVisibleEventHandlers.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ReviewVisibleEventHandlers.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2109: Review visible event handlers + /// CA2109: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ReviewVisibleEventHandlersAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/SealMethodsThatSatisfyPrivateInterfaces.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/SealMethodsThatSatisfyPrivateInterfaces.cs index b913ca84a8..476b87e66e 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/SealMethodsThatSatisfyPrivateInterfaces.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/SealMethodsThatSatisfyPrivateInterfaces.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA2119: Seal methods that satisfy private interfaces + /// CA2119: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SealMethodsThatSatisfyPrivateInterfacesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/UseLiteralsWhereAppropriate.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/UseLiteralsWhereAppropriate.cs index 69f5a3514e..7a814c0a96 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/UseLiteralsWhereAppropriate.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/UseLiteralsWhereAppropriate.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines using static MicrosoftCodeQualityAnalyzersResources; /// - /// CA1802: Use literals where appropriate + /// CA1802: /// public abstract class UseLiteralsWhereAppropriateAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethods.cs b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethods.cs index 686614864a..198f3f4eb0 100644 --- a/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethods.cs +++ b/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/ValidateArgumentsOfPublicMethods.cs @@ -13,6 +13,9 @@ namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1062: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ValidateArgumentsOfPublicMethods : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Data/ReviewSqlQueriesForSecurityVulnerabilities.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Data/ReviewSqlQueriesForSecurityVulnerabilities.cs index 8f04ed069e..d030ac21b0 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Data/ReviewSqlQueriesForSecurityVulnerabilities.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Data/ReviewSqlQueriesForSecurityVulnerabilities.cs @@ -15,6 +15,9 @@ namespace Microsoft.NetCore.Analyzers.Data { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2100: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ReviewSqlQueriesForSecurityVulnerabilities : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValue.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValue.cs index 8acdf5107e..0af739ebc7 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValue.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/ImmutableCollections/DoNotCallToImmutableCollectionOnAnImmutableCollectionValue.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.ImmutableCollections using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2009: Do not call ToImmutableCollection on an ImmutableCollection value + /// CA2009: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotCallToImmutableCollectionOnAnImmutableCollectionValueAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/AvoidStringBuilderPInvokeParameters.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/AvoidStringBuilderPInvokeParameters.cs index fdfad15c01..8feae163ba 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/AvoidStringBuilderPInvokeParameters.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/AvoidStringBuilderPInvokeParameters.cs @@ -11,7 +11,7 @@ namespace Microsoft.NetCore.Analyzers.InteropServices using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1838: Avoid StringBuilder parameters for P/Invokes + /// CA1838: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidStringBuilderPInvokeParametersAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DisableRuntimeMarshalling.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DisableRuntimeMarshalling.cs index 99010ef05c..f105702d9f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DisableRuntimeMarshalling.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DisableRuntimeMarshalling.cs @@ -12,6 +12,10 @@ namespace Microsoft.NetCore.Analyzers.InteropServices { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1420: + /// CA1421: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] internal sealed partial class DisableRuntimeMarshallingAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DoNotUseOutAttributeStringPInvokeParameters.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DoNotUseOutAttributeStringPInvokeParameters.cs index 04eac77d82..4f53cbac17 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DoNotUseOutAttributeStringPInvokeParameters.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DoNotUseOutAttributeStringPInvokeParameters.cs @@ -11,7 +11,7 @@ namespace Microsoft.NetCore.Analyzers.InteropServices using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1417: Do not use [Out] string parameters for P/Invokes + /// CA1417: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseOutAttributeStringPInvokeParametersAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DynamicInterfaceCastableImplementation.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DynamicInterfaceCastableImplementation.cs index 326fe72ef5..ba36699443 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DynamicInterfaceCastableImplementation.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/DynamicInterfaceCastableImplementation.cs @@ -10,6 +10,11 @@ namespace Microsoft.NetCore.Analyzers.InteropServices { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2256: + /// CA2257: + /// CA2258: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] internal sealed class DynamicInterfaceCastableImplementationAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PInvokeDiagnosticAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PInvokeDiagnosticAnalyzer.cs index ff3f2c5dda..b0147f4e1a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PInvokeDiagnosticAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PInvokeDiagnosticAnalyzer.cs @@ -12,6 +12,10 @@ namespace Microsoft.NetCore.Analyzers.InteropServices { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1401: + /// CA2101: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PInvokeDiagnosticAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.OperationVisitor.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.OperationVisitor.cs index 3474e83270..492d720e4d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.OperationVisitor.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.OperationVisitor.cs @@ -32,12 +32,19 @@ public OperationVisitor( _relatedPlatforms = relatedPlatforms; } - internal bool TryParseGuardAttributes(ISymbol symbol, ref GlobalFlowStateAnalysisValueSet value) + /// + /// If the provided annotated with any guard attribute update the accordingly. + /// + /// Symbol for which the attributes will be examined. + /// Resulting flow analysis value. + /// Arguments passed to the method symbol. + /// True if any guard attribute found and changed accordingly, false otherwise + internal bool TryParseGuardAttributes(ISymbol symbol, ref GlobalFlowStateAnalysisValueSet value, ImmutableArray visitedArguments) { var attributes = symbol.GetAttributes(); if (symbol.GetMemberType()!.SpecialType != SpecialType.System_Boolean || - !HasAnyGuardAttribute(attributes, out var guardAttributes)) + !HasAnyGuardAttribute(attributes, visitedArguments, out var guardAttributes)) { return false; } @@ -56,12 +63,17 @@ internal bool TryParseGuardAttributes(ISymbol symbol, ref GlobalFlowStateAnalysi return true; } - value = GlobalFlowStateAnalysisValueSet.Unknown; - return false; } - private static bool HasAnyGuardAttribute(ImmutableArray attributes, [NotNullWhen(true)] out SmallDictionary? mappedAttributes) + /// + /// Checks if there is any guard attribute within , parse found attributes into platform to version map + /// + /// Attributes to check + /// If the symbol is method symbol provide its arguments + /// Guard attributes parsed into platform to version map + /// True if there were any guard attributes found and parsed successfully, false otherwise + private static bool HasAnyGuardAttribute(ImmutableArray attributes, ImmutableArray methodArguments, [NotNullWhen(true)] out SmallDictionary? mappedAttributes) { mappedAttributes = null; @@ -70,6 +82,12 @@ private static bool HasAnyGuardAttribute(ImmutableArray attribute if (attribute.AttributeClass.Name is SupportedOSPlatformGuardAttribute or UnsupportedOSPlatformGuardAttribute && TryParsePlatformNameAndVersion(attribute, out var platformName, out var version)) { + if (version == EmptyVersion && !methodArguments.IsEmpty && + TryDecodeOSVersion(methodArguments, null, out var apiVersion)) + { + version = apiVersion; + } + mappedAttributes ??= new(StringComparer.OrdinalIgnoreCase); if (!mappedAttributes.TryGetValue(platformName, out var versions)) { @@ -95,6 +113,12 @@ private static bool HasAnyGuardAttribute(ImmutableArray attribute return mappedAttributes != null; } + /// + /// Convert each platform and versions pair from map into s and add into array + /// + /// Map of platforms to versions populated from guard attributes + /// Converted array of s + /// True if any added into the , false otherwise public bool TryDecodeGuardAttributes(SmallDictionary mappedAttributes, ArrayBuilder infosBuilder) { foreach (var (name, versions) in mappedAttributes) @@ -183,12 +207,10 @@ public override GlobalFlowStateAnalysisValueSet VisitInvocation_NonLambdaOrDeleg return value; } - - return GlobalFlowStateAnalysisValueSet.Unknown; } - else if (TryParseGuardAttributes(method, ref value)) + else // Not a known guard method, check if annotated with guard attributes { - return value; + TryParseGuardAttributes(method, ref value, visitedArguments); } return value; @@ -232,7 +254,7 @@ public override GlobalFlowStateAnalysisValueSet VisitFieldReference(IFieldRefere { var value = base.VisitFieldReference(operation, argument); - if (TryParseGuardAttributes(operation.Field, ref value)) + if (TryParseGuardAttributes(operation.Field, ref value, ImmutableArray.Empty)) { return value; } @@ -244,7 +266,7 @@ public override GlobalFlowStateAnalysisValueSet VisitPropertyReference(IProperty { var value = base.VisitPropertyReference(operation, argument); - if (TryParseGuardAttributes(operation.Property, ref value)) + if (TryParseGuardAttributes(operation.Property, ref value, ImmutableArray.Empty)) { return value; } diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.Value.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.Value.cs index b5224975aa..3af28b5fc2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.Value.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.Value.cs @@ -145,71 +145,6 @@ private static bool TryDecodeRuntimeInformationIsOSPlatform( return false; } - private static bool TryDecodeOSVersion( - ImmutableArray arguments, - ValueContentAnalysisResult? valueContentAnalysisResult, - [NotNullWhen(returnValue: true)] out Version? osVersion, - int skip = 0) - { - - using var versionBuilder = ArrayBuilder.GetInstance(4, fillWithValue: 0); - var index = 0; - - foreach (var argument in arguments.GetArgumentsInParameterOrder().Skip(skip)) - { - if (!TryDecodeOSVersionPart(argument, valueContentAnalysisResult, out var osVersionPart)) - { - osVersion = null; - return false; - } - - versionBuilder[index++] = osVersionPart; - } - - osVersion = CreateVersion(versionBuilder); - return true; - - static bool TryDecodeOSVersionPart(IArgumentOperation argument, ValueContentAnalysisResult? valueContentAnalysisResult, out int osVersionPart) - { - if (argument.Value.ConstantValue.HasValue && - argument.Value.ConstantValue.Value is int versionPart) - { - osVersionPart = versionPart; - return true; - } - - if (valueContentAnalysisResult != null) - { - var valueContentValue = valueContentAnalysisResult[argument.Value]; - if (valueContentValue.IsLiteralState && - valueContentValue.LiteralValues.Count == 1 && - valueContentValue.LiteralValues.Single() is int part) - { - osVersionPart = part; - return true; - } - } - - osVersionPart = default; - return false; - } - - static Version CreateVersion(ArrayBuilder versionBuilder) - { - if (versionBuilder[3] == 0) - { - if (versionBuilder[2] == 0) - { - return new Version(versionBuilder[0], versionBuilder[1]); - } - - return new Version(versionBuilder[0], versionBuilder[1], versionBuilder[2]); - } - - return new Version(versionBuilder[0], versionBuilder[1], versionBuilder[2], versionBuilder[3]); - } - } - public override string ToString() { var result = $"{PlatformName};{Version}"; @@ -250,5 +185,63 @@ bool IEquatable.Equals(IAbstractAnalysisValue other) return !(left == right); } } + + private static bool TryDecodeOSVersion( + ImmutableArray arguments, + ValueContentAnalysisResult? valueContentAnalysisResult, + [NotNullWhen(returnValue: true)] out Version? osVersion, + int skip = 0) + { + + using var versionBuilder = ArrayBuilder.GetInstance(4, fillWithValue: 0); + var index = 0; + + foreach (var argument in arguments.GetArgumentsInParameterOrder().Skip(skip)) + { + if (!TryDecodeOSVersionPart(argument, valueContentAnalysisResult, out var osVersionPart)) + { + osVersion = null; + return false; + } + + versionBuilder[index++] = osVersionPart; + } + + osVersion = CreateVersion(versionBuilder); + return true; + + static bool TryDecodeOSVersionPart(IArgumentOperation argument, ValueContentAnalysisResult? valueContentAnalysisResult, out int osVersionPart) + { + if (argument.Value.ConstantValue.HasValue && + argument.Value.ConstantValue.Value is int versionPart) + { + osVersionPart = versionPart; + return true; + } + + if (valueContentAnalysisResult != null) + { + var valueContentValue = valueContentAnalysisResult[argument.Value]; + if (valueContentValue.IsLiteralState && + valueContentValue.LiteralValues.Count == 1 && + valueContentValue.LiteralValues.Single() is int part) + { + osVersionPart = part; + return true; + } + } + + osVersionPart = default; + return false; + } + + static Version CreateVersion(ArrayBuilder versionBuilder) => versionBuilder switch + { + [int major, int minor, 0, 0] => new Version(major, minor), + [int major, int minor, int build, 0] => new Version(major, minor, build), + [int major, int minor, int build, int revision] => new Version(major, minor, build, revision), + _ => EmptyVersion + }; + } } } \ No newline at end of file diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs index dda807de25..6086108e20 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs @@ -23,7 +23,8 @@ namespace Microsoft.NetCore.Analyzers.InteropServices using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1416: Analyzer that informs developers when they use platform-specific APIs from call sites where the API might not be available + /// CA1416: + /// CA1422: /// /// It finds usage of platform-specific or unsupported APIs and diagnoses if the /// API is guarded by platform check or if it is annotated with corresponding platform specific attribute. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/ProvidePublicParameterlessSafeHandleConstructor.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/ProvidePublicParameterlessSafeHandleConstructor.cs index a7961d4114..5c9c2b77a9 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/ProvidePublicParameterlessSafeHandleConstructor.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/ProvidePublicParameterlessSafeHandleConstructor.cs @@ -10,6 +10,9 @@ namespace Microsoft.NetCore.Analyzers.InteropServices { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1419: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ProvidePublicParameterlessSafeHandleConstructorAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/UseValidPlatformString.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/UseValidPlatformString.cs index aedbf1b409..129704cf8a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/UseValidPlatformString.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/UseValidPlatformString.cs @@ -15,6 +15,9 @@ namespace Microsoft.NetCore.Analyzers.InteropServices { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1418: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseValidPlatformString : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx index 53c4f3dff1..15bc6ced94 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx @@ -1864,6 +1864,42 @@ '{0}' uses the preview type '{1}' and needs to opt into preview features. See {2} for more information. + + Incorrect usage of ConstantExpected attribute + + + ConstantExpected attribute is not applied correctly on the parameter. + + + A constant is expected for the parameter + + + The parameter expects a constant for optimal performance. + + + The '{0}' type is not supported for ConstantExpected attribute + + + The '{0}' value is not compatible with parameter type of '{1}' + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + + + The Min and Max values are inverted + + + The constant does not fit within the value bounds of '{0}' to '{1}' + + + The constant is not of the same '{0}' type as the parameter + + + The argument should be a constant for optimal performance + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Specify a culture or use an invariant version diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs new file mode 100644 index 0000000000..5060578fd6 --- /dev/null +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Operations; + +namespace Microsoft.NetCore.Analyzers.Performance +{ + public abstract partial class ConstantExpectedAnalyzer + { + private sealed class UnmanagedHelper where T : unmanaged + { + private static readonly ConstantExpectedParameterFactory? _instance; + private static ConstantExpectedParameterFactory Instance => _instance ?? throw new InvalidOperationException("unsupported type"); + + static UnmanagedHelper() + { + if (typeof(T) == typeof(long)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformInt64); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + else if (typeof(T) == typeof(ulong)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformUInt64); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + else if (typeof(T) == typeof(float)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformSingle); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + else if (typeof(T) == typeof(double)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformDouble); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + else if (typeof(T) == typeof(char)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformChar); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + else if (typeof(T) == typeof(bool)) + { + var helper = new UnmanagedHelper.TransformHelper(TryTransformBoolean); + _instance = new ConstantExpectedParameterFactory((TransformHelper)(object)helper); + } + } + + public static bool TryCreate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, [NotNullWhen(true)] out ConstantExpectedParameter? parameter) + => Instance.TryCreate(parameterSymbol, attributeData, typeMin, typeMax, out parameter); + public static bool Validate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, DiagnosticHelper diagnosticHelper, out ImmutableArray diagnostics) + => Instance.Validate(parameterSymbol, attributeData, typeMin, typeMax, diagnosticHelper, out diagnostics); + + public delegate bool TryTransform(object constant, out T value, out bool isInvalid); + public sealed class TransformHelper + { + private readonly TryTransform _tryTransform; + + public TransformHelper(TryTransform tryTransform) + { + _tryTransform = tryTransform; + } + + public bool IsLessThan(T operand1, T operand2) => Comparer.Default.Compare(operand1, operand2) < 0; + public bool TryTransformMin(object constant, out T value, ref ErrorKind errorFlags) + { + if (_tryTransform(constant, out value, out bool isInvalid)) + { + return true; + } + + errorFlags |= isInvalid ? ErrorKind.MinIsIncompatible : ErrorKind.MinIsOutOfRange; + return false; + } + + public bool TryTransformMax(object constant, out T value, ref ErrorKind errorFlags) + { + if (_tryTransform(constant, out value, out bool isInvalid)) + { + return true; + } + + errorFlags |= isInvalid ? ErrorKind.MaxIsIncompatible : ErrorKind.MaxIsOutOfRange; + return false; + } + public bool TryConvert(object val, out T value) => _tryTransform(val, out value, out _); + } + + public sealed class ConstantExpectedParameterFactory + { + private readonly TransformHelper _helper; + + public ConstantExpectedParameterFactory(TransformHelper helper) + { + _helper = helper; + } + public bool Validate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, DiagnosticHelper diagnosticHelper, out ImmutableArray diagnostics) + { + if (!IsValidMinMax(attributeData, typeMin, typeMax, out _, out _, out ErrorKind errorFlags)) + { + diagnostics = diagnosticHelper.GetError(errorFlags, parameterSymbol, attributeData.ApplicationSyntaxReference.GetSyntax(), typeMin.ToString(), typeMax.ToString()); + return false; + } + + diagnostics = ImmutableArray.Empty; + return true; + } + + public bool TryCreate(IParameterSymbol parameterSymbol, AttributeData attributeData, T typeMin, T typeMax, [NotNullWhen(true)] out ConstantExpectedParameter? parameter) + { + if (!IsValidMinMax(attributeData, typeMin, typeMax, out T minValue, out T maxValue, out _)) + { + parameter = null; + return false; + } + + parameter = new UnmanagedConstantExpectedParameter(parameterSymbol, minValue, maxValue, _helper); + return true; + } + + private bool IsValidMinMax(AttributeData attributeData, T typeMin, T typeMax, out T minValue, out T maxValue, out ErrorKind errorFlags) + { + minValue = typeMin; + maxValue = typeMax; + var ac = AttributeConstant.Get(attributeData); + errorFlags = ErrorKind.None; + if (ac.Min is not null && _helper.TryTransformMin(ac.Min, out minValue, ref errorFlags)) + { + if (_helper.IsLessThan(minValue, typeMin) || _helper.IsLessThan(typeMax, minValue)) + { + errorFlags |= ErrorKind.MinIsOutOfRange; + } + } + + if (ac.Max is not null && _helper.TryTransformMax(ac.Max, out maxValue, ref errorFlags)) + { + if (_helper.IsLessThan(maxValue, typeMin) || _helper.IsLessThan(typeMax, maxValue)) + { + errorFlags |= ErrorKind.MaxIsOutOfRange; + } + } + + if (errorFlags != ErrorKind.None) + { + return false; + } + + if (_helper.IsLessThan(maxValue, minValue)) + { + errorFlags = ErrorKind.MinMaxInverted; + return false; + } + return true; + } + } + + public sealed class UnmanagedConstantExpectedParameter : ConstantExpectedParameter + { + private readonly TransformHelper _helper; + public UnmanagedConstantExpectedParameter(IParameterSymbol parameter, T min, T max, TransformHelper helper) : base(parameter) + { + Min = min; + Max = max; + _helper = helper; + } + + public T Min { get; } + public T Max { get; } + + public override bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics) + { + if (Parameter.Type.SpecialType != subsetCandidate.Parameter.Type.SpecialType || + subsetCandidate is not UnmanagedConstantExpectedParameter subsetCandidateTParameter) + { + validationDiagnostics = CreateConstantInvalidConstantRuleDiagnostic(argument); + return false; + } + + if (!_helper.IsLessThan(subsetCandidateTParameter.Min, Min) && !_helper.IsLessThan(Max, subsetCandidateTParameter.Max)) + { + //within range + validationDiagnostics = null; + return true; + } + validationDiagnostics = CreateConstantOutOfBoundsRuleDiagnostic(argument, Min.ToString(), Max.ToString()); + return false; + } + + public override bool ValidateValue(IArgumentOperation argument, Optional constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics) + { + if (!ValidateConstant(argument, constant, out validationDiagnostics)) + { + return false; + } + + if (constant.Value is not null && _helper.TryConvert(constant.Value, out T value)) + { + if (!_helper.IsLessThan(value, Min) && !_helper.IsLessThan(Max, value)) + { + validationDiagnostics = null; + return true; + } + validationDiagnostics = CreateConstantOutOfBoundsRuleDiagnostic(argument, Min.ToString(), Max.ToString()); + return false; + } + validationDiagnostics = CreateConstantInvalidConstantRuleDiagnostic(argument); + return false; + } + } + } + + private static bool TryConvertSignedInteger(object constant, out long integer) + { + try + { + if (constant is string or bool) + { + integer = default; + return false; + } + integer = Convert.ToInt64(constant); + } + catch + { + integer = default; + return false; + } + return true; + } + private static bool TryConvertUnsignedInteger(object constant, out ulong integer) + { + try + { + if (constant is string or bool) + { + integer = default; + return false; + } + integer = Convert.ToUInt64(constant); + } + catch + { + integer = default; + return false; + } + return true; + } + + private static bool TryTransformInt64(object constant, out long value, out bool isInvalid) + { + bool isValidSigned = TryConvertSignedInteger(constant, out value); + isInvalid = false; + if (isValidSigned) + { + return isValidSigned; + } + if (!TryConvertUnsignedInteger(constant, out _)) + { + isInvalid = true; + } + return isValidSigned; + } + private static bool TryTransformUInt64(object constant, out ulong value, out bool isInvalid) + { + bool isValidUnsigned = TryConvertUnsignedInteger(constant, out value); + isInvalid = false; + if (isValidUnsigned) + { + return isValidUnsigned; + } + if (!TryConvertSignedInteger(constant, out _)) + { + isInvalid = true; + } + return isValidUnsigned; + } + + private static bool TryTransformChar(object constant, out char value, out bool isInvalid) + { + try + { + if (constant is string or bool) + { + return Invalid(out value, out isInvalid); + } + value = Convert.ToChar(constant); + } + catch + { + return Invalid(out value, out isInvalid); + } + isInvalid = false; + return true; + } + + private static bool TryTransformBoolean(object constant, out bool value, out bool isInvalid) + { + if (constant is bool b) + { + value = b; + isInvalid = false; + return true; + } + return Invalid(out value, out isInvalid); + } + + private static bool TryTransformSingle(object constant, out float value, out bool isInvalid) + { + if (constant is string or bool) + { + return Invalid(out value, out isInvalid); + } + value = Convert.ToSingle(constant); + isInvalid = false; + return true; + } + + private static bool TryTransformDouble(object constant, out double value, out bool isInvalid) + { + if (constant is string or bool) + { + return Invalid(out value, out isInvalid); + } + value = Convert.ToDouble(constant); + isInvalid = false; + return true; + } + + private static bool Invalid(out T value, out bool isInvalid) where T : unmanaged + { + value = default; + isInvalid = true; + return false; + } + } +} diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs new file mode 100644 index 0000000000..4d9ad2ab30 --- /dev/null +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs @@ -0,0 +1,646 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using Analyzer.Utilities; +using Analyzer.Utilities.Extensions; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Operations; + +namespace Microsoft.NetCore.Analyzers.Performance +{ + using static MicrosoftNetCoreAnalyzersResources; + public abstract partial class ConstantExpectedAnalyzer : DiagnosticAnalyzer + { + protected static readonly string ConstantExpectedAttribute = nameof(ConstantExpectedAttribute); + protected static readonly string ConstantExpected = nameof(ConstantExpected); + protected const string ConstantExpectedMin = "Min"; + protected const string ConstantExpectedMax = "Max"; + private static readonly LocalizableString s_localizableApplicationTitle = CreateLocalizableResourceString(nameof(ConstantExpectedApplicationTitle)); + private static readonly LocalizableString s_localizableApplicationDescription = CreateLocalizableResourceString(nameof(ConstantExpectedApplicationDescription)); + private static readonly LocalizableString s_localizableUsageTitle = CreateLocalizableResourceString(nameof(ConstantExpectedUsageTitle)); + private static readonly LocalizableString s_localizableUsageDescription = CreateLocalizableResourceString(nameof(ConstantExpectedUsageDescription)); + + internal static class CA1856 + { + internal const string Id = nameof(CA1856); + internal const RuleLevel Level = RuleLevel.BuildError; + internal static readonly DiagnosticDescriptor UnsupportedTypeRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableApplicationTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedNotSupportedMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableApplicationDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor IncompatibleConstantTypeRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableApplicationTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedIncompatibleConstantTypeMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableApplicationDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor InvalidBoundsRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableApplicationTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedInvalidBoundsMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableApplicationDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor InvertedRangeRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableApplicationTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedInvertedRangeMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableApplicationDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + } + + internal static class CA1857 + { + internal const string Id = nameof(CA1857); + internal const RuleLevel Level = RuleLevel.BuildWarning; + + internal static readonly DiagnosticDescriptor ConstantOutOfBoundsRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableUsageTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedOutOfBoundsMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableUsageDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor ConstantNotConstantRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableUsageTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedNotConstantMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableUsageDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor ConstantInvalidConstantRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableUsageTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedInvalidMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableUsageDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + + internal static readonly DiagnosticDescriptor AttributeExpectedRule = DiagnosticDescriptorHelper.Create( + Id, + s_localizableUsageTitle, + CreateLocalizableResourceString(nameof(ConstantExpectedAttributExpectedMessage)), + DiagnosticCategory.Performance, + Level, + description: s_localizableUsageDescription, + isPortedFxCopRule: false, + isDataflowRule: false); + } + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create( + CA1856.UnsupportedTypeRule, CA1856.IncompatibleConstantTypeRule, + CA1856.InvalidBoundsRule, CA1856.InvertedRangeRule, + CA1857.ConstantOutOfBoundsRule, CA1857.ConstantInvalidConstantRule, + CA1857.ConstantNotConstantRule, CA1857.AttributeExpectedRule); + + protected abstract DiagnosticHelper Helper { get; } + + public override void Initialize(AnalysisContext context) + { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.RegisterCompilationStartAction(OnCompilationStart); + } + + private void OnCompilationStart(CompilationStartAnalysisContext context) + { + if (!ConstantExpectedContext.TryCreate(context.Compilation, out var constantExpectedContext)) + { + return; + } + context.RegisterOperationAction(context => OnInvocation(context, constantExpectedContext), OperationKind.Invocation); + context.RegisterSymbolAction(context => OnMethodSymbol(context, constantExpectedContext), SymbolKind.Method); + RegisterAttributeSyntax(context, constantExpectedContext); + } + + private static void OnMethodSymbol(SymbolAnalysisContext context, ConstantExpectedContext constantExpectedContext) + { + var methodSymbol = (IMethodSymbol)context.Symbol; + if (methodSymbol.ExplicitInterfaceImplementations + .FirstOrDefault(methodSymbol.IsImplementationOfInterfaceMember) is { } explicitInterfaceMethod) + { + CheckParameters(methodSymbol.Parameters, explicitInterfaceMethod.Parameters); + } + else if (methodSymbol.OverriddenMethod is not null) + { + CheckParameters(methodSymbol.Parameters, methodSymbol.OverriddenMethod.Parameters); + } + else if (methodSymbol.IsImplementationOfAnyImplicitInterfaceMember(out IMethodSymbol interfaceMethodSymbol)) + { + CheckParameters(methodSymbol.Parameters, interfaceMethodSymbol.Parameters); + } + + + void CheckParameters(ImmutableArray parameters, ImmutableArray baseParameters) + { + if (constantExpectedContext.ValidatesAttributeImplementedFromParent(parameters, baseParameters, out var diagnostics)) + { + return; + } + + foreach (var diagnostic in diagnostics) + { + context.ReportDiagnostic(diagnostic); + } + } + } + + private static void OnInvocation(OperationAnalysisContext context, ConstantExpectedContext constantExpectedContext) + { + var invocation = (IInvocationOperation)context.Operation; + + foreach (var argument in invocation.Arguments) + { + if (!constantExpectedContext.TryCreateConstantExpectedParameter(argument.Parameter, out var argConstantParameter)) + { + continue; + } + var v = argument.Value.WalkDownConversion(); + if (v is IParameterReferenceOperation parameterReference && + constantExpectedContext.TryCreateConstantExpectedParameter(parameterReference.Parameter, out var currConstantParameter)) + { + if (!argConstantParameter.ValidateParameterIsWithinRange(currConstantParameter, argument, out var parameterCheckDiagnostic)) + { + context.ReportDiagnostic(parameterCheckDiagnostic); + } + continue; + } + var constantValue = v.ConstantValue; + if (!argConstantParameter.ValidateValue(argument, constantValue, out var valueDiagnostic)) + { + context.ReportDiagnostic(valueDiagnostic); + } + } + } + + protected abstract void RegisterAttributeSyntax(CompilationStartAnalysisContext context, ConstantExpectedContext constantExpectedContext); + + protected void OnParameterWithConstantExpectedAttribute(IParameterSymbol parameter, ConstantExpectedContext constantExpectedContext, Action reportAction) + { + if (!constantExpectedContext.ValidateConstantExpectedParameter(parameter, Helper, out ImmutableArray diagnostics)) + { + foreach (var diagnostic in diagnostics) + { + reportAction(diagnostic); + } + } + } + + protected sealed class ConstantExpectedContext + { + public INamedTypeSymbol AttributeSymbol { get; } + + public ConstantExpectedContext(INamedTypeSymbol attributeSymbol) + { + AttributeSymbol = attributeSymbol; + } + /// + /// Validates for ConstantExpected attribute in base parameter and returns AttributeExpectedRule if the coresponding implementation parameter does not have it + /// + /// + /// + /// Non empty when method returns false + /// + public bool ValidatesAttributeImplementedFromParent(ImmutableArray parameters, ImmutableArray baseParameters, out ImmutableArray diagnostics) + { + var arraybuilder = ImmutableArray.CreateBuilder(); + for (var i = 0; i < parameters.Length; i++) + { + var parameter = parameters[i]; + if (!IsConstantCompatible(parameter.Type)) + { + continue; + } + var baseParameter = baseParameters[i]; + if (HasConstantExpectedAttributeData(baseParameter) && !HasConstantExpectedAttributeData(parameter)) + { + // mark the parameter including the type and name + var diagnostic = parameter.DeclaringSyntaxReferences[0].GetSyntax().CreateDiagnostic(CA1857.AttributeExpectedRule); + arraybuilder.Add(diagnostic); + } + } + diagnostics = arraybuilder.ToImmutable(); + return diagnostics.Length is 0; + } + + private static bool IsConstantCompatible(ITypeSymbol type) + { + return type.SpecialType switch + { + SpecialType.System_Char => true, + SpecialType.System_Byte => true, + SpecialType.System_UInt16 => true, + SpecialType.System_UInt32 => true, + SpecialType.System_UInt64 => true, + SpecialType.System_SByte => true, + SpecialType.System_Int16 => true, + SpecialType.System_Int32 => true, + SpecialType.System_Int64 => true, + SpecialType.System_Single => true, + SpecialType.System_Double => true, + SpecialType.System_Boolean => true, + SpecialType.System_String => true, + SpecialType.None when type.TypeKind == TypeKind.TypeParameter => true, + _ => false, + }; + } + + /// + /// Tries to create a ConstantExpectedParameter to represent the ConstantExpected attribute application + /// + /// + /// + /// + public bool TryCreateConstantExpectedParameter(IParameterSymbol parameterSymbol, [NotNullWhen(true)] out ConstantExpectedParameter? parameter) + { + var underlyingType = GetUnderlyingType(parameterSymbol); + + if (!TryGetConstantExpectedAttributeData(parameterSymbol, out var attributeData)) + { + parameter = null; + return false; + } + + switch (underlyingType.SpecialType) + { + case SpecialType.System_Char: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, char.MinValue, char.MaxValue, out parameter); + case SpecialType.System_Byte: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, byte.MinValue, byte.MaxValue, out parameter); + case SpecialType.System_UInt16: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, ushort.MinValue, ushort.MaxValue, out parameter); + case SpecialType.System_UInt32: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, uint.MinValue, uint.MaxValue, out parameter); + case SpecialType.System_UInt64: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, ulong.MinValue, ulong.MaxValue, out parameter); + case SpecialType.System_SByte: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, sbyte.MinValue, sbyte.MaxValue, out parameter); + case SpecialType.System_Int16: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, short.MinValue, short.MaxValue, out parameter); + case SpecialType.System_Int32: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, int.MinValue, int.MaxValue, out parameter); + case SpecialType.System_Int64: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, long.MinValue, long.MaxValue, out parameter); + case SpecialType.System_Single: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, float.MinValue, float.MaxValue, out parameter); + case SpecialType.System_Double: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, double.MinValue, double.MaxValue, out parameter); + case SpecialType.System_Boolean: + return UnmanagedHelper.TryCreate(parameterSymbol, attributeData, false, true, out parameter); + case SpecialType.System_String: + return StringConstantExpectedParameter.TryCreate(parameterSymbol, attributeData, out parameter); + default: + parameter = null; + return false; + } + } + + /// + /// Validates that the parameter has a valid application of the ConstantExpected attributes. Returns diagnostics otherwise + /// + /// + /// + /// not empty when method returns false + /// + public bool ValidateConstantExpectedParameter(IParameterSymbol parameterSymbol, DiagnosticHelper helper, out ImmutableArray diagnostics) + { + var underlyingType = GetUnderlyingType(parameterSymbol); + + if (!TryGetConstantExpectedAttributeData(parameterSymbol, out var attributeData)) + { + diagnostics = ImmutableArray.Empty; + return false; + } + + switch (underlyingType.SpecialType) + { + case SpecialType.System_Char: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, char.MinValue, char.MaxValue, helper, out diagnostics); + case SpecialType.System_Byte: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, byte.MinValue, byte.MaxValue, helper, out diagnostics); + case SpecialType.System_UInt16: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, ushort.MinValue, ushort.MaxValue, helper, out diagnostics); + case SpecialType.System_UInt32: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, uint.MinValue, uint.MaxValue, helper, out diagnostics); + case SpecialType.System_UInt64: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, ulong.MinValue, ulong.MaxValue, helper, out diagnostics); + case SpecialType.System_SByte: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, sbyte.MinValue, sbyte.MaxValue, helper, out diagnostics); + case SpecialType.System_Int16: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, short.MinValue, short.MaxValue, helper, out diagnostics); + case SpecialType.System_Int32: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, int.MinValue, int.MaxValue, helper, out diagnostics); + case SpecialType.System_Int64: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, long.MinValue, long.MaxValue, helper, out diagnostics); + case SpecialType.System_Single: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, float.MinValue, float.MaxValue, helper, out diagnostics); + case SpecialType.System_Double: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, double.MinValue, double.MaxValue, helper, out diagnostics); + case SpecialType.System_Boolean: + return UnmanagedHelper.Validate(parameterSymbol, attributeData, false, true, helper, out diagnostics); + case SpecialType.System_String: + return ValidateMinMaxIsNull(parameterSymbol, attributeData, helper, out diagnostics); + case SpecialType.None when parameterSymbol.Type.TypeKind == TypeKind.TypeParameter: + return ValidateMinMaxIsNull(parameterSymbol, attributeData, helper, out diagnostics); + default: + diagnostics = helper.ParameterIsInvalid(parameterSymbol.Type.ToDisplayString(), attributeData.ApplicationSyntaxReference.GetSyntax()); + return false; + } + + static bool ValidateMinMaxIsNull(IParameterSymbol parameterSymbol, AttributeData attributeData, DiagnosticHelper helper, out ImmutableArray diagnostics) + { + ErrorKind errorFlags = 0; + + foreach (var namedArg in attributeData.NamedArguments) + { + if (namedArg.Key.Equals(ConstantExpectedMin, StringComparison.Ordinal) + && !namedArg.Value.IsNull) + { + errorFlags |= ErrorKind.MinIsIncompatible; + } + else if (namedArg.Key.Equals(ConstantExpectedMax, StringComparison.Ordinal) + && !namedArg.Value.IsNull) + { + errorFlags |= ErrorKind.MaxIsIncompatible; + } + } + if (errorFlags is not 0) + { + diagnostics = helper.GetError(errorFlags, parameterSymbol, attributeData.ApplicationSyntaxReference.GetSyntax(), "null", "null"); + return false; + } + diagnostics = ImmutableArray.Empty; + return true; + } + } + + private static ITypeSymbol GetUnderlyingType(IParameterSymbol parameterSymbol) + { + ITypeSymbol underlyingType; + if (parameterSymbol.Type.TypeKind is TypeKind.Enum) + { + var enumType = (INamedTypeSymbol)parameterSymbol.Type; + underlyingType = enumType.EnumUnderlyingType; + } + else + { + underlyingType = parameterSymbol.Type; + } + + return underlyingType; + } + + public bool TryGetConstantExpectedAttributeData(IParameterSymbol parameter, [NotNullWhen(true)] out AttributeData? attributeData) + { + attributeData = parameter.GetAttributes() + .FirstOrDefault(attrData => IsConstantExpectedAttribute(attrData.AttributeClass)); + return attributeData is not null; + } + + private bool HasConstantExpectedAttributeData(IParameterSymbol parameter) + { + return parameter.GetAttributes() + .Any(attrData => IsConstantExpectedAttribute(attrData.AttributeClass)); + } + + private bool IsConstantExpectedAttribute(INamedTypeSymbol namedType) + { + return namedType.Equals(AttributeSymbol, SymbolEqualityComparer.Default); + } + + public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out ConstantExpectedContext? constantExpectedContext) + { + if (!compilation.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemDiagnosticsCodeAnalysisConstantExpectedAttribute, out var attributeSymbol)) + { + constantExpectedContext = null; + return false; + } + + constantExpectedContext = new ConstantExpectedContext(attributeSymbol); + return true; + } + } + + /// + /// Encodes a parameter with its ConstantExpected attribute rules + /// + protected abstract class ConstantExpectedParameter + { + protected ConstantExpectedParameter(IParameterSymbol parameter) + { + Parameter = parameter; + } + /// + /// Parameter with the ConstantExpected attribute + /// + public IParameterSymbol Parameter { get; } + + /// + /// Validates the provided constant value is within the constaints of ConstantExpected attribute set + /// + /// + /// + /// Non empty when method returns false + /// + public abstract bool ValidateValue(IArgumentOperation argument, Optional constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics); + + public bool ValidateConstant(IArgumentOperation argument, Optional constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics) + { + if (!constant.HasValue) + { + validationDiagnostics = argument.CreateDiagnostic(CA1857.ConstantNotConstantRule); + return false; + } + validationDiagnostics = null; + return true; + } + + public abstract bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics); + protected Diagnostic CreateConstantInvalidConstantRuleDiagnostic(IArgumentOperation argument) => argument.CreateDiagnostic(CA1857.ConstantInvalidConstantRule, Parameter.Type.ToDisplayString()); + protected Diagnostic CreateConstantOutOfBoundsRuleDiagnostic(IArgumentOperation argument, string minText, string maxText) => argument.CreateDiagnostic(CA1857.ConstantOutOfBoundsRule, minText, maxText); + } + + private sealed class StringConstantExpectedParameter : ConstantExpectedParameter + { + public StringConstantExpectedParameter(IParameterSymbol parameter) : base(parameter) { } + + public override bool ValidateParameterIsWithinRange(ConstantExpectedParameter subsetCandidate, IArgumentOperation argument, [NotNullWhen(false)] out Diagnostic? validationDiagnostics) + { + if (subsetCandidate is not StringConstantExpectedParameter) + { + validationDiagnostics = CreateConstantInvalidConstantRuleDiagnostic(argument); + return false; + } + validationDiagnostics = null; + return true; + } + + public override bool ValidateValue(IArgumentOperation argument, Optional constant, [NotNullWhen(false)] out Diagnostic? validationDiagnostics) + { + if (!ValidateConstant(argument, constant, out validationDiagnostics)) + { + return false; + } + if (constant.Value is not string and not null) + { + validationDiagnostics = CreateConstantInvalidConstantRuleDiagnostic(argument); + return false; + } + validationDiagnostics = null; + return true; + } + + public static bool TryCreate(IParameterSymbol parameterSymbol, AttributeData attributeData, [NotNullWhen(true)] out ConstantExpectedParameter? parameter) + { + var ac = AttributeConstant.Get(attributeData); + if (ac.Min is not null || ac.Max is not null) + { + parameter = null; + return false; + } + parameter = new StringConstantExpectedParameter(parameterSymbol); + return true; + } + } + + private readonly struct AttributeConstant + { + public readonly object? Min; + public readonly object? Max; + + public AttributeConstant(object? min, object? max) + { + Min = min; + Max = max; + } + public static AttributeConstant Get(AttributeData attributeData) + { + object? minConstant = null; + object? maxConstant = null; + + foreach (var namedArg in attributeData.NamedArguments) + { + if (namedArg.Key.Equals(ConstantExpectedMin, StringComparison.Ordinal)) + { + minConstant = ToObject(namedArg.Value); + } + else if (namedArg.Key.Equals(ConstantExpectedMax, StringComparison.Ordinal)) + { + maxConstant = ToObject(namedArg.Value); + } + } + + return new AttributeConstant(minConstant, maxConstant); + + static object? ToObject(TypedConstant typedConstant) + { + if (typedConstant.IsNull) + { + return null; + } + return typedConstant.Kind == TypedConstantKind.Array ? typedConstant.Values : typedConstant.Value; + } + } + } + + + protected abstract class DiagnosticHelper + { + public abstract Location? GetMinLocation(SyntaxNode attributeSyntax); + public abstract Location? GetMaxLocation(SyntaxNode attributeSyntax); + + public ImmutableArray ParameterIsInvalid(string expectedTypeName, SyntaxNode attributeSyntax) => ImmutableArray.Create(Diagnostic.Create(CA1856.UnsupportedTypeRule, attributeSyntax.GetLocation(), expectedTypeName)); + + public Diagnostic MinIsIncompatible(string expectedTypeName, SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.IncompatibleConstantTypeRule, GetMinLocation(attributeSyntax)!, ConstantExpectedMin, expectedTypeName); + + public Diagnostic MaxIsIncompatible(string expectedTypeName, SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.IncompatibleConstantTypeRule, GetMaxLocation(attributeSyntax)!, ConstantExpectedMax, expectedTypeName); + + public Diagnostic MinIsOutOfRange(SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue) => Diagnostic.Create(CA1856.InvalidBoundsRule, GetMinLocation(attributeSyntax)!, ConstantExpectedMin, typeMinValue, typeMaxValue); + + public Diagnostic MaxIsOutOfRange(SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue) => Diagnostic.Create(CA1856.InvalidBoundsRule, GetMaxLocation(attributeSyntax)!, ConstantExpectedMax, typeMinValue, typeMaxValue); + + public static Diagnostic MinMaxIsInverted(SyntaxNode attributeSyntax) => Diagnostic.Create(CA1856.InvertedRangeRule, attributeSyntax.GetLocation()); + + public ImmutableArray GetError(ErrorKind errorFlags, IParameterSymbol parameterSymbol, SyntaxNode attributeSyntax, string typeMinValue, string typeMaxValue) + { + switch (errorFlags) + { + case ErrorKind.MinIsIncompatible: + return ImmutableArray.Create(MinIsIncompatible(parameterSymbol.Type.ToDisplayString(), attributeSyntax)); + case ErrorKind.MaxIsIncompatible: + return ImmutableArray.Create(MaxIsIncompatible(parameterSymbol.Type.ToDisplayString(), attributeSyntax)); + case ErrorKind.MinIsIncompatible | ErrorKind.MaxIsIncompatible: + var expectedTypeName = parameterSymbol.Type.ToDisplayString(); + return ImmutableArray.Create(MinIsIncompatible(expectedTypeName, attributeSyntax), MaxIsIncompatible(expectedTypeName, attributeSyntax)); + case ErrorKind.MinIsOutOfRange: + return ImmutableArray.Create(MinIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue)); + case ErrorKind.MaxIsOutOfRange: + return ImmutableArray.Create(MaxIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue)); + case ErrorKind.MinIsOutOfRange | ErrorKind.MaxIsOutOfRange: + return ImmutableArray.Create(MinIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue), MaxIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue)); + case ErrorKind.MinIsOutOfRange | ErrorKind.MaxIsIncompatible: + return ImmutableArray.Create(MinIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue), MaxIsIncompatible(parameterSymbol.Type.ToDisplayString(), attributeSyntax)); + case ErrorKind.MinIsIncompatible | ErrorKind.MaxIsOutOfRange: + return ImmutableArray.Create(MinIsIncompatible(parameterSymbol.Type.ToDisplayString(), attributeSyntax), MaxIsOutOfRange(attributeSyntax, typeMinValue, typeMaxValue)); + case ErrorKind.MinMaxInverted: + return ImmutableArray.Create(MinMaxIsInverted(attributeSyntax)); + default: + throw new ArgumentOutOfRangeException(nameof(errorFlags)); + } + } + } + + [Flags] + protected enum ErrorKind + { + None = 0, + /// + /// mutually exclusive with MinIsIncompatible and MinMaxInverted + /// + MinIsOutOfRange = 1, + /// + /// mutually exclusive with MinIsOutOfRange and MinMaxInverted + /// + MinIsIncompatible = 1 << 2, + /// + /// mutually exclusive with MaxIsIncompatible and MinMaxInverted + /// + MaxIsOutOfRange = 1 << 3, + /// + /// mutually exclusive with MaxIsOutOfRange and MinMaxInverted + /// + MaxIsIncompatible = 1 << 4, + /// + /// mutually exclusive + /// + MinMaxInverted = 1 << 5, + } + } +} diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/DoNotGuardDictionaryRemoveByContainsKey.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/DoNotGuardDictionaryRemoveByContainsKey.cs index 0f12a930d1..cbd7dfadf8 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/DoNotGuardDictionaryRemoveByContainsKey.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/DoNotGuardDictionaryRemoveByContainsKey.cs @@ -14,7 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Performance { using static MicrosoftNetCoreAnalyzersResources; /// - /// Do not guard 'Dictionary.Remove(key)' with 'Dictionary.ContainsKey(key)' + /// CA1853: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotGuardDictionaryRemoveByContainsKey : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/PreferHashDataOverComputeHash.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/PreferHashDataOverComputeHash.cs index 78736cc130..f8ba580eab 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/PreferHashDataOverComputeHash.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/PreferHashDataOverComputeHash.cs @@ -17,7 +17,7 @@ namespace Microsoft.NetCore.Analyzers.Performance using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1850: Prefer static HashData over ComputeHash + /// CA1850: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferHashDataOverComputeHashAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseAsSpanInsteadOfRangeIndexer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseAsSpanInsteadOfRangeIndexer.cs index 529557b6a5..54f625c440 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseAsSpanInsteadOfRangeIndexer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseAsSpanInsteadOfRangeIndexer.cs @@ -16,7 +16,9 @@ namespace Microsoft.NetCore.Analyzers.Performance using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1831, CA1832, CA1833: Use AsSpan or AsMemory instead of Range-based indexers when appropriate. + /// CA1831: + /// CA1832: + /// CA1833: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseAsSpanInsteadOfRangeIndexerAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseCountProperly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseCountProperly.cs index baf65706ce..708a961df7 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseCountProperly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseCountProperly.cs @@ -16,10 +16,10 @@ namespace Microsoft.NetCore.Analyzers.Performance using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1827: Do not use Count()/LongCount() when Any() can be used. - /// CA1828: Do not use CountAsync()/LongCountAsync() when AnyAsync() can be used. - /// CA1829: Use property instead of , when available. - /// CA1836: Prefer IsEmpty over Count when available. + /// CA1827: + /// CA1828: + /// CA1829: + /// CA1836: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseCountProperlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseSpanClearInsteadOfFill.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseSpanClearInsteadOfFill.cs index 112355e9bd..3b9500f7cf 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseSpanClearInsteadOfFill.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseSpanClearInsteadOfFill.cs @@ -14,7 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Performance using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1855: Use Span.Clear instead of Span.Fill(default) + /// CA1855: /// public abstract class UseSpanClearInsteadOfFillAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseStringContainsCharOverloadWithSingleCharactersAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseStringContainsCharOverloadWithSingleCharactersAnalyzer.cs index cdb67fd596..eca54ef9a6 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseStringContainsCharOverloadWithSingleCharactersAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/UseStringContainsCharOverloadWithSingleCharactersAnalyzer.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Performance { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1847: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseStringContainsCharOverloadWithSingleCharactersAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Resources/MarkAssembliesWithNeutralResourcesLanguage.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Resources/MarkAssembliesWithNeutralResourcesLanguage.cs index 675658b207..d84b8e6a13 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Resources/MarkAssembliesWithNeutralResourcesLanguage.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Resources/MarkAssembliesWithNeutralResourcesLanguage.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.Resources using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1824: Mark assemblies with NeutralResourcesLanguageAttribute + /// CA1824: /// public abstract class MarkAssembliesWithNeutralResourcesLanguageAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AttributeStringLiteralsShouldParseCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AttributeStringLiteralsShouldParseCorrectly.cs index 2627aa75fd..a78f4bed78 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AttributeStringLiteralsShouldParseCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AttributeStringLiteralsShouldParseCorrectly.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2243: Attribute string literals should parse correctly + /// CA2243: /// Unlike FxCop, this rule does not fire diagnostics for ill-formed versions /// Reason: There is wide usage of semantic versioning which does not follow traditional versioning grammar. /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidUnsealedAttributes.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidUnsealedAttributes.cs index fd70b51cac..5ed9fde8bf 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidUnsealedAttributes.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidUnsealedAttributes.cs @@ -13,7 +13,8 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1813: Seal attribute types for improved performance. Sealing attribute types speeds up performance during reflection on custom attributes. + /// CA1813: + /// Seal attribute types for improved performance. Sealing attribute types speeds up performance during reflection on custom attributes. /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class AvoidUnsealedAttributesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidZeroLengthArrayAllocations.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidZeroLengthArrayAllocations.cs index 4d4ab2ac6c..28c2d21663 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidZeroLengthArrayAllocations.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/AvoidZeroLengthArrayAllocations.cs @@ -13,7 +13,10 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; - /// Base type for an analyzer that looks for empty array allocations and recommends their replacement. + /// + /// CA1825: + /// Base type for an analyzer that looks for empty array allocations and recommends their replacement. + /// public abstract class AvoidZeroLengthArrayAllocationsAnalyzer : DiagnosticAnalyzer { internal const string RuleId = "CA1825"; diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/BufferBlockCopyLengthAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/BufferBlockCopyLengthAnalyzer.cs index ea83808370..0f3f4ae881 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/BufferBlockCopyLengthAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/BufferBlockCopyLengthAnalyzer.cs @@ -14,6 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2018: /// Check for the intended use of .Length on arrays passed into Buffer.BlockCopy /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/CallGCSuppressFinalizeCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/CallGCSuppressFinalizeCorrectly.cs index f615624abe..7bc6af46ec 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/CallGCSuppressFinalizeCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/CallGCSuppressFinalizeCorrectly.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1816: Dispose methods should call SuppressFinalize + /// CA1816: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class CallGCSuppressFinalizeCorrectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs index 3d92e3e30d..c28816f46d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs @@ -18,6 +18,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2252: /// Detect the use of [RequiresPreviewFeatures] in assemblies that have not opted into preview features /// public abstract class DetectPreviewFeatureAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposed.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposed.cs index 9912a0820b..e1e7e037b1 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposed.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposed.cs @@ -18,6 +18,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2213: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DisposableFieldsShouldBeDisposed : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableTypesShouldDeclareFinalizer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableTypesShouldDeclareFinalizer.cs index d00582c12b..acdde1f7aa 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableTypesShouldDeclareFinalizer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposableTypesShouldDeclareFinalizer.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2216: Disposable types should declare finalizer + /// CA2216: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DisposableTypesShouldDeclareFinalizerAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeMethodsShouldCallBaseClassDispose.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeMethodsShouldCallBaseClassDispose.cs index cabcf3e669..328b4de801 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeMethodsShouldCallBaseClassDispose.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeMethodsShouldCallBaseClassDispose.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2215: Dispose methods should call base class dispose + /// CA2215: /// /// A type that implements System.IDisposable inherits from a type that also implements IDisposable. /// The Dispose method of the inheriting type does not call the Dispose method of the parent type. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScope.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScope.cs index 58d9b70e77..7b3e581026 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScope.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScope.cs @@ -18,6 +18,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2000: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DisposeObjectsBeforeLosingScope : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotDefineFinalizersForTypesDerivedFromMemoryManager.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotDefineFinalizersForTypesDerivedFromMemoryManager.cs index 8853222d9a..353b28e574 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotDefineFinalizersForTypesDerivedFromMemoryManager.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotDefineFinalizersForTypesDerivedFromMemoryManager.cs @@ -12,7 +12,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2015: Do not define finalizers for types derived from MemoryManager<T>. + /// CA2015: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDefineFinalizersForTypesDerivedFromMemoryManager : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotLockOnObjectsWithWeakIdentity.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotLockOnObjectsWithWeakIdentity.cs index 232658ed5c..ccc141fe7e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotLockOnObjectsWithWeakIdentity.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotLockOnObjectsWithWeakIdentity.cs @@ -12,7 +12,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2002: Do not lock on objects with weak identities + /// CA2002: /// /// Cause: /// A thread that attempts to acquire a lock on an object that has a weak identity could cause hangs. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotRaiseReservedExceptionTypes.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotRaiseReservedExceptionTypes.cs index 9c8d199c17..a507b1c09f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotRaiseReservedExceptionTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotRaiseReservedExceptionTypes.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2201: Do not raise reserved exception types + /// CA2201: /// /// Too generic: /// System.Exception diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectly.cs index 423b9848eb..95ed41867e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectly.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly + /// CA1826: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseReferenceEqualsWithValueTypes.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseReferenceEqualsWithValueTypes.cs index 4187e61c85..9e14a4187e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseReferenceEqualsWithValueTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseReferenceEqualsWithValueTypes.cs @@ -12,7 +12,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2013: Do not use ReferenceEquals with value types. + /// CA2013: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseReferenceEqualsWithValueTypesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsAnalyzer.cs index 11f7b9ea94..8e3eee5189 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsAnalyzer.cs @@ -9,6 +9,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2014: + /// public abstract class DoNotUseStackallocInLoopsAnalyzer : DiagnosticAnalyzer { internal const string RuleId = "CA2014"; diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocations.Analyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocations.Analyzer.cs index 745fc26ca3..3067d29a8c 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocations.Analyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocations.Analyzer.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2016: Forward CancellationToken to invocations. + /// CA2016: /// /// Conditions for positive cases: /// - The containing method signature receives a ct parameter. It can be a method, a nested method, an action or a func. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InitializeStaticFieldsInline.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InitializeStaticFieldsInline.cs index b123a15cd9..59a462f856 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InitializeStaticFieldsInline.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InitializeStaticFieldsInline.cs @@ -13,8 +13,8 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1810: Initialize reference type static fields inline - /// CA2207: Initialize value type static fields inline + /// CA1810: + /// CA2207: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class InitializeStaticFieldsInlineAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InstantiateArgumentExceptionsCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InstantiateArgumentExceptionsCorrectly.cs index 02107ec338..76be088859 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InstantiateArgumentExceptionsCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/InstantiateArgumentExceptionsCorrectly.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2208: Instantiate argument exceptions correctly + /// CA2208: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class InstantiateArgumentExceptionsCorrectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/LoggerMessageDefineAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/LoggerMessageDefineAnalyzer.cs index 728ca34424..310e78a904 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/LoggerMessageDefineAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/LoggerMessageDefineAnalyzer.cs @@ -16,6 +16,13 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftCodeQualityAnalyzersResources; + /// + /// CA1727: + /// CA1848: + /// CA2253: + /// CA2254: + /// CA2017: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class LoggerMessageDefineAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ModuleInitializerAttributeShouldNotBeUsedInLibraries.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ModuleInitializerAttributeShouldNotBeUsedInLibraries.cs index 56c6e0a8e8..c20db43a1e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ModuleInitializerAttributeShouldNotBeUsedInLibraries.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ModuleInitializerAttributeShouldNotBeUsedInLibraries.cs @@ -11,7 +11,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime { /// - /// CA2255: ModuleInitializer attributes should not be used in libraries. + /// CA2255: /// /// /// ModuleInitializer methods must: diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferAsSpanOverSubstring.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferAsSpanOverSubstring.cs index 4a6db344e3..acf1ac40b3 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferAsSpanOverSubstring.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferAsSpanOverSubstring.cs @@ -16,7 +16,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime { /// - /// CA1842: Prefer 'AsSpan' over 'Substring'. + /// CA1846: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferAsSpanOverSubstring : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferConstCharOverConstUnitStringAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferConstCharOverConstUnitStringAnalyzer.cs index a02ab8ea30..44599d5c2f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferConstCharOverConstUnitStringAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferConstCharOverConstUnitStringAnalyzer.cs @@ -13,6 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// + /// CA1834: /// Test for single character strings passed in to StringBuilder.Append /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryContainsMethods.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryContainsMethods.cs index e9f3048bef..61b08f7884 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryContainsMethods.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryContainsMethods.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { + /// + /// CA1841: + /// public abstract class PreferDictionaryContainsMethods : DiagnosticAnalyzer { internal const string RuleId = "CA1841"; diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryTryGetValueAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryTryGetValueAnalyzer.cs index fd5c257793..e5e95670fb 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryTryGetValueAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferDictionaryTryGetValueAnalyzer.cs @@ -14,6 +14,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { + /// + /// CA1854: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferDictionaryTryGetValueAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStreamAsyncMemoryOverloads.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStreamAsyncMemoryOverloads.cs index a3ccb9d8a2..df9861d8ff 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStreamAsyncMemoryOverloads.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStreamAsyncMemoryOverloads.cs @@ -14,7 +14,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1835: Prefer Memory/ReadOnlyMemory overloads for Stream ReadAsync/WriteAsync methods. + /// CA1835: + /// + /// Prefer Memory/ReadOnlyMemory overloads for Stream ReadAsync/WriteAsync methods. /// /// Undesired methods (available since .NET Framework 4.5): /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStringContainsOverIndexOfAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStringContainsOverIndexOfAnalyzer.cs index 5a544ab759..7424a15d6a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStringContainsOverIndexOfAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferStringContainsOverIndexOfAnalyzer.cs @@ -13,6 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2249: /// Prefer string.Contains over string.IndexOf when the result is used to check for the presence/absence of a substring /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferTypedStringBuilderAppendOverloads.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferTypedStringBuilderAppendOverloads.cs index 732f4ae503..74c13ac05d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferTypedStringBuilderAppendOverloads.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreferTypedStringBuilderAppendOverloads.cs @@ -12,7 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; - /// CA1830: Prefer strongly-typed StringBuilder.Append overloads. + /// + /// CA1830: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PreferTypedStringBuilderAppendOverloads : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreventNumericIntPtrUIntPtrBehavioralChanges.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreventNumericIntPtrUIntPtrBehavioralChanges.cs index d847ce9e88..db77655a00 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreventNumericIntPtrUIntPtrBehavioralChanges.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/PreventNumericIntPtrUIntPtrBehavioralChanges.cs @@ -12,7 +12,8 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2020: Detects Behavioral Changes introduced by new Numeric IntPtr UIntPtr feature + /// CA2020: + /// Detects Behavioral Changes introduced by new Numeric IntPtr UIntPtr feature /// public abstract class PreventNumericIntPtrUIntPtrBehavioralChanges : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs index 244ae92372..a2760e2c9e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2241: Provide correct arguments to formatting methods + /// CA2241: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class ProvideCorrectArgumentsToFormattingMethodsAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideStreamMemoryBasedAsyncOverrides.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideStreamMemoryBasedAsyncOverrides.cs index 554dacf6c3..fb5722cea3 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideStreamMemoryBasedAsyncOverrides.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideStreamMemoryBasedAsyncOverrides.cs @@ -12,9 +12,10 @@ namespace Microsoft.NetCore.Analyzers.Runtime { /// - /// CA1840: Reports a diagnostic if a class that directly subclasses overrides + /// CA1840: + /// Reports a diagnostic if a class that directly subclasses overrides /// and/or , - /// and does not override the corrasponding memory-based version. + /// and does not override the corresponding memory-based version. /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ProvideStreamMemoryBasedAsyncOverrides : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypes.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypes.cs index 7f74bf3958..f70db6761c 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypes.cs @@ -10,6 +10,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { + /// + /// CA1852: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SealInternalTypes : DiagnosticAnalyzer { @@ -57,7 +60,8 @@ private static void OnCompilationStart(CompilationStartAnalysisContext context) !type.IsStatic && !type.IsSealed && !type.IsExternallyVisible() && - !type.HasAttribute(comImportAttributeType)) + !type.HasAttribute(comImportAttributeType) && + !type.IsTopLevelStatementsEntryPointType()) { candidateTypes.Add(type); } diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs index 8543a49d8a..bf62215ece 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs @@ -11,6 +11,11 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2229: + /// CA2237: + /// CA2235: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SerializationRulesDiagnosticAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForEmptyStringsUsingStringLength.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForEmptyStringsUsingStringLength.cs index 2f757f2877..eef192380e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForEmptyStringsUsingStringLength.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForEmptyStringsUsingStringLength.cs @@ -14,7 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA1820: Test for empty strings using string length. + /// CA1820: /// /// Comparing strings using the property or the method is significantly faster than using . /// This is because Equals executes significantly more MSIL instructions than either IsNullOrEmpty or the number of instructions executed to retrieve the Length property value and compare it to zero. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForNaNCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForNaNCorrectly.cs index 91ca9b0f66..7eeef5b518 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForNaNCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/TestForNaNCorrectly.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2242: Test for NaN correctly + /// CA2242: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class TestForNaNCorrectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseAsyncMethodInAsyncContext.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseAsyncMethodInAsyncContext.cs index 7628167555..0b542df6de 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseAsyncMethodInAsyncContext.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseAsyncMethodInAsyncContext.cs @@ -16,6 +16,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// + /// CA1849: /// This analyzer suggests using the async version of a method when inside a Task-returning method /// In addition, calling Task.Wait(), Task.Result or Task.GetAwaiter().GetResult() will produce a diagnostic /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseCancellationTokenThrowIfCancellationRequested.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseCancellationTokenThrowIfCancellationRequested.cs index 27d24e8c6c..e5f1e1ab20 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseCancellationTokenThrowIfCancellationRequested.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseCancellationTokenThrowIfCancellationRequested.cs @@ -13,6 +13,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { + /// + /// CA2250: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseCancellationTokenThrowIfCancellationRequested : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseEnvironmentMembers.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseEnvironmentMembers.cs index 08da1334a5..7b74f0fb0a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseEnvironmentMembers.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseEnvironmentMembers.cs @@ -12,7 +12,11 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; - /// CA1837, CA1839, CA1840: Use Environment.ProcessId / ProcessPath / CurrentManagedThreadId + /// + /// CA1837: + /// CA1839: + /// CA1840: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseEnvironmentMembers : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseSpanBasedStringConcat.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseSpanBasedStringConcat.cs index afe9a4ab8b..c1065a9ff5 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseSpanBasedStringConcat.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseSpanBasedStringConcat.cs @@ -14,6 +14,9 @@ namespace Microsoft.NetCore.Analyzers.Runtime { + /// + /// CA1845: + /// public abstract class UseSpanBasedStringConcat : DiagnosticAnalyzer { internal const string RuleId = "CA1845"; diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseStringEqualsOverStringCompare.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseStringEqualsOverStringCompare.cs index a4311678be..3dd5156b47 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseStringEqualsOverStringCompare.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseStringEqualsOverStringCompare.cs @@ -14,6 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Runtime { /// + /// CA2251: /// Reports a diagnostic on any that: /// /// Is an equals or not-equals operation diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseThreadStaticCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseThreadStaticCorrectly.cs index 650f3e1df2..c7cb42ff11 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseThreadStaticCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/UseThreadStaticCorrectly.cs @@ -11,6 +11,10 @@ namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2259: + /// CA2019: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseThreadStaticCorrectly : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/ApprovedCipherModeAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/ApprovedCipherModeAnalyzer.cs index 077646831f..fa18cd8325 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/ApprovedCipherModeAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/ApprovedCipherModeAnalyzer.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5358: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ApprovedCipherModeAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInIFormatterSerializableObjectGraphAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInIFormatterSerializableObjectGraphAnalyzer.cs index a552676e79..3a93dabb30 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInIFormatterSerializableObjectGraphAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInIFormatterSerializableObjectGraphAnalyzer.cs @@ -14,6 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2354: /// For detecting deserialization of or in an /// IFormatter deserialized object graph. /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableObjectGraphAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableObjectGraphAnalyzer.cs index 2f65e56bf8..a1d8f135b4 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableObjectGraphAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableObjectGraphAnalyzer.cs @@ -16,6 +16,7 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2355: /// For detecting deserialization of or in an /// deserialized object graph for certain serializers. /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableTypeAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableTypeAnalyzer.cs index 8e598681a3..8bc14aead1 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableTypeAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableTypeAnalyzer.cs @@ -15,6 +15,9 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2352: + /// CA2353: + /// CA2362: /// For detecting or deserializable members. /// [SuppressMessage("Documentation", "CA1200:Avoid using cref tags with a prefix", Justification = "The comment references a type that is not referenced by this compilation.")] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInWebSerializableObjectGraphAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInWebSerializableObjectGraphAnalyzer.cs index 1320471849..2d8c954acf 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInWebSerializableObjectGraphAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInWebSerializableObjectGraphAnalyzer.cs @@ -14,6 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2356: /// For detecting deserialization of or in an /// web API / WCF API serializable object graph. /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAddSchemaByURL.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAddSchemaByURL.cs index 53e9708ad4..5f282d9041 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAddSchemaByURL.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAddSchemaByURL.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA3061: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotAddSchemaByURL : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAlwaysSkipTokenValidationInDelegates.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAlwaysSkipTokenValidationInDelegates.cs index 313aa98f38..cbcc47ddd1 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAlwaysSkipTokenValidationInDelegates.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotAlwaysSkipTokenValidationInDelegates.cs @@ -14,6 +14,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5405: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotAlwaysSkipTokenValidationInDelegates : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotCallDangerousMethodsInDeserialization.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotCallDangerousMethodsInDeserialization.cs index 6e8c9f4086..ff0697bb54 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotCallDangerousMethodsInDeserialization.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotCallDangerousMethodsInDeserialization.cs @@ -17,6 +17,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5360: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotCallDangerousMethodsInDeserialization : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableCertificateValidation.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableCertificateValidation.cs index f0d138503c..aa6440daac 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableCertificateValidation.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableCertificateValidation.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5359: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDisableCertificateValidation : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpClientCRLCheck.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpClientCRLCheck.cs index 8cd77611f7..ca7ad2876f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpClientCRLCheck.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpClientCRLCheck.cs @@ -20,6 +20,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5399: + /// CA5400: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] internal class DoNotDisableHttpClientCRLCheck : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpHeaderChecking.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpHeaderChecking.cs index 1562e06aee..6ef5762394 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpHeaderChecking.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpHeaderChecking.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5365: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDisableHTTPHeaderChecking : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableRequestValidation.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableRequestValidation.cs index 4bd5499ada..4e9db99144 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableRequestValidation.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableRequestValidation.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5363: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDisableRequestValidation : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableTokenValidationChecks.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableTokenValidationChecks.cs index 8ca7a59bf5..05c69a191d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableTokenValidationChecks.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotDisableTokenValidationChecks.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5404: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotDisableTokenValidationChecks : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotInstallRootCert.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotInstallRootCert.cs index 6355a9befa..9bc11d47fd 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotInstallRootCert.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotInstallRootCert.cs @@ -21,6 +21,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5380: + /// CA5381: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotInstallRootCert : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSerializeTypeWithPointerFields.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSerializeTypeWithPointerFields.cs index a734bda43d..d5e67c50f2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSerializeTypeWithPointerFields.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSerializeTypeWithPointerFields.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5367: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotSerializeTypeWithPointerFields : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSetSwitch.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSetSwitch.cs index 8fe1833cd6..c62ab672b7 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSetSwitch.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotSetSwitch.cs @@ -19,6 +19,8 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA5361: + /// CA5378: /// Analyzer for System.AppContext.SetSwitch invocations. /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseAccountSAS.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseAccountSAS.cs index c039706275..f334323a05 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseAccountSAS.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseAccountSAS.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5375: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseAccountSAS : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseCreateEncryptorWithNonDefaultIV.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseCreateEncryptorWithNonDefaultIV.cs index eb96a2f3ca..21b4f3aa27 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseCreateEncryptorWithNonDefaultIV.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseCreateEncryptorWithNonDefaultIV.cs @@ -19,6 +19,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5401: + /// CA5402: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseCreateEncryptorWithNonDefaultIV : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDSA.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDSA.cs index 500abd444f..72eb3c5529 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDSA.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDSA.cs @@ -13,6 +13,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5384: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseDSA : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDeprecatedSecurityProtocols.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDeprecatedSecurityProtocols.cs index 37ef45b8ce..7dbc689d4e 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDeprecatedSecurityProtocols.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseDeprecatedSecurityProtocols.cs @@ -13,6 +13,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5364: + /// CA5386: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseDeprecatedSecurityProtocols : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithms.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithms.cs index b649f666d0..bc087ce1f2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithms.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureCryptographicAlgorithms.cs @@ -13,6 +13,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5350: + /// CA5351: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseInsecureCryptographicAlgorithmsAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs index bf091cd9ef..d6977b5a5b 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs @@ -21,6 +21,8 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2321: + /// CA2322: /// For detecting deserialization with . /// [SuppressMessage("Documentation", "CA1200:Avoid using cref tags with a prefix", Justification = "The comment references a type that is not referenced by this compilation.")] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs index 1c548a9bf7..910000584d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs @@ -22,6 +22,8 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2329: + /// CA2330: /// For detecting deserialization with when its TypeNameHandling != None /// and its Binder/SerializationBinder is null. /// diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureRandomness.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureRandomness.cs index 715bbeabd6..dcce1cdbd8 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureRandomness.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureRandomness.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5394: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseInsecureRandomness : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNet.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNet.cs index 82c778916b..f7ce5bd5ba 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNet.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNet.cs @@ -22,6 +22,8 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2327: + /// CA2328: /// For detecting potentially insecure deserialization settings with . /// [SuppressMessage("Documentation", "CA1200:Avoid using cref tags with a prefix", Justification = "The comment references a type that is not referenced by this compilation.")] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseObsoleteKDFAlgorithm.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseObsoleteKDFAlgorithm.cs index 6bf72ff7ff..506ae06bf3 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseObsoleteKDFAlgorithm.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseObsoleteKDFAlgorithm.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5373: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseObsoleteKDFAlgorithm : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFAlgorithm.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFAlgorithm.cs index f77aa42ac2..6f0863183a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFAlgorithm.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFAlgorithm.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5379: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseWeakKDFAlgorithm : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFInsufficientIterationCount.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFInsufficientIterationCount.cs index 032ae9ae7a..c013aa0037 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFInsufficientIterationCount.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFInsufficientIterationCount.cs @@ -22,6 +22,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5387: + /// CA5388: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseWeakKDFInsufficientIterationCount : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseXslTransform.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseXslTransform.cs index b8e715ca7d..2b8286fd30 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseXslTransform.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/DoNotUseXslTransform.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5374: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseXslTransform : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandling.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandling.cs index c282f45af2..947d527c1f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandling.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandling.cs @@ -14,6 +14,7 @@ namespace Microsoft.NetCore.Analyzers.Security using static MicrosoftNetCoreAnalyzersResources; /// + /// CA2326: /// For using a values other than None. /// [SuppressMessage("Documentation", "CA1200:Avoid using cref tags with a prefix", Justification = "The comment references a type that is not referenced by this compilation.")] diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/PotentialReferenceCycleInDeserializedObjectGraph.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/PotentialReferenceCycleInDeserializedObjectGraph.cs index 3df8635004..996b26bd07 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/PotentialReferenceCycleInDeserializedObjectGraph.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/PotentialReferenceCycleInDeserializedObjectGraph.cs @@ -13,6 +13,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5362: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PotentialReferenceCycleInDeserializedObjectGraph : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetHttpOnlyForHttpCookie.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetHttpOnlyForHttpCookie.cs index d58e9927da..39dd99b4d1 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetHttpOnlyForHttpCookie.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetHttpOnlyForHttpCookie.cs @@ -18,6 +18,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5396: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] internal class SetHttpOnlyForHttpCookie : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetViewStateUserKey.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetViewStateUserKey.cs index 3385d1b982..f72cbb3d4f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetViewStateUserKey.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SetViewStateUserKey.cs @@ -12,6 +12,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5368: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SetViewStateUserKey : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SslProtocolsAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SslProtocolsAnalyzer.cs index 0b4ffcba10..bb860181aa 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SslProtocolsAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/SslProtocolsAnalyzer.cs @@ -14,6 +14,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5397: + /// CA5398: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SslProtocolsAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseAutoValidateAntiforgeryToken.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseAutoValidateAntiforgeryToken.cs index f5003f8dc1..04dee9d017 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseAutoValidateAntiforgeryToken.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseAutoValidateAntiforgeryToken.cs @@ -18,6 +18,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5391: + /// CA5395: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseAutoValidateAntiforgeryToken : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseContainerLevelAccessPolicy.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseContainerLevelAccessPolicy.cs index 098c2cbf7c..83af9391be 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseContainerLevelAccessPolicy.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseContainerLevelAccessPolicy.cs @@ -16,6 +16,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5377: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseContainerLevelAccessPolicy : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttribute.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttribute.cs index 34180817ee..90914dff12 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttribute.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttribute.cs @@ -14,6 +14,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5392: + /// CA5393: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseDefaultDllImportSearchPathsAttribute : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseRSAWithSufficientKeySize.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseRSAWithSufficientKeySize.cs index 8de88da0db..83213ca8f6 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseRSAWithSufficientKeySize.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseRSAWithSufficientKeySize.cs @@ -14,6 +14,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5385: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseRSAWithSufficientKeySize : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSecureCookiesASPNetCore.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSecureCookiesASPNetCore.cs index 52b1e2b69d..239c95dcb3 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSecureCookiesASPNetCore.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSecureCookiesASPNetCore.cs @@ -19,6 +19,10 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5382: + /// CA5383: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseSecureCookiesASPNetCore : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSharedAccessProtocolHttpsOnly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSharedAccessProtocolHttpsOnly.cs index c89a876c4f..a2ddf70023 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSharedAccessProtocolHttpsOnly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Security/UseSharedAccessProtocolHttpsOnly.cs @@ -15,6 +15,9 @@ namespace Microsoft.NetCore.Analyzers.Security { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA5376: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseSharedAccessProtocolHttpsOnly : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTaskCompletionSourceWithWrongArguments.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTaskCompletionSourceWithWrongArguments.cs index 9a829866c7..26393bb408 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTaskCompletionSourceWithWrongArguments.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTaskCompletionSourceWithWrongArguments.cs @@ -11,7 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Tasks { using static MicrosoftNetCoreAnalyzersResources; - /// CA2012: Use ValueTasks correctly. + /// + /// CA2247: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotCreateTaskCompletionSourceWithWrongArguments : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTasksWithoutPassingATaskScheduler.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTasksWithoutPassingATaskScheduler.cs index 94eac5bc1d..d50f01e2d9 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTasksWithoutPassingATaskScheduler.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotCreateTasksWithoutPassingATaskScheduler.cs @@ -13,7 +13,7 @@ namespace Microsoft.NetCore.Analyzers.Tasks using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2008: Do not create tasks without passing a TaskScheduler + /// CA2008: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotCreateTasksWithoutPassingATaskSchedulerAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotUseWhenAllOrWaitAllWithSingleArgument.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotUseWhenAllOrWaitAllWithSingleArgument.cs index 94a3c68eba..281d206e6f 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotUseWhenAllOrWaitAllWithSingleArgument.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/DoNotUseWhenAllOrWaitAllWithSingleArgument.cs @@ -14,6 +14,10 @@ namespace Microsoft.NetCore.Analyzers.Tasks { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA1842: + /// CA1843: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class DoNotUseWhenAllOrWaitAllWithSingleArgument : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/UseValueTasksCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/UseValueTasksCorrectly.cs index 0f84c79c8e..29380944b6 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/UseValueTasksCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Tasks/UseValueTasksCorrectly.cs @@ -17,7 +17,9 @@ namespace Microsoft.NetCore.Analyzers.Tasks { using static MicrosoftNetCoreAnalyzersResources; - /// CA2012: Use ValueTasks correctly. + /// + /// CA2012: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class UseValueTasksCorrectlyAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ImplementGenericMathInterfacesCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ImplementGenericMathInterfacesCorrectly.cs index 67ed576657..6c276c28c2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ImplementGenericMathInterfacesCorrectly.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ImplementGenericMathInterfacesCorrectly.cs @@ -11,7 +11,8 @@ namespace Microsoft.NetCore.Analyzers.Usage using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2260: Some generic math interfaces require the derived type itself to be used for the self recurring type parameter, enforces that requirement + /// CA2260: + /// Some generic math interfaces require the derived type itself to be used for the self recurring type parameter, enforces that requirement /// public abstract class ImplementGenericMathInterfacesCorrectly : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ProvideCorrectArgumentToEnumHasFlag.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ProvideCorrectArgumentToEnumHasFlag.cs index c1478387bd..7f59a1d82c 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ProvideCorrectArgumentToEnumHasFlag.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Usage/ProvideCorrectArgumentToEnumHasFlag.cs @@ -11,6 +11,9 @@ namespace Microsoft.NetCore.Analyzers.Usage { using static MicrosoftNetCoreAnalyzersResources; + /// + /// CA2248: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class ProvideCorrectArgumentToEnumHasFlag : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf index c21cbc9fc3..f5fd320eff 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + Atribut ConstantExpected není u parametru použit správně. + + + + Incorrect usage of ConstantExpected attribute + Nesprávné použití atributu ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Atribut ConstantExpected je pro parametr vyžadován z důvodu poznámky nadřazené metody. + + + + The '{0}' value is not compatible with parameter type of '{1}' + Hodnota {0} není kompatibilní s typem parametru {1}. + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + Hodnota {0} se nevejde do mezí hodnot parametru od {1} do {2}. + + + + The constant is not of the same '{0}' type as the parameter + Konstanta nemá stejný typ {0} jako parametr. + + + + The Min and Max values are inverted + Hodnoty Min a Max jsou obrácené. + + + + The argument should be a constant for optimal performance + Aby parametr fungoval optimálně, měl by být konstantou. + + + + The '{0}' type is not supported for ConstantExpected attribute + Typ {0} není pro atribut ConstantExpected podporován. + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + Konstanta se nevejde do mezí hodnot od {0} do {1}. + + + + The parameter expects a constant for optimal performance. + Aby parametr fungoval optimálně, očekává konstantu. + + + + A constant is expected for the parameter + Pro parametr se očekává konstanta. + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Při deserializaci nedůvěryhodného vstupu není deserializace objektu {0} bezpečná. Objekt {1} je buď objektem {0}, nebo je z tohoto objektu odvozený. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf index bea79d481b..4872d290b2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + Das ConstantExpected-Attribut wird nicht ordnungsgemäß auf den Parameter angewendet. + + + + Incorrect usage of ConstantExpected attribute + Falsche Verwendung des ConstantExpected-Attributs + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Das ConstantExpected-Attribut ist für den Parameter aufgrund der Anmerkung der übergeordneten Methode erforderlich. + + + + The '{0}' value is not compatible with parameter type of '{1}' + Der Wert "{0}" ist nicht mit dem Parametertyp "{1}" kompatibel. + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + Der Wert "{0}" passt nicht in die Parameterwertgrenzen von "{1}" bis "{2}". + + + + The constant is not of the same '{0}' type as the parameter + Die Konstante weist nicht denselben Typ "{0}" wie der Parameter auf. + + + + The Min and Max values are inverted + Die Werte "Min" und "Max" werden invertiert. + + + + The argument should be a constant for optimal performance + Das Argument sollte eine Konstante sein, um eine optimale Leistung zu erzielen. + + + + The '{0}' type is not supported for ConstantExpected attribute + Der Typ "{0}" wird für das ConstantExpected-Attribut nicht unterstützt. + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + Die Konstante passt nicht in die Wertebegrenzungen von "{0}" bis "{1}". + + + + The parameter expects a constant for optimal performance. + Der Parameter erwartet eine Konstante, um eine optimale Leistung zu erzielen. + + + + A constant is expected for the parameter + Für den Parameter wird eine Konstante erwartet. + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Beim Deserialisieren einer nicht vertrauenswürdigen Eingabe ist die Deserialisierung eines {0}-Objekts unsicher. "{1}" ist entweder "{0}" oder davon abgeleitet. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf index 59f4ea7e1c..f773d5cf26 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + El atributo ConstantExpected no se aplica correctamente en el parámetro. + + + + Incorrect usage of ConstantExpected attribute + Uso incorrecto del atributo ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + El atributo ConstantExpected es necesario para el parámetro debido a la anotación del método primario + + + + The '{0}' value is not compatible with parameter type of '{1}' + El valor '{0}' no es compatible con el tipo de parámetro de '{1}' + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + El valor '{0}' no cabe dentro de los límites de valor de parámetro de '{1}' a '{2}' + + + + The constant is not of the same '{0}' type as the parameter + La constante no es del mismo tipo '{0}' que el parámetro + + + + The Min and Max values are inverted + Los valores Mínimo y Máximo están invertidos + + + + The argument should be a constant for optimal performance + El argumento debe ser una constante para obtener un rendimiento óptimo + + + + The '{0}' type is not supported for ConstantExpected attribute + No se admite el tipo '{0}' para el atributo ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + La constante no cabe dentro de los límites de valor de '{0}' a '{1}' + + + + The parameter expects a constant for optimal performance. + El parámetro espera una constante para un rendimiento óptimo. + + + + A constant is expected for the parameter + Se espera una constante para el parámetro + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Cuando se deserializa una entrada que no es de confianza, no es segura la deserialización de un objeto {0}. "{1}" es {0} o se deriva de este. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf index f5938d10bf..30abcd0b59 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + L’attribut ConstantExpected n’est pas appliqué correctement au paramètre. + + + + Incorrect usage of ConstantExpected attribute + Utilisation incorrecte de l’attribut ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + L’attribut ConstantExpected est requis pour le paramètre en raison de l’annotation de méthode parente + + + + The '{0}' value is not compatible with parameter type of '{1}' + La valeur « {0} » n’est pas compatible avec le type de paramètre « {1} » + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + La valeur « {0} » ne tient pas dans les limites de valeur de paramètre de « {1} » à « {2} » + + + + The constant is not of the same '{0}' type as the parameter + La constante n’est pas du même type « {0} » que le paramètre + + + + The Min and Max values are inverted + Les valeurs Min et Max sont inversées + + + + The argument should be a constant for optimal performance + L’argument doit être une constante pour des performances optimales + + + + The '{0}' type is not supported for ConstantExpected attribute + Le type « {0} » n’est pas pris en charge pour l’attribut ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + La constante ne tient pas dans les limites de valeur de « {0} » à « {1} » + + + + The parameter expects a constant for optimal performance. + Le paramètre attend une constante pour des performances optimales. + + + + A constant is expected for the parameter + Une constante est attendue pour le paramètre + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Quand vous désérialisez une entrée non fiable, la désérialisation d'un objet {0} n'est pas une action sécurisée. '{1}' est égal à ou dérive de {0} diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf index 2902232194..67c8f750fd 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + Attributo ConstantExpected non applicato correttamente al parametro. + + + + Incorrect usage of ConstantExpected attribute + Utilizzo non corretto dell'attributo ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + L'attributo ConstantExpected è obbligatorio per il parametro a causa dell'annotazione del metodo padre + + + + The '{0}' value is not compatible with parameter type of '{1}' + Il valore '{0}' non è compatibile con il tipo di parametro di '{1}' + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + Il valore '{0}' non rientra nei limiti del valore del parametro di '{1}' per '{2}' + + + + The constant is not of the same '{0}' type as the parameter + La costante non è dello stesso tipo '{0}' del parametro + + + + The Min and Max values are inverted + I valori minimo e massimo sono invertiti + + + + The argument should be a constant for optimal performance + L'argomento deve essere una costante per prestazioni ottimali + + + + The '{0}' type is not supported for ConstantExpected attribute + Il tipo di '{0}' non è supportato per l'attributo ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + La costante non rientra nei limiti dei valori di '{0}' a '{1}' + + + + The parameter expects a constant for optimal performance. + Il parametro prevede una costante per prestazioni ottimali. + + + + A constant is expected for the parameter + È prevista una costante per il parametro + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Quando si deserializza input non attendibile, la deserializzazione di un oggetto {0} non è sicura. '{1}' è {0} o deriva da esso diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf index e4b9b7b671..417889b0e2 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + ConstantExpected 属性がパラメーターに正しく適用されていません。 + + + + Incorrect usage of ConstantExpected attribute + ConstantExpected 属性の使用法が正しくありません + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + 親メソッドの注釈により、パラメーターには ConstantExpected 属性が必要です + + + + The '{0}' value is not compatible with parameter type of '{1}' + '{0}' 値は、'{1}' のパラメーターの型と互換性がありません + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + '{0}' の値が '{1}' から '{2}' までのパラメーター値の範囲内に収まりません + + + + The constant is not of the same '{0}' type as the parameter + 定数の '{0}' 型がパラメーターと同じではありません + + + + The Min and Max values are inverted + 最小値と最大値が反転されます + + + + The argument should be a constant for optimal performance + 最適なパフォーマンスを得るには、引数を定数にする必要があります + + + + The '{0}' type is not supported for ConstantExpected attribute + '{0}' 型は ConstantExpected 属性ではサポートされていません + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + 定数は '{0}' から '{1}' までの値の範囲内に収まりません + + + + The parameter expects a constant for optimal performance. + パラメーターには、最適なパフォーマンスを得るための定数が必要です。 + + + + A constant is expected for the parameter + パラメーターには定数が必要です + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} 信頼されていない入力を逆シリアル化する場合、{0} オブジェクトの逆シリアル化は安全ではありません。'{1}' は {0} であるか、それから派生しています diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf index f0e880e976..570b001929 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + ConstantExpected 특성이 매개 변수에 올바르게 적용되지 않았습니다. + + + + Incorrect usage of ConstantExpected attribute + ConstantExpected 특성의 사용이 잘못되었습니다. + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + 부모 메서드 주석으로 인해 매개 변수에 ConstantExpected 특성이 필요합니다. + + + + The '{0}' value is not compatible with parameter type of '{1}' + '{0}' 값이 '{1}' 매개 변수 형식과 호환되지 않습니다. + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + '{0}' 값이 '{1}'에서 '{2}'까지 매개 변수 값 범위 내에 맞지 않습니다. + + + + The constant is not of the same '{0}' type as the parameter + 상수가 매개 변수와 동일한 '{0}' 형식이 아닙니다. + + + + The Min and Max values are inverted + 최소 및 최대값이 반전됩니다. + + + + The argument should be a constant for optimal performance + 최적의 성능을 위해 인수는 상수여야 합니다. + + + + The '{0}' type is not supported for ConstantExpected attribute + ConstantExpected 특성에는 '{0}' 형식이 지원되지 않습니다. + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + 상수가 '{0}'에서 '{1}'까지 값 범위 내에 맞지 않습니다. + + + + The parameter expects a constant for optimal performance. + 매개 변수에는 최적의 성능을 위해 상수가 필요합니다. + + + + A constant is expected for the parameter + 매개 변수에 상수가 필요합니다. + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} 신뢰할 수 없는 입력을 역직렬화하는 경우 {0} 개체를 역직렬화하는 것은 안전하지 않습니다. '{1}'은(는) {0}이거나 이 항목에서 파생됩니다. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf index fe6b747a4e..e1e4642c6c 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + Atrybut ConstantExpected nie jest poprawnie stosowany do parametru. + + + + Incorrect usage of ConstantExpected attribute + Nieprawidłowe użycie atrybutu ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Atrybut ConstantExpected jest wymagany dla parametru z powodu adnotacji metody nadrzędnej + + + + The '{0}' value is not compatible with parameter type of '{1}' + Wartość „{0}” jest niezgodna z typem parametru „{1}” + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + Wartość „{0}” nie mieści się w granicach wartości parametru od „{1}” do „{2}” + + + + The constant is not of the same '{0}' type as the parameter + Stała nie jest tego samego typu „{0}” co parametr + + + + The Min and Max values are inverted + Wartości Min i Max są odwrócone + + + + The argument should be a constant for optimal performance + Argument powinien być stałą w celu uzyskania optymalnej wydajności + + + + The '{0}' type is not supported for ConstantExpected attribute + Typ „{0}” nie jest obsługiwany dla atrybutu ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + Stała nie mieści się w granicach wartości od „{0}” do „{1}” + + + + The parameter expects a constant for optimal performance. + Parametr oczekuje stałej w celu uzyskania optymalnej wydajności. + + + + A constant is expected for the parameter + Oczekiwano stałej dla parametru + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Deserializowanie obiektu {0} podczas deserializacji niezaufanych danych wejściowych nie jest bezpieczne. Element „{1}” jest elementem {0} lub pochodzi od niego diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pt-BR.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pt-BR.xlf index f41ca002a3..4a69c624f0 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pt-BR.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pt-BR.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + O atributo ConstantExpected não está aplicado corretamente no parâmetro. + + + + Incorrect usage of ConstantExpected attribute + Uso incorreto do atributo ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + O atributo ConstantExpected é necessário para o parâmetro devido à anotação do método pai + + + + The '{0}' value is not compatible with parameter type of '{1}' + O valor '{0}' não é compatível com o tipo de parâmetro de '{1}' + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + O valor '{0}' não cabe dentro dos limites do valor do parâmetro de '{1}' para '{2}' + + + + The constant is not of the same '{0}' type as the parameter + A constante não é do mesmo tipo '{0}' do parâmetro + + + + The Min and Max values are inverted + Os valores Min e Max são invertidos + + + + The argument should be a constant for optimal performance + O argumento deve ser uma constante para desempenho ideal + + + + The '{0}' type is not supported for ConstantExpected attribute + O tipo '{0}' não é suportado para o atributo ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + A constante não cabe dentro dos limites de valor de '{0}' para '{1}' + + + + The parameter expects a constant for optimal performance. + O parâmetro espera uma constante para desempenho ideal. + + + + A constant is expected for the parameter + Espera-se uma constante para o parâmetro + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Ao desserializar uma entrada não confiável, a desserialização de um objeto {0} não é segura. '{1}' é {0} ou deriva-se dele diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf index 1c7c4647a1..7b8d7e9869 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + Атрибут ConstantExpected неправильно применен к параметру. + + + + Incorrect usage of ConstantExpected attribute + Неправильное использование атрибута ConstantExpected + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Атрибут ConstantExpected является обязательным для параметра из-за заметки родительского метода + + + + The '{0}' value is not compatible with parameter type of '{1}' + Значение "{0}" несовместимо с типом параметра "{1}" + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + Значение "{0}" не соответствует границам значения параметра от "{1}" до "{2}" + + + + The constant is not of the same '{0}' type as the parameter + Константа отличается от типа "{0}" параметра + + + + The Min and Max values are inverted + Минимальное и максимальное значения инвертированы + + + + The argument should be a constant for optimal performance + Аргумент должен быть константой для оптимальной производительности + + + + The '{0}' type is not supported for ConstantExpected attribute + Тип "{0}" не поддерживается для атрибута ConstantExpected + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + Константа не соответствует границам значений от "{0}" до "{1}" + + + + The parameter expects a constant for optimal performance. + Параметр ожидает константу для оптимальной производительности. + + + + A constant is expected for the parameter + Для параметра ожидается константа + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} При десериализации недоверенных входных данных десериализация объекта {0} является небезопасной. Объект "{1}" является объектом {0} или производным от него объектом. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf index 1ec2744d62..7869ae4372 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + ConstantExpected özniteliği parametreye doğru olarak uygulanmadı. + + + + Incorrect usage of ConstantExpected attribute + ConstantExpected özniteliğinin yanlış kullanımı + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + Üst yöntem ek açıklaması nedeniyle parametre için ConstantExpected özniteliği gereklidir + + + + The '{0}' value is not compatible with parameter type of '{1}' + '{0}' değeri '{1}' parametre türüyle uyumlu değil + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + '{0}' değeri, '{2}' için '{1}' parametre değeri sınırlarına uymuyor + + + + The constant is not of the same '{0}' type as the parameter + Sabit, parametreyle aynı '{0}' türünde değil + + + + The Min and Max values are inverted + Min ve Max değerleri ters çevrilmiş + + + + The argument should be a constant for optimal performance + En iyi performans için bağımsız değişken sabit olmalıdır + + + + The '{0}' type is not supported for ConstantExpected attribute + '{0}' türü ConstantExpected özniteliği için desteklenmiyor + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + Sabit, '{1}' için '{0}' değer sınırlarına uymuyor + + + + The parameter expects a constant for optimal performance. + Parametre, en iyi performans için bir sabit bekliyor. + + + + A constant is expected for the parameter + Parametre için bir sabit bekleniyor + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} Güvenilmeyen giriş seri durumdan çıkarılırken, {0} nesnesinin seri durumdan çıkarılması güvenli değildir. '{1}', {0} nesnesidir veya bu nesneden türetilmiştir diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hans.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hans.xlf index 4009a1927f..73854a712a 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hans.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hans.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + ConstantExpected 属性未正确应用于参数。 + + + + Incorrect usage of ConstantExpected attribute + ConstantExpected 属性的用法不正确 + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + 由于父方法批注,参数需要 ConstantExpected 属性 + + + + The '{0}' value is not compatible with parameter type of '{1}' + "{0}" 值与 "{1}" 的参数类型不兼容 + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + "{0}" 值不符合 "{1}" 到 "{2}" 的参数值界限 + + + + The constant is not of the same '{0}' type as the parameter + 常量与参数的 "{0}" 类型不同 + + + + The Min and Max values are inverted + 已反转最小值和最大值 + + + + The argument should be a constant for optimal performance + 参数应是一个常量,以获得最佳性能 + + + + The '{0}' type is not supported for ConstantExpected attribute + ConstantExpected 特性不支持 "{0}" 类型 + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + 该常量不适合 "{0}" 到 "{1}" 的值边界内 + + + + The parameter expects a constant for optimal performance. + 该参数需要一个常量来获得最佳性能。 + + + + A constant is expected for the parameter + 参数需要常量 + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} 对不受信任的输入进行反序列化处理时,反序列化 {0} 对象是不安全的。“{1}”是或派生自 {0} diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hant.xlf b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hant.xlf index 8daf60318c..a46db4b206 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hant.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.zh-Hant.xlf @@ -182,6 +182,66 @@ , Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’} + + ConstantExpected attribute is not applied correctly on the parameter. + 未在參數上正確套用 ConstantExpected 屬性。 + + + + Incorrect usage of ConstantExpected attribute + ConstantExpected 屬性的用法不正確 + + + + The ConstantExpected attribute is required for the parameter due to the parent method annotation + 由於父方法註釋,參數需要 ConstantExpected 屬性 + + + + The '{0}' value is not compatible with parameter type of '{1}' + '{0}' 值與 '{1}' 的參數類型不相容 + + + + The '{0}' value does not fit within the parameter value bounds of '{1}' to '{2}' + '{0}' 值不符合 '{1}' 到 '{2}' 的參數值範圍 + + + + The constant is not of the same '{0}' type as the parameter + 常數不是與參數相同的 '{0}' 類型 + + + + The Min and Max values are inverted + 最小值和最大值會反轉 + + + + The argument should be a constant for optimal performance + 引數應為常數,以獲得最佳效能 + + + + The '{0}' type is not supported for ConstantExpected attribute + ConstantExpected 屬性不支援 '{0}' 類型 + + + + The constant does not fit within the value bounds of '{0}' to '{1}' + 常數不符合 '{0}' 到 '{1}' 的值範圍 + + + + The parameter expects a constant for optimal performance. + 參數需要常數,以獲得最佳效能。 + + + + A constant is expected for the parameter + 預期參數為常數 + + When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0} 還原序列化不受信任的輸入時,將 {0} 物件還原序列化並不安全。'{1}' 屬於或衍生自 {0} diff --git a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessing.cs b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessing.cs index 25b1136f7a..2a7b121ebf 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessing.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessing.cs @@ -18,6 +18,7 @@ namespace Microsoft.NetFramework.Analyzers using static MicrosoftNetFrameworkAnalyzersResources; /// + /// CA3075: /// Secure DTD processing and entity resolution in XML /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] diff --git a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesign.cs b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesign.cs index e5bc76b9e4..50258cb331 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesign.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesign.cs @@ -16,6 +16,9 @@ namespace Microsoft.NetFramework.Analyzers { using static MicrosoftNetFrameworkAnalyzersResources; + /// + /// CA3077: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseInsecureDtdProcessingInApiDesignAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureXSLTScriptExecution.cs b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureXSLTScriptExecution.cs index d4b2485967..7824ae2774 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureXSLTScriptExecution.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/DoNotUseInsecureXSLTScriptExecution.cs @@ -14,6 +14,9 @@ namespace Microsoft.NetFramework.Analyzers { using static MicrosoftNetFrameworkAnalyzersResources; + /// + /// CA3076: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotUseInsecureXSLTScriptExecutionAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/MarkVerbHandlersWithValidateAntiforgeryTokenAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/MarkVerbHandlersWithValidateAntiforgeryTokenAnalyzer.cs index f515c188d4..283d1af982 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/MarkVerbHandlersWithValidateAntiforgeryTokenAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/MarkVerbHandlersWithValidateAntiforgeryTokenAnalyzer.cs @@ -10,6 +10,9 @@ namespace Microsoft.NetFramework.Analyzers { using static MicrosoftNetFrameworkAnalyzersResources; + /// + /// CA3147: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public partial class MarkVerbHandlersWithValidateAntiforgeryTokenAnalyzer : DiagnosticAnalyzer { diff --git a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/TypesShouldNotExtendCertainBaseTypes.cs b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/TypesShouldNotExtendCertainBaseTypes.cs index b43dcce749..a9d9234704 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/TypesShouldNotExtendCertainBaseTypes.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetFramework.Analyzers/TypesShouldNotExtendCertainBaseTypes.cs @@ -15,7 +15,7 @@ namespace Microsoft.NetFramework.Analyzers using static MicrosoftNetFrameworkAnalyzersResources; /// - /// CA1058: Types should not extend certain base types + /// CA1058: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class TypesShouldNotExtendCertainBaseTypesAnalyzer : DiagnosticAnalyzer diff --git a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md index 915f89dc29..81beb9229c 100644 --- a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md +++ b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md @@ -1584,6 +1584,30 @@ It is more efficient to use 'Clear', instead of 'Fill' with default value. |CodeFix|True| --- +## [CA1856](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1856): Incorrect usage of ConstantExpected attribute + +ConstantExpected attribute is not applied correctly on the parameter. + +|Item|Value| +|-|-| +|Category|Performance| +|Enabled|True| +|Severity|Error| +|CodeFix|False| +--- + +## [CA1857](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1857): A constant is expected for the parameter + +The parameter expects a constant for optimal performance. + +|Item|Value| +|-|-| +|Category|Performance| +|Enabled|True| +|Severity|Warning| +|CodeFix|False| +--- + ## [CA2000](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000): Dispose objects before losing scope If a disposable object is not explicitly disposed before all references to it are out of scope, the object will be disposed at some indeterminate time when the garbage collector runs the finalizer of the object. Because an exceptional event might occur that will prevent the finalizer of the object from running, the object should be explicitly disposed instead. diff --git a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif index 4844f36fb0..b6535f5012 100644 --- a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif +++ b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif @@ -5,7 +5,7 @@ { "tool": { "name": "Microsoft.CodeAnalysis.CSharp.NetAnalyzers", - "version": "7.0.0", + "version": "8.0.0", "language": "en-US" }, "rules": { @@ -304,6 +304,44 @@ ] } }, + "CA1856": { + "id": "CA1856", + "shortDescription": "Incorrect usage of ConstantExpected attribute", + "fullDescription": "ConstantExpected attribute is not applied correctly on the parameter.", + "defaultLevel": "error", + "helpUri": "https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1856", + "properties": { + "category": "Performance", + "isEnabledByDefault": true, + "typeName": "CSharpConstantExpectedAnalyzer", + "languages": [ + "C#" + ], + "tags": [ + "Telemetry", + "EnabledRuleInAggressiveMode" + ] + } + }, + "CA1857": { + "id": "CA1857", + "shortDescription": "A constant is expected for the parameter", + "fullDescription": "The parameter expects a constant for optimal performance.", + "defaultLevel": "warning", + "helpUri": "https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1857", + "properties": { + "category": "Performance", + "isEnabledByDefault": true, + "typeName": "CSharpConstantExpectedAnalyzer", + "languages": [ + "C#" + ], + "tags": [ + "Telemetry", + "EnabledRuleInAggressiveMode" + ] + } + }, "CA2014": { "id": "CA2014", "shortDescription": "Do not use stackalloc in loops", @@ -538,7 +576,7 @@ { "tool": { "name": "Microsoft.CodeAnalysis.NetAnalyzers", - "version": "7.0.0", + "version": "8.0.0", "language": "en-US" }, "rules": { @@ -5815,7 +5853,7 @@ { "tool": { "name": "Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers", - "version": "7.0.0", + "version": "8.0.0", "language": "en-US" }, "rules": { diff --git a/src/NetAnalyzers/RulesMissingDocumentation.md b/src/NetAnalyzers/RulesMissingDocumentation.md index ca15484494..acfaceed87 100644 --- a/src/NetAnalyzers/RulesMissingDocumentation.md +++ b/src/NetAnalyzers/RulesMissingDocumentation.md @@ -3,13 +3,9 @@ Rule ID | Missing Help Link | Title | --------|-------------------|-------| CA1311 | | Specify a culture or use an invariant version | -CA1420 | | Property, type, or attribute requires runtime marshalling | CA1421 | | This method uses runtime marshalling even when the 'DisableRuntimeMarshallingAttribute' is applied | -CA1422 | | Validate platform compatibility | CA1852 | | Seal internal types | CA1853 | | Unnecessary call to 'Dictionary.ContainsKey(key)' | CA1855 | | Prefer 'Clear' over 'Fill' | -CA2019 | | Improper 'ThreadStatic' field initialization | -CA2020 | | Prevent behavioral change | -CA2259 | | 'ThreadStatic' only affects static fields | -CA2260 | | Use correct type parameter | +CA1856 | | Incorrect usage of ConstantExpected attribute | +CA1857 | | A constant is expected for the parameter | diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs index 8544441cc1..bb5d77427b 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs @@ -4815,6 +4815,195 @@ void M1() await VerifyAnalyzerCSAsync(source, s_msBuildPlatforms); } + [Fact] + public async Task DynamicallyLoadGuardingVersionFromCallingApiArguments() + { + var source = @" +using System; +using System.Diagnostics; +using System.Runtime.Versioning; + +class Test +{ + [SupportedOSPlatformGuard(""ios"")] + private bool IsIosSupported(int major, int minor) => true; + + [UnsupportedOSPlatformGuard(""ios"")] + private bool IosNotSupportedFrom(int major) => true; + + void M1() + { + [|SupportedOniOS11()|]; + [|UnsupportedOniOS11()|]; + + if (IsIosSupported(11, 0)) + { + SupportedOniOS11(); + [|UnsupportedOniOS11()|]; + } + else + { + [|SupportedOniOS11()|]; + UnsupportedOniOS11(); + } + + if (IosNotSupportedFrom(11)) + { + [|SupportedOniOS11()|]; + UnsupportedOniOS11(); + } + else + { + SupportedOniOS11(); + [|UnsupportedOniOS11()|]; + } + } + + [SupportedOSPlatform(""ios11.0"")] + void SupportedOniOS11() { } + + [UnsupportedOSPlatform(""ios11.0"")] + void UnsupportedOniOS11() { } +}"; + + await VerifyAnalyzerCSAsync(source, s_msBuildPlatforms); + } + + [Fact] + public async Task DynamicallyLoadGuardingVersionFromCallingApiArguments_MultipleAttriubtesApplied() + { + var source = @" +using System; +using System.Diagnostics; +using System.Runtime.Versioning; + +class Test +{ + [SupportedOSPlatformGuard(""ios"")] + [SupportedOSPlatformGuard(""watchos"")] + private bool IsIosWatchOsSupported(int major, int minor, int build = 0) => true; + + [SupportedOSPlatformGuard(""ios"")] + private bool IsIosSupported(int major, int minor, int build = 0) => true; + + [SupportedOSPlatform(""ios13.0.2"")] + [SupportedOSPlatform(""watchos13.0"")] + void SupportedOnIosAndWatchOs13() { } + + [SupportedOSPlatform(""ios13.0.2"")] + void SupportedOnIos13() { } + + [SupportedOSPlatform(""watchos10.0"")] + void SupportedOnWatchOs10() { } + + void M1() + { + if (IsIosWatchOsSupported(13, 0, 2)) + { + [|SupportedOnIos13()|]; + [|SupportedOnWatchOs10()|]; + SupportedOnIosAndWatchOs13(); + } + + if (OperatingSystem.IsIOSVersionAtLeast(13, 0, 2) || OperatingSystem.IsWatchOSVersionAtLeast(13)) + { + [|SupportedOnIos13()|]; + [|SupportedOnWatchOs10()|]; + SupportedOnIosAndWatchOs13(); + } + + if (IsIosSupported(13, 0, 2)) + { + SupportedOnIos13(); + [|SupportedOnWatchOs10()|]; + SupportedOnIosAndWatchOs13(); + } + } +}"; + + await VerifyAnalyzerCSAsync(source); + } + + [Fact] + public async Task DynamicallyLoadGuardingVersionFromCallingApiArguments_NotWarningCases() + { + var source = @" +using System; +using System.Diagnostics; +using System.Runtime.Versioning; + +class Test +{ + [SupportedOSPlatformGuard(""ios"")] + private bool IsIosSupported(int major, string minor, int build = 0) => true; // string parameter not accepted + + [SupportedOSPlatformGuard(""ios"")] + private bool IsIosSupported(int major, long minor, int build = 0) => true; // long parameter not accepted + + [SupportedOSPlatformGuard(""ios"")] + private string IsIosSupported(int major, int minor, int build = 0) => ""true""; // not return boolean + + [SupportedOSPlatform(""ios13.0.2"")] + void SupportedOnIos13() { } + + void M1() + { + if (IsIosSupported(13, ""0"", 2)) + { + [|SupportedOnIos13()|]; + } + + if (IsIosSupported(13, 0l, 2)) + { + [|SupportedOnIos13()|]; + } + + if (IsIosSupported(13, 0, 2) == ""true"") + { + [|SupportedOnIos13()|]; + } + } +}"; + + await VerifyAnalyzerCSAsync(source); + } + + [Fact] + public async Task ApiAndGuardAttributeBothHasVersions_AttributeVersionWins() + { + var source = @" +using System; +using System.Diagnostics; +using System.Runtime.Versioning; + +class Test +{ + [SupportedOSPlatformGuard(""ios10.0"")] + private bool IsIos10Supported(int major, int minor) => true; + + [SupportedOSPlatformGuard(""ios11.0"")] + private bool IsIos11Supported(int major, int minor) => true; + + [SupportedOSPlatform(""ios11.0"")] + void SupportedOnIos11() { } + + void M1() + { + if (IsIos10Supported(11, 0)) + { + [|SupportedOnIos11()|]; // Warns because API version 11.0+ is ignored and attribute version ios 10.0+ accounted + } + + if (IsIos11Supported(10, 0)) + { + SupportedOnIos11(); // Not warn because API version 10.0+ is ignored and attribute version ios 11.0+ accounted + } + } +}"; + + await VerifyAnalyzerCSAsync(source, s_msBuildPlatforms); + } + [Fact] public async Task OneOfSupportsNeedsGuard_AllOtherSuppressedByCallsite() { diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs new file mode 100644 index 0000000000..51dd7a0c18 --- /dev/null +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs @@ -0,0 +1,1125 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Testing; +using Xunit; +using VerifyCS = Test.Utilities.CSharpCodeFixVerifier< + Microsoft.NetCore.CSharp.Analyzers.Performance.CSharpConstantExpectedAnalyzer, + Microsoft.CodeAnalysis.Testing.EmptyCodeFixProvider>; + +namespace Microsoft.NetCore.Analyzers.Performance.UnitTests +{ + public sealed class ConstantExpectedTests + { + [Theory] + [InlineData("char", "char.MinValue", "char.MaxValue")] + [InlineData("sbyte", "sbyte.MinValue", "sbyte.MaxValue")] + [InlineData("short", "short.MinValue", "short.MaxValue")] + [InlineData("int", "int.MinValue", "int.MaxValue")] + [InlineData("long", "long.MinValue", "long.MaxValue")] + [InlineData("byte", "byte.MinValue", "byte.MaxValue")] + [InlineData("ushort", "ushort.MinValue", "ushort.MaxValue")] + [InlineData("uint", "uint.MinValue", "uint.MaxValue")] + [InlineData("ulong", "ulong.MinValue", "ulong.MaxValue")] + [InlineData("bool", "false", "true")] + [InlineData("float", "float.MinValue", "float.MaxValue")] + [InlineData("double", "double.MinValue", "double.MaxValue")] + public static async Task TestConstantExpectedSupportedUnmanagedTypesAsync(string type, string minValue, string maxValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod1([ConstantExpected] {type} val) {{ }} + public static void TestMethod2([ConstantExpected(Min={minValue})] {type} val) {{ }} + public static void TestMethod3([ConstantExpected(Max={maxValue})] {type} val) {{ }} + public static void TestMethod4([ConstantExpected(Min={minValue}, Max={maxValue})] {type} val) {{ }} + public static void TestMethod5([ConstantExpected(Min=null)] {type} val) {{ }} + public static void TestMethod6([ConstantExpected(Max=null)] {type} val) {{ }} + public static void TestMethod7([ConstantExpected(Min=null, Max=null)] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("sbyte", "sbyte.MinValue", "sbyte.MaxValue")] + [InlineData("short", "short.MinValue", "short.MaxValue")] + [InlineData("int", "int.MinValue", "int.MaxValue")] + [InlineData("long", "long.MinValue", "long.MaxValue")] + [InlineData("byte", "byte.MinValue", "byte.MaxValue")] + [InlineData("ushort", "ushort.MinValue", "ushort.MaxValue")] + [InlineData("uint", "uint.MinValue", "uint.MaxValue")] + [InlineData("ulong", "ulong.MinValue", "ulong.MaxValue")] + public static async Task TestConstantExpectedSupportedEnumTypesAsync(string type, string minValue, string maxValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod1([ConstantExpected] AEnum val) {{ }} + public static void TestMethod2([ConstantExpected(Min={minValue})] AEnum val) {{ }} + public static void TestMethod3([ConstantExpected(Max={maxValue})] AEnum val) {{ }} + public static void TestMethod4([ConstantExpected(Min={minValue}, Max={maxValue})] AEnum val) {{ }} + public static void TestMethod5([ConstantExpected(Min=null)] AEnum val) {{ }} + public static void TestMethod6([ConstantExpected(Max=null)] AEnum val) {{ }} + public static void TestMethod7([ConstantExpected(Min=null, Max=null)] AEnum val) {{ }} +}} + +public enum AEnum : {type} +{{ + One, + Two +}} +"; + await TestCSAsync(csInput); + } + + [Fact] + public static async Task TestConstantExpectedSupportedComplexTypesAsync() + { + string csInput = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{ + public static void TestMethodString([ConstantExpected] string val) { } + public static void TestMethodGeneric([ConstantExpected] T val) { } + + public static class GenenricClass + { + public static void TestMethodGeneric([ConstantExpected] T val) { } + } +} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("char")] + [InlineData("sbyte")] + [InlineData("short")] + [InlineData("int")] + [InlineData("long")] + [InlineData("byte")] + [InlineData("ushort")] + [InlineData("uint")] + [InlineData("ulong")] + [InlineData("float")] + [InlineData("double")] + [InlineData("bool")] + [InlineData("string")] + public static async Task TestConstantExpectedSupportedComplex2TypesAsync(string type) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public interface ITest + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public interface ITest2 + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public abstract class AbstractTest + {{ + public abstract T Method2(T operand1, [ConstantExpected] T operand2); + }} + + public class Generic : AbstractTest<{type}>, ITest<{type}>, ITest2<{type}> + {{ + public {type} Method({type} operand1, {{|#0:{type} operand2|}}) => throw new NotImplementedException(); + {type} ITest2<{type}>.Method({type} operand1, {{|#1:{type} operand2|}}) => throw new NotImplementedException(); + public override {type} Method2({type} operand1, {{|#2:{type} operand2|}}) => throw new NotImplementedException(); + }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(0), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(1), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(2)); + } + + [Theory] + [InlineData("char")] + [InlineData("sbyte")] + [InlineData("short")] + [InlineData("int")] + [InlineData("long")] + [InlineData("byte")] + [InlineData("ushort")] + [InlineData("uint")] + [InlineData("ulong")] + [InlineData("float")] + [InlineData("double")] + [InlineData("bool")] + [InlineData("string")] + public static async Task TestMissingConstantExpectedSupportedComplex2TypesAsync(string type) + { + string csInput = @$" +using System; +using Similar; +#nullable enable + +public class Test +{{ + public interface ITest + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public interface ITest2 + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public abstract class AbstractTest + {{ + public abstract T Method2(T operand1, [ConstantExpected] T operand2); + }} + + public class Generic : AbstractTest<{type}>, ITest<{type}>, ITest2<{type}> + {{ + public {type} Method({type} operand1, {type} operand2) => throw new NotImplementedException(); + {type} ITest2<{type}>.Method({type} operand1, {type} operand2) => throw new NotImplementedException(); + public override {type} Method2({type} operand1, {type} operand2) => throw new NotImplementedException(); + }} +}} +"; + await TestCSMissingAttributeAsync(csInput); + } + + [Fact] + public static async Task TestConstantExpectedSupportedComplex3TypesAsync() + { + string csInput = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{ + public interface ITest + { + T Method(T operand1, [ConstantExpected] T operand2); + } + public interface ITest2 + { + T Method(T operand1, [ConstantExpected] T operand2); + } + public abstract class AbstractTest + { + public abstract T Method2(T operand1, [ConstantExpected] T operand2); + } + public class GenericForward : AbstractTest, ITest, ITest2 + { + public T Method(T operand1, {|#0:T operand2|}) => throw new NotImplementedException(); + T ITest2.Method(T operand1, {|#1:T operand2|}) => throw new NotImplementedException(); + public override T Method2(T operand1, {|#2:T operand2|}) => throw new NotImplementedException(); + } +} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(0), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(1), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.AttributeExpectedRule) + .WithLocation(2)); + } + + [Theory] + [InlineData("", "", "nint", "nint")] + [InlineData("", "", "nuint", "nuint")] + [InlineData("", "", "object", "object")] + [InlineData("", "", "Test", "Test")] + [InlineData("", "", "Guid", "System.Guid")] + [InlineData("", "", "decimal", "decimal")] + [InlineData("", "", "byte[]", "byte[]")] + [InlineData("", "", "(int, long)", "(int, long)")] + [InlineData("", "", "T[]", "T[]")] + [InlineData("", "", "T[]", "T[]")] + public static async Task TestConstantExpectedUnsupportedTypesAsync(string classGeneric, string methodGeneric, string type, string diagnosticType) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test{classGeneric} +{{ + public static void TestMethod{methodGeneric}([{{|#0:ConstantExpected|}}] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.UnsupportedTypeRule) + .WithLocation(0) + .WithArguments(diagnosticType)); + } + + [Theory] + [InlineData("object")] + [InlineData("Test")] + [InlineData("Guid")] + [InlineData("decimal")] + [InlineData("byte[]")] + [InlineData("(int, long)")] + public static async Task TestConstantExpectedUnsupportedIgnoredComplexTypesAsync(string type) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public interface ITest + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public interface ITest2 + {{ + T Method(T operand1, [ConstantExpected] T operand2); + }} + public abstract class AbstractTest + {{ + public abstract T Method2(T operand1, [ConstantExpected] T operand2); + }} + public class Generic : AbstractTest<{type}>, ITest<{type}>, ITest2<{type}> + {{ + public {type} Method({type} operand1, {type} operand2) => throw new NotImplementedException(); + {type} ITest2<{type}>.Method({type} operand1, {type} operand2) => throw new NotImplementedException(); + public override {type} Method2({type} operand1, {type} operand2) => throw new NotImplementedException(); + }} +}} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("", "", "char", "\"a\"", "\"a\"")] + [InlineData("", "", "sbyte", "\"a\"", "\"a\"")] + [InlineData("", "", "short", "\"a\"", "\"a\"")] + [InlineData("", "", "int", "\"a\"", "\"a\"")] + [InlineData("", "", "long", "\"a\"", "\"a\"")] + [InlineData("", "", "byte", "\"a\"", "\"a\"")] + [InlineData("", "", "ushort", "\"a\"", "\"a\"")] + [InlineData("", "", "uint", "\"a\"", "\"a\"")] + [InlineData("", "", "ulong", "\"a\"", "\"a\"")] + [InlineData("", "", "bool", "\"a\"", "\"a\"")] + [InlineData("", "", "float", "\"a\"", "\"a\"")] + [InlineData("", "", "double", "\"a\"", "\"a\"")] + [InlineData("", "", "string", "true", "false")] + [InlineData("", "", "T", "\"min\"", "false")] + [InlineData("", "", "T", "\"min\"", "false")] + public static async Task TestConstantExpectedIncompatibleConstantTypeErrorAsync(string classGeneric, string methodGeneric, string type, string badMinValue, string badMaxValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test{classGeneric} +{{ + public static void TestMethod{methodGeneric}([ConstantExpected({{|#0:Min = {badMinValue}|}})] {type} val) {{ }} + public static void TestMethod2{methodGeneric}([ConstantExpected({{|#1:Min = {badMinValue}|}}, {{|#2:Max = {badMaxValue}|}})] {type} val) {{ }} + public static void TestMethod3{methodGeneric}([ConstantExpected({{|#3:Max = {badMaxValue}|}})] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(0) + .WithArguments("Min", type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(1) + .WithArguments("Min", type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(2) + .WithArguments("Max", type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(3) + .WithArguments("Max", type)); + } + + [Theory] + [InlineData("char", "'Z'", "'A'")] + [InlineData("sbyte", "1", "0")] + [InlineData("short", "1", "0")] + [InlineData("int", "1", "0")] + [InlineData("long", "1", "0")] + [InlineData("byte", "1", "0")] + [InlineData("ushort", "1", "0")] + [InlineData("uint", "1", "0")] + [InlineData("ulong", "1", "0")] + [InlineData("float", "1", "0")] + [InlineData("double", "1", "0")] + public static async Task TestConstantExpectedInvertedConstantTypeErrorAsync(string type, string min, string max) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([{{|#0:ConstantExpected(Min = {min}, Max = {max})|}}] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvertedRangeRule) + .WithLocation(0)); + } + + [Theory] + [InlineData("sbyte", "AEnum.Five", "AEnum.Two")] + [InlineData("short", "AEnum.Five", "AEnum.Two")] + [InlineData("int", "AEnum.Five", "AEnum.Two")] + [InlineData("long", "AEnum.Five", "AEnum.Two")] + [InlineData("byte", "AEnum.Five", "AEnum.Two")] + [InlineData("ushort", "AEnum.Five", "AEnum.Two")] + [InlineData("uint", "AEnum.Five", "AEnum.Two")] + [InlineData("ulong", "AEnum.Five", "AEnum.Two")] + public static async Task TestEnumConstantExpectedInvertedConstantTypeErrorAsync(string type, string min, string max) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([{{|#0:ConstantExpected(Min = {min}, Max = {max})|}}] {type} val) {{ }} +}} + +public enum AEnum : {type} +{{ + Zero, + One = 1, + Two = 1 << 1, + Three = 1 << 2, + Four = 1 << 3, + Five = 1 << 4 +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvertedRangeRule) + .WithLocation(0)); + } + + [Theory] + [InlineData("sbyte", sbyte.MinValue, sbyte.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("short", short.MinValue, short.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("int", int.MinValue, int.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("long", long.MinValue, long.MaxValue, "ulong.MaxValue", "ulong.MaxValue", "false", "true")] + [InlineData("byte", byte.MinValue, byte.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("ushort", ushort.MinValue, ushort.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("uint", uint.MinValue, uint.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("ulong", ulong.MinValue, ulong.MaxValue, "long.MinValue", "-1", "false", "true")] + [InlineData("float", float.MinValue, float.MaxValue, "double.MinValue", "double.MaxValue", "false", "true")] + public static async Task TestConstantExpectedInvalidBoundsAsync(string type, object min, object max, string min1, string max1, string badMinValue, string badMaxValue) + { + string minString = min.ToString(); + string maxString = max.ToString(); + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([ConstantExpected({{|#0:Min = {min1}|}})] {type} val) {{ }} + public static void TestMethod2([ConstantExpected({{|#1:Min = {min1}|}}, {{|#2:Max = {max1}|}})] {type} val) {{ }} + public static void TestMethod3([ConstantExpected({{|#3:Max = {max1}|}})] {type} val) {{ }} + public static void TestMethod4([ConstantExpected({{|#4:Min = {badMinValue}|}}, {{|#5:Max = {max1}|}})] {type} val) {{ }} + public static void TestMethod5([ConstantExpected({{|#6:Min = {min1}|}}, {{|#7:Max = {badMaxValue}|}})] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(0) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(1) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(2) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(3) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(4) + .WithArguments("Min", type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(5) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(6) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(7) + .WithArguments("Max", type)); + } + + [Theory] + [InlineData("sbyte", sbyte.MinValue, sbyte.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("short", short.MinValue, short.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("int", int.MinValue, int.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("long", long.MinValue, long.MaxValue, "ulong.MaxValue", "ulong.MaxValue", "false", "true")] + [InlineData("byte", byte.MinValue, byte.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("ushort", ushort.MinValue, ushort.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("uint", uint.MinValue, uint.MaxValue, "long.MinValue", "long.MaxValue", "false", "true")] + [InlineData("ulong", ulong.MinValue, ulong.MaxValue, "long.MinValue", "-1", "false", "true")] + public static async Task TestEnumConstantExpectedInvalidBoundsAsync(string type, object min, object max, string min1, string max1, string badMinValue, string badMaxValue) + { + string minString = min.ToString(); + string maxString = max.ToString(); + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([ConstantExpected({{|#0:Min = {min1}|}})] AEnum val) {{ }} + public static void TestMethod2([ConstantExpected({{|#1:Min = {min1}|}}, {{|#2:Max = {max1}|}})] AEnum val) {{ }} + public static void TestMethod3([ConstantExpected({{|#3:Max = {max1}|}})] AEnum val) {{ }} + public static void TestMethod4([ConstantExpected({{|#4:Min = {badMinValue}|}}, {{|#5:Max = {max1}|}})] AEnum val) {{ }} + public static void TestMethod5([ConstantExpected({{|#6:Min = {min1}|}}, {{|#7:Max = {badMaxValue}|}})] AEnum val) {{ }} +}} + +public enum AEnum : {type} +{{ + Zero, + One = 1, + Two = 1 << 1, + Three = 1 << 2, + Four = 1 << 3, + Five = 1 << 4 +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(0) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(1) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(2) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(3) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(4) + .WithArguments("Min", "AEnum"), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(5) + .WithArguments("Max", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.InvalidBoundsRule) + .WithLocation(6) + .WithArguments("Min", minString, maxString), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1856.IncompatibleConstantTypeRule) + .WithLocation(7) + .WithArguments("Max", "AEnum")); + } + + [Theory] + [InlineData("char", "'A'", "'Z'", "'A'", "(char)('A'+'\\u0001')")] + [InlineData("sbyte", "10", "20", "10", "2*5")] + [InlineData("short", "10", "20", "10", "2*5")] + [InlineData("int", "10", "20", "10", "2*5")] + [InlineData("long", "10", "20", "10", "2*5")] + [InlineData("byte", "10", "20", "10", "2*5")] + [InlineData("ushort", "10", "20", "10", "2*5")] + [InlineData("uint", "10", "20", "10", "2*5")] + [InlineData("ulong", "10", "20", "10", "2*5")] + [InlineData("float", "10", "20", "10", "2*5")] + [InlineData("double", "10", "20", "10", "2*5")] + [InlineData("bool", "true", "true", "true", "!false")] + [InlineData("string", "null", "null", "\"true\"", "\"false\"")] + public static async Task TestArgumentConstantAsync(string type, string minValue, string maxValue, string value, string expression) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod() + {{ + TestMethodWithConstant({value}); + TestMethodWithConstant({expression}); + TestMethodWithConstrainedConstant({value}); + TestMethodWithConstrainedConstant({expression}); + TestMethodGeneric<{type}>({value}); + TestMethodGeneric<{type}>({expression}); + GenericClass<{type}>.TestMethodGeneric({value}); + GenericClass<{type}>.TestMethodGeneric({expression}); + }} + public static void TestMethodWithConstant([ConstantExpected] {type} val) {{ }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {minValue}, Max = {maxValue})] {type} val) {{ }} + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + + public static class GenericClass + {{ + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + }} +}} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("sbyte", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("short", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("int", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("long", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("byte", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("ushort", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("uint", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + [InlineData("ulong", "AEnum.One", "AEnum.Five", "AEnum.Two", "AEnum.One | AEnum.Two")] + public static async Task TestEnumArgumentConstantAsync(string type, string minValue, string maxValue, string value, string expression) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod() + {{ + TestMethodWithConstant({value}); + TestMethodWithConstant({expression}); + TestMethodWithConstrainedConstant({value}); + TestMethodWithConstrainedConstant({expression}); + TestMethodGeneric({value}); + TestMethodGeneric({expression}); + GenericClass.TestMethodGeneric({value}); + GenericClass.TestMethodGeneric({expression}); + }} + public static void TestMethodWithConstant([ConstantExpected] AEnum val) {{ }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {minValue}, Max = {maxValue})] AEnum val) {{ }} + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + + public static class GenericClass + {{ + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + }} +}} + +public enum AEnum : {type} +{{ + Zero, + One = 1, + Two = 1 << 1, + Three = 1 << 2, + Four = 1 << 3, + Five = 1 << 4 +}} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("char")] + [InlineData("sbyte")] + [InlineData("short")] + [InlineData("int")] + [InlineData("long")] + [InlineData("byte")] + [InlineData("ushort")] + [InlineData("uint")] + [InlineData("ulong")] + [InlineData("float")] + [InlineData("double")] + [InlineData("string")] + public static async Task TestArgumentNotConstantAsync(string type) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod({type} nonConstant) + {{ + TestMethodWithConstant({{|#0:nonConstant|}}); + TestMethodGeneric<{type}>({{|#1:nonConstant|}}); + GenenricClass<{type}>.TestMethodGeneric({{|#2:nonConstant|}}); + }} + public static void TestMethodWithConstant([ConstantExpected] {type} val) {{ }} + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + + public static class GenenricClass + {{ + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(0), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(1), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(2)); + } + + [Theory] + [InlineData("sbyte")] + [InlineData("short")] + [InlineData("int")] + [InlineData("long")] + [InlineData("byte")] + [InlineData("ushort")] + [InlineData("uint")] + [InlineData("ulong")] + public static async Task TestEnumArgumentNotConstantAsync(string type) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod(AEnum nonConstant) + {{ + TestMethodWithConstant({{|#0:nonConstant|}}); + TestMethodGeneric({{|#1:nonConstant|}}); + GenenricClass.TestMethodGeneric({{|#2:nonConstant|}}); + }} + public static void TestMethodWithConstant([ConstantExpected] AEnum val) {{ }} + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + + public static class GenenricClass + {{ + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + }} +}} + +public enum AEnum : {type} +{{ + One, + Two +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(0), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(1), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantNotConstantRule) + .WithLocation(2)); + } + + [Theory] + [InlineData("char", "(char)(object)10.5")] + [InlineData("string", "(string)(object)20")] + public static async Task TestArgumentInvalidConstantAsync(string type, string constant) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod() + {{ + TestMethodWithConstant({{|#0:{constant}|}}); + TestMethodGeneric<{type}>({{|#1:{constant}|}}); + GenericClass<{type}>.TestMethodGeneric({{|#2:{constant}|}}); + }} + public static void TestMethodWithConstant([ConstantExpected] {type} val) {{ }} + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + + public static class GenericClass + {{ + public static void TestMethodGeneric([ConstantExpected] T val) {{ }} + }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(0) + .WithArguments(type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(1) + .WithArguments(type), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(2) + .WithArguments(type)); + } + + [Theory] + [InlineData("char", "'B'", "'C'", "'D'")] + [InlineData("sbyte", "3", "4", "5")] + [InlineData("short", "3", "4", "5")] + [InlineData("int", "3", "4", "5")] + [InlineData("long", "3", "4", "5")] + [InlineData("byte", "3", "4", "5")] + [InlineData("ushort", "3", "4", "5")] + [InlineData("uint", "3", "4", "5")] + [InlineData("ulong", "3", "4", "5")] + [InlineData("float", "3", "4", "5")] + [InlineData("double", "3", "4", "5")] + public static async Task TestArgumentOutOfBoundsConstantAsync(string type, string min, string max, string testValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod() + {{ + TestMethodWithConstant({{|#0:{testValue}|}}); + }} + public static void TestMethodWithConstant([ConstantExpected(Min = {min}, Max = {max})] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantOutOfBoundsRule) + .WithLocation(0) + .WithArguments(min.Trim('\''), max.Trim('\''))); + } + + [Theory] + [InlineData("sbyte", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("short", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("int", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("long", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("byte", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("ushort", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("uint", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + [InlineData("ulong", "AEnum.Three", "AEnum.Four", "AEnum.Five")] + public static async Task TestEnumArgumentOutOfBoundsConstantAsync(string type, string min, string max, string testValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod() + {{ + TestMethodWithConstant({{|#0:{testValue}|}}); + }} + public static void TestMethodWithConstant([ConstantExpected(Min = {min}, Max = {max})] AEnum val) {{ }} +}} + +public enum AEnum : {type} +{{ + Zero, + One, + Two, + Three, + Four, + Five +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantOutOfBoundsRule) + .WithLocation(0) + .WithArguments("3", "4")); + } + + [Fact] + public static async Task TestArgumentInvalidGenericTypeParameterConstantAsync() + { + string csInput = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{ + public static void TestMethod(int[] nonConstant) + { + TestMethodGeneric(nonConstant); // ignore scenario + GenericClass.TestMethodGeneric(nonConstant); // ignore scenario + } + public static void TestMethodGeneric([ConstantExpected] T val) { } + + public static class GenericClass + { + public static void TestMethodGeneric([ConstantExpected] T val) { } + } +} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("char", "'B'", "'C'")] + [InlineData("sbyte", "3", "4")] + [InlineData("short", "3", "4")] + [InlineData("int", "3", "4")] + [InlineData("long", "3", "4")] + [InlineData("byte", "3", "4")] + [InlineData("ushort", "3", "4")] + [InlineData("uint", "3", "4")] + [InlineData("ulong", "3", "4")] + [InlineData("float", "3", "4")] + [InlineData("double", "3", "4")] + [InlineData("bool", "false", "false")] + public static async Task TestConstantCompositionAsync(string type, string min, string max) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([ConstantExpected] {type} constant) + {{ + TestMethodWithConstant(constant); + }} + public static void TestMethodWithConstant([ConstantExpected] {type} val) {{ }} + public static void TestMethodConstrained([ConstantExpected(Min = {min}, Max = {max})] {type} constant) + {{ + TestMethodWithConstant(constant); + TestMethodWithConstrainedConstant(constant); + }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {min}, Max = {max})] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("sbyte", "AEnum.Two", "AEnum.Three")] + [InlineData("short", "AEnum.Two", "AEnum.Three")] + [InlineData("int", "AEnum.Two", "AEnum.Three")] + [InlineData("long", "AEnum.Two", "AEnum.Three")] + [InlineData("byte", "AEnum.Two", "AEnum.Three")] + [InlineData("ushort", "AEnum.Two", "AEnum.Three")] + [InlineData("uint", "AEnum.Two", "AEnum.Three")] + [InlineData("ulong", "AEnum.Two", "AEnum.Three")] + public static async Task TestEnumConstantCompositionAsync(string type, string min, string max) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethod([ConstantExpected] AEnum constant) + {{ + TestMethodWithConstant(constant); + }} + public static void TestMethodWithConstant([ConstantExpected] AEnum val) {{ }} + public static void TestMethodConstrained([ConstantExpected(Min = {min}, Max = {max})] AEnum constant) + {{ + TestMethodWithConstant(constant); + TestMethodWithConstrainedConstant(constant); + }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {min}, Max = {max})] AEnum val) {{ }} +}} + +public enum AEnum : {type} +{{ + Zero, + One = 1, + Two = 1 << 1, + Three = 1 << 2, + Four = 1 << 3, + Five = 1 << 4 +}} +"; + await TestCSAsync(csInput); + } + + [Fact] + public static async Task TestConstantCompositionStringAsync() + { + string csInput = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{ + public static void TestMethod([ConstantExpected] string constant) + { + TestMethodWithConstant(constant); + } + public static void TestMethodWithConstant([ConstantExpected] string val) { } +} +"; + await TestCSAsync(csInput); + } + + [Theory] + [InlineData("char", "'B'", "'C'", "'D'", 'B', 'C')] + [InlineData("sbyte", "3", "4", "5", 3, 4)] + [InlineData("short", "3", "4", "5", 3, 4)] + [InlineData("int", "3", "4", "5", 3, 4)] + [InlineData("long", "3", "4", "5", 3, 4)] + [InlineData("byte", "3", "4", "5", 3, 4)] + [InlineData("ushort", "3", "4", "5", 3, 4)] + [InlineData("uint", "3", "4", "5", 3, 4)] + [InlineData("ulong", "3", "4", "5", 3, 4)] + [InlineData("float", "3", "4", "5", 3, 4)] + [InlineData("double", "3", "4", "5", 3, 4)] + [InlineData("bool", "false", "false", "true", false, false)] + public static async Task TestConstantCompositionOutOfBoundsAsync(string type, string min, string max, string outOfBoundMax, object minValue, object maxValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethodConstrained([ConstantExpected(Min = {min}, Max = {outOfBoundMax})] {type} constant) + {{ + TestMethodWithConstrainedConstant({{|#0:constant|}}); + }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {min}, Max = {max})] {type} val) {{ }} +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantOutOfBoundsRule) + .WithLocation(0) + .WithArguments(minValue.ToString(), maxValue.ToString())); + } + + [Theory] + [InlineData("sbyte", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("short", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("int", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("long", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("byte", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("ushort", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("uint", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + [InlineData("ulong", "AEnum.Two", "AEnum.Three", "AEnum.Four", 2, 4)] + public static async Task TestEnumConstantCompositionOutOfBoundsAsync(string type, string min, string max, string outOfBoundMax, object minValue, object maxValue) + { + string csInput = @$" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{{ + public static void TestMethodConstrained([ConstantExpected(Min = {min}, Max = {outOfBoundMax})] AEnum constant) + {{ + TestMethodWithConstrainedConstant({{|#0:constant|}}); + }} + public static void TestMethodWithConstrainedConstant([ConstantExpected(Min = {min}, Max = {max})] AEnum val) {{ }} +}} + +public enum AEnum : {type} +{{ + Zero, + One = 1, + Two = 1 << 1, + Three = 1 << 2, + Four = 1 << 3, + Five = 1 << 4 +}} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantOutOfBoundsRule) + .WithLocation(0) + .WithArguments(minValue.ToString(), maxValue.ToString())); + } + + [Fact] + public static async Task TestConstantCompositionNotSameTypeAsync() + { + string csInput = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +public class Test +{ + public static void TestMethod([ConstantExpected] long constant) + { + TestMethodWithConstant({|#0:(int)constant|}); + TestMethodWithStringConstant({|#1:(string)(object)constant|}); + } + public static void TestMethod([ConstantExpected] short constant) + { + TestMethodWithConstant({|#2:constant|}); + } + public static void TestMethodWithConstant([ConstantExpected] int val) { } + public static void TestMethodWithStringConstant([ConstantExpected] string val) { } +} +"; + await TestCSAsync(csInput, + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(0) + .WithArguments("int"), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(1) + .WithArguments("string"), + VerifyCS.Diagnostic(ConstantExpectedAnalyzer.CA1857.ConstantInvalidConstantRule) + .WithLocation(2) + .WithArguments("int")); + } + + private static async Task TestCSAsync(string source, params DiagnosticResult[] diagnosticResults) + { + var test = new VerifyCS.Test + { + TestCode = source, + ReferenceAssemblies = ReferenceAssemblies.Net.Net70, + LanguageVersion = CodeAnalysis.CSharp.LanguageVersion.Preview, + }; + test.ExpectedDiagnostics.AddRange(diagnosticResults); + await test.RunAsync(); + } + + private static async Task TestCSMissingAttributeAsync(string source, params DiagnosticResult[] diagnosticResults) + { + var test = new VerifyCS.Test + { + TestCode = source, + ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + LanguageVersion = CodeAnalysis.CSharp.LanguageVersion.Preview, + }; + test.TestState.Sources.Add(s_similarAttributeSource); + test.ExpectedDiagnostics.AddRange(diagnosticResults); + await test.RunAsync(); + } + + private static readonly string s_similarAttributeSource = @"#nullable enable +using System; +namespace Similar +{ + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + public sealed class ConstantExpectedAttribute : Attribute + { + public object? Min { get; set; } + public object? Max { get; set; } + } +}"; + } +} diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseCountProperlyTests.Data.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseCountProperlyTests.Data.cs index 7407916ad2..f1665b4e4d 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseCountProperlyTests.Data.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/UseCountProperlyTests.Data.cs @@ -72,7 +72,7 @@ public IEnumerator GetEnumerator() } #pragma warning disable CA1815 // Override equals and operator equals on value types - public struct OperatorKind + public readonly struct OperatorKind { public int BasicOperatorLength { get; } public int CSharpOperatorLength { get; } diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposedTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposedTests.cs index 5d4464c717..6b216aad62 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposedTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposableFieldsShouldBeDisposedTests.cs @@ -651,6 +651,186 @@ End Function }.RunAsync(); } + [Fact, WorkItem(6075, "https://github.com/dotnet/roslyn-analyzers/issues/6075")] + public async Task AsyncDisposableDisposedInExplicitAsyncDisposable_Disposed_NoDiagnosticAsync() + { + await new VerifyCS.Test + { + ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithAsyncInterfaces, + TestCode = @" +using System; +using System.IO; +using System.Net.Http; +using System.Threading.Tasks; + +class FileStream2 : IAsyncDisposable +{ + public ValueTask DisposeAsync() => default; +} + +public sealed class Test : IAsyncDisposable, IDisposable +{ + private readonly HttpClient client; + private readonly FileStream2 stream; + + public Test() + { + client = new HttpClient(); + stream = new FileStream2(); + } + + public void Dispose() + { + client.Dispose(); + } + + async ValueTask IAsyncDisposable.DisposeAsync() + { + await stream.DisposeAsync(); + } +} +" + }.RunAsync(); + + await new VerifyVB.Test + { + ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithAsyncInterfaces, + TestCode = @" +Imports System +Imports System.IO +Imports System.Net.Http +Imports System.Threading.Tasks + +class FileStream2 + implements IAsyncDisposable + public function DisposeAsync() as ValueTask implements IAsyncDisposable.DisposeAsync + return nothing + end function +end class + +public class Test + implements IAsyncDisposable, IDisposable + + private readonly client as HttpClient + private readonly stream as FileStream2 + + public sub new() + client = new HttpClient + stream = new FileStream2 + end sub + + public sub Dispose() implements IDisposable.Dispose + client.Dispose() + end sub + + function DisposeAsync() as ValueTask implements IAsyncDisposable.DisposeAsync + return stream.DisposeAsync() + end function +end class +" + }.RunAsync(); + + await new VerifyVB.Test + { + ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithAsyncInterfaces, + TestCode = @" +Imports System +Imports System.IO +Imports System.Net.Http +Imports System.Threading.Tasks + +class FileStream2 + implements IAsyncDisposable + public function DisposeAsync() as ValueTask implements IAsyncDisposable.DisposeAsync + return nothing + end function +end class + +public class Test + implements IAsyncDisposable, IDisposable + + private readonly client as HttpClient + private readonly stream as FileStream2 + + public sub new() + client = new HttpClient + stream = new FileStream2 + end sub + + public sub Dispose() implements IDisposable.Dispose + client.Dispose() + end sub + + rem arbitrary implementation name + function DisposeOtherAsync() as ValueTask implements IAsyncDisposable.DisposeAsync + return stream.DisposeAsync() + end function +end class +" + }.RunAsync(); + } + + [Fact, WorkItem(6075, "https://github.com/dotnet/roslyn-analyzers/issues/6075")] + public async Task DisposableDisposedInExplicitDisposable_Disposed_NoDiagnosticAsync() + { + await new VerifyCS.Test + { + ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithAsyncInterfaces, + TestCode = @" +using System; +using System.IO; +using System.Net.Http; +using System.Threading.Tasks; + +public sealed class Test : IDisposable +{ + private readonly HttpClient client; + private readonly FileStream stream; + + public Test() + { + client = new HttpClient(); + stream = new FileStream(""C://some-path"", FileMode.CreateNew); + } + + void IDisposable.Dispose() + { + client.Dispose(); + stream.Dispose(); + } +} +" + }.RunAsync(); + + await new VerifyVB.Test + { + ReferenceAssemblies = AdditionalMetadataReferences.DefaultWithAsyncInterfaces, + TestCode = @" +Imports System +Imports System.IO +Imports System.Net.Http +Imports System.Threading.Tasks + +public class Test + implements IDisposable + + private readonly client as HttpClient + private readonly stream as FileStream + + public sub new() + client = new HttpClient + stream = new FileStream(""C://some-path"", FileMode.CreateNew) + end sub + + public sub Dispose() implements IDisposable.Dispose + client.Dispose() + stream.Dispose() + end sub +end class +" + }.RunAsync(); + } + [Fact] public async Task DisposableAllocation_AssignedThroughLocal_Disposed_NoDiagnosticAsync() { @@ -3552,5 +3732,105 @@ class SubSub : Sub }" }.RunAsync(); } + + [Fact] + public async Task FieldDisposableThatDoNotRequireToBeDisposed() + { + await VerifyCS.VerifyAnalyzerAsync(@" +using System; +using System.IO; +using System.Threading.Tasks; + +public class BaseClass : IDisposable +{ + private readonly MemoryStream _stream = new MemoryStream(); + private readonly StringReader _stringReader = new StringReader(""something""); + private readonly Task _task = new Task(() => {}); + + public void Dispose() + { + } +} +"); + } + + [Fact, WorkItem(6172, "https://github.com/dotnet/roslyn-analyzers/issues/6172")] + public async Task FieldIsDisposedInSubClassFollowingDisposePattern() + { + await VerifyCS.VerifyAnalyzerAsync(@" +using System; +using System.IO; + +public class BaseClass : IDisposable +{ + private bool disposedValue; + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects) + } + + // TODO: free unmanaged resources (unmanaged objects) and override finalizer + // TODO: set large fields to null + disposedValue = true; + } + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } +} + +public class SubClass1 : BaseClass +{ + private readonly MemoryStream _stream; + + public SubClass1() + { + _stream = new MemoryStream(); + } + + protected override void Dispose(bool disposing) + { + _stream.Dispose(); + } +} + +public class SubClass2 : BaseClass +{ + private readonly MemoryStream _stream; + private bool _isDisposed = false; + + public SubClass2() + { + _stream = new MemoryStream(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (_isDisposed) + { + return; + } + + if (disposing) + { + // free managed resources + _stream.Dispose(); + } + + _isDisposed = true; + } +}"); + } } } diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScopeTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScopeTests.cs index a10d6580fc..7d643fcdd6 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScopeTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DisposeObjectsBeforeLosingScopeTests.cs @@ -12616,5 +12616,41 @@ public void TestCa2000() } }"); } + + [WorkItem(4981, "https://github.com/dotnet/roslyn-analyzers/issues/4981")] + [Theory] + [InlineData("ms != null")] + [InlineData("ms is not null")] + [InlineData("!(ms is null)")] + public async Task TryFinallyIsNotNull_NoDiagnostic(string condition) + { + var code = @$" +using System.IO; + +class Test +{{ + void M1() + {{ + MemoryStream ms = null; + try + {{ + ms = new MemoryStream(); + }} + finally + {{ + if ({condition}) {{ + ms.Dispose(); + }} + }} + }} +}} +"; + await new VerifyCS.Test + { + TestCode = code, + FixedCode = code, + LanguageVersion = CSharpLanguageVersion.CSharp9, + }.RunAsync(); + } } } diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsTests.cs index b4ad3cbeb0..94a375f9c7 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotUseStackallocInLoopsTests.cs @@ -285,5 +285,26 @@ private static void SourceOfForeachLoopInAnotherLoop() { }" }.RunAsync(); } + + [Fact] + public async Task Diagnostics_StackallocAsSourceOfForeachVariableLoop() + { + await new VerifyCS.Test + { + LanguageVersion = LanguageVersion.CSharp8, + TestCode = @" + using System; + public class C + { + public static void Foo() + { + foreach (var (x, y) in stackalloc (double, double)[] { (0, 0) }) + { + Span span = {|CA2014:stackalloc byte[1024]|}; + } + } + }" + }.RunAsync(); + } } } diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypesTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypesTests.cs index 7cd34e816c..547235c5ee 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypesTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/SealInternalTypesTests.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Test.Utilities; using Xunit; using VerifyCS = Test.Utilities.CSharpCodeFixVerifier< @@ -202,6 +203,20 @@ End Class #endregion #region No Diagnostic + [Fact, WorkItem(6141, "https://github.com/dotnet/roslyn-analyzers/issues/6141")] + public Task TopLevelStatementsProgram() + { + return new VerifyCS.Test() + { + TestState = + { + Sources = { "System.Console.WriteLine();" }, + OutputKind = OutputKind.ConsoleApplication, + }, + LanguageVersion = CodeAnalysis.CSharp.LanguageVersion.CSharp9, + }.RunAsync(); + } + [Fact] public Task PublicClassType_NoDiagnostic_CS() { diff --git a/src/PerformanceTests/Tests/Enabled/CSharp_CA1856.cs b/src/PerformanceTests/Tests/Enabled/CSharp_CA1856.cs new file mode 100644 index 0000000000..feb838880a --- /dev/null +++ b/src/PerformanceTests/Tests/Enabled/CSharp_CA1856.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.NetCore.CSharp.Analyzers.Performance; +using PerformanceTests.Utilities; +using PerfUtilities; + +namespace CSharpPerformanceTests.Enabled +{ + public class CSharp_CA1856 + { + [IterationSetup] + public static void CreateEnvironmentCA1856() + { + var sources = new List<(string name, string content)>(); + string attributeSource = @"#nullable enable +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + public sealed class ConstantExpectedAttribute : Attribute + { + public object? Min { get; set; } + public object? Max { get; set; } + } +}"; + sources.Add(("attributeSource", attributeSource)); + + for (var i = 0; i < Constants.Number_Of_Code_Files; i++) + { + var name = "TypeName" + i; + sources.Add((name, @$" +using System; +using System.Diagnostics.CodeAnalysis; + +class {name} +{{ + public void Test([ConstantExpected(Min = 30, Max = 15)] int val) // diagnostic x2 + {{ + }} + + public void Test2([ConstantExpected(Min = 0, Max = 15)] int val) // no diagnostic + {{ + }} +}} +")); + } + + var compilation = CSharpCompilationHelper.CreateAsync(sources.ToArray()).GetAwaiter().GetResult(); + BaselineCompilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(new EmptyAnalyzer())); + CompilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(new CSharpConstantExpectedAnalyzer())); + } + + private static CompilationWithAnalyzers BaselineCompilationWithAnalyzers; + private static CompilationWithAnalyzers CompilationWithAnalyzers; + + [Benchmark] + public async Task CA1856_DiagnosticsProduced() + { + var analysisResult = await CompilationWithAnalyzers.GetAnalysisResultAsync(CancellationToken.None); + var diagnostics = analysisResult.GetAllDiagnostics(analysisResult.Analyzers.First()); + if (analysisResult.Analyzers.Length != 1) + { + throw new InvalidOperationException($"Expected a single analyzer but found '{analysisResult.Analyzers.Length}'"); + } + + if (analysisResult.CompilationDiagnostics.Count != 0) + { + throw new InvalidOperationException($"Expected no compilation diagnostics but found '{analysisResult.CompilationDiagnostics.Count}'"); + } + + if (diagnostics.Length != 2 * Constants.Number_Of_Code_Files) + { + throw new InvalidOperationException($"Expected '{2 * Constants.Number_Of_Code_Files:N0}' analyzer diagnostics but found '{diagnostics.Length}'"); + } + } + + [Benchmark(Baseline = true)] + public async Task CA1856_Baseline() + { + var analysisResult = await BaselineCompilationWithAnalyzers.GetAnalysisResultAsync(CancellationToken.None); + var diagnostics = analysisResult.GetAllDiagnostics(analysisResult.Analyzers.First()); + if (analysisResult.Analyzers.Length != 1) + { + throw new InvalidOperationException($"Expected a single analyzer but found '{analysisResult.Analyzers.Length}'"); + } + + if (analysisResult.CompilationDiagnostics.Count != 0) + { + throw new InvalidOperationException($"Expected no compilation diagnostics but found '{analysisResult.CompilationDiagnostics.Count}'"); + } + + if (diagnostics.Length != 0) + { + throw new InvalidOperationException($"Expected no analyzer diagnostics but found '{diagnostics.Length}'"); + } + } + } +} diff --git a/src/PerformanceTests/Tests/Enabled/CSharp_CA1857.cs b/src/PerformanceTests/Tests/Enabled/CSharp_CA1857.cs new file mode 100644 index 0000000000..361979b26f --- /dev/null +++ b/src/PerformanceTests/Tests/Enabled/CSharp_CA1857.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.NetCore.CSharp.Analyzers.Performance; +using PerformanceTests.Utilities; +using PerfUtilities; + +namespace CSharpPerformanceTests.Enabled +{ + public class CSharp_CA1857 + { + [IterationSetup] + public static void CreateEnvironmentCA1856() + { + var sources = new List<(string name, string content)>(); + string attributeSource = @"#nullable enable +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + public sealed class ConstantExpectedAttribute : Attribute + { + public object? Min { get; set; } + public object? Max { get; set; } + } +}"; + sources.Add(("attributeSource", attributeSource)); + + string testClass = @" +using System; +using System.Diagnostics.CodeAnalysis; +#nullable enable + +namespace ConstantExpectedTest +{ + public class Test + { + public void TestMethodInt32([ConstantExpected] int val) { } + public void TestMethodInt32Ex([ConstantExpected(Min = 0, Max = 15)] int val) { } + } + public interface ITestInterface + { + void TestMethod([ConstantExpected] T val) { } + } +} +"; + sources.Add(("testClass", testClass)); + for (var i = 0; i < Constants.Number_Of_Code_Files; i++) + { + var name = "TypeName" + i; + sources.Add((name, @$" +using System; +using ConstantExpectedTest; + +class {name} +{{ + private readonly Test _test; + + public {name}(Test test) + {{ + _test = test; + }} + + public void Test(int a) + {{ + _test.TestMethodInt32(20); + _test.TestMethodInt32Ex(20); // diagnostic + }} + + private sealed class TestImpl : ITestInterface + {{ + public void TestMethod(int val) {{ }} // diagnostic + }} +}} +")); + } + + var compilation = CSharpCompilationHelper.CreateAsync(sources.ToArray()).GetAwaiter().GetResult(); + BaselineCompilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(new EmptyAnalyzer())); + CompilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(new CSharpConstantExpectedAnalyzer())); + } + + private static CompilationWithAnalyzers BaselineCompilationWithAnalyzers; + private static CompilationWithAnalyzers CompilationWithAnalyzers; + + [Benchmark] + public async Task CA1857_DiagnosticsProduced() + { + var analysisResult = await CompilationWithAnalyzers.GetAnalysisResultAsync(CancellationToken.None); + var diagnostics = analysisResult.GetAllDiagnostics(analysisResult.Analyzers.First()); + if (analysisResult.Analyzers.Length != 1) + { + throw new InvalidOperationException($"Expected a single analyzer but found '{analysisResult.Analyzers.Length}'"); + } + + if (analysisResult.CompilationDiagnostics.Count != 0) + { + throw new InvalidOperationException($"Expected no compilation diagnostics but found '{analysisResult.CompilationDiagnostics.Count}'"); + } + + if (diagnostics.Length != 2 * Constants.Number_Of_Code_Files) + { + throw new InvalidOperationException($"Expected '{2 * Constants.Number_Of_Code_Files:N0}' analyzer diagnostics but found '{diagnostics.Length}'"); + } + } + + [Benchmark(Baseline = true)] + public async Task CA1857_Baseline() + { + var analysisResult = await BaselineCompilationWithAnalyzers.GetAnalysisResultAsync(CancellationToken.None); + var diagnostics = analysisResult.GetAllDiagnostics(analysisResult.Analyzers.First()); + if (analysisResult.Analyzers.Length != 1) + { + throw new InvalidOperationException($"Expected a single analyzer but found '{analysisResult.Analyzers.Length}'"); + } + + if (analysisResult.CompilationDiagnostics.Count != 0) + { + throw new InvalidOperationException($"Expected no compilation diagnostics but found '{analysisResult.CompilationDiagnostics.Count}'"); + } + + if (diagnostics.Length != 0) + { + throw new InvalidOperationException($"Expected no analyzer diagnostics but found '{diagnostics.Length}'"); + } + } + } +} diff --git a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.Impl.cs b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.Impl.cs index 0d2791551d..737e67f5be 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.Impl.cs +++ b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.Impl.cs @@ -53,7 +53,7 @@ internal RemovedApiLine(string text, ApiLine apiLine) } #pragma warning disable CA1815 // Override equals and operator equals on value types - private struct ApiName + private readonly struct ApiName #pragma warning restore CA1815 // Override equals and operator equals on value types { public string Name { get; } diff --git a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.cs b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.cs index 10121813a1..0b4ebc0ff2 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.cs +++ b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.cs @@ -102,47 +102,49 @@ public override void Initialize(AnalysisContext context) private void OnCompilationStart(CompilationStartAnalysisContext compilationContext) { - var errors = new List(); - // Switch to "RegisterAdditionalFileAction" available in Microsoft.CodeAnalysis "3.8.x" to report additional file diagnostics: https://github.com/dotnet/roslyn-analyzers/issues/3918 - if (!TryGetAndValidateApiFiles(compilationContext.Options, compilationContext.Compilation, isPublic: true, compilationContext.CancellationToken, errors, out ApiData publicShippedData, out ApiData publicUnshippedData) - || !TryGetAndValidateApiFiles(compilationContext.Options, compilationContext.Compilation, isPublic: false, compilationContext.CancellationToken, errors, out ApiData internalShippedData, out ApiData internalUnshippedData)) + CheckAndRegisterImplementation(isPublic: true); + CheckAndRegisterImplementation(isPublic: false); + + void CheckAndRegisterImplementation(bool isPublic) { - compilationContext.RegisterCompilationEndAction(context => + var errors = new List(); + // Switch to "RegisterAdditionalFileAction" available in Microsoft.CodeAnalysis "3.8.x" to report additional file diagnostics: https://github.com/dotnet/roslyn-analyzers/issues/3918 + if (!TryGetAndValidateApiFiles(compilationContext.Options, compilationContext.Compilation, isPublic, compilationContext.CancellationToken, errors, out ApiData shippedData, out ApiData unshippedData)) { - foreach (Diagnostic cur in errors) + compilationContext.RegisterCompilationEndAction(context => { - context.ReportDiagnostic(cur); - } - }); + foreach (Diagnostic cur in errors) + { + context.ReportDiagnostic(cur); + } + }); - return; - } + return; + } - Debug.Assert(errors.Count == 0); + Debug.Assert(errors.Count == 0); - var publicImpl = new Impl(compilationContext.Compilation, publicShippedData, publicUnshippedData, isPublic: true, compilationContext.Options); - var internalImpl = new Impl(compilationContext.Compilation, internalShippedData, internalUnshippedData, isPublic: false, compilationContext.Options); - RegisterImplActions(compilationContext, publicImpl); - RegisterImplActions(compilationContext, internalImpl); + RegisterImplActions(compilationContext, new Impl(compilationContext.Compilation, shippedData, unshippedData, isPublic, compilationContext.Options)); - static bool TryGetAndValidateApiFiles(AnalyzerOptions options, Compilation compilation, bool isPublic, CancellationToken cancellationToken, List errors, out ApiData shippedData, out ApiData unshippedData) - { - return TryGetApiData(options, compilation, isPublic, errors, cancellationToken, out shippedData, out unshippedData) - && ValidateApiFiles(shippedData, unshippedData, isPublic, errors); - } + static bool TryGetAndValidateApiFiles(AnalyzerOptions options, Compilation compilation, bool isPublic, CancellationToken cancellationToken, List errors, out ApiData shippedData, out ApiData unshippedData) + { + return TryGetApiData(options, compilation, isPublic, errors, cancellationToken, out shippedData, out unshippedData) + && ValidateApiFiles(shippedData, unshippedData, isPublic, errors); + } - static void RegisterImplActions(CompilationStartAnalysisContext compilationContext, Impl impl) - { - compilationContext.RegisterSymbolAction( - impl.OnSymbolAction, - SymbolKind.NamedType, - SymbolKind.Event, - SymbolKind.Field, - SymbolKind.Method); - compilationContext.RegisterSymbolAction( - impl.OnPropertyAction, - SymbolKind.Property); - compilationContext.RegisterCompilationEndAction(impl.OnCompilationEnd); + static void RegisterImplActions(CompilationStartAnalysisContext compilationContext, Impl impl) + { + compilationContext.RegisterSymbolAction( + impl.OnSymbolAction, + SymbolKind.NamedType, + SymbolKind.Event, + SymbolKind.Field, + SymbolKind.Method); + compilationContext.RegisterSymbolAction( + impl.OnPropertyAction, + SymbolKind.Property); + compilationContext.RegisterCompilationEndAction(impl.OnCompilationEnd); + } } } diff --git a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer_Diagnostics.cs b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer_Diagnostics.cs index 386a2220cd..f0d86090e9 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer_Diagnostics.cs +++ b/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer_Diagnostics.cs @@ -7,6 +7,31 @@ namespace Microsoft.CodeAnalysis.PublicApiAnalyzers { using static PublicApiAnalyzerResources; + /// + /// RS0016: + /// RS0017: + /// RS0022: + /// RS0024: + /// RS0025: + /// RS0026: + /// RS0027: + /// RS0036: + /// RS0037: + /// RS0041: + /// RS0048: + /// RS0050: + /// RS0051: + /// RS0052: + /// RS0053: + /// RS0054: + /// RS0055: + /// RS0056: + /// RS0057: + /// RS0058: + /// RS0059: + /// RS0060: + /// RS0061: + /// public partial class DeclarePublicApiAnalyzer { internal static readonly DiagnosticDescriptor DeclareNewPublicApiRule = new( diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.cs.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.cs.xlf index bac1f490db..d40c8bf2da 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.cs.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.cs.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Přidat všechny položky v dokumentu {0} do rozhraní API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Přidat všechny položky v projektu {0} do rozhraní API Add all items in the solution to the API - Add all items in the solution to the API + Přidat všechny položky v řešení do rozhraní API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Přidat anotaci ke všem položkám v dokumentu {0} v rozhraní API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Přidat anotaci ke všem položkám v projektu {0} rozhraní API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Přidat anotaci ke všem položkám v řešení v rozhraní API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Všechny interní typy a členy by se měly deklarovat s anotacemi o možnosti použití hodnoty null v souboru InternalAPI.txt. To přitáhne pozornost ke změnám možnosti použití hodnoty null u rozhraní API při revizích a v historii správy zdrojového kódu a pomůže předejít změnám způsobujícím chybu. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + U symbolu {0} chybí v deklarovaném rozhraní API anotace o možnosti použití hodnoty null. Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Přidat anotace o možnosti použití hodnoty null u interních typů a členů v deklarovaném rozhraní API @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Všechny interní typy a členy by se měly deklarovat v souboru InternalAPI.txt. To přivádí pozornost ke změnám rozhraní API v revizích a historii správy zdrojového kódu a pomáhá předcházet změnám způsobujícím chybu. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Symbol {0} není součástí deklarovaného rozhraní API. Add internal types and members to the declared API - Add internal types and members to the declared API + Přidat interní typy a členy do deklarovaného rozhraní API @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Symbol {0} není součástí deklarovaného veřejné rozhraní API. @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Symbol {0} se v souborech interního rozhraní API vyskytuje více než jednou. Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Neduplikovat symboly v souborech interního rozhraní API @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Povolit anotace o možnosti použití hodnoty null v rozhraní API pro projekt {0} Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Povolit anotace o možnosti použití hodnoty null v rozhraní API pro řešení @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + implicitní konstruktor pro {0} implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + implicitní přístupový objekt get pro {0} implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + implicitní přístupový objekt set pro {0} Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Soubor interního rozhraní API {0} chybí nebo není označený jako doplňkový soubor analyzátoru. Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Chybí vydaný nebo nevydaný soubor interního rozhraní API The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Obsah souborů interních rozhraní API není platný: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Obsah souborů interních rozhraní API není platný The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + Řešení musí obsahovat dva soubory typu AdditionalFiles: InternalAPI.Unshipped.txt a InternalAPI.Shipped.txt. Nejméně jeden z těchto souborů chybí nebo nemá správný typ. One or both of the internal API files are missing - One or both of the internal API files are missing + Chybí nejméně jeden soubor interního rozhraní API All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Všechny interní členové by měly používat odkazové typy s možnou hodnotou null, nebo bez ní, ale ne odkazové typy bez určení možnosti použití hodnoty null. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Symbol {0} používá některé odkazové typy bez určení možnosti použití hodnoty null. Internal members should not use oblivious types - Internal members should not use oblivious types + Interní členové by neměly používat typy bez určení možnosti použití hodnoty null @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + {0} porušuje požadavek na zpětnou kompatibilitu: Rozhraní API s nepovinnými parametry by mělo mít ze všech veřejných přetížení nejvíce parametrů. Podrobnosti najdete tady: {1} API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + Rozhraní API s nepovinnými parametry by mělo mít ze všech veřejných přetížení nejvíce parametrů @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Když se odebírá interní typ nebo člen, vložte tuto položku do souboru InternalAPI.Unshipped.txt s předponou *REMOVED*. To upozorňuje na změny rozhraní API v revizích kódu a historii správy zdrojového kódu a pomáhá předcházet změnám způsobujícím chybu. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Symbol {0} je součástí deklarovaného interního rozhraní API, ale buď není vnitřní, nebo se ho nepovedlo najít. Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Odebrat odstraněné typy a členy z deklarovaného interního rozhraní API When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Když se odebírá veřejný typ nebo člen, vložte tuto položku do souboru PublicAPI.Unshipped.txt s předponou *REMOVED*. To upozorňuje na změny rozhraní API v revizích kódu a historii správy zdrojového kódu a pomáhá předcházet změnám způsobujícím chybu. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Symbol {0} je součástí deklarovaného rozhraní API, ale buď není veřejný, nebo se ho nepovedlo najít. Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Odebrat odstraněné typy a členy z deklarovaného rozhraní API @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + Rozhraní API se označilo jako odebrané, ale existuje ve zdrojovém kódu. InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Soubory InternalAPI.txt by měly mít #nullable enable, aby se sledovala informace o možné hodnotě null, nebo by se tato diagnostika měla potlačit. Když se možnost nastavit hodnotu null povolí, InternalAPI.txt bude uchovávat informace o tom, které typy bude možné nastavit na null (přípona typu ?) a které ne (přípona !). Kromě toho sleduje všechna rozhraní API, která stále používá typ odkazu, který se nepoužívá (předpona ~na řádku). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + V souboru InternalAPI.txt chybí #nullable enable, takže se nezaznamenají anotace o možnosti použití hodnoty null u rozhraní API. Doporučuje se toto sledování povolit. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Povolit sledování možnosti použití hodnoty null pro typy odkazů v deklarovaném rozhraní API PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Soubory PublicAPI.txt by měly mít #nullable enable, aby se sledovala informace o možné hodnotě null, nebo by se tato diagnostika měla potlačit. Když se možnost nastavit hodnotu null povolí, PublicAPI.txt bude uchovávat informace o tom, které typy bude možné nastavit na null (přípona typu ?) a které ne (přípona !). Kromě toho sleduje všechna rozhraní API, která stále používají typy bez určení možnosti použití hodnoty null (předpona ~ na řádku). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + V souboru PublicAPI.txt chybí #nullable enable, takže se nezaznamenají anotace o možnosti použití hodnoty null u rozhraní API. Doporučuje se toto sledování povolit. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Povolit sledování možnosti použití hodnoty null pro typy odkazů v deklarovaném rozhraní API diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.de.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.de.xlf index 91973dd166..7bd484ba77 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.de.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.de.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Alle Elemente im Dokument „{0}“ der API hinzufügen Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Alle Elemente im Projekt „{0}“ der API hinzufügen Add all items in the solution to the API - Add all items in the solution to the API + Alle Elemente in der Lösung der API hinzufügen Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Alle Elemente im Dokument „{0}“ in der API anmerken Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Alle Elemente im Projekt „{0}“ in der API anmerken Annotate all items in the solution in the API - Annotate all items in the solution in the API + Alle Elemente in der Lösung in der API anmerken All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Alle internen Typen und Member müssen in InternalAPI.txt mit Anmerkungen zur NULL-Zulässigkeit deklariert werden. Dadurch wird die Aufmerksamkeit auf Änderungen an der NULL-Zulässigkeit der API in den Code Reviews und im Quellcodeverwaltungsverlauf gelenkt, und Breaking Changes werden verhindert. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + Für das Symbol "{0}" fehlen Anmerkungen zur NULL-Zulässigkeit in der deklarierten API. Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + NULL-Zulässigkeit von internen Typen und Member in der deklarierten API anmerken @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Alle internen Typen und Member müssen in InternalAPI.txt deklariert werden. Dadurch wird die Aufmerksamkeit auf API-Änderungen in den Code Reviews und im Quellcodeverwaltungsverlauf gelenkt, und Breaking Changes werden verhindert. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Das Symbol "{0}" ist nicht Teil der deklarierten API. Add internal types and members to the declared API - Add internal types and members to the declared API + Interne Typen und Member der deklarierten API hinzufügen @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Das Symbol „{0}“ ist nicht Teil der deklarierten öffentlichen API. @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Das Symbol „{0}“ erscheint mehr als einmal in den internen API-Dateien Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Symbole in internen API-Dateien nicht duplizieren @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Anmerkungen zur NULL-Zulässigkeit in der API für das Projekt „{0}“ aktivieren Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Anmerkungen zur NULL-Zulässigkeit in der API für die Lösung aktivieren @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + Impliziter Konstruktor für "{0}" implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + Impliziter get-Accessor für "{0}" implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + Impliziter set-Accessor für "{0}" Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Die interne API-Datei „{0}“ fehlt oder ist nicht als zusätzliche Analysetooldatei gekennzeichnet. Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Fehlende versandte oder nicht versandte interne API-Datei The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Die Inhalte der internen API-Dateien sind ungültig: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Die Inhalte der internen API-Dateien sind ungültig The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + Die Lösung muss zwei Dateien mit dem Typ „AdditionalFiles“ enthalten: InternalAPI.Unshipped.txt und InternalAPI.Shipped.txt. Mindestens eine dieser Dateien fehlt oder weist den falschen Typ auf. One or both of the internal API files are missing - One or both of the internal API files are missing + Mindestens eine der beiden internen API-Dateien fehlt All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Alle internen Member sollten Verweistypen verwenden, die Nullwerte zulassen oder nicht zulassen, aber keine nicht bewussten Verweistypen. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Das Symbol "{0}" verwendet einige nicht beachtende Verweistypen. Internal members should not use oblivious types - Internal members should not use oblivious types + Interne Member dürfen keine nicht bewussten Typen verwenden. @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + „{0}“ verletzt die Anforderungen der Rückwärtskompatibilität: Die API mit optionalen Parametern sollte die meisten Parameter bei den öffentlichen Überladungen aufweisen. Details finden Sie unter „{1}“. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + Die API mit optionalen Parametern sollte die meisten Parameter bei den öffentlichen Überladungen aufweisen @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Wenn Sie einen internen Typ oder ein internes Member entfernen, fügen Sie diesen Eintrag in InternalAPI.Unshipped.txt mit dem Präfix „*REMOVED*“ ein. Dadurch wird die Aufmerksamkeit auf API-Änderungen in den Code Reviews und dem Quellcodeverwaltungsverlauf gelenkt,und Breaking Changes werden verhindert. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Das Symbol „{0}“ ist Teil der deklarierten internen API, ist jedoch entweder nicht intern oder wurde nicht gefunden. Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Gelöschte Typen und Member aus der deklarierten internen API entfernen When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Wenn Sie einen öffentlichen Typ oder Member entfernen, fügen Sie diesen Eintrag in "PublicAPI.Unshipped.txt" mit dem Präfix "*REMOVED*" ein. Dadurch wird die Aufmerksamkeit auf API-Änderungen in den Codeüberprüfungen und dem Quellcodeverwaltungsverlauf gelenkt und trägt dazu bei, Breaking Changes zu verhindern. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Das Symbol "{0}" ist Teil der deklarierten API, aber entweder nicht öffentlich oder nicht auffindbar. Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Gelöschte Typen und Member aus der deklarierten API entfernen @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + Die API ist als entfernt markiert, ist jedoch im Quellcode vorhanden. InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Für InternalAPI.txt-Dateien muss „#nullable enable“ festgelegt sein, um Informationen zur NULL-Zulässigkeit nachzuverfolgen. Andernfalls sollte diese Diagnose unterdrückt werden. Bei aktivierter NULL-Zulässigkeit zeichnet InternalAPI.txt auf, welche Typen Nullwerte zulassen (Suffix „?“ für den Typ) bzw. keine Nullwerte zulassen (Suffix „!“). Zudem werden alle APIs verfolgt, die noch immer einen nicht bewussten Verweistyp verwenden (Präfix „~“ in der Zeile). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + In InternalAPI.txt fehlt „#nullable enable“, daher werden die Anmerkungen zur NULL-Zulässigkeit der API nicht aufgezeichnet. Es wird empfohlen, diese Nachverfolgung zu aktivieren. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Nachverfolgung der NULL-Zulässigkeit von Verweistypen in der deklarierten API aktivieren PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Für "PublicAPI.txt"-Dateien muss "#nullable enable" festgelegt sein, um Informationen zur NULL-Zulässigkeit nachzuverfolgen. Andernfalls sollte diese Diagnose unterdrückt werden. Bei aktivierter NULL-Zulässigkeit zeichnet "PublicAPI.txt" auf, welche Typen NULL-Werte zulassen (Suffix "?" für den Typ) bzw. keine NULL-Werte zulassen (Suffix "!"). Zudem werden alle APIs verfolgt, die noch immer einen Verweistyp ohne Beachtung verwenden (Präfix "~" in der Zeile). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + In "PublicAPI.txt" fehlt "#nullable enable", daher werden die Anmerkungen zur NULL-Zulässigkeit der API nicht aufgezeichnet. Es wird empfohlen, diese Nachverfolgung zu aktivieren. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Nachverfolgung der NULL-Zulässigkeit von Verweistypen in der deklarierten API aktivieren diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.es.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.es.xlf index 7dfdc8c441..ec9e890f38 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.es.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.es.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Agregue todos los elementos del documento "{0}" a la API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Agregue todos los elementos del proyecto "{0}" a la API Add all items in the solution to the API - Add all items in the solution to the API + Agregar todos los elementos de la solución a la API pública Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Anote todos los elementos del documento "{0}" en la API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Anotar todos los elementos del proyecto "{0}" en la API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Anote todos los elementos de la solución en la API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Todos los tipos y miembros internos deben declararse con anotaciones de nulabilidad en InternalAPI.txt. Esto atrae la atención a los cambios de nulabilidad de la API en las revisiones de código y el historial de control de código fuente; además, ayuda a evitar cambios importantes. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + El símbolo "{0}" no tiene anotaciones de nulabilidad en la API declarada. Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Anotar la nulabilidad de los miembros y tipos en la API declarada @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Todos los tipos y miembros internos deben declararse en PublicAPI.txt. Esto atrae la atención a los cambios de la API en las revisiones de código y el historial de control de código fuente; además, ayuda a evitar cambios importantes. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + El símbolo "{0}" no forma parte de la API declarada. Add internal types and members to the declared API - Add internal types and members to the declared API + Agregue miembros y tipos internos a la API declarada @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + El símbolo "{0}" no forma parte de la API pública declarada. @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + El símbolo "{0}" aparece más de una vez en los archivos internos de la API. Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + No duplique símbolos en los archivos internos de la API @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Habilite las anotaciones de nulabilidad en la API para el proyecto "{0}" Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Habilite las anotaciones de nulabilidad en la API para la solución @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + constructor implícito para "{0}" implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + descriptor de acceso get implícito para "{0}" implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + descriptor de acceso set implícito para "{0}" Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + El archivo interno de la API "{0}" falta o no está marcado como archivo de analizador adicional. Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Falta un archivo interno de la API pública enviado o con envío anulado The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + El contenido de los archivos internos de la API no es válido: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + El contenido de los archivos internos de la API no es válido The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + La solución debe contener dos archivos con el tipo "AdditionalFiles": InternalAPI.Unshipped.txt y InternalAPI.Shipped.txt. Al menos uno de estos archivos falta o tiene un tipo incorrecto. One or both of the internal API files are missing - One or both of the internal API files are missing + Faltan uno o los dos archivos internos de la API All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Todos los miembros públicos deben usar tipos de referencia que se puedan o no anular, pero no tipos de referencia inconscientes. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + El símbolo "{0}" usa algunos tipos de referencia ajenos. Internal members should not use oblivious types - Internal members should not use oblivious types + Los miembros internos no deben usar tipos inconscientes @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + "{0}" infringe el requisito de compatibilidad con versiones anteriores: "La API con parámetros opcionales debe tener la mayoría de los parámetros entre sus sobrecargas públicas". Consulte "{1}" para conocer más detalles. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + La API con parámetros opcionales debe tener la mayoría de los parámetros entre sus sobrecargas públicas @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Al quitar un tipo o miembro público, coloque esa entrada en InternalAPI.Unshipped.txt con el prefijo "*REMOVED*". Esto atrae la atención a los cambios de la API en las revisiones de código y el historial de control de código fuente; además, ayuda a evitar cambios importantes. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + El símbolo "{0}" forma parte de la API interna declarada, pero no es interna o no se encontró. Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Quitar tipos y miembros eliminados de la API interna declarada When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Al quitar un tipo o miembro público, coloque esa entrada en PublicAPI.Unshipped.txt con el prefijo "*REMOVED*". Esto atrae la atención a los cambios de la API en las revisiones de código y el historial de control de código fuente; además, ayuda a evitar cambios importantes. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + El símbolo "{0}" forma parte de la API declarada, pero no es pública o no se encontró. Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Quitar tipos y miembros eliminados de la API declarada @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + La API se marcó como quitada, pero existe en el código fuente InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Los archivos InternalAPI.txt deben tener "#nullable enable" para hacer un seguimiento de la información de nulabilidad, o bien se debe suprimir este diagnóstico. Con la nulabilidad habilitada, PublicAPI.txt registra los tipos se pueden anular (sufijo "?" en el tipo) o que no se pueden anular (sufijo "!"). También realiza el seguimiento de cualquier API que aún use un tipo de referencia obvio (prefijo "~" en la línea). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + Falta "#nullable enable" en InternalAPI.txt, por lo que las anotaciones de nulabilidad de la API no se registran. Se recomienda habilitar este seguimiento. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Habilitar el seguimiento de la nulabilidad de los tipos de referencia en la API declarada PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Los archivos PublicAPI.txt deben tener "#nullable Enable" para hacer un seguimiento de la información de nulabilidad, o bien se debe suprimir este diagnóstico. Con la nulabilidad habilitada, PublicAPI.txt registra los tipos que aceptan valores NULL (sufijo "?" en el tipo) o que no admiten valores NULL (sufijo "!"). También realiza el seguimiento de cualquier API que aún use un tipo de referencia obvio (prefijo "~" en la línea). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + Falta "#nullable enable" en PublicAPI.txt, por lo que las anotaciones de nulabilidad de la API no se registran. Se recomienda habilitar este seguimiento. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Habilitar el seguimiento de la nulabilidad de los tipos de referencia en la API declarada diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.fr.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.fr.xlf index 421a4ec31c..9eb6ad52bb 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.fr.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.fr.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Ajouter tous les éléments du document «{0}» à l’API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Ajouter tous les éléments du projet «{0}» à l’API Add all items in the solution to the API - Add all items in the solution to the API + Ajouter tous les éléments de la solution à l’API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Annoter tous les éléments du document «{0}» dans l’API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Annoter tous les éléments du projet '{0}' dans l’API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Annoter tous les éléments de la solution dans l’API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Tous les types et membres internes doivent être déclarés avec des annotations de nullabilité dans InternalAPI.txt. Cela attire l’attention sur les modifications de nullabilité de l’API dans les révisions de code et l’historique du contrôle de code source, et permet d’éviter les changements cassants. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + Il manque des annotations de nullabilité pour le symbole '{0}' dans l'API déclarée Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Annoter la nullabilité des types internes et des membres dans l’API déclarée @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Tous les types et membres internes doivent être déclarés dans InternalAPI.txt. Cela attire l’attention sur les modifications d’API dans les révisions de code et l’historique du contrôle de code source, et permet d’éviter les changements cassants. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Le symbole '{0}' ne fait pas partie de l'API déclarée Add internal types and members to the declared API - Add internal types and members to the declared API + Ajouter des types et des membres internes à l’API déclarée @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Le symbole '{0}' ne fait pas partie de l’API publique déclarée @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Le symbole «{0}» apparaît plusieurs fois dans les fichiers d’API internes Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Ne pas dupliquer les symboles dans les fichiers d’API internes @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Activer les annotations de nullabilité dans l’API pour le projet «{0}» Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Activer les annotations de nullabilité dans l’API pour la solution @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + constructeur implicite pour '{0}' implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + accesseur get implicite pour '{0}' implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + accesseur set implicite pour '{0}' Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Le fichier d’API interne «{0}» est manquant ou n’est pas marqué comme fichier d’analyseur supplémentaire Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Fichier d’API interne non expédié ou non expédié manquant The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Le contenu des fichiers d’API internes n’est pas valide : {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Le contenu des fichiers d’API internes n’est pas valide The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + La solution doit contenir deux fichiers de type « AdditionalFiles » : InternalAPI.Unshipped.txt et internalAPI.Shipped.txt. Au moins un de ces fichiers est manquant ou a un type incorrect. One or both of the internal API files are missing - One or both of the internal API files are missing + Un ou les deux fichiers d’API internes sont manquants All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Tous les membres internes doivent utiliser des types référence nullables ou non nullables, mais aucun type référence inconscient. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Le symbole '{0}' utilise des types référence inconscients Internal members should not use oblivious types - Internal members should not use oblivious types + Les membres internes ne doivent pas utiliser de types inconscients @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + «{0}» ne respecte pas l’exigence de compatibilité descendante : « L’API avec le ou les paramètres facultatifs doit avoir le plus de paramètres parmi ses surcharges publiques ». Pour plus d’informations, consultez «{1}». API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + L’API avec des paramètres facultatifs doit avoir le plus de paramètres parmi ses surcharges publiques @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Lors de la suppression d’un type ou d’un membre interne, placez cette entrée dans InternalAPI.Unshipped.txt avec le préfixe '*REMOVED*'. Cela attire l’attention sur les modifications d’API dans les révisions de code et l’historique du contrôle de code source, et permet d’éviter les changements cassants. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Le symbole '{0}' fait partie de l’API interne déclarée, mais n’est pas interne ou est introuvable Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Supprimer les types et membres supprimés de l’API interne déclarée When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Lorsque vous supprimez un type ou un membre public, placez cette entrée dans PublicAPI.Unshipped.txt avec le préfixe « *REMOVED* ». Cela permet d'attirer l'attention sur les modifications de l'API dans les revues de code et l'historique du contrôle de la source, et d'éviter les modifications de rupture. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Le symbole '{0}' fait partie de l'API déclarée, mais il n'est pas public ou est introuvable Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Enlever les types et membres supprimés de l'API déclarée @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + L’API est marquée comme supprimée, mais elle existe dans le code source InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Les fichiers InternalAPI.txt doivent avoir « #nullable activé » pour suivre les informations de nullabilité, ou ce diagnostic doit être supprimé. Une fois la possibilité de valeur Null activée, InternalAPI.txt enregistre les types qui sont nullables (suffixe « ? » sur le type) ou non Nullable (suffixe « ! »). Il effectue également le suivi de toute API qui utilise toujours un type référence obondant (préfixe « ~ » sur la ligne). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt ne contient pas '#nullable enable', donc les annotations de nullabilité de l’API ne sont pas enregistrées. Il est recommandé d’activer ce suivi. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Activer le suivi de la possibilité de valeur null des types référence dans l'API déclarée PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Les fichiers PublicAPI.txt doivent avoir '#nullable enable' pour effectuer le suivi des informations de possibilité de valeur null ou ce diagnostic doit être supprimé. Si l'option de possibilité de valeur null est activée, PublicAPI.txt enregistre les types nullable (suffixe '?' sur le type) ou non-nullable (suffixe '!'). Il effectue également le suivi des API qui utilisent encore un type référence inconscient (préfixe '~' sur la ligne). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt ne contient pas '#nullable enable'. Les annotations de nullabilité de l'API ne sont donc pas enregistrées. Il est recommandé d'activer ce suivi. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Activer le suivi de la possibilité de valeur null des types référence dans l'API déclarée diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.it.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.it.xlf index 69da583275..687bfd7de6 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.it.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.it.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Aggiungi tutti gli elementi del documento '{0}' all'API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Aggiungi tutti gli elementi del progetto '{0}' all'API Add all items in the solution to the API - Add all items in the solution to the API + Aggiungi tutti gli elementi della soluzione all'API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Annota tutti gli elementi del documento '{0}' nell'API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Annota tutti gli elementi del progetto '{0}' nell'API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Annota tutti gli elementi della soluzione nell'API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Tutti i tipi e i membri interni devono essere dichiarati con annotazioni di supporto dei valori Null in InternalAPI.txt. In questo modo si richiama l'attenzione sulle modifiche del supporto dei valori Null all'API nelle revisioni del codice e nella cronologia del controllo del codice sorgente e si contribuisce a evitare modifiche che causano un'interruzione. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + Nel simbolo '{0}' mancano le annotazioni di supporto dei valori Null nell'API dichiarata Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Annota il supporto dei valori Null di tipi interni e membri nell'API dichiarata @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Tutti i tipi e i membri interni devono essere dichiarati in InternalAPI.txt. In questo modo si richiama l'attenzione sulle modifiche all'API nelle revisioni del codice e nella cronologia del controllo del codice sorgente e contribuisce a evitare modifiche che causano un'interruzione. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Il simbolo '{0}' non fa parte dell'API dichiarata Add internal types and members to the declared API - Add internal types and members to the declared API + Aggiungere tipi e membri interni all'API dichiarata @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Il simbolo '{0}' non fa parte dell'API pubblica dichiarata @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Il simbolo '{0}' è presente più volte nei file dell'API interna Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Non duplicare simboli nei file API interni @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Abilita le annotazioni di supporto dei valori Null nell'API per il progetto '{0}' Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Abilita le annotazioni di supporto dei valori Null nell'API per la soluzione @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + costruttore implicito per '{0}' implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + funzione di accesso get implicita per '{0}' implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + funzione di accesso set implicita per '{0}' Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Il file di API interna '{0}' manca o non è contrassegnato come file aggiuntivo dell'analizzatore Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + File di API interno distribuito o non distribuito mancante The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Il contenuto dei file dell'API interna non è valido: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Il contenuto dei file dell'API interna non è valido: The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + La soluzione deve contenere due file con il tipo "AdditionalFiles": InternalAPI.unshipped.txt e InternalAPI.shipped.txt. Almeno uno di questi file manca o è di tipo errato. One or both of the internal API files are missing - One or both of the internal API files are missing + Uno o entrambi i file dell'API interna sono mancanti All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Tutti i membri interni devono usare tipi riferimento nullable o non nullable, ma non tipi riferimento oblivious. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Il simbolo '{0}' usa alcuni tipi di riferimento oblivious Internal members should not use oblivious types - Internal members should not use oblivious types + I membri interni non devono usare tipi oblivious @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}' viola il requisito di compatibilità con le versioni precedenti: 'L'API con parametri facoltativi deve includere la maggior parte dei parametri tra i relativi overload public'. Per dettagli, vedere '{1}'. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + L'API con parametri facoltativi deve includere la maggior parte dei parametri tra i relativi overload public @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Quando si rimuove un tipo o un membro interno, è necessario inserire questa voce in InternalAPI.Unshipped.txt con prefisso '*REMOVED*’. In questo modo si richiama l'attenzione sulle modifiche all'API nelle revisioni del codice e nella cronologia dei controlli del codice sorgente, e si contribuisce a evitare modifiche che causano un'interruzione. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Il simbolo '{0}' fa parte dell'API interna dichiarata, ma non è interno oppure non è stato possibile trovarlo Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Rimuovere tipi e membri eliminati dall'API interna dichiarata When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Quando si rimuove un tipo o un membro pubblico, è necessario inserire questa voce in PublicAPI.Unshipped.txt con prefisso '*REMOVED*’. In questo modo si richiama l'attenzione sulle modifiche all'API nelle revisioni del codice e nella cronologia dei controlli del codice sorgente, e si contribuisce a evitare modifiche che causano un'interruzione. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Il simbolo '{0}' fa parte dell'API dichiarata, ma non è public oppure non è stato possibile trovarlo Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Rimuovere tipi e membri eliminati dall'API dichiarata @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + L'API è contrassegnata come rimossa, ma è presente nel codice sorgente InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + I file InternalAPI.txt devono includere `#nullable enable` per tenere traccia delle informazioni sul supporto dei valori Null, in caso contrario questa diagnostica deve essere eliminata. Se il supporto dei valori Null è abilitato, InternalAPI.txt registra i tipi nullable (suffisso `?` nel tipo) o non nullable (suffisso `!`). Tiene inoltre traccia di eventuali API che usano ancora un tipo riferimento senza annotazioni nullable (prefisso `~` nella riga). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + In InternalAPI.txt manca '#nullable enable', di conseguenza le annotazioni di supporto dei valori Null dell'API non sono registrate. È consigliabile abilitare questa verifica. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Abilita il rilevamento del supporto dei valori Null dei tipi riferimento nell'API dichiarata PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + I file PublicAPI.txt devono includere `#nullable enable` per tenere traccia delle informazioni sul supporto dei valori Null, in caso contrario questa diagnostica deve essere eliminata. Se il supporto dei valori Null è abilitato, PublicAPI.txt registra i tipi nullable (suffisso `?` nel tipo) o non nullable (suffisso `!`). Tiene inoltre traccia di eventuali API che usano ancora un tipo riferimento senza annotazioni nullable (prefisso `~` nella riga). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + In PublicAPI.txt manca '#nullable enable', di conseguenza le annotazioni di supporto dei valori Null dell'API non sono registrate. È consigliabile abilitare questa verifica. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Abilita il rilevamento del supporto dei valori Null dei tipi riferimento nell'API dichiarata diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ja.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ja.xlf index c03c8c38ad..2ce75ecf79 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ja.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ja.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + ドキュメント '{0}' 内のすべての項目を API へ追加 Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + プロジェクト '{0}' 内のすべての項目を API へ追加 Add all items in the solution to the API - Add all items in the solution to the API + ソリューション内のすべての項目を API へ追加 Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + API のドキュメント '{0}' 内のすべての項目に注釈を付ける Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + API のプロジェクト '{0}' 内のすべての項目に注釈を付ける Annotate all items in the solution in the API - Annotate all items in the solution in the API + API のソリューション内のすべての項目に注釈を付ける All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + すべての内部の型とメンバーは、NULL 値許容の注釈を付けて、InternalAPI.txt で宣言する必要があります。これにより、コード レビューとソース管理履歴で API の NULL 値の許容の変更に注意を引くことができ、破壊的変更を防ぐことができます。 Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + シンボル '{0}' では、宣言された API に NULL 許容の注釈がありません Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + 宣言された内部 API の型とメンバーの NULL 値許容の注釈を付ける @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + すべての内部の型とメンバーは、 InternalAPI.txt で宣言する必要があります。これにより、コード レビューとソース管理履歴で API 変更に注意を引くことができ、破壊的変更を防ぐことができます。 Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + シンボル '{0}' は宣言された API の一部ではありません Add internal types and members to the declared API - Add internal types and members to the declared API + 宣言された API に内部の型とメンバーを追加する @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + シンボル '{0}' は宣言されたパブリック API の一部ではありません @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + シンボル '{0}' が、内部 API ファイルに複数含まれています Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + 内部 API ファイル内でシンボルを重複させない @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + プロジェクト '{0}' の API で、NULL 値許容の注釈を有効にする Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + ソリューションの API で、NULL 値許容の注釈を有効にする @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + '{0}' の暗黙的なコンストラクター implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + '{0}' の暗黙的な get アクセサー implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + '{0}' の暗黙的な set アクセサー Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + 内部 API ファイル '{0}' が存在しないか、追加のアナライザー ファイルとしてマークされていません Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + 出荷済みまたは未出荷の内部 API ファイルがない The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + 内部 API ファイルのコンテンツが無効です: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + 内部 API ファイルのコンテンツが無効 The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + ソリューションには、種類が "AdditionalFiles" の 2 つのファイル (InternalAPI.Unshipped.txt と InternalAPI.Unshipped.txt) が含まれている必要があります。これらのファイルのうち少なくとも 1 つが見つからないか、種類が正しくありません。 One or both of the internal API files are missing - One or both of the internal API files are missing + 内部 API ファイルの 1 つまたは両方が見つからない All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + すべての内部メンバーは、Null 許容参照型と null 非許容参照型のいずれかを使用する必要がありますが、oblivious 参照型は使用しません。 Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + シンボル '{0}' ではいくつかの oblivious 参照型が使用されています Internal members should not use oblivious types - Internal members should not use oblivious types + 内部メンバーによる oblivious 型の使用禁止 @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}' は下位互換性の要件、「省略可能なパラメーターを持つ API は、そのパブリック オーバーロード内のほとんどのパラメーターを持つ必要がある」に違反しています。詳細は '{1}' を参照してください。 API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + 省略可能なパラメーターを持つ API は、そのパブリック オーバーロード内のほとんどのパラメーターを持つ必要がある @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 内部の型またはメンバーを削除する際、その項目を InternalAPI.Unshipped.txt に '*REMOVED*' プレフィックスを付けて記入する必要があります。これにより、コード レビューとソース管理履歴で API の変更に注意を引くことができ、破壊的変更を防ぐことができます。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + シンボル '{0}' は宣言された内部 API の一部ですが、内部ではないか、見つかりませんでした Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + 削除された型とメンバーを、宣言された内部 API から削除する When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + パブリックの型またはメンバーを削除する際、その項目を PublicAPI.Unshipped.txt に '*REMOVED*' プレフィックスを付けて記入する必要があります。これにより、コード レビューとソース管理履歴で API の変更に注意を引くことができ、破壊的変更を防ぐことができます。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + シンボル '{0}' は宣言された API の一部ですが、パブリックではないか、見つかりませんでした Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + 削除された型とメンバーを、宣言された API から削除する @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API が削除済みとマークされているが、ソース コード内に存在する InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + InternalAPI.txt ファイルでは、NULL 値の許容情報を追跡するために '#nullable enable' を指定する必要があります。指定されていない場合は、この診断を中止する必要があります。NULL 値の許容を有効にすると、InternalAPI.txt は、どの型が null 許容 (型にサフィックス '?' を含む) または null 非許容 (サフィックス '!') かを記録します。また、oblivious 参照型 (行にプレフィックス '~' を含む) を使用している API を追跡します。 InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt に '#nullable enable' がありません。そのため、API の NULL 値許容の注釈は記録されていません。この追跡を有効にすることをお勧めします。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 宣言された API 内で参照型の NULL 値の許容を追跡できるようにする PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + PublicAPI.txt ファイルでは、NULL 値の許容情報を追跡するために '#nullable enable' を指定する必要があります。指定されていない場合は、この診断を中止する必要があります。NULL 値の許容を有効にすると、PublicAPI.txt は、どの型が null 許容 (型にサフィックス '?' を含む) または null 非許容 (サフィックス '!') かを記録します。また、oblivious 参照型 (行にプレフィックス '~' を含む) を使用している API を追跡します。 PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt に '#nullable enable' がありません。そのため、API の NULL 許容の注釈は記録されていません。この追跡を有効にすることをお勧めします。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 宣言された API 内で参照型の NULL 値の許容を追跡できるようにする diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ko.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ko.xlf index dd453ee0d8..1a4d8bfee6 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ko.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ko.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + 문서 '{0}'의 모든 항목을 API에 추가 Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + 프로젝트 '{0}'의 모든 항목을 API에 추가 Add all items in the solution to the API - Add all items in the solution to the API + API에 솔루션의 모든 항목 추가 Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + API에서 문서 '{0}'의 모든 항목에 주석 달기 Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + API에서 프로젝트 '{0}'의 모든 항목에 주석 추가 Annotate all items in the solution in the API - Annotate all items in the solution in the API + API에서 솔루션의 모든 항목에 주석 달기 All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + 모든 내부 형식 및 구성원은 InternalAPI.txt에서 Null 허용 여부 주석을 포함하여 선언되어야 합니다. 그러면 코드 검토 및 소스 제어 기록에서 API Null 허용 여부 변경 내용을 쉽게 확인할 수 있고 호환성이 손상되는 변경을 방지할 수 있습니다. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + 선언된 API에서 '{0}' 기호에 Null 허용 여부 주석이 없습니다. Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + 선언된 API에서 내부 형식 및 구성원의 Null 허용 여부 주석 추가 @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 모든 내부 형식 및 구성원은 InternalAPI.txt에서 선언해야 합니다. 이로 인해 코드 검토 및 소스 제어 기록에서 API 변경 내용을 쉽게 확인할 수 있고 큰 변경을 방지할 수 있습니다. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + '{0}' 기호가 선언된 API에 포함되지 않습니다. Add internal types and members to the declared API - Add internal types and members to the declared API + 선언된 API에 내부 형식 및 구성원 추가 @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + 기호 '{0}'은(는) 선언된 공개 API의 일부가 아닙니다. @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + 내부 API 파일에 '{0}' 기호가 두 번 이상 나타납니다. Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + 내부 API 파일에서 기호를 복제하지 마세요. @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + API에서 프로젝트 '{0}'에 Null 허용 여부 주석 사용 Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + 솔루션에 대한 API에서 null 허용 여부 주석 사용 @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + '{0}'의 암시적 생성자 implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + '{0}'의 암시적 get 접근자 implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + '{0}'의 암시적 set 접근자 Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + 내부 API 파일 '{0}'이(가) 누락되었거나 추가 분석기 파일로 표시되지 않았습니다. Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + 배송되거나 배송되지 않은 내부 API 파일 누락 The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + 내부 API 파일의 내용이 잘못되었습니다. {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + 내부 API 파일의 내용이 잘못되었습니다. The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + 솔루션에는 "AdditionalFiles" 형식의 두 파일(InternalAPI.Unshipped.txt 및 internalAPI.Shipped.txt)이 포함되어야 합니다. 이러한 파일 중 하나 이상이 없거나 형식이 잘못되었습니다. One or both of the internal API files are missing - One or both of the internal API files are missing + 내부 API 파일 중 하나 또는 둘 다 없습니다. All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + 모든 내부 구성원은 null을 허용하거나 null을 허용하지 않는 참조 형식을 사용해야 하지만, 인식 불가능한 참조 형식은 사용하면 안 됩니다. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + '{0}' 기호는 일부 인식 불가능한 참조 형식을 사용합니다. Internal members should not use oblivious types - Internal members should not use oblivious types + 내부 구성원은 인식 불가능한 형식을 사용하면 안 됩니다. @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}'이(가) backcompat 요구 사항인 '선택적 매개 변수가 있는 API는 공용 오버로드 중 가장 많은 매개 변수를 보유해야 합니다'를 위반합니다. 자세한 내용은 '{1}'을(를) 참조하세요. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + 선택적 매개 변수가 있는 API에는 공개 오버로드 중에서 가장 많은 매개 변수가 있어야 합니다. @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 내부 형식 또는 구성원을 제거할 때 해당 항목을 InternalAPI.Unshipped.txt에 '*REMOVED*' 접두어를 추가합니다. 이는 코드 검토 및 소스 제어 기록의 API 변경 내용에 주의를 기울이고 주요 변경 내용을 방지하는 데 도움이 됩니다. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + 기호 '{0}'은(는) 선언된 내부 API의 일부이지만 내부가 아니거나 찾을 수 없습니다. Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + 선언된 내부 API에서 삭제된 형식 및 구성원 제거 When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + public 형식 및 멤버를 제거할 경우 해당 항목을 '*REMOVED*' 접두사를 사용해 PublicAPI.Unshipped.txt에 넣습니다. 이렇게 하면 코드 검토와 원본 제어 기록에서 API 변경 내용에 주의를 기울이게 하고, 호환성이 손상되는 변경을 방지할 수 있습니다. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + '{0}' 기호가 선언된 API의 일부이지만, 공용이 아니거나 찾을 수 없습니다. Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + 선언된 API에서 삭제된 형식 및 멤버 제거 @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API가 제거된 것으로 표시되지만 소스 코드에 존재합니다. InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + InternalAPI.txt 파일에는 Null 허용 여부 정보를 추적하기 위해 `#nullable enable`이 있어야 합니다. 그렇지 않으면 이 진단이 억제되어야 합니다. Null 허용 여부를 사용하도록 설정하면 InternalAPI.txt는 Null을 허용(형식의 접미사 `?`)하거나 null을 허용하지 않는(접미사 `!`) 형식을 기록합니다. 또한 여전히 인식 불가능한 참조 형식(접두사 `~` 온라인)을 사용하는 모든 API를 추적합니다. InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt에 '#nullable enable'이 없으므로 API의 Null 허용 여부 주석이 기록되지 않았습니다. 이 추적을 사용하도록 설정하는 것이 좋습니다. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 선언된 API에서 참조 형식의 Null 허용 여부 추적 사용 PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Null 허용 여부 정보를 추적하려면 PublicAPI.txt 파일에 '#nullable enable'이 있어야 합니다. 또는 이 진단이 표시되지 않아야 합니다. Null 허용 여부를 사용하는 경우 PublicAPI.txt는 nullable 형식(형식에 접미사 '?') 또는 nullable이 아닌 형식(접미사 '!')을 기록합니다. 또한 null을 허용하지 않는 참조 형식(줄에 접두사 '~')을 계속 사용하는 모든 API를 추적합니다. PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt에 '#nullable enable'이 없으므로 API의 Null 허용 여부 주석이 기록되지 않았습니다. 이 추적을 사용하도록 설정하는 것이 좋습니다. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 선언된 API에서 참조 형식의 Null 허용 여부 추적 사용 diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pl.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pl.xlf index d4abf91a74..6fd3e14f13 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pl.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pl.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Dodaj wszystkie elementy w dokumencie „{0}” do interfejsu API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Dodaj wszystkie elementy w projekcie „{0}” do interfejsu API Add all items in the solution to the API - Add all items in the solution to the API + Dodaj wszystkie elementy w rozwiązaniu interfejsu API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Dodawanie adnotacji do wszystkich elementów w dokumencie „{0}” w interfejsie API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Dodawanie adnotacji do wszystkich elementów w projekcie „{0}” w interfejsie API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Dodawanie adnotacji do wszystkich elementów w rozwiązaniu w interfejsie API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Wszystkie wewnętrzne typy i składowe powinny być zadeklarowane w pliku PublicAPI.txt z adnotacjami opcji dopuszczania wartości null. To zwraca uwagę na zmiany opcji dopuszczania wartości null interfejsu API w przeglądach kodu i historii kontroli źródła oraz pomaga zapobiegać zmianom powodującym nieprawidłowe działanie. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + Symbol „{0}” nie ma adnotacji opcji dopuszczania wartości null w zadeklarowanym interfejsie API Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Dodawanie adnotacji opcji dopuszczania wartości null typów i składowych w zadeklarowanym interfejsie API @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Wszystkie typy wewnętrzne i składowe powinny być zadeklarowane w pliku InternalAPI.txt. Zwraca to uwagę na zmiany interfejsu API w przeglądach kodu i historii kontroli źródła oraz pomaga zapobiegać zmianom powodującym niezgodność. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Symbol „{0}” nie jest częścią zadeklarowanego interfejsu API Add internal types and members to the declared API - Add internal types and members to the declared API + Dodaj publiczne typy i składowe do zadeklarowanego interfejsu API @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Symbol „{0}” nie jest częścią zadeklarowanego publicznego interfejsu API @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Symbol „{0}” występuje więcej niż raz w plikach wewnętrznego interfejsu API Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Nie duplikuj symboli w plikach wewnętrznego interfejsu API @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Włącz adnotacje dopuszczające wartość null w interfejsie API dla projektu „{0}” Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Włącz adnotacje opcji dopuszczania wartości null w publicznym interfejsie API dla rozwiązania @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + niejawny konstruktor dla elementu „{0}” implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + niejawna metoda dostępu get dla elementu „{0}” implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + niejawna metoda dostępu set dla elementu „{0}” Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Brak pliku wewnętrznego interfejsu API „{0}” lub nie jest on oznaczony jako dodatkowy plik analizatora Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Brak dostarczonego lub niewysłanego pliku wewnętrznego interfejsu API The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Zawartość plików wewnętrznego interfejsu API jest nieprawidłowa: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Zawartość plików wewnętrznego interfejsu API jest nieprawidłowa The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + Rozwiązanie musi zawierać dwa pliki typu „AdditionalFiles”: PublicAPI.Unshipped.txt i PublicAPI.Shipped.txt. Brakuje co najmniej jednego z tych plików lub ma on nieprawidłowy typ. One or both of the internal API files are missing - One or both of the internal API files are missing + Brak jednego lub obu plików wewnętrznego interfejsu API All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Wszystkie publiczne składowe powinny używać typów referencyjnych dopuszczających wartość null lub nie dopuszczających jej, ale nie nieświadomych typów referencyjnych. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Symbol „{0}” używa pewnych nieświadomych typów referencyjnych Internal members should not use oblivious types - Internal members should not use oblivious types + Publiczne składowe nie powinny używać typów obojętnych @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + „{0}” narusza wymaganie dotyczące zgodności z kopią zapasową: „Interfejs API z opcjonalnymi parametrami powinien mieć najwięcej parametrów spośród przeciążeń publicznych”. Aby uzyskać szczegółowe informacje, zobacz „{1}”. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + Publiczny interfejs API z opcjonalnymi parametrami powinien mieć najwięcej parametrów spośród jego przeciążeń publicznych @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + W przypadku usunięcia typu wewnętrznego lub składowej należy usunąć także powiązany wpis w pliku PublicAPI.Unshipped.txt. z prefiksem ’*REMOVED*’. To przyciąga uwagę do zmian interfejsu API w przeglądach kodu i historii kontroli źródła oraz pomaga zapobiegać zmianom powodującym nieprawidłowe działanie. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Symbol „{0}” jest częścią zadeklarowanego wewnętrznego interfejsu API, ale nie jest wewnętrzny lub nie można go znaleźć Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Usuń skasowane typy i składowe ze zadeklarowanego wewnętrznego interfejsu API When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + W przypadku usunięcia typu publicznego lub składowej należy usunąć także powiązany wpis w pliku PublicAPI.Unshipped.txt. z prefiksem ’*REMOVED*’. To przyciąga uwagę do zmian interfejsu API w przeglądach kodu i historii kontroli źródła oraz pomaga zapobiegać zmianom powodującym nieprawidłowe działanie. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Symbol „{0}” jest częścią zadeklarowanego interfejsu API, ale nie jest publiczny lub nie można go odnaleźć Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Usuń usunięte typy i składowe z zadeklarowanego interfejsu API @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + Publiczny interfejs API został oznaczony jako usunięty, ale istnieje w kodzie źródłowym InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Pliki PublicAPI.txt powinny zawierać wartość „#nullable enable” na potrzeby śledzenia informacji o dopuszczaniu wartości null lub należy pominąć tę diagnostykę. W przypadku włączenia informacji o dopuszczaniu wartości null plik PublicAPI.txt rejestruje typy dopuszczające wartość null (sufiks „?” dla typu) i niedopuszczające wartości null (sufiks „!”). Śledzi on również wszelkie interfejsy API, które nadal korzystają z nieświadomego typu odwołania (prefiks „~” w wierszu). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + W pliku PublicAPI.txt brakuje elementu „#nullable enable”, dlatego adnotacje opcji dopuszczania wartości null nie są rejestrowane. Zaleca się włączenie tego śledzenia. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Włącz śledzenie wartości null typów referencyjnych w zadeklarowanym interfejsie API PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Pliki PublicAPI.txt powinny zawierać wartość „#nullable enable” w celu śledzenia informacji o dopuszczaniu wartości null lub należy pominąć tę diagnostykę. W przypadku włączenia informacji o dopuszczaniu wartości null plik PublicAPI.txt rejestruje typy dopuszczające wartość null (sufiks „?” dla typu) i niedopuszczające wartości null (sufiks „!”). Śledzi on również wszelkie interfejsy API, które nadal korzystają z nieświadomego typu odwołania (prefiks „~” w wierszu). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + W pliku PublicAPI.txt brakuje elementu „#nullable enable”, dlatego adnotacje opcji dopuszczania wartości null nie są rejestrowane. Zaleca się włączenie tego śledzenia. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Włącz śledzenie wartości null typów referencyjnych w zadeklarowanym interfejsie API diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pt-BR.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pt-BR.xlf index 897e762c9f..2af67d4956 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pt-BR.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.pt-BR.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Adicione todos os itens do documento '{0}' à API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Adicione todos os itens do projeto '{0}' à API Add all items in the solution to the API - Add all items in the solution to the API + Adicione todos os itens da solução à API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Anote todos os itens no documento '{0}' na API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Anotar todos os itens no projeto '{0}' na API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Anote todos os itens da solução na API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Todos os tipos e membros internos devem ser declarados com anotações de nulidade em InternalAPI.txt. Isso chama a atenção para as alterações de nulidade da API nas revisões de código e no histórico de controle do código-fonte e ajuda a evitar alterações significativas. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + O símbolo '{0}' não tem anotações de nulidade na API declarada Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Anote a nulidade de tipos e membros internos na API declarada @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Todos os tipos e membros internos devem ser declarados em InternalAPI.txt. Isso chama a atenção para as alterações da API nas revisões de código e no histórico de controle do código-fonte e ajuda a evitar alterações significativas. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + O símbolo '{0}' não faz parte da API declarada Add internal types and members to the declared API - Add internal types and members to the declared API + Adicionar tipos e membros internos à API declarada @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + O símbolo '{0}' não faz parte da API pública declarada @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + O símbolo '{0}' aparece mais de uma vez nos arquivos internos da API Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Não duplique símbolos em arquivos de API internos @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Habilitar anotações de nulidade na API para o projeto '{0}' Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Ativar anotações de nulidade na API para a solução @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + construtor implícito para '{0}' implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + acessador get implícito para '{0}' implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + acessador set implícito para '{0}' Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + O arquivo de API interno '{0}' está ausente ou não está marcado como um arquivo de analisador adicional Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Arquivo de API interno enviado ou não enviado ausente The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + O conteúdo dos arquivos internos da API é inválido: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + O conteúdo dos arquivos internos da API é inválido The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + A solução deve conter dois arquivos do tipo "AdditionalFiles": InternalAPI.Unshipped.txt e internalAPI.Shipped.txt. Pelo menos um desses arquivos está ausente ou tem o tipo errado. One or both of the internal API files are missing - One or both of the internal API files are missing + Um ou ambos os arquivos internos da API estão ausentes All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Todos os membros internos devem usar tipos de referência anuláveis ​​ou não anuláveis, mas nenhum tipo de referência inconsciente. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + O símbolo '{0}' usa alguns tipos de referência vagos Internal members should not use oblivious types - Internal members should not use oblivious types + Membros internos não devem usar tipos alheios @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}' viola o requisito de backcompat: 'API com parâmetro(s) opcional deve ter o maior número de parâmetros entre suas sobrecargas públicas'. Veja '{1}' para detalhes. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + API com parâmetro(s) opcional deve ter o maior número de parâmetros entre suas sobrecargas públicas @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Ao remover um tipo ou membro interno, coloque essa entrada em InternalAPI.Unshipped.txt com o prefixo '*REMOVED*'. Isso chama a atenção para as alterações da API nas revisões de código e no histórico de controle do código-fonte e ajuda a evitar alterações significativas. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + O símbolo '{0}' faz parte da API interna declarada, mas não é interno ou não foi encontrado Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Remova tipos e membros excluídos da API interna declarada When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Ao remover um tipo ou membro público, coloque essa entrada em PublicAPI.Unshipped.txt com o prefixo '*REMOVED*'. Isso chama a atenção para as alterações da API nas revisões de código e no histórico de controle de origem e ajuda a evitar alterações significativas. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + O símbolo '{0}' faz parte da API declarada, mas não é público ou não pôde ser encontrado Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Remova os tipos e membros excluídos da API declarada @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + A API está marcada como removida, mas existe no código-fonte InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Os arquivos InternalAPI.txt devem ter `#nullable enable` para rastrear informações de nulidade ou esse diagnóstico deve ser suprimido. Com a nulidade habilitada, InternalAPI.txt registra quais tipos são anuláveis ​​(sufixo `?` no tipo) ou não anuláveis ​​(sufixo `!`). Ele também rastreia qualquer API que ainda esteja usando um tipo de referência inconsciente (prefixo `~` on line). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt está faltando '#nullable enable', então as anotações de nulidade da API não são registradas. Recomenda-se habilitar esse rastreamento. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Habilitar o acompanhamento de nulidade de tipos de referência na API declarada PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Os arquivos PublicAPI.txt devem ter `#nullable enable` para controlar as informações de nulidade ou esse diagnóstico deve ser suprimido. Com a nulidade habilitada, o PublicAPI.txt registra quais tipos são anuláveis (sufixo `?` no tipo) ou não anuláveis (sufixo `!`). Ele também rastreia APIs que ainda estejam usando um tipo de referência alheio (prefixo `~` na linha). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + O PublicAPI.txt está sem '#nullable enable', portanto, as anotações de nulidade da API não estão sendo registradas. É recomendado que esse controle seja habilitado. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Habilitar o acompanhamento de nulidade de tipos de referência na API declarada diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ru.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ru.xlf index 3ff3bbb897..18c842a84f 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ru.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.ru.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + Добавить все элементы документа "{0}" в API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + Добавить все элементы проекта "{0}" в API Add all items in the solution to the API - Add all items in the solution to the API + Добавить все элементы решения в API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + Добавлять заметки для всех элементов в документе "{0}" в API Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + Добавлять заметки для всех элементов в проекте "{0}" в API Annotate all items in the solution in the API - Annotate all items in the solution in the API + Добавлять заметки ко всем элементам решения в API All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Все внутренние типы и элементы должны быть объявлены в InternalAPI.txt. с заметками допустимости значений NULL. Это привлекает внимание к изменениям допустимости значений NULL в API при проверках кода и в журнале системы управления версиями и помогает предотвратить критические изменения. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + В объявленном API для символа "{0}" отсутствуют заметки о допустимости значений NULL. Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Добавлять заметки о допустимости значений NULL для типов и элементов в объявленном API @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Все внутренние типы и элементы должны быть объявлены в InternalAPI.txt.. Это привлекает внимание к изменениям API при проверках кода и в журнале системы управления версиями и помогает предотвратить критические изменения. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + Символ "{0}" не является частью объявленного API. Add internal types and members to the declared API - Add internal types and members to the declared API + Добавить открытые типы и элементы в объявленный API @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + Символ "{0}" не является частью объявленного общедоступного API. @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + Символ "{0}" встречается больше одного раза в файлах внутреннего API. Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Не дублировать символы во внутренних файлах API @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + Включить заметки о допустимости значений NULL в API для проекта "{0}" Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Включить аннотации, допускающие значение NULL, в API для решения. @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + неявный конструктор для "{0}" implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + неявный метод доступа get для "{0}" implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + неявный метод доступа set для "{0}" Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + Файл внутреннего API "{0}" отсутствует или не помечен как дополнительный файл анализатора. Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Отсутствует отправленный или неотправленный файл общедоступного API The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Недопустимое содержимое внутренних файлов API: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Недопустимое содержимое внутренних файлов API The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + Решение должно содержать два файла с типом "AdditionalFiles": InternalAPI.Unshipped.txt и internalAPI.Shipped.txt. По меньшей мере один из этих файлов отсутствует или относится к неправильному типу. One or both of the internal API files are missing - One or both of the internal API files are missing + Отсутствует один или оба файла внутреннего API All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Все внутренние элементы должны использовать ссылочные типы, допускающие или не допускающие значение NULL, но не игнорируемые ссылочные типы. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + Символ "{0}" использует некоторые игнорируемые ссылочные типы. Internal members should not use oblivious types - Internal members should not use oblivious types + Внутренние элементы не должны использовать игнорируемые типы @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + "{0}" нарушает требование обратной совместимости: "большинство параметров открытого API с необязательными параметрами должны находиться среди его общедоступных перегрузок". Дополнительные сведения см. в "{1}". API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + Большинство параметров открытого API с необязательными параметрами должны находиться среди его общедоступных перегрузок. @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + При удалении внутреннего типа или элемента поместите эту запись в файл InternalAPI.Unshipped.txt с префиксом "*REMOVED*". Это привлекает внимание к изменениям API в проверках кода и журнала управления версиями и помогает предотвратить критические изменения. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + Символ "{0}" является частью объявленного внутреннего API, но не является внутренним или не найден Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Удалить удаленные типы и элементы из объявленного API When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + При удалении открытого типа или элемента поместите эту запись в файл PublicAPI.Unshipped.txt с префиксом "*REMOVED*". Это привлечет внимание к изменениями API при проверке кода и в истории управления версиями, а также поможет предотвратить критические изменения. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + Символ "{0}" является частью объявленного API, однако не является открытым либо не был найден Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Удалите удаленные типы и элементы из объявленного API @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API помечен как удаленный, но существует в исходном коде InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Для файлов InternalAPI.txt необходимо установить директиву "#nullable enable", чтобы отслеживать сведения о допустимости значений NULL или отключить этот параметр диагностики. Если значения NULL являются допустимыми, в файлах InternalAPI.txt записываются типы, допускающие значения NULL (суффикс "?" типа) или не допускают значения NULL (суффикс "!"). Также отслеживаются все API, в которых все еще используется ссылочный тип без заметок о допустимости значений NULL (префикс "~" в строке). InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + В файле PublicAPI.txt отсутствует "#nullable enable", поэтому заметки о допустимости значений NULL для API не записываются. Рекомендуется включить это отслеживание. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Включение отслеживания допустимости значений NULL ссылочных типов в объявленном API PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + Для файлов PublicAPI.txt необходимо установить директиву #nullable enable, чтобы отслеживать сведения о допустимости значений NULL, либо отключить этот параметр диагностики. Если значения NULL являются допустимыми, в файлах PublicAPI.txt записываются типы, которые допускают значения NULL (суффикс "?" типа) или не допускают значения NULL (суффикс "!"). Также отслеживаются все API, в которых все еще используется ссылочный тип без заметок о допустимости значений NULL (префикс "~" в строке). PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + В файле PublicAPI.txt отсутствует "#nullable enable", поэтому заметки о допустимости значений NULL для API не записываются. Рекомендуется включить их отслеживание. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Включение отслеживания допустимости значений NULL ссылочных типов в объявленном API diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.tr.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.tr.xlf index 838fa841c5..4adbcea967 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.tr.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.tr.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + '{0}' belgesindeki tüm öğeleri API'ye ekle Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + '{0}' projesindeki tüm öğeleri API'ye ekle Add all items in the solution to the API - Add all items in the solution to the API + Çözümdeki tüm öğeleri API'ye ekleyin Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + API'de yer alan '{0}' belgesindeki tüm öğelere not ekleyin Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + API'de yer alan '{0}' projesindeki tüm öğelere not ekleyin Annotate all items in the solution in the API - Annotate all items in the solution in the API + API'de yer alan çözümdeki tüm öğelere not ekleyin All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + Tüm genel türler ve üyeler PublicAPI.txt içinde null atanabilirlik ek açıklamalarıyla tanımlanmalıdır. Bu işlem, kod incelemeleri ve kaynak denetimi geçmişindeki API null atanabilirlik değişikliklerine dikkat çeker ve hataya neden olan değişikliklerin önlenmesine yardımcı olur. Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + '{0}' sembolünde, bildirilen API'deki null atanabilirlik ek açıklamaları eksik Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + Tanımlanan API'deki dahili türlerin ve üyelerin null atanabilirliğine not ekleyin @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Tüm dahili türler ve üyeler InternalAPI.txt içinde tanımlanmalıdır. Bu, kod incelemelerindeki ve kaynak kontrol geçmişindeki API değişikliklerine dikkat çeker ve hataya neden olan değişiklikleri önlemeye yardımcı olur. Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + '{0}' sembolü bildirilen API'nin bir parçası değil Add internal types and members to the declared API - Add internal types and members to the declared API + Tanımlanan API'ye dahili türler ve üyeler ekleyin @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + '{0}' sembolü, tanımlanan genel API'nin bir parçası değil @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + '{0}' sembolü, dahili API dosyalarında birden çok kez görünüyor Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + Sembolleri dahili API dosyalarında çoğaltmayın @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + '{0}' projesi için API'de null atanabilirlik ek açıklamalarını etkinleştir Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + Çözüm için API'de geçersizlik ek açıklamalarını etkinleştirin @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + '{0}' için örtük oluşturucu implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + '{0}' için örtük get erişimcisi implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + '{0}' için örtük set erişimcisi Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + '{0}' dahili API dosyası eksik veya ek bir çözümleyici dosyası olarak işaretlenmemiş Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + Gönderilen veya gönderilmeyen dahili API dosyası eksik The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + Dahili API dosyalarının içerikleri geçersiz: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + Dahili API dosyalarının içeriği geçersiz The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + Çözüm, "AdditionalFiles" türünde iki dosya içermelidir: InternalAPI.Unshipped.txt ve internalAPI.Shipped.txt. Bu dosyalardan en az biri eksik veya yanlış türde. One or both of the internal API files are missing - One or both of the internal API files are missing + Dahili API dosyalarından biri veya ikisi eksik All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + Tüm dahili üyeler, null atanabilir veya null atanamaz başvuru türleri kullanmalı, ancak habersiz başvuru türleri kullanmamalıdır. Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + '{0}' sembolü uyarısız atanabilen bazı başvuru türlerini kullanıyor Internal members should not use oblivious types - Internal members should not use oblivious types + Dahili üyeler habersiz türleri kullanmamalıdır @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}', geri uyumluluk gereksinimini ihlal ediyor: 'İsteğe bağlı parametre(ler) içeren API, genel aşırı yüklemeleri arasında en fazla parametreye sahip olmalıdır'. Ayrıntılar için '{1}' bölümüne bakın. API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + İsteğe bağlı parametrelere sahip API, genel aşırı yüklemeleri arasında en fazla parametreye sahip olmalıdır @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Bir dahili türü veya üyeyi kaldırırken, o girişi '*REMOVED*' önekiyle InternalAPI.Unshipped.txt dosyasına koyun. Bu, kod incelemelerindeki ve kaynak denetimi geçmişindeki API değişikliklerine dikkat çeker ve değişikliklerin bozulmasını önlemeye yardımcı olur. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + '{0}' sembolü tanımlanan dahili API'nin parçası, ancak dahili değil veya bulunamadı Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + Silinen türleri ve üyeleri tanımlanan dahili API'den kaldırın When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + Bir genel türü veya üyeyi kaldırırken, bu girişi PublicAPI.Unshipped.txt dosyasına '*REMOVED*' önekiyle birlikte yerleştirin. Bu işlem, kod incelemeleri ve kaynak denetimi geçmişindeki API değişikliklerine dikkat çeker ve hataya neden olan değişikliklerin önlenmesine yardımcı olur. {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + '{0}' sembolü bildirilen API'nin parçası, ancak genel değil veya bulunamadı Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + Silinen türleri ve üyeleri bildirilen API'den kaldırın @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API kaldırıldı olarak işaretlendi ancak kaynak kodunda mevcut InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + InternalAPI.txt dosyalarında null atanabilirlik bilgilerini izlemek için `#nullable enable` bulunmalıdır veya bu tanılama gizlenmelidir. Null atanabilirlik etkin olduğunda InternalAPI.txt, null atanabilir (türde `?` soneki) veya null atanamaz (`!` soneki) türleri kaydeder. Ayrıca, hala bir habersiz başvuru türünü (satırda `~` ön eki) kullanan tüm API'leri de izler. InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt'de '#nullable enable' eksik, bu nedenle API'nin null atanabilirlik ek açıklamaları kaydedilmiyor. Bu izlemeyi etkinleştirmeniz önerilir. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Bildirilen API'de başvuru türlerinin null olduğunu izlemeyi etkinleştirin PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + PublicAPI.txt dosyalarında null atanabilirlik bilgilerini izlemek için `#nullable enable` bulunmalıdır veya bu tanılama gizlenmelidir. Null atanabilirlik etkin olduğunda PublicAPI.txt, null atanabilir (türde `?` soneki) veya null atanamaz (`!` soneki) türleri kaydeder. Ayrıca, hala bir kayıtsız başvuru türünü (satırda `~` ön eki) kullanan tüm API'leri de izler. PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt dosyasında '#nullable enable' eksik olduğundan API'nin null atanabilirlik ek açıklamaları kaydedilmiyor. Bu izlemenin etkinleştirilmesi önerilir. Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + Bildirilen API'de başvuru türlerinin null olduğunu izlemeyi etkinleştirin diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hans.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hans.xlf index 42a54b5753..39595c7789 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hans.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hans.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + 将文档“{0}”中的所有项添加到 API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + 将项目“{0}”中的所有项添加到 API Add all items in the solution to the API - Add all items in the solution to the API + 将解决方案中的所有项添加到 API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + 在 API 中对文档“{0}”中的所有项进行批注 Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + 在 API 中对项目“{0}”中的所有项进行批注 Annotate all items in the solution in the API - Annotate all items in the solution in the API + 在 API 中对解决方案中的所有项进行批注 All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + 应在 InternalAPI.txt 中使用为 Null 性注释声明所有内部类型和成员。这将关注代码评审和源代码管理历史记录中的 API 为 Null 性更改,并有助于防止中断性变更。 Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + 符号“{0}”在声明的 API 中缺少为 Null 性注释 Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + 在声明的 API 中对内部类型和成员的为 Null 性进行批注 @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 应在 InternalAPI.txt 中声明所有内部类型和成员。这将关注代码评审和源代码管理历史记录中的 API 更改,并有助于防止重大更改。 Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + 符号“{0}”不是已声明 API 的一部分 Add internal types and members to the declared API - Add internal types and members to the declared API + 向已内部 API 添加公共类型和成员 @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + 符号“{0}”不是已声明公共 API 的一部分 @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + 符号“{0}”多次出现在内部 API 文件中 Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + 请勿在内部 API 文件中复制符号 @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + 在项目“{0}”的 API 中启用为 Null 性注释 Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + 在解决方案的 API 中启用为 Null 性注释 @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + “{0}”的隐式构造函数 implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + “{0}”的隐式 get 访问器 implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + “{0}”的隐式 set 访问器 Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + 缺少内部 API 文件“{0}”,或者未将它标记为附加分析器文件 Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + 缺少附带/未附带的内部 API 文件 The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + 内部 API 文件的内容无效: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + 内部 API 文件的内容无效 The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + 解决方案必须包含两个具有类型 "AdditionalFiles" 的文件(InternalAPI.Unshipped.txt 和 InternalAPI.Shipped.txt)。其中至少有一个文件缺失或类型错误。 One or both of the internal API files are missing - One or both of the internal API files are missing + 缺少一个或两个内部 API 文件 All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + 所有内部成员都应使用可以为 null 或不可为 null 的引用类型,但不能使用未知引用类型。 Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + 符号“{0}”使用了一些未知引用类型 Internal members should not use oblivious types - Internal members should not use oblivious types + 内部成员不得使用未知类型 @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + “{0}”违反了 backcompat 要求:“具有可选参数的 API 应在其公共重载中具有最多参数”。有关详细信息,请参阅“{1}”。 API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + 具有可选参数的 API 应在其公共重载中具有最多参数 @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 删除内部类型或成员时,将其项输入 InternalAPI.Unshipped.txt 中,并附上前缀 "*REMOVED*"。这样能够在代码评审和源代码管理历史记录中引起对 API 更改的注意,有助于防止中断性更改。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + 符号“{0}”是已声明内部 API 的一部分,但此符号不是内部符号或无法找到 Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + 从已声明内部 API 中删除已删除的类型和成员 When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 删除公共类型或成员时,将其项输入 PublicAPI.Unshipped.txt 中,并附上前缀 "*REMOVED*"。这样能够在代码评审和源代码管理历史记录中引起对 API 更改的注意,有助于防止中断性更改。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + 符号“{0}”是已声明 API 的一部分,但此符号不是公共符号或无法找到 Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + 从已声明 API 中删除已删除的类型和成员 @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API 标记为已删除,但它存在于源代码中 InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + InternalAPI.txt 文件应具有 "#nullable enable" 以跟踪为 Null 性信息,或者应取消显示此诊断。如果启用了为 Null 性,则 InternalAPI.txt 会记录哪些类型可为 Null (类型上带后缀 "?")而哪些不可为 Null (带后缀 "!")。它还会跟踪所有仍在使用不带此信息的引用类型(行上带前缀 "~007E;")的 API。 InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt 缺少 "#nullable enable",因此不会记录 API 的为 Null 性注释。建议启用此跟踪。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 在已声明 API 中启用对引用类型的为 Null 性的跟踪 PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + PublicAPI.txt 文件应具有 "#nullable enable" 以跟踪为 Null 性信息,或者应取消显示此诊断。如果启用了为 Null 性,则 PublicAPI.txt 会记录哪些类型可为 Null (类型上带后缀 "?")而哪些不可为 Null (带后缀 "!")。它还会跟踪所有仍在使用不带此信息的引用类型(行上带前缀 "~")的 API。 PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt 缺少 "#nullable enable",因此不会记录 API 的为 Null 性注释。建议启用此跟踪。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 在已声明 API 中启用对引用类型的为 Null 性的跟踪 diff --git a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hant.xlf b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hant.xlf index a568e60fd5..fc3c34eec1 100644 --- a/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hant.xlf +++ b/src/PublicApiAnalyzers/Core/Analyzers/xlf/PublicApiAnalyzerResources.zh-Hant.xlf @@ -4,47 +4,47 @@ Add all items in document '{0}' to the API - Add all items in document '{0}' to the API + 將文件 '{0}' 中的所有項目新增至 API Add all items in project '{0}' to the API - Add all items in project '{0}' to the API + 將專案 '{0}' 中的所有項目新增至 API Add all items in the solution to the API - Add all items in the solution to the API + 將解決方案中的所有項目新增至 API Annotate all items in document '{0}' in the API - Annotate all items in document '{0}' in the API + 標註 API 中文件 '{0}' 的所有項目 Annotate all items in project '{0}' in the API - Annotate all items in project '{0}' in the API + 標註 API 中專案 '{0}' 的所有項目 Annotate all items in the solution in the API - Annotate all items in the solution in the API + 標註 API 中解決方案的所有項目 All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared with nullability annotations in InternalAPI.txt. This draws attention to API nullability changes in the code reviews and source control history, and helps prevent breaking changes. + 應在 InternalAPI.txt 中宣告所有內部類型與成員並加上可 NULL 性註釋。這麼做會讓您注意到程式碼檢閱與原始檔控制歷程記錄中的 API 可 NULL 性變更,同時有助於避免重大變更。 Symbol '{0}' is missing nullability annotations in the declared API - Symbol '{0}' is missing nullability annotations in the declared API + 在宣告的 API 中,符號 '{0}' 缺少可為 Null 的註釋 Annotate nullability of internal types and members in the declared API - Annotate nullability of internal types and members in the declared API + 標註已宣告 API 中內部類型和成員的可 NULL 性 @@ -74,17 +74,17 @@ All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - All internal types and members should be declared in InternalAPI.txt. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 應在 InternalAPI.txt 中宣告所有內部類型與成員。這麼做會讓您注意到程式碼檢閱與原始檔控制歷程記錄中的 API 變更,同時有助於避免重大變更。 Symbol '{0}' is not part of the declared API - Symbol '{0}' is not part of the declared API + 符號 '{0}' 並非宣告 API 的一部分 Add internal types and members to the declared API - Add internal types and members to the declared API + 為宣告的 API 新增公用類型與成員 @@ -94,7 +94,7 @@ Symbol '{0}' is not part of the declared public API - Symbol '{0}' is not part of the declared public API + 符號 '{0}' 並非宣告的公用 API 的一部分 @@ -104,12 +104,12 @@ The symbol '{0}' appears more than once in the internal API files - The symbol '{0}' appears more than once in the internal API files + 內部 API 檔案中出現多次符號 '{0}' Do not duplicate symbols in internal API files - Do not duplicate symbols in internal API files + 不要複製內部 API 檔案中的符號 @@ -124,12 +124,12 @@ Enable nullability annotations in the API for project '{0}' - Enable nullability annotations in the API for project '{0}' + 啟用 API 中專案 '{0}' 的可 NULL 性註釋 Enable nullability annotations in the API for the solution - Enable nullability annotations in the API for the solution + 啟用 API 中解決方案的可 NULL 性註釋 @@ -144,62 +144,62 @@ implicit constructor for '{0}' - implicit constructor for '{0}' + '{0}' 的隱含建構函式 implicit get-accessor for '{0}' - implicit get-accessor for '{0}' + '{0}' 的隱含 get 存取子 implicit set-accessor for '{0}' - implicit set-accessor for '{0}' + '{0}' 的隱含 set 存取子 Internal API file '{0}' is missing or not marked as an additional analyzer file - Internal API file '{0}' is missing or not marked as an additional analyzer file + 遺失內部 API 檔案 '{0}',或未將其標示為額外的分析器檔案 Missing shipped or unshipped internal API file - Missing shipped or unshipped internal API file + 遺失隨附或未隨附的內部 API 檔案 The contents of the internal API files are invalid: {0} - The contents of the internal API files are invalid: {0} + 內部 API 檔案的內容無效: {0} The contents of the internal API files are invalid - The contents of the internal API files are invalid + 內部 API 檔案的內容無效 The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. - The solution must contain two files with the type "AdditionalFiles": InternalAPI.Unshipped.txt and internalAPI.Shipped.txt. At least one of these files is missing or has the wrong type. + 解決方案必須包含兩個類型為 "AdditionalFiles" 的檔案: InternalAPI.Unshipped.txt 與 internalAPI.Shipped.txt。這些檔案中至少遺失一個或具有錯誤的類型。 One or both of the internal API files are missing - One or both of the internal API files are missing + 遺失兩個內部 API 檔案的其中一個或兩者 All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. - All internal members should use either nullable or non-nullable reference types, but no oblivious reference types. + 所有內部成員都應使用可為 Null 或不可為 Null 的參考類型,但不可使用無警示的參考類型。 Symbol '{0}' uses some oblivious reference types - Symbol '{0}' uses some oblivious reference types + 符號 '{0}' 使用了部分無必要的參考型別 Internal members should not use oblivious types - Internal members should not use oblivious types + 內部成員不應使用無警示的類型 @@ -219,12 +219,12 @@ '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. - '{0}' violates the backcompat requirement: 'API with optional parameter(s) should have the most parameters amongst its public overloads'. See '{1}' for details. + '{0}' 違反回溯相容性需求:「具有選擇性參數的 API,大部分的參數應位於其公用多載之間」。請參閱 '{1}' 以取得詳細資料。 API with optional parameter(s) should have the most parameters amongst its public overloads - API with optional parameter(s) should have the most parameters amongst its public overloads + 具有選擇性參數的 API,大部分的參數應位於其公用多載之間 @@ -259,32 +259,32 @@ When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a internal type or member, put that entry in InternalAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 移除內部類型或成員時,請將該項目放在 InternalAPI.Unshipped.txt 中並包含 '*REMOVED*' 前置詞。這麼做會讓您注意到程式碼檢閱與原始檔控制歷程記錄中的 API 變更,同時有助於避免重大變更。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found - Symbol '{0}' is part of the declared internal API, but is either not internal or could not be found + 符號 '{0}' 是宣告的內部 API 的一部分,但可能非內部或找不到 Remove deleted types and members from the declared internal API - Remove deleted types and members from the declared internal API + 從宣告的內部 API 移除已刪除的類型和成員 When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. - When removing a public type or member, put that entry in PublicAPI.Unshipped.txt with '*REMOVED*' prefix. This draws attention to API changes in the code reviews and source control history, and helps prevent breaking changes. + 移除公用類型或成員時,請將該項目放在 PublicAPI.Unshipped.txt 中並包含 '*REMOVED*' 前置詞。如此會讓您注意到在程式碼檢閱以及原始檔控制歷程記錄中 API 的變更,同時有助於避免發生中斷性變更。 {Locked="*REMOVED*"} Symbol '{0}' is part of the declared API, but is either not public or could not be found - Symbol '{0}' is part of the declared API, but is either not public or could not be found + 符號 '{0}' 是宣告 API 的一部分,但可能找不到或並非公用 Remove deleted types and members from the declared API - Remove deleted types and members from the declared API + 從宣告的 API 移除已刪除的類型與成員 @@ -294,37 +294,37 @@ API is marked as removed but it exists in source code - API is marked as removed but it exists in source code + API 標記為已移除,但存在於原始程式碼中 InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - InternalAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, InternalAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + InternalAPI.txt 檔案應該具備 `#nullable enable`,才能追蹤可為 NULL 的資訊,否則應隱藏此診斷。若啟用可為 NULL,InternalAPI.txt 便能記錄可為 Null (類型的尾碼為 `?`) 或不可為 Null (尾碼為 `!`) 的類型。其也會追蹤仍在使用無警示參考類型的任何 API (行的首碼為 `~`)。 InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - InternalAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + InternalAPI.txt 遺失 '#nullable enable',因此未記錄 API 的可 NULL 性註釋。建議啟用此追蹤。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 在宣告 API 中啟用參考型別的可為 Null 追蹤 PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). - PublicAPI.txt files should have `#nullable enable` to track nullability information, or this diagnostic should be suppressed. With nullability enabled, PublicAPI.txt records which types are nullable (suffix `?` on type) or non-nullable (suffix `!`). It also tracks any API that is still using an oblivious reference type (prefix `~` on line). + PublicAPI.txt 檔案必須具備 '#nullable enable',才能追蹤可為 NULL 的資訊,否則應隱藏此診斷。若啟用可為 NULL,PublicAPI.txt 便能記錄型可為 Null (類型的尾碼為 '?') 或不可為 Null (尾碼為 '!') 的類型。其也會追蹤仍在使用未經察覺之參考型別的任何 API (行的首碼為 '~')。 PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. - PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking. + PublicAPI.txt 缺少 '#nullable enable',因此未記錄 API 的可 NULL 性註釋。建議啟用此追蹤。 Enable tracking of nullability of reference types in the declared API - Enable tracking of nullability of reference types in the declared API + 在宣告 API 中啟用參考型別的可為 Null 追蹤 diff --git a/src/PublicApiAnalyzers/Core/CodeFixes/AnnotatePublicApiFix.cs b/src/PublicApiAnalyzers/Core/CodeFixes/AnnotatePublicApiFix.cs index 76aa333aa6..df78fdab16 100644 --- a/src/PublicApiAnalyzers/Core/CodeFixes/AnnotatePublicApiFix.cs +++ b/src/PublicApiAnalyzers/Core/CodeFixes/AnnotatePublicApiFix.cs @@ -14,8 +14,6 @@ using DiagnosticIds = Roslyn.Diagnostics.Analyzers.RoslynDiagnosticIds; -#nullable enable - namespace Microsoft.CodeAnalysis.PublicApiAnalyzers { [ExportCodeFixProvider(LanguageNames.CSharp, Name = "AnnotatePublicApiFix"), Shared] diff --git a/src/PublicApiAnalyzers/Core/CodeFixes/NullableEnablePublicApiFix.cs b/src/PublicApiAnalyzers/Core/CodeFixes/NullableEnablePublicApiFix.cs index 6f4ea7d1dc..22084766c4 100644 --- a/src/PublicApiAnalyzers/Core/CodeFixes/NullableEnablePublicApiFix.cs +++ b/src/PublicApiAnalyzers/Core/CodeFixes/NullableEnablePublicApiFix.cs @@ -13,8 +13,6 @@ using Microsoft.CodeAnalysis.Text; using DiagnosticIds = Roslyn.Diagnostics.Analyzers.RoslynDiagnosticIds; -#nullable enable - namespace Microsoft.CodeAnalysis.PublicApiAnalyzers { [ExportCodeFixProvider(LanguageNames.CSharp, Name = "NullableEnablePublicApiFix"), Shared] diff --git a/src/PublicApiAnalyzers/UnitTests/DeclarePublicAPIAnalyzerTestsBase.cs b/src/PublicApiAnalyzers/UnitTests/DeclarePublicAPIAnalyzerTestsBase.cs index 9ce30748a9..45183671e8 100644 --- a/src/PublicApiAnalyzers/UnitTests/DeclarePublicAPIAnalyzerTestsBase.cs +++ b/src/PublicApiAnalyzers/UnitTests/DeclarePublicAPIAnalyzerTestsBase.cs @@ -310,6 +310,25 @@ private C() { } await VerifyCSharpAsync(source, shippedText, unshippedText, $"[*]\r\n{editorconfigText}", expectedDiagnostics); } + [Fact] + public async Task AnalyzerFilePresent_MissingNonEnabledText() + { + var source = $$""" + + {{EnabledModifierCSharp}} class C + { + private C() { } + } + """; + + string? shippedText = ""; + string? unshippedText = ""; + + var expectedDiagnostics = new[] { GetCSharpResultAt(2, 8 + EnabledModifierCSharp.Length, DeclareNewApiRule, "C") }; + + await VerifyCSharpAsync(source, shippedText, unshippedText, $"[*]\r\ndotnet_public_api_analyzer.require_api_files = true", expectedDiagnostics); + } + [Fact] public async Task EmptyPublicAPIFilesAsync() { diff --git a/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpAvoidOptSuffixForNullableEnableCode.cs b/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpAvoidOptSuffixForNullableEnableCode.cs index ce52f15887..78b1480466 100644 --- a/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpAvoidOptSuffixForNullableEnableCode.cs +++ b/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpAvoidOptSuffixForNullableEnableCode.cs @@ -19,7 +19,7 @@ namespace Roslyn.Diagnostics.CSharp.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// - /// RS0046: Avoid 'Opt' suffix for nullable enable code + /// RS0046: /// [DiagnosticAnalyzer(LanguageNames.CSharp)] public sealed class CSharpAvoidOptSuffixForNullableEnableCode : DiagnosticAnalyzer diff --git a/src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentslRefactoring.cs b/src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentsRefactoring.cs similarity index 95% rename from src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentslRefactoring.cs rename to src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentsRefactoring.cs index 8d57783c49..5a1fedbfc0 100644 --- a/src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentslRefactoring.cs +++ b/src/Roslyn.Diagnostics.Analyzers/CSharp/NumberCommentsRefactoring.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. -#nullable enable - using System; using System.Composition; using System.Globalization; @@ -26,8 +24,8 @@ namespace Roslyn.Diagnostics.Analyzers /// This pattern is commonly used by compiler tests. /// Comments that don't look like numbered comments are left alone. For instance, any comment that contains alpha characters. /// - [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = nameof(NumberCommentslRefactoring)), Shared] - internal sealed class NumberCommentslRefactoring : CodeRefactoringProvider + [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = nameof(NumberCommentsRefactoring)), Shared] + internal sealed class NumberCommentsRefactoring : CodeRefactoringProvider { public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context) { @@ -50,7 +48,10 @@ private static async Task FixCommentsAsync(Document document, LiteralE var newValueText = FixComments(stringLiteral.Token.ValueText, prefix: null); var oldText = stringLiteral.Token.Text; var newText = FixComments(oldText, getPrefix(oldText)); - var newStringLiteral = stringLiteral.Update(SyntaxFactory.Literal(text: newText, value: newValueText)).WithTriviaFrom(stringLiteral); + + var oldToken = stringLiteral.Token; + var newToken = SyntaxFactory.Token(oldToken.LeadingTrivia, kind: oldToken.Kind(), text: newText, valueText: newValueText, oldToken.TrailingTrivia); + var newStringLiteral = stringLiteral.Update(newToken); var editor = await DocumentEditor.CreateAsync(document, c).ConfigureAwait(false); editor.ReplaceNode(stringLiteral, newStringLiteral); diff --git a/src/Roslyn.Diagnostics.Analyzers/CSharp/PreferNullLiteral.cs b/src/Roslyn.Diagnostics.Analyzers/CSharp/PreferNullLiteral.cs index 52518287eb..cdab6cff36 100644 --- a/src/Roslyn.Diagnostics.Analyzers/CSharp/PreferNullLiteral.cs +++ b/src/Roslyn.Diagnostics.Analyzers/CSharp/PreferNullLiteral.cs @@ -11,6 +11,9 @@ namespace Roslyn.Diagnostics.CSharp.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0038: + /// [DiagnosticAnalyzer(LanguageNames.CSharp)] public sealed class PreferNullLiteral : DiagnosticAnalyzer { diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/AbstractDoNotCopyValue.cs b/src/Roslyn.Diagnostics.Analyzers/Core/AbstractDoNotCopyValue.cs index 3a20549a65..352d4d3ca2 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/AbstractDoNotCopyValue.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/AbstractDoNotCopyValue.cs @@ -19,6 +19,9 @@ namespace Roslyn.Diagnostics.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0042: + /// public abstract class AbstractDoNotCopyValue : DiagnosticAnalyzer { private static readonly LocalizableString s_localizableTitle = CreateLocalizableResourceString(nameof(DoNotCopyValueTitle)); diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs b/src/Roslyn.Diagnostics.Analyzers/Core/DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs index e49e2bdc07..8e698233e8 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs @@ -15,6 +15,9 @@ namespace Roslyn.Diagnostics.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0040: + /// #pragma warning disable RS1004 // Recommend adding language support to diagnostic analyzer [DiagnosticAnalyzer(LanguageNames.CSharp)] #pragma warning restore RS1004 // Recommend adding language support to diagnostic analyzer diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/DoNotCallGetTestAccessor.cs b/src/Roslyn.Diagnostics.Analyzers/Core/DoNotCallGetTestAccessor.cs index d1ef4174c4..c694d40ef7 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/DoNotCallGetTestAccessor.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/DoNotCallGetTestAccessor.cs @@ -12,6 +12,9 @@ namespace Roslyn.Diagnostics.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0043: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotCallGetTestAccessor : DiagnosticAnalyzer { diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/DoNotMixAttributesFromDifferentVersionsOfMEF.cs b/src/Roslyn.Diagnostics.Analyzers/Core/DoNotMixAttributesFromDifferentVersionsOfMEF.cs index 6096585071..0bec9d2656 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/DoNotMixAttributesFromDifferentVersionsOfMEF.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/DoNotMixAttributesFromDifferentVersionsOfMEF.cs @@ -16,7 +16,7 @@ namespace Roslyn.Diagnostics.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// - /// RS0006: Do not mix attributes from different versions of MEF + /// RS0006: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class DoNotMixAttributesFromDifferentVersionsOfMEFAnalyzer : DiagnosticAnalyzer diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/ExportedPartsShouldHaveImportingConstructor.cs b/src/Roslyn.Diagnostics.Analyzers/Core/ExportedPartsShouldHaveImportingConstructor.cs index 68e90afaf5..ea16cb05f8 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/ExportedPartsShouldHaveImportingConstructor.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/ExportedPartsShouldHaveImportingConstructor.cs @@ -17,6 +17,7 @@ namespace Roslyn.Diagnostics.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// + /// RS0034: /// MEF-exported types should have exactly one constructor, which should be explicitly defined and marked with /// . /// diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/ImportingConstructorShouldBeObsolete.cs b/src/Roslyn.Diagnostics.Analyzers/Core/ImportingConstructorShouldBeObsolete.cs index 6962a7bbda..ed0754baeb 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/ImportingConstructorShouldBeObsolete.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/ImportingConstructorShouldBeObsolete.cs @@ -15,6 +15,8 @@ namespace Roslyn.Diagnostics.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// + /// RS0033: + /// /// The importing constructor for a MEF-exported type should be marked obsolete. /// /// diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/PartsExportedWithMEFv2MustBeMarkedAsShared.cs b/src/Roslyn.Diagnostics.Analyzers/Core/PartsExportedWithMEFv2MustBeMarkedAsShared.cs index ace3f524dd..d5036fe26d 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/PartsExportedWithMEFv2MustBeMarkedAsShared.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/PartsExportedWithMEFv2MustBeMarkedAsShared.cs @@ -14,7 +14,7 @@ namespace Roslyn.Diagnostics.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// - /// RS0023: Parts exported with MEFv2 must be marked as Shared + /// RS0023: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class PartsExportedWithMEFv2MustBeMarkedAsSharedAnalyzer : DiagnosticAnalyzer diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/SpecializedEnumerableCreationAnalyzer.cs b/src/Roslyn.Diagnostics.Analyzers/Core/SpecializedEnumerableCreationAnalyzer.cs index 41be38e3f0..98f1117c0c 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/SpecializedEnumerableCreationAnalyzer.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/SpecializedEnumerableCreationAnalyzer.cs @@ -18,6 +18,10 @@ namespace Roslyn.Diagnostics.Analyzers // TODO: This should be updated to follow the flow of array creation expressions // that are eventually converted to and leave a given method as IEnumerable once we have // the ability to do more thorough data-flow analysis in diagnostic analyzers. + /// + /// RS0001: + /// RS0002: + /// public abstract class SpecializedEnumerableCreationAnalyzer : DiagnosticAnalyzer { internal const string SpecializedCollectionsMetadataName = "Roslyn.Utilities.SpecializedCollections"; diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/SymbolDeclaredEventMustBeGeneratedForSourceSymbols.cs b/src/Roslyn.Diagnostics.Analyzers/Core/SymbolDeclaredEventMustBeGeneratedForSourceSymbols.cs index 70120d88d5..8192ebd0ae 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/SymbolDeclaredEventMustBeGeneratedForSourceSymbols.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/SymbolDeclaredEventMustBeGeneratedForSourceSymbols.cs @@ -16,6 +16,10 @@ namespace Roslyn.Diagnostics.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0019: + /// + /// public abstract class SymbolDeclaredEventAnalyzer : DiagnosticAnalyzer where TSyntaxKind : struct { diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/TemporaryArrayAsRefAnalyzer.cs b/src/Roslyn.Diagnostics.Analyzers/Core/TemporaryArrayAsRefAnalyzer.cs index 63784c2142..ece2262011 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/TemporaryArrayAsRefAnalyzer.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/TemporaryArrayAsRefAnalyzer.cs @@ -12,6 +12,9 @@ namespace Roslyn.Diagnostics.Analyzers { using static RoslynDiagnosticsAnalyzersResources; + /// + /// RS0049: + /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public class TemporaryArrayAsRefAnalyzer : DiagnosticAnalyzer { diff --git a/src/Roslyn.Diagnostics.Analyzers/Core/TestExportsShouldNotBeDiscoverable.cs b/src/Roslyn.Diagnostics.Analyzers/Core/TestExportsShouldNotBeDiscoverable.cs index 9eab204f5f..d8dfd94bd2 100644 --- a/src/Roslyn.Diagnostics.Analyzers/Core/TestExportsShouldNotBeDiscoverable.cs +++ b/src/Roslyn.Diagnostics.Analyzers/Core/TestExportsShouldNotBeDiscoverable.cs @@ -16,6 +16,7 @@ namespace Roslyn.Diagnostics.Analyzers using static RoslynDiagnosticsAnalyzersResources; /// + /// RS0032: /// MEF-exported types defined in test assemblies should be marked with /// to avoid polluting the container(s) created for testing. These parts should be explicitly added to the container /// when required for specific tests. diff --git a/src/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs b/src/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs index b9f83f1ba3..479861b564 100644 --- a/src/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs +++ b/src/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Testing; using Xunit; -using VerifyCS = Test.Utilities.CSharpCodeRefactoringVerifier; +using VerifyCS = Test.Utilities.CSharpCodeRefactoringVerifier; namespace Roslyn.Diagnostics.Analyzers.UnitTests { @@ -28,6 +29,74 @@ class D { } // 1 await VerifyCS.VerifyRefactoringAsync(source, fixedSource); } + [Fact] + public async Task TestAsync_RawStringLiteral() + { + const string source = """" +public class C +{ + string s = """ +[||]class D { } // +"""; +} +""""; + const string fixedSource = """" +public class C +{ + string s = """ +class D { } // 1 +"""; +} +""""; + await VerifyCSharp11Async(source, fixedSource); + } + + [Fact] + public async Task TestAsync_RawStringLiteral_Indented() + { + const string source = """" +public class C +{ + string s = """ + [||]class D { } // + """; +} +""""; + const string fixedSource = """" +public class C +{ + string s = """ + class D { } // 1 + """; +} +""""; + await VerifyCSharp11Async(source, fixedSource); + } + + [Fact] + public async Task TestAsync_RawStringLiteral_Indented_Multiple() + { + const string source = """" +public class C +{ + string s = """ + [||]class D { } // + class E { } //, + """; +} +""""; + const string fixedSource = """" +public class C +{ + string s = """ + class D { } // 1 + class E { } // 2, 3 + """; +} +""""; + await VerifyCSharp11Async(source, fixedSource); + } + [Fact] public async Task CSharp_VerifyFix_WithTriviaAsync() { @@ -219,5 +288,20 @@ class C // 1 await VerifyCS.VerifyRefactoringAsync(source, fixedSource); } + + #region Utilities + private async Task VerifyCSharp11Async(string source, string fixedSource) + { + var test = new VerifyCS.Test + { + TestCode = source, + FixedCode = fixedSource, + LanguageVersion = Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp11, + }; + + test.ExpectedDiagnostics.AddRange(DiagnosticResult.EmptyDiagnosticResults); + await test.RunAsync(); + } + #endregion } } diff --git a/src/Text.Analyzers/Core/EnumsShouldHavePluralNames.cs b/src/Text.Analyzers/Core/EnumsShouldHavePluralNames.cs index 3a9d94f974..614197705e 100644 --- a/src/Text.Analyzers/Core/EnumsShouldHavePluralNames.cs +++ b/src/Text.Analyzers/Core/EnumsShouldHavePluralNames.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. -#nullable enable - using System; using System.Collections.Immutable; using System.Linq; @@ -16,8 +14,8 @@ namespace Text.Analyzers using static TextAnalyzersResources; /// - /// CA1714: Flags enums should have plural names - /// CA1717: Only Flags enums should have plural names + /// CA1714: + /// CA1717: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class EnumsShouldHavePluralNamesAnalyzer : DiagnosticAnalyzer diff --git a/src/Text.Analyzers/Core/IdentifiersShouldBeSpelledCorrectly.cs b/src/Text.Analyzers/Core/IdentifiersShouldBeSpelledCorrectly.cs index d92ee3825c..0a4b423006 100644 --- a/src/Text.Analyzers/Core/IdentifiersShouldBeSpelledCorrectly.cs +++ b/src/Text.Analyzers/Core/IdentifiersShouldBeSpelledCorrectly.cs @@ -16,7 +16,7 @@ namespace Text.Analyzers using static TextAnalyzersResources; /// - /// CA1704: Identifiers should be spelled correctly + /// CA1704: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class IdentifiersShouldBeSpelledCorrectlyAnalyzer : DiagnosticAnalyzer diff --git a/src/Tools/GenerateDocumentationAndConfigFiles/Program.cs b/src/Tools/GenerateDocumentationAndConfigFiles/Program.cs index b9606e17ba..6654d8d338 100644 --- a/src/Tools/GenerateDocumentationAndConfigFiles/Program.cs +++ b/src/Tools/GenerateDocumentationAndConfigFiles/Program.cs @@ -666,7 +666,7 @@ async Task checkHelpLinkAsync(string helpLink) async Task createGlobalConfigFilesAsync() { - using var shippedFilesDataBuilder = ArrayBuilder.GetInstance(); + using var releaseTrackingFilesDataBuilder = ArrayBuilder.GetInstance(); using var versionsBuilder = PooledHashSet.GetInstance(); // Validate all assemblies exist on disk and can be loaded. @@ -705,7 +705,19 @@ async Task createGlobalConfigFilesAsync() var assemblyName = Path.GetFileNameWithoutExtension(assembly); var shippedFile = Path.Combine(assemblyDir, "AnalyzerReleases", assemblyName, ReleaseTrackingHelper.ShippedFileName); - if (File.Exists(shippedFile)) + var unshippedFile = Path.Combine(assemblyDir, "AnalyzerReleases", assemblyName, ReleaseTrackingHelper.UnshippedFileName); + var shippedFileExists = File.Exists(shippedFile); + var unshippedFileExists = File.Exists(unshippedFile); + + if (shippedFileExists ^ unshippedFileExists) + { + var existingFile = shippedFileExists ? shippedFile : unshippedFile; + var nonExistingFile = shippedFileExists ? unshippedFile : shippedFile; + await Console.Error.WriteLineAsync($"Expected both '{shippedFile}' and '{unshippedFile}' to exist or not exist, but '{existingFile}' exists and '{nonExistingFile}' does not exist.").ConfigureAwait(false); + return false; + } + + if (shippedFileExists) { sawShippedFile = true; @@ -717,14 +729,24 @@ async Task createGlobalConfigFilesAsync() try { + // Read shipped file using var fileStream = File.OpenRead(shippedFile); var sourceText = SourceText.From(fileStream); var releaseTrackingData = ReleaseTrackingHelper.ReadReleaseTrackingData(shippedFile, sourceText, - onDuplicateEntryInRelease: (_1, _2, _3, _4, line) => throw new Exception($"Duplicate entry in {shippedFile} at {line.LineNumber}: '{line}'"), - onInvalidEntry: (line, _2, _3, _4) => throw new Exception($"Invalid entry in {shippedFile} at {line.LineNumber}: '{line}'"), + onDuplicateEntryInRelease: (_1, _2, _3, _4, line) => throw new InvalidOperationException($"Duplicate entry in {shippedFile} at {line.LineNumber}: '{line}'"), + onInvalidEntry: (line, _2, _3, _4) => throw new InvalidOperationException($"Invalid entry in {shippedFile} at {line.LineNumber}: '{line}'"), isShippedFile: true); - shippedFilesDataBuilder.Add(releaseTrackingData); + releaseTrackingFilesDataBuilder.Add(releaseTrackingData); versionsBuilder.AddRange(releaseTrackingData.Versions); + + // Read unshipped file + using var fileStreamUnshipped = File.OpenRead(unshippedFile); + var sourceTextUnshipped = SourceText.From(fileStreamUnshipped); + var releaseTrackingDataUnshipped = ReleaseTrackingHelper.ReadReleaseTrackingData(unshippedFile, sourceTextUnshipped, + onDuplicateEntryInRelease: (_1, _2, _3, _4, line) => throw new InvalidOperationException($"Duplicate entry in {unshippedFile} at {line.LineNumber}: '{line}'"), + onInvalidEntry: (line, _2, _3, _4) => throw new InvalidOperationException($"Invalid entry in {unshippedFile} at {line.LineNumber}: '{line}'"), + isShippedFile: false); + releaseTrackingFilesDataBuilder.Add(releaseTrackingDataUnshipped); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) @@ -744,33 +766,49 @@ async Task createGlobalConfigFilesAsync() if (versionsBuilder.Count > 0) { - var shippedFilesData = shippedFilesDataBuilder.ToImmutable(); + var releaseTrackingData = releaseTrackingFilesDataBuilder.ToImmutableArray(); - // Generate global analyzer config files for each shipped version, if required. + // Generate global analyzer config files for each shipped version. foreach (var version in versionsBuilder) { - var analysisLevelVersionString = GetNormalizedVersionStringForEditorconfigFileNameSuffix(version); - - foreach (var analysisMode in Enum.GetValues(typeof(AnalysisMode))) - { - CreateGlobalConfig(version, analysisLevelVersionString, (AnalysisMode)analysisMode!, shippedFilesData, category: null); - foreach (var category in categories) - { - CreateGlobalConfig(version, analysisLevelVersionString, (AnalysisMode)analysisMode!, shippedFilesData, category); - } - } + CreateGlobalConfigsForVersion(version, isShippedVersion: true, releaseTrackingData); } + + // Generate global analyzer config files for unshipped version. + // See https://github.com/dotnet/roslyn-analyzers/issues/6247 for details. + + // Use 'unshippedVersion = maxShippedVersion + 1' for unshipped data. + var maxShippedVersion = versionsBuilder.Max(); + var unshippedVersion = new Version(maxShippedVersion!.Major + 1, maxShippedVersion.Minor); + CreateGlobalConfigsForVersion(unshippedVersion, isShippedVersion: false, releaseTrackingData); } return true; // Local functions. + void CreateGlobalConfigsForVersion( + Version version, + bool isShippedVersion, + ImmutableArray releaseTrackingData) + { + var analysisLevelVersionString = GetNormalizedVersionStringForEditorconfigFileNameSuffix(version); + + foreach (var analysisMode in Enum.GetValues(typeof(AnalysisMode))) + { + CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, (AnalysisMode)analysisMode!, releaseTrackingData, category: null); + foreach (var category in categories!) + { + CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, (AnalysisMode)analysisMode!, releaseTrackingData, category); + } + } + } void CreateGlobalConfig( Version version, + bool isShippedVersion, string analysisLevelVersionString, AnalysisMode analysisMode, - ImmutableArray shippedFilesData, + ImmutableArray releaseTrackingData, string? category) { var analysisLevelPropName = "AnalysisLevel"; @@ -793,7 +831,7 @@ void CreateGlobalConfig( analysisMode, category, allRulesById, - (shippedFilesData, version)); + (releaseTrackingData, version, isShippedVersion)); } static string GetNormalizedVersionStringForEditorconfigFileNameSuffix(Version version) @@ -1125,7 +1163,7 @@ private static void CreateGlobalconfig( AnalysisMode analysisMode, string? category, SortedList sortedRulesById, - (ImmutableArray shippedFiles, Version version) shippedReleaseData) + (ImmutableArray releaseTrackingData, Version version, bool isShippedVersion) releaseTrackingDataAndVersion) { Debug.Assert(editorconfigFileName.EndsWith(".editorconfig", StringComparison.Ordinal)); @@ -1135,7 +1173,7 @@ private static void CreateGlobalconfig( analysisMode, category, sortedRulesById, - shippedReleaseData); + releaseTrackingDataAndVersion); var directory = Directory.CreateDirectory(folder); var editorconfigFilePath = Path.Combine(directory.FullName, editorconfigFileName.ToLowerInvariant()); File.WriteAllText(editorconfigFilePath, text); @@ -1148,7 +1186,7 @@ static string GetGlobalconfigText( AnalysisMode analysisMode, string? category, SortedList sortedRulesById, - (ImmutableArray shippedFiles, Version version)? shippedReleaseData) + (ImmutableArray releaseTrackingData, Version version, bool isShippedVersion)? releaseTrackingDataAndVersion) { var result = new StringBuilder(); StartGlobalconfig(); @@ -1257,14 +1295,16 @@ bool AddRule(DiagnosticDescriptor rule, string? category) effectiveSeverity = DiagnosticSeverity.Warning; } - if (shippedReleaseData != null) + if (releaseTrackingDataAndVersion != null) { isEnabledByDefault = isEnabledRuleForNonDefaultAnalysisMode; - var maxVersion = shippedReleaseData.Value.version; + var maxVersion = releaseTrackingDataAndVersion.Value.isShippedVersion ? + releaseTrackingDataAndVersion.Value.version : + ReleaseTrackingHelper.UnshippedVersion; var foundReleaseTrackingEntry = false; - foreach (var shippedFile in shippedReleaseData.Value.shippedFiles) + foreach (var releaseTrackingData in releaseTrackingDataAndVersion.Value.releaseTrackingData) { - if (shippedFile.TryGetLatestReleaseTrackingLine(rule.Id, maxVersion, out _, out var releaseTrackingLine)) + if (releaseTrackingData.TryGetLatestReleaseTrackingLine(rule.Id, maxVersion, out _, out var releaseTrackingLine)) { foundReleaseTrackingEntry = true; diff --git a/src/Utilities/Compiler/Analyzer.Utilities.projitems b/src/Utilities/Compiler/Analyzer.Utilities.projitems index f3eba76a29..c3966e0119 100644 --- a/src/Utilities/Compiler/Analyzer.Utilities.projitems +++ b/src/Utilities/Compiler/Analyzer.Utilities.projitems @@ -65,6 +65,7 @@ + diff --git a/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt b/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt index cca82ee27c..00c64a2dd3 100644 --- a/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt +++ b/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt @@ -12,7 +12,7 @@ Design: CA2210, CA1000-CA1070 Globalization: CA2101, CA1300-CA1311 Mobility: CA1600-CA1601 -Performance: HA, CA1800-CA1855 +Performance: HA, CA1800-CA1857 Security: CA2100-CA2153, CA2300-CA2330, CA3000-CA3147, CA5300-CA5405 Usage: CA1801, CA1806, CA1816, CA2200-CA2209, CA2211-CA2260 Naming: CA1700-CA1727 diff --git a/src/Utilities/Compiler/Extensions/IMethodSymbolExtensions.cs b/src/Utilities/Compiler/Extensions/IMethodSymbolExtensions.cs index 03f7a3c106..3c9cd76252 100644 --- a/src/Utilities/Compiler/Extensions/IMethodSymbolExtensions.cs +++ b/src/Utilities/Compiler/Extensions/IMethodSymbolExtensions.cs @@ -337,7 +337,7 @@ public static DisposeMethodKind GetDisposeMethodKind( { return DisposeMethodKind.DisposeBool; } - else if (method.HasDisposeAsyncMethodSignature(task, valueTask)) + else if (method.IsAsyncDisposeImplementation(iAsyncDisposable, valueTask) || method.HasDisposeAsyncMethodSignature(task, valueTask)) { return DisposeMethodKind.DisposeAsync; } diff --git a/src/Utilities/Compiler/Lightup/INegatedPatternOperationWrapper.cs b/src/Utilities/Compiler/Lightup/INegatedPatternOperationWrapper.cs new file mode 100644 index 0000000000..fe0caee4f2 --- /dev/null +++ b/src/Utilities/Compiler/Lightup/INegatedPatternOperationWrapper.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +#if HAS_IOPERATION + +namespace Analyzer.Utilities.Lightup +{ + using System; + using System.Diagnostics.CodeAnalysis; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Operations; + + [SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Not a comparable instance.")] + internal readonly struct INegatedPatternOperationWrapper : IOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.INegatedPatternOperation"; + private static readonly Type? WrappedType = OperationWrapperHelper.GetWrappedType(typeof(INegatedPatternOperationWrapper)); + + private static readonly Func PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern), fallbackResult: null!); + + private INegatedPatternOperationWrapper(IOperation operation) + { + WrappedOperation = operation; + } + + public IOperation WrappedOperation { get; } + public ITypeSymbol? Type => this.WrappedOperation.Type; + public IPatternOperation Pattern => PatternAccessor(WrappedOperation); + + public static INegatedPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new INegatedPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} + +#endif diff --git a/src/Utilities/Compiler/Lightup/OperationWrapperHelper.cs b/src/Utilities/Compiler/Lightup/OperationWrapperHelper.cs index 289ed6ee0e..bbc6af2065 100644 --- a/src/Utilities/Compiler/Lightup/OperationWrapperHelper.cs +++ b/src/Utilities/Compiler/Lightup/OperationWrapperHelper.cs @@ -15,7 +15,8 @@ internal static class OperationWrapperHelper private static readonly ImmutableDictionary WrappedTypes = ImmutableDictionary.Create() .Add(typeof(IUsingDeclarationOperationWrapper), s_codeAnalysisAssembly.GetType(IUsingDeclarationOperationWrapper.WrappedTypeName)) - .Add(typeof(IFunctionPointerInvocationOperationWrapper), s_codeAnalysisAssembly.GetType(IFunctionPointerInvocationOperationWrapper.WrappedTypeName)); + .Add(typeof(IFunctionPointerInvocationOperationWrapper), s_codeAnalysisAssembly.GetType(IFunctionPointerInvocationOperationWrapper.WrappedTypeName)) + .Add(typeof(INegatedPatternOperationWrapper), s_codeAnalysisAssembly.GetType(INegatedPatternOperationWrapper.WrappedTypeName)); /// /// Gets the type that is wrapped by the given wrapper. diff --git a/src/Utilities/Compiler/PooledObjects/PooledConcurrentSet.cs b/src/Utilities/Compiler/PooledObjects/PooledConcurrentSet.cs index 652bfa7729..6b5b4c9dc7 100644 --- a/src/Utilities/Compiler/PooledObjects/PooledConcurrentSet.cs +++ b/src/Utilities/Compiler/PooledObjects/PooledConcurrentSet.cs @@ -137,7 +137,7 @@ void ICollection.Add(T item) } #pragma warning disable CA1815 // Override equals and operator equals on value types - public struct KeyEnumerator + public readonly struct KeyEnumerator #pragma warning restore CA1815 // Override equals and operator equals on value types { private readonly IEnumerator> _kvpEnumerator; diff --git a/src/Utilities/Compiler/RoslynString.cs b/src/Utilities/Compiler/RoslynString.cs index 4c55fca58c..ec18966bda 100644 --- a/src/Utilities/Compiler/RoslynString.cs +++ b/src/Utilities/Compiler/RoslynString.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. -#nullable enable - using System.Diagnostics.CodeAnalysis; namespace Analyzer.Utilities diff --git a/src/Utilities/Compiler/SmallDictionary.cs b/src/Utilities/Compiler/SmallDictionary.cs index 7cb32a837d..dd66bcd4f8 100644 --- a/src/Utilities/Compiler/SmallDictionary.cs +++ b/src/Utilities/Compiler/SmallDictionary.cs @@ -611,7 +611,7 @@ private void AddNode(AvlNode node, AvlNode? parent, K key, V value) public KeyCollection Keys => new(this); #pragma warning disable CA1815 // Override equals and operator equals on value types - internal struct KeyCollection : IEnumerable + internal readonly struct KeyCollection : IEnumerable { private readonly SmallDictionary _dict; @@ -727,7 +727,7 @@ IEnumerator IEnumerable.GetEnumerator() public ValueCollection Values => new(this); - internal struct ValueCollection : IEnumerable + internal readonly struct ValueCollection : IEnumerable { private readonly SmallDictionary _dict; diff --git a/src/Utilities/Compiler/WellKnownTypeNames.cs b/src/Utilities/Compiler/WellKnownTypeNames.cs index 016c1f1f5c..fdbfca0d8d 100644 --- a/src/Utilities/Compiler/WellKnownTypeNames.cs +++ b/src/Utilities/Compiler/WellKnownTypeNames.cs @@ -197,6 +197,7 @@ internal static class WellKnownTypeNames public const string SystemDateTimeOffset = "System.DateTimeOffset"; public const string SystemDecimal = "System.Decimal"; public const string SystemDiagnosticContractsContract = "System.Diagnostics.Contracts.Contract"; + public const string SystemDiagnosticsCodeAnalysisConstantExpectedAttribute = "System.Diagnostics.CodeAnalysis.ConstantExpectedAttribute"; public const string SystemDiagnosticsCodeAnalysisNotNullAttribute = "System.Diagnostics.CodeAnalysis.NotNullAttribute"; public const string SystemDiagnosticsConditionalAttribute = "System.Diagnostics.ConditionalAttribute"; public const string SystemDiagnosticsContractsPureAttribute = "System.Diagnostics.Contracts.PureAttribute"; diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs index 3ac48ff7ce..dca93888c8 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs @@ -90,29 +90,9 @@ protected override DisposeAbstractValue HandleInstanceCreation(IOperation creati return defaultValue; } - // Special case: Do not track System.Threading.Tasks.Task as you are not required to dispose them. - if (TaskNamedType != null && - instanceType.DerivesFrom(TaskNamedType, baseTypesOnly: true)) - { - return defaultValue; - } - - // StringReader doesn't need to be disposed: https://learn.microsoft.com/en-us/dotnet/api/system.io.stringreader?view=netframework-4.8 - if (StringReaderType != null && - instanceType.Equals(StringReaderType)) - { - return defaultValue; - } - - // Special case: MemoryStream doesn't need to be disposed. Subclasses *might* need to be disposed, but that is the less common case, and the common case is a huge source of noisy warnings. - if (MemoryStreamNamedType != null && - instanceType.Equals(MemoryStreamNamedType)) - { - return defaultValue; - } - - // Handle user option for additional excluded types - if (DataFlowAnalysisContext.IsConfiguredToSkipAnalysis(instanceType)) + // Handle special cases where we don't want to track the type although we know + // it is disposable (user option, special types...) + if (DataFlowAnalysisContext.IsDisposableTypeNotRequiringToBeDisposed(instanceType)) { return defaultValue; } diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.cs index 57da6917da..78c10616ec 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.cs @@ -61,13 +61,19 @@ private DisposeAnalysis(DisposeAnalysisDomain analysisDomain, DisposeDataFlowOpe rule, owningSymbol, wellKnownTypeProvider.Compilation, defaultValue: defaultDisposeOwnershipTransferAtConstructor); var disposeOwnershipTransferAtMethodCall = analyzerOptions.GetDisposeOwnershipTransferAtMethodCall( rule, owningSymbol, wellKnownTypeProvider.Compilation, defaultValue: defaultDisposeOwnershipTransferAtMethodCall); - return TryGetOrComputeResult(cfg, owningSymbol, analyzerOptions, wellKnownTypeProvider, - interproceduralAnalysisConfig, interproceduralAnalysisPredicate, - disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor, + + _ = DisposeAnalysisHelper.TryGetOrCreate(wellKnownTypeProvider.Compilation, out var disposeAnalysisHelper); + + return TryGetOrComputeResult(cfg, owningSymbol, analyzerOptions, wellKnownTypeProvider, interproceduralAnalysisConfig, + interproceduralAnalysisPredicate, disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor, disposeOwnershipTransferAtMethodCall, trackInstanceFields, exceptionPathsAnalysis, - pointsToAnalysisKind: analyzerOptions.GetPointsToAnalysisKindOption(rule, owningSymbol, wellKnownTypeProvider.Compilation, defaultPointsToAnalysisKind), - performCopyAnalysis: analyzerOptions.GetCopyAnalysisOption(rule, owningSymbol, wellKnownTypeProvider.Compilation, defaultValue: performCopyAnalysisIfNotUserConfigured), - isConfiguredToSkipAnalysis: (ISymbol symbol) => analyzerOptions.IsConfiguredToSkipAnalysis(rule, symbol, owningSymbol, wellKnownTypeProvider.Compilation), + pointsToAnalysisKind: analyzerOptions.GetPointsToAnalysisKindOption(rule, owningSymbol, wellKnownTypeProvider.Compilation, + defaultPointsToAnalysisKind), + performCopyAnalysis: analyzerOptions.GetCopyAnalysisOption(rule, owningSymbol, wellKnownTypeProvider.Compilation, + defaultValue: performCopyAnalysisIfNotUserConfigured), + isDisposableTypeNotRequiringToBeDisposed: (ITypeSymbol typeSymbol) => + disposeAnalysisHelper?.IsDisposableTypeNotRequiringToBeDisposed(typeSymbol) == true + || analyzerOptions.IsConfiguredToSkipAnalysis(rule, typeSymbol, owningSymbol, wellKnownTypeProvider.Compilation), out pointsToAnalysisResult); } @@ -85,7 +91,7 @@ private DisposeAnalysis(DisposeAnalysisDomain analysisDomain, DisposeDataFlowOpe bool exceptionPathsAnalysis, PointsToAnalysisKind pointsToAnalysisKind, bool performCopyAnalysis, - Func isConfiguredToSkipAnalysis, + Func isDisposableTypeNotRequiringToBeDisposed, out PointsToAnalysisResult? pointsToAnalysisResult) { Debug.Assert(wellKnownTypeProvider.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemIDisposable, out _)); @@ -99,9 +105,10 @@ private DisposeAnalysis(DisposeAnalysisDomain analysisDomain, DisposeDataFlowOpe } var analysisContext = DisposeAnalysisContext.Create( - DisposeAbstractValueDomain.Default, wellKnownTypeProvider, cfg, owningSymbol, analyzerOptions, interproceduralAnalysisConfig, interproceduralAnalysisPredicate, - PessimisticAnalysis, exceptionPathsAnalysis, pointsToAnalysisResult, TryGetOrComputeResultForAnalysisContext, - disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor, disposeOwnershipTransferAtMethodCall, trackInstanceFields, isConfiguredToSkipAnalysis); + DisposeAbstractValueDomain.Default, wellKnownTypeProvider, cfg, owningSymbol, analyzerOptions, interproceduralAnalysisConfig, + interproceduralAnalysisPredicate, PessimisticAnalysis, exceptionPathsAnalysis, pointsToAnalysisResult, + TryGetOrComputeResultForAnalysisContext, disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor, + disposeOwnershipTransferAtMethodCall, trackInstanceFields, isDisposableTypeNotRequiringToBeDisposed); return TryGetOrComputeResultForAnalysisContext(analysisContext); } diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs index b7f6c6a736..a15b0df064 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs @@ -39,7 +39,7 @@ private DisposeAnalysisContext( ControlFlowGraph? parentControlFlowGraph, InterproceduralDisposeAnalysisData? interproceduralAnalysisData, InterproceduralAnalysisPredicate? interproceduralAnalysisPredicate, - Func isConfiguredToSkipAnalysis) + Func isDisposableTypeNotRequiringToBeDisposed) : base(valueDomain, wellKnownTypeProvider, controlFlowGraph, owningSymbol, analyzerOptions, interproceduralAnalysisConfig, pessimisticAnalysis, predicateAnalysis: false, @@ -56,7 +56,7 @@ private DisposeAnalysisContext( DisposeOwnershipTransferAtConstructor = disposeOwnershipTransferAtConstructor; DisposeOwnershipTransferAtMethodCall = disposeOwnershipTransferAtMethodCall; TrackInstanceFields = trackInstanceFields; - IsConfiguredToSkipAnalysis = isConfiguredToSkipAnalysis; + IsDisposableTypeNotRequiringToBeDisposed = isDisposableTypeNotRequiringToBeDisposed; } internal static DisposeAnalysisContext Create( @@ -75,7 +75,7 @@ internal static DisposeAnalysisContext Create( bool disposeOwnershipTransferAtConstructor, bool disposeOwnershipTransferAtMethodCall, bool trackInstanceFields, - Func isConfiguredToSkipAnalysis) + Func isDisposableTypeNotRequiringToBeDisposed) { return new DisposeAnalysisContext( valueDomain, wellKnownTypeProvider, controlFlowGraph, @@ -83,7 +83,7 @@ internal static DisposeAnalysisContext Create( exceptionPathsAnalysis, pointsToAnalysisResult, tryGetOrComputeAnalysisResult, disposeOwnershipTransferLikelyTypes, disposeOwnershipTransferAtConstructor, disposeOwnershipTransferAtMethodCall, trackInstanceFields, parentControlFlowGraph: null, interproceduralAnalysisData: null, - interproceduralAnalysisPredicate, isConfiguredToSkipAnalysis); + interproceduralAnalysisPredicate, isDisposableTypeNotRequiringToBeDisposed); } public override DisposeAnalysisContext ForkForInterproceduralAnalysis( @@ -100,14 +100,14 @@ public override DisposeAnalysisContext ForkForInterproceduralAnalysis( return new DisposeAnalysisContext(ValueDomain, WellKnownTypeProvider, invokedCfg, invokedMethod, AnalyzerOptions, InterproceduralAnalysisConfiguration, PessimisticAnalysis, ExceptionPathsAnalysis, pointsToAnalysisResult, TryGetOrComputeAnalysisResult, DisposeOwnershipTransferLikelyTypes, DisposeOwnershipTransferAtConstructor, - DisposeOwnershipTransferAtMethodCall, TrackInstanceFields, ControlFlowGraph, interproceduralAnalysisData, InterproceduralAnalysisPredicate, IsConfiguredToSkipAnalysis); + DisposeOwnershipTransferAtMethodCall, TrackInstanceFields, ControlFlowGraph, interproceduralAnalysisData, InterproceduralAnalysisPredicate, IsDisposableTypeNotRequiringToBeDisposed); } internal ImmutableHashSet DisposeOwnershipTransferLikelyTypes { get; } internal bool DisposeOwnershipTransferAtConstructor { get; } internal bool DisposeOwnershipTransferAtMethodCall { get; } internal bool TrackInstanceFields { get; } - internal Func IsConfiguredToSkipAnalysis { get; } + internal Func IsDisposableTypeNotRequiringToBeDisposed { get; } protected override void ComputeHashCodePartsSpecific(ref RoslynHashCode hashCode) { diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisHelper.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisHelper.cs index 9e69dcbbc3..b9fceb1726 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisHelper.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisHelper.cs @@ -44,6 +44,8 @@ internal sealed class DisposeAnalysisHelper public INamedTypeSymbol? IAsyncDisposable { get; } public INamedTypeSymbol? Task { get; } public INamedTypeSymbol? ValueTask { get; } + public INamedTypeSymbol? StringReader { get; } + public INamedTypeSymbol? MemoryStream { get; } private DisposeAnalysisHelper(Compilation compilation) { @@ -53,6 +55,8 @@ private DisposeAnalysisHelper(Compilation compilation) IAsyncDisposable = _wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemIAsyncDisposable); Task = _wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemThreadingTasksTask); ValueTask = _wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemThreadingTasksValueTask); + StringReader = _wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemIOStringReader); + MemoryStream = _wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemIOMemoryStream); _disposeOwnershipTransferLikelyTypes = IDisposable != null ? GetDisposeOwnershipTransferLikelyTypes(compilation) : @@ -145,6 +149,16 @@ public bool HasAnyDisposableCreationDescendant(ImmutableArray operat HasDisposableOwnershipTransferForConstructorParameter(containingMethod); } + public bool IsDisposableTypeNotRequiringToBeDisposed(ITypeSymbol typeSymbol) => + // Common case doesn't require dispose. https://learn.microsoft.com/dotnet/api/system.threading.tasks.task.dispose + typeSymbol.DerivesFrom(Task, baseTypesOnly: true) || + // StringReader doesn't need to be disposed: https://learn.microsoft.com/dotnet/api/system.io.stringreader + SymbolEqualityComparer.Default.Equals(typeSymbol, StringReader) || + // MemoryStream doesn't need to be disposed. https://learn.microsoft.com/dotnet/api/system.io.memorystream + // Subclasses *might* need to be disposed, but that is the less common case, + // and the common case is a huge source of noisy warnings. + SymbolEqualityComparer.Default.Equals(typeSymbol, MemoryStream); + public ImmutableHashSet GetDisposableFields(INamedTypeSymbol namedType) { EnsureDisposableFieldsMap(); @@ -163,7 +177,7 @@ public ImmutableHashSet GetDisposableFields(INamedTypeSymbol named { disposableFields = namedType.GetMembers() .OfType() - .Where(f => IsDisposable(f.Type) && !f.Type.DerivesFrom(Task)) + .Where(f => IsDisposable(f.Type) && !IsDisposableTypeNotRequiringToBeDisposed(f.Type)) .ToImmutableHashSet(); } diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs index 97569b3a8d..a4e7bc7e14 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs @@ -8,6 +8,7 @@ using System.Linq; using Analyzer.Utilities; using Analyzer.Utilities.Extensions; +using Analyzer.Utilities.Lightup; using Analyzer.Utilities.PooledObjects; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; @@ -1260,29 +1261,33 @@ private bool TryInferConversion( } // Handle is pattern operations with constant pattern. - if (operation is IIsPatternOperation patternOperation && - patternOperation.Pattern is IConstantPatternOperation constantPattern) + if (operation is IIsPatternOperation isPatternOperation) { - if (constantPattern.Value.ConstantValue.HasValue) + IPatternOperation patternOperation = isPatternOperation.Pattern; + bool direct = true; + + if (INegatedPatternOperationWrapper.IsInstance(patternOperation)) { - if (constantPattern.Value.ConstantValue.Value == null) + INegatedPatternOperationWrapper negatedPattern = INegatedPatternOperationWrapper.FromOperation(patternOperation); + patternOperation = negatedPattern.Pattern; + direct = false; + } + + if (patternOperation is IConstantPatternOperation { Value.ConstantValue: { HasValue: true, Value: null } }) + { + switch (pointsToValue.NullState) { - switch (pointsToValue.NullState) - { - case NullAbstractValue.Null: - inference.AlwaysSucceed = true; - break; + case NullAbstractValue.Null: + inference.AlwaysSucceed = direct; + break; - case NullAbstractValue.NotNull: - inference.AlwaysFail = true; - break; - } + case NullAbstractValue.NotNull: + inference.AlwaysFail = direct; + break; } return true; } - - return false; } if (targetType == null) diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralCaptureId.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralCaptureId.cs index 6967351fec..6ed08f47eb 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralCaptureId.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralCaptureId.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow /// This type essentially wraps each , which is unique for each control flow graph, /// with its owning . /// - public struct InterproceduralCaptureId : IEquatable + public readonly struct InterproceduralCaptureId : IEquatable { internal InterproceduralCaptureId(CaptureId captureId, ControlFlowGraph controlFlowGraph, bool isLValueFlowCapture) {