From 25358070ce2e991daa12544b3987c7c51c2dfbd0 Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Tue, 5 Sep 2023 15:28:30 -0700 Subject: [PATCH 1/3] Remove CA2229 Implement serialization constructors --- ...mentSerializationMethodsCorrectly.Fixer.cs | 17 - ...pImplementSerializationMethodsCorrectly.cs | 16 - .../Core/AnalyzerReleases.Unshipped.md | 1 + .../MicrosoftNetCoreAnalyzersResources.resx | 66 --- ...mplementSerializationConstructors.Fixer.cs | 107 ----- ...mentSerializationMethodsCorrectly.Fixer.cs | 29 -- .../ImplementSerializationMethodsCorrectly.cs | 87 ---- .../SerializationRulesDiagnosticAnalyzer.cs | 88 +--- .../MicrosoftNetCoreAnalyzersResources.cs.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.de.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.es.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.fr.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.it.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.ja.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.ko.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.pl.xlf | 110 ----- ...crosoftNetCoreAnalyzersResources.pt-BR.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.ru.xlf | 110 ----- .../MicrosoftNetCoreAnalyzersResources.tr.xlf | 110 ----- ...osoftNetCoreAnalyzersResources.zh-Hans.xlf | 110 ----- ...osoftNetCoreAnalyzersResources.zh-Hant.xlf | 110 ----- .../Microsoft.CodeAnalysis.NetAnalyzers.md | 12 - .../Microsoft.CodeAnalysis.NetAnalyzers.sarif | 21 - .../ImplementISerializableCorrectlyTests.cs | 8 - ...entSerializationConstructorsTests.Fixer.cs | 244 ----------- ...ImplementSerializationConstructorsTests.cs | 388 ------------------ ...ementSerializationMethodsCorrectlyTests.cs | 8 - ...lizableTypesWithSerializableTests.Fixer.cs | 22 - ...ISerializableTypesWithSerializableTests.cs | 65 --- ...mentSerializationMethodsCorrectly.Fixer.vb | 17 - ...cImplementSerializationMethodsCorrectly.vb | 16 - 31 files changed, 3 insertions(+), 2639 deletions(-) delete mode 100644 src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.Fixer.cs delete mode 100644 src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.cs delete mode 100644 src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructors.Fixer.cs delete mode 100644 src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.Fixer.cs delete mode 100644 src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.cs delete mode 100644 src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectlyTests.cs delete mode 100644 src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.Fixer.cs delete mode 100644 src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.cs delete mode 100644 src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectlyTests.cs delete mode 100644 src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.Fixer.vb delete mode 100644 src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.vb diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.Fixer.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.Fixer.cs deleted file mode 100644 index 64afa6bbf0..0000000000 --- a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.Fixer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Composition; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.NetCore.Analyzers.Runtime; - -namespace Microsoft.NetCore.CSharp.Analyzers.Runtime -{ - /// - /// CA2238: Implement serialization methods correctly - /// - [ExportCodeFixProvider(LanguageNames.CSharp), Shared] - public class CSharpImplementSerializationMethodsCorrectlyFixer : ImplementSerializationMethodsCorrectlyFixer - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.cs deleted file mode 100644 index 115c57c8a8..0000000000 --- a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementSerializationMethodsCorrectly.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.NetCore.Analyzers.Runtime; - -namespace Microsoft.NetCore.CSharp.Analyzers.Runtime -{ - /// - /// CA2238: Implement serialization methods correctly - /// - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public sealed class CSharpImplementSerializationMethodsCorrectlyAnalyzer : ImplementSerializationMethodsCorrectlyAnalyzer - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md index a4b1a7ebbd..5a88cc2d89 100644 --- a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md +++ b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md @@ -30,3 +30,4 @@ CA2021 | Reliability | Warning | DoNotCallEnumerableCastOrOfTypeWithIncompatible Rule ID | Category | Severity | Notes --------|----------|----------|------- CA2109 | Security | Disabled | ReviewVisibleEventHandlersAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2109) +CA2229 | Usage | Hidden | SerializationRulesDiagnosticAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2229) diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx index f5c67ef4e1..72017396c9 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx @@ -473,24 +473,6 @@ Add Serializable attribute - - Implement Serialization constructor - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - Declare the serialization constructor of {0}, a sealed type, as private. - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - - - Implement serialization constructors - An instance field of a type that is not serializable is declared in a type that is serializable. @@ -509,54 +491,6 @@ Mark ISerializable types with serializable - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - - - Add an implementation of GetObjectData to type {0} - - - Make {0}.GetObjectData virtual and overridable - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - - - Implement ISerializable correctly - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - - - Implement serialization methods correctly - - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - - - Provide deserialization methods for optional fields - Potential SQL injection vulnerability was found where '{0}' in method '{1}' may be tainted by user-controlled data from '{2}' in method '{3}'. diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructors.Fixer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructors.Fixer.cs deleted file mode 100644 index 4ce178c676..0000000000 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructors.Fixer.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Collections.Immutable; -using System.Composition; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Editing; -using Analyzer.Utilities; -using Analyzer.Utilities.Extensions; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; - -namespace Microsoft.NetCore.Analyzers.Runtime -{ - /// - /// CA2229: Implement serialization constructors. - /// - [ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic, Name = "CA2229 CodeFix provider"), Shared] - public sealed class ImplementSerializationConstructorsFixer : CodeFixProvider - { - public sealed override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(SerializationRulesDiagnosticAnalyzer.RuleCA2229Id); - - public override async Task RegisterCodeFixesAsync(CodeFixContext context) - { - SyntaxNode root = await context.Document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); - SyntaxNode node = root.FindNode(context.Span); - SemanticModel model = await context.Document.GetRequiredSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); - ISymbol? symbol = model.GetDeclaredSymbol(node, context.CancellationToken); - - if (symbol == null) - { - return; - } - - INamedTypeSymbol? notImplementedExceptionType = model.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemNotImplementedException); - if (notImplementedExceptionType == null) - { - return; - } - - // There was no constructor and so the diagnostic was on the type. Generate a serialization ctor. - string title = MicrosoftNetCoreAnalyzersResources.ImplementSerializationConstructorsCodeActionTitle; - if (symbol.Kind == SymbolKind.NamedType) - { - context.RegisterCodeFix(CodeAction.Create(title, - async ct => await GenerateConstructorAsync(context.Document, node, (INamedTypeSymbol)symbol, notImplementedExceptionType, ct).ConfigureAwait(false), - equivalenceKey: title), - context.Diagnostics); - } - // There is a serialization constructor but with incorrect accessibility. Set that right. - else if (symbol.Kind == SymbolKind.Method) - { - context.RegisterCodeFix(CodeAction.Create(title, - async ct => await SetAccessibilityAsync(context.Document, (IMethodSymbol)symbol, ct).ConfigureAwait(false), - equivalenceKey: title), - context.Diagnostics); - } - } - - private static async Task GenerateConstructorAsync(Document document, SyntaxNode node, INamedTypeSymbol typeSymbol, INamedTypeSymbol notImplementedExceptionType, CancellationToken cancellationToken) - { - SymbolEditor editor = SymbolEditor.Create(document); - - await editor.EditOneDeclarationAsync(typeSymbol, node.GetLocation(), (docEditor, declaration) => - { - SyntaxGenerator generator = docEditor.Generator; - SyntaxNode throwStatement = generator.ThrowStatement(generator.ObjectCreationExpression(generator.TypeExpression(notImplementedExceptionType))); - SyntaxNode ctorDecl = generator.ConstructorDeclaration( - typeSymbol.Name, - new[] - { - generator.ParameterDeclaration("serializationInfo", generator.TypeExpression(docEditor.SemanticModel.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemRuntimeSerializationSerializationInfo))), - generator.ParameterDeclaration("streamingContext", generator.TypeExpression(docEditor.SemanticModel.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemRuntimeSerializationStreamingContext))) - }, - typeSymbol.IsSealed ? Accessibility.Private : Accessibility.Protected, - statements: new[] { throwStatement }); - - docEditor.AddMember(declaration, ctorDecl); - }, cancellationToken).ConfigureAwait(false); - - return editor.GetChangedDocuments().First(); - } - - private static async Task SetAccessibilityAsync(Document document, IMethodSymbol methodSymbol, CancellationToken cancellationToken) - { - SymbolEditor editor = SymbolEditor.Create(document); - - // This would be constructor and can have only one definition. - Debug.Assert(methodSymbol.IsConstructor() && methodSymbol.DeclaringSyntaxReferences.HasExactly(1)); - await editor.EditOneDeclarationAsync(methodSymbol, (docEditor, declaration) => - { - Accessibility newAccessibility = methodSymbol.ContainingType.IsSealed ? Accessibility.Private : Accessibility.Protected; - docEditor.SetAccessibility(declaration, newAccessibility); - }, cancellationToken).ConfigureAwait(false); - - return editor.GetChangedDocuments().First(); - } - - public override FixAllProvider GetFixAllProvider() - { - return WellKnownFixAllProviders.BatchFixer; - } - } -} diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.Fixer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.Fixer.cs deleted file mode 100644 index 1d27f765dc..0000000000 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.Fixer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis.CodeFixes; -using System.Collections.Immutable; -using System.Threading.Tasks; - -namespace Microsoft.NetCore.Analyzers.Runtime -{ - /// - /// CA2238: Implement serialization methods correctly - /// - public abstract class ImplementSerializationMethodsCorrectlyFixer : CodeFixProvider - { - public sealed override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Empty; - - public sealed override FixAllProvider GetFixAllProvider() - { - // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for more information on Fix All Providers - return WellKnownFixAllProviders.BatchFixer; - } - - public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) - { - // Fixer not yet implemented. - return Task.CompletedTask; - - } - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.cs deleted file mode 100644 index 0a926ffdf5..0000000000 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectly.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Collections.Immutable; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace Microsoft.NetCore.Analyzers.Runtime -{ - /// - /// CA2238: Implement serialization methods correctly - /// - public abstract class ImplementSerializationMethodsCorrectlyAnalyzer : DiagnosticAnalyzer - { - internal const string RuleId = "CA2238"; - - /*private static readonly LocalizableString s_localizableTitle = CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyTitle)); - private static readonly LocalizableString s_localizableDescription = CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyDescription)); - - internal static readonly DiagnosticDescriptor VisibilityRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyMessageVisibility)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor ReturnTypeRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyMessageReturnType)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor ParametersRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyMessageParameters)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor GenericRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyMessageGeneric)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor StaticRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementSerializationMethodsCorrectlyMessageStatic)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false);*/ - - public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Empty; - //DiagnosticHelpers.EnabledByDefaultIfNotBuildingVSIX ? ImmutableArray.Create(VisibilityRule, ReturnTypeRule, ParametersRule, GenericRule, StaticRule) : ImmutableArray.Empty; - -#pragma warning disable RS1025 // Configure generated code analysis - public override void Initialize(AnalysisContext context) -#pragma warning restore RS1025 // Configure generated code analysis - { - context.EnableConcurrentExecution(); - - // TODO: Configure generated code analysis. - //analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); - } - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs index 5fadcebd5c..d455163d69 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SerializationRulesDiagnosticAnalyzer.cs @@ -12,49 +12,12 @@ namespace Microsoft.NetCore.Analyzers.Runtime using static MicrosoftNetCoreAnalyzersResources; /// - /// CA2229: /// CA2237: /// CA2235: /// [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SerializationRulesDiagnosticAnalyzer : DiagnosticAnalyzer { - // Implement serialization constructors - internal const string RuleCA2229Id = "CA2229"; - - private static readonly LocalizableString s_localizableTitleCA2229 = CreateLocalizableResourceString(nameof(ImplementSerializationConstructorsTitle)); - private static readonly LocalizableString s_localizableDescriptionCA2229 = CreateLocalizableResourceString(nameof(ImplementSerializationConstructorsDescription)); - - internal static readonly DiagnosticDescriptor RuleCA2229Default = DiagnosticDescriptorHelper.Create( - RuleCA2229Id, - s_localizableTitleCA2229, - ImplementSerializationConstructorsMessageCreateMagicConstructor, - DiagnosticCategory.Usage, - RuleLevel.IdeHidden_BulkConfigurable, - description: s_localizableDescriptionCA2229, - isPortedFxCopRule: true, - isDataflowRule: false); - - internal static readonly DiagnosticDescriptor RuleCA2229Sealed = DiagnosticDescriptorHelper.Create( - RuleCA2229Id, - s_localizableTitleCA2229, - ImplementSerializationConstructorsMessageMakeSealedMagicConstructorPrivate, - DiagnosticCategory.Usage, - RuleLevel.IdeHidden_BulkConfigurable, - description: s_localizableDescriptionCA2229, - isPortedFxCopRule: true, - isDataflowRule: false); - - internal static readonly DiagnosticDescriptor RuleCA2229Unsealed = DiagnosticDescriptorHelper.Create( - RuleCA2229Id, - s_localizableTitleCA2229, - ImplementSerializationConstructorsMessageMakeUnsealedMagicConstructorFamily, - DiagnosticCategory.Usage, - RuleLevel.IdeHidden_BulkConfigurable, - description: s_localizableDescriptionCA2229, - isPortedFxCopRule: true, - isDataflowRule: false); - // Mark ISerializable types with SerializableAttribute internal const string RuleCA2237Id = "CA2237"; @@ -81,7 +44,7 @@ public sealed class SerializationRulesDiagnosticAnalyzer : DiagnosticAnalyzer isPortedFxCopRule: true, isDataflowRule: false); - public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(RuleCA2229Default, RuleCA2229Sealed, RuleCA2229Unsealed, RuleCA2235, RuleCA2237); + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(RuleCA2235, RuleCA2237); public override void Initialize(AnalysisContext context) { @@ -97,18 +60,6 @@ public override void Initialize(AnalysisContext context) return; } - INamedTypeSymbol? serializationInfoTypeSymbol = context.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemRuntimeSerializationSerializationInfo); - if (serializationInfoTypeSymbol == null) - { - return; - } - - INamedTypeSymbol? streamingContextTypeSymbol = context.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemRuntimeSerializationStreamingContext); - if (streamingContextTypeSymbol == null) - { - return; - } - INamedTypeSymbol? serializableAttributeTypeSymbol = context.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemSerializableAttribute); if (serializableAttributeTypeSymbol == null) { @@ -123,7 +74,7 @@ public override void Initialize(AnalysisContext context) var isNetStandardAssembly = !context.Compilation.TargetsDotNetFramework(); - var symbolAnalyzer = new SymbolAnalyzer(iserializableTypeSymbol, serializationInfoTypeSymbol, streamingContextTypeSymbol, serializableAttributeTypeSymbol, nonSerializedAttributeTypeSymbol, isNetStandardAssembly); + var symbolAnalyzer = new SymbolAnalyzer(iserializableTypeSymbol, serializableAttributeTypeSymbol, nonSerializedAttributeTypeSymbol, isNetStandardAssembly); context.RegisterSymbolAction(symbolAnalyzer.AnalyzeSymbol, SymbolKind.NamedType); }); } @@ -131,23 +82,17 @@ public override void Initialize(AnalysisContext context) private sealed class SymbolAnalyzer { private readonly INamedTypeSymbol _iserializableTypeSymbol; - private readonly INamedTypeSymbol _serializationInfoTypeSymbol; - private readonly INamedTypeSymbol _streamingContextTypeSymbol; private readonly INamedTypeSymbol _serializableAttributeTypeSymbol; private readonly INamedTypeSymbol _nonSerializedAttributeTypeSymbol; private readonly bool _isNetStandardAssembly; public SymbolAnalyzer( INamedTypeSymbol iserializableTypeSymbol, - INamedTypeSymbol serializationInfoTypeSymbol, - INamedTypeSymbol streamingContextTypeSymbol, INamedTypeSymbol serializableAttributeTypeSymbol, INamedTypeSymbol nonSerializedAttributeTypeSymbol, bool isNetStandardAssembly) { _iserializableTypeSymbol = iserializableTypeSymbol; - _serializationInfoTypeSymbol = serializationInfoTypeSymbol; - _streamingContextTypeSymbol = streamingContextTypeSymbol; _serializableAttributeTypeSymbol = serializableAttributeTypeSymbol; _nonSerializedAttributeTypeSymbol = nonSerializedAttributeTypeSymbol; _isNetStandardAssembly = isNetStandardAssembly; @@ -177,35 +122,6 @@ public void AnalyzeSymbol(SymbolAnalysisContext context) context.ReportDiagnostic(namedTypeSymbol.CreateDiagnostic(RuleCA2237, namedTypeSymbol.Name)); } } - else - { - // Look for a serialization constructor. - // A serialization constructor takes two params of type SerializationInfo and StreamingContext. - IMethodSymbol? serializationCtor = namedTypeSymbol.Constructors - .FirstOrDefault(c => c.IsSerializationConstructor(_serializationInfoTypeSymbol, _streamingContextTypeSymbol)); - - // There is no serialization ctor - issue a diagnostic. - if (serializationCtor == null) - { - context.ReportDiagnostic(namedTypeSymbol.CreateDiagnostic(RuleCA2229Default, namedTypeSymbol.Name)); - } - else - { - // Check the accessibility - // The serialization ctor should be protected if the class is unsealed and private if the class is sealed. - if (namedTypeSymbol.IsSealed && - serializationCtor.DeclaredAccessibility != Accessibility.Private) - { - context.ReportDiagnostic(serializationCtor.CreateDiagnostic(RuleCA2229Sealed, namedTypeSymbol.Name)); - } - - if (!namedTypeSymbol.IsSealed && - serializationCtor.DeclaredAccessibility != Accessibility.Protected) - { - context.ReportDiagnostic(serializationCtor.CreateDiagnostic(RuleCA2229Unsealed, namedTypeSymbol.Name)); - } - } - } } // If this is type is marked Serializable and doesn't implement ISerializable, check its fields' types as well 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 137ae94cef..43d310dde9 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf @@ -1333,101 +1333,11 @@ Obecné přetypování (IL unbox.any) používané sekvencí vrácenou metodou E Použít správný parametr typu - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Pokud chcete porušení tohoto pravidla opravit, nastavte metodu GetObjectData jako viditelnou a přepsatelnou a ujistěte se, že všechna pole instance jsou součástí procesu serializace nebo explicitně označená atributem NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Přidejte implementaci GetObjectData k typu {0}. - - - - Make {0}.GetObjectData virtual and overridable - Učiňte {0}.GetObjectData virtuální a přepisovatelnou. - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Zvýšit přístupnost {0}.GetObjectData tak, že je viditelná pro odvozené typy. - - - - Implement ISerializable correctly - Implementujte správně ISerializable - - Implement inherited interfaces Implementace zděděných rozhraní - - Implement Serialization constructor - Naimplementovat konstruktor Serialization - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Pokud chcete porušení tohoto pravidla opravit, naimplementujte serializační konstruktor. Pro zapečetěné třídy nastavte konstruktor jako private, jinak jako protected. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Přidejte konstruktor k {0} s následující signaturou: 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Deklarujte serializační konstruktor {0}, zapečetěný typ, jako soukromý. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Deklarujte serializační konstruktor {0}, zapečetěný typ, jako chráněný. - - - - Implement serialization constructors - Implementovat serializační konstruktory - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Metoda, která zpracovává událost serializace, nemá správnou signaturu, návratový typ nebo viditelnost. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Protože {0} je označená pomocí OnSerializing, OnSerialized, OnDeserializing nebo OnDeserialized, změňte její signaturu tak, že již není nadále obecná. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Protože {0} je označená pomocí OnSerializing, OnSerialized, OnDeserializing nebo OnDeserialized, změňte její signaturu tak, že vyžaduje jeden parametr typu 'System.Runtime.Serialization.StreamingContext'. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Protože {0} je označená pomocí OnSerializing, OnSerialized, OnDeserializing nebo OnDeserialized, změňte její návratový typ z {1} na void (Sub v jazyce Visual Basic). - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Protože {0} je označená pomocí OnSerializing, OnSerialized, OnDeserializing nebo OnDeserialized, změňte ji ze statické (sdílené v jazyce Visual Basic) na instanční metodu. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Protože {0} je označená pomocí OnSerializing, OnSerialized, OnDeserializing nebo OnDeserialized, změňte její přístupnost na soukromou. - - - - Implement serialization methods correctly - Implementujte správně metody serializace - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. {0} je implementuje rozhraní preview {1} a proto vyžaduje vyjádření výslovného souhlasu s funkcemi preview. Další informace najdete v {2}. @@ -2303,26 +2213,6 @@ Obecné přetypování (IL unbox.any) používané sekvencí vrácenou metodou E Poskytněte metodám formátování správné argumenty - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Typ má pole, které je označené atributem System.Runtime.Serialization.OptionalFieldAttribute, ale tento typ neposkytuje metody pro zpracování události deserializace. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Přidejte metodu 'private void OnDeserialized(StreamingContext)' k typu {0} a označte ji pomocí System.Runtime.Serialization.OnDeserializedAttribute. - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Přidejte metodu 'private void OnDeserializing(StreamingContext)' k typu {0} a označte ji pomocí System.Runtime.Serialization.OnDeserializingAttribute. - - - - Provide deserialization methods for optional fields - Poskytujte metody deserializace pro volitelné pole - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Poskytnutí konstruktoru bez parametrů, který je viditelný jako nadřazený typ pro typ odvozený od System.Runtime.InteropServices.SafeHandle, umožňuje lepší výkon a využití s řešeními spolupráce generovanými zdroji. 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 4f473ce27b..ff3b8f8b1c 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.de.xlf @@ -1333,101 +1333,11 @@ Erweiterungen und benutzerdefinierte Konvertierungen werden bei generischen Type Richtigen Typparameter verwenden - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Um einen Verstoß gegen diese Regel zu beheben, legen Sie die GetObjectData-Methode als sichtbar und überschreibbar fest, und stellen Sie sicher, dass alle Instanzfelder in den Serialisierungsvorgang eingeschlossen oder durch das NonSerializedAttribute-Attribut explizit markiert werden. - - - - Add an implementation of GetObjectData to type {0} - Fügen Sie Typ "{0}" eine Implementierung von "GetObjectData" hinzu. - - - - Make {0}.GetObjectData virtual and overridable - Markieren Sie "{0}.GetObjectData" als virtuell und überschreibbar. - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Vergrößern Sie den Zugriff auf "{0}.GetObjectData" für abgeleitete Typen als sichtbar. - - - - Implement ISerializable correctly - ISerializable ordnungsgemäß implementieren - - Implement inherited interfaces Geerbte Schnittstellen implementieren - - Implement Serialization constructor - Serialisierungskonstruktor implementieren - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Um einen Verstoß gegen diese Regel zu beheben, implementieren Sie den Serialisierungskonstruktor. Definieren Sie den Konstruktor bei einer versiegelten Klasse als privat und in anderen Fällen als geschützt. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Fügen Sie {0} einen Konstruktor mit der folgenden Signatur hinzu: "protected {0}(SerializationInfo info, StreamingContext context)". - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Deklarieren Sie den Serialisierungskonstruktor von {0} (versiegelter Typ) als privat. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Deklarieren Sie den Serialisierungskonstruktor von {0} (nicht versiegelter Typ) als geschützt. - - - - Implement serialization constructors - Serialisierungskonstruktoren implementieren - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Eine Methode, die ein Serialisierungsereignis behandelt, besitzt nicht die richtige Signatur, den richtigen Rückgabetyp oder die richtige Sichtbarkeit. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Da "{0}" mit "OnSerializing", "OnSerialized", "OnDeserializing" oder "OnDeserialized" markiert ist, ändern Sie die zugehörige Signatur so, dass sie nicht mehr generisch ist. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Da "{0}" mit "OnSerializing", "OnSerialized", "OnDeserializing" oder "OnDeserialized" markiert ist, ändern Sie die zugehörige Signatur so, dass ein einzelner Parameter vom Typ "System.Runtime.Serialization.StreamingContext" akzeptiert wird. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Da "{0}" mit "OnSerializing", "OnSerialized", "OnDeserializing" oder "OnDeserialized" markiert ist, ändern Sie dessen Rückgabetyp von "{1}" in "void" ("Sub" in Visual Basic). - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Da "{0}" mit "OnSerializing", "OnSerialized", "OnDeserializing" oder "OnDeserialized" markiert ist, nehmen Sie eine Änderung von "static" ("Shared" in Visual Basic) in eine Instanzmethode vor. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Da "{0}" mit "OnSerializing", "OnSerialized", "OnDeserializing" oder "OnDeserialized" markiert ist, ändern Sie den Zugriff in privat. - - - - Implement serialization methods correctly - Serialisierungsmethoden korrekt implementieren - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. „{0}“ implementiert die Vorschauschnittstelle „{1}“, daher müssen Vorschaufeatures abonniert werden. Weitere Informationen finden Sie unter {2}. @@ -2303,26 +2213,6 @@ Erweiterungen und benutzerdefinierte Konvertierungen werden bei generischen Type Geeignete Argumente für Formatierungsmethoden angeben - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Ein Typ weist ein Feld auf, das mit dem System.Runtime.Serialization.OptionalFieldAttribute-Attribut gekennzeichnet ist, und der Typ stellt keine Behandlungsmethoden für Deserialisierungsereignisse bereit. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Fügen Sie dem Typ "{0}" eine private Methode "void OnDeserialized(StreamingContext)" hinzu, und weisen Sie "System.Runtime.Serialization.OnDeserializedAttribute" zu. - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Fügen Sie dem Typ "{0}" eine Methode "private void OnDeserializing(StreamingContext)" hinzu, und weisen Sie "System.Runtime.Serialization.OnDeserializingAttribute" zu. - - - - Provide deserialization methods for optional fields - Deserialisierungsmethoden für optionale Felder angeben - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Indem Sie für einen von "System.Runtime.InteropServices.SafeHandle" abgeleiteten Typ einen parameterlosen Konstruktor bereitstellen, der ebenso sichtbar ist wie der enthaltende Typ, erzielen Sie eine bessere Leistung und Nutzung mit aus der Quelle generierten Interop-Lösungen. 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 60d7531526..913fb8f2e8 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.es.xlf @@ -1333,101 +1333,11 @@ La ampliación y las conversiones definidas por el usuario no se admiten con tip Use el parámetro de tipo correcto - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Para corregir una infracción de esta regla, haga que el método GetObjectData sea visible y se pueda reemplazar; además, asegúrese de que todos los campos de la instancia se incluyen en el proceso de serialización o se marcan explícitamente con el atributo NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Agregue una implementación de GetObjectData al tipo {0}. - - - - Make {0}.GetObjectData virtual and overridable - Hacer que {0}.GetObjectData sea virtual y reemplazable. - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Aumente la accesibilidad de {0}.GetObjectData para que esté visible para los tipos derivados. - - - - Implement ISerializable correctly - Implementar ISerializable correctamente - - Implement inherited interfaces Implementación de interfaces heredadas - - Implement Serialization constructor - Implementar un constructor de serialización - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Para corregir una infracción de esta regla, implemente el constructor de serialización. Para una clase sealed, convierta el constructor en privado; de lo contrario, haga que esté protegido. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Agregue un constructor a {0} con la siguiente signatura: 'información protegida de {0}(SerializationInfo, contexto de StreamingContext)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Declare el constructor de serialización de {0}, un tipo sellado, como privado. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Declare el constructor de serialización de {0}, un tipo no sellado, como protegido. - - - - Implement serialization constructors - Implementar constructores de serialización - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Un método que controla un evento de serialización no tiene la signatura, el tipo de valor devuelto o la visibilidad correctos. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Puesto que {0} está marcado con OnSerializing, OnSerialized, OnDeserializing u OnDeserialized, cambie su signatura para que deje de ser genérico. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Puesto que {0} está marcado con OnSerializing, OnSerialized, OnDeserializing u OnDeserialized, cambie su signatura para que tome un solo parámetro de tipo "System.Runtime.Serialization.StreamingContext". - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Puesto que {0} está marcado con OnSerializing, OnSerialized, OnDeserializing u OnDeserialized, cambie su tipo de datos devueltos de {1} a void (Sub en Visual Basic). - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Puesto que {0} está marcado con OnSerializing, OnSerialized, OnDeserializing u OnDeserialized, cámbielo de static (Shared en Visual Basic) a un método de instancia. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Puesto que {0} está marcado con OnSerializing, OnSerialized, OnDeserializing u OnDeserialized, cambie su accesibilidad a private. - - - - Implement serialization methods correctly - Implementar métodos de serialización correctamente - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}' implementa la interfaz de vista previa '{1}' y, por lo tanto, debe participar en las características en versión preliminar. Consulte {2} para obtener más información. @@ -2303,26 +2213,6 @@ La ampliación y las conversiones definidas por el usuario no se admiten con tip Proporcionar argumentos correctos para los métodos de formato - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Un tipo tiene un campo marcado con el atributo System.Runtime.Serialization.OptionalFieldAttribute y el tipo no proporciona ningún método de control de eventos de deserialización. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Agregue un método "private void OnDeserialized(StreamingContext)" al tipo {0} y asígnele el atributo System.Runtime.Serialization.OnDeserializedAttribute. - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Agregue un método "private void OnDeserializing(StreamingContext)" al tipo {0} y asígnele el atributo System.Runtime.Serialization.OnDeserializingAttribute. - - - - Provide deserialization methods for optional fields - Proporcionar métodos de deserialización para campos opcionales - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Proporcionar un constructor sin parámetros tan visible como el tipo contenedor para un tipo derivado de 'System.Runtime.InteropServices.SafeHandle' permite un mejor rendimiento y uso con soluciones de interoperabilidad generadas por el origen. 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 c6b0b30652..51cbcedeef 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.fr.xlf @@ -1333,101 +1333,11 @@ Les conversions étendues et définies par l’utilisateur ne sont pas prises en Utiliser le paramètre de type correct - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Pour corriger toute violation de cette règle, rendez la méthode GetObjectData visible et substituable. De plus, vérifiez que tous les champs d'instance sont inclus dans le processus de sérialisation ou qu'ils sont marqués explicitement avec l'attribut NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Ajoutez une implémentation de GetObjectData au type {0} - - - - Make {0}.GetObjectData virtual and overridable - Définissez {0}.GetObjectData en tant que méthode virtuelle et substituable - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Augmentez l'accessibilité de {0}.GetObjectData afin qu'il soit visible par les types dérivés - - - - Implement ISerializable correctly - Implémentez ISerializable comme il se doit - - Implement inherited interfaces Implémenter les interfaces héritées - - Implement Serialization constructor - Implémenter le constructeur de sérialisation - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Pour corriger toute violation de cette règle, implémentez le constructeur de sérialisation. Dans le cas d'une classe sealed, rendez le constructeur privé ; sinon, affectez-lui l'état protégé. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Ajoutez un constructeur à {0} avec la signature suivante : 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Déclarez le constructeur de sérialisation du type sealed {0} comme privé. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Déclarez le constructeur de sérialisation du type unsealed {0} comme protégé. - - - - Implement serialization constructors - Implémentez des constructeurs de sérialisation - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Une méthode qui gère un événement de sérialisation n'a pas la signature, le type de retour ou la visibilité appropriée. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Comme {0} est marqué avec OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, changez sa signature afin qu'il ne soit plus générique - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Comme {0} est marqué avec OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, changez sa signature afin qu'il n'accepte qu'un seul paramètre de type 'System.Runtime.Serialization.StreamingContext' - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Comme {0} est marqué avec OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, changez son type de retour de {1} en void (Sub en Visual Basic) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Comme {0} est marqué avec OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, changez-le de static (Shared en Visual Basic) en une méthode d'instance - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Dans la mesure où {0} est marqué avec OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, changez son accessibilité en private - - - - Implement serialization methods correctly - Implémentez les méthodes de sérialisation comme il se doit - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}' met en œuvre l’interface de prévisualisation '{1}' et doit donc opter pour les fonctionnalités de prévisualisation. Voir {2}pour plus d'informations. @@ -2303,26 +2213,6 @@ Les conversions étendues et définies par l’utilisateur ne sont pas prises en Indiquer le nombre correct d'arguments dans les méthodes de mise en forme - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Un type a un champ marqué avec l'attribut System.Runtime.Serialization.OptionalFieldAttribute et ne fournit aucune méthode de gestion des événements de désérialisation. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Ajoutez une méthode 'private void OnDeserialized(StreamingContext)' au type {0} et affectez-lui l'attribut System.Runtime.Serialization.OnDeserializedAttribute - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Ajoutez une méthode 'private void OnDeserializing(StreamingContext)' au type {0} et affectez-lui l'attribut System.Runtime.Serialization.OnDeserializingAttribute - - - - Provide deserialization methods for optional fields - Spécifiez des méthodes de désérialisation pour les champs facultatifs - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. La fourniture d’un constructeur sans paramètre qui est aussi visible que le type conteneur pour un type dérivé de ’System. Runtime. InteropServices. SafeHandle’ permet d’améliorer les performances et l’utilisation des solutions d’interopérabilité générées par le code source. 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 21d943a5f7..e18e3a4716 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.it.xlf @@ -1333,101 +1333,11 @@ L'ampliamento e le conversioni definite dall'utente non sono supportate con tipi Usare il parametro di tipo corretto - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Per correggere una violazione di questa regola, impostare il metodo GetObjectData come visibile e sottoponibile a override e assicurarsi che tutti i campi di istanza siano inclusi nel processo di serializzazione o contrassegnati in modo esplicito usando l'attributo NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Aggiungere un'implementazione di GetObjectData al tipo {0} - - - - Make {0}.GetObjectData virtual and overridable - Rendere {0}.GetObjectData virtuale e sottoponibile a override - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Aumentare l'accessibilità di {0}.GetObjectData in modo che sia visibile ai tipi derivati - - - - Implement ISerializable correctly - Implementare ISerializable in modo corretto - - Implement inherited interfaces Implementare interfacce ereditate - - Implement Serialization constructor - Implementare il costruttore di serializzazione - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Per correggere una violazione di questa regola, implementare il costruttore di serializzazione. Per una classe sealed impostare il costruttore come private; in caso contrario impostarlo come protected. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Aggiungere un costruttore a {0} con la seguente firma: 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Dichiarare il costruttore di serializzazione di {0}, tipo sealed, come privato. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Dichiarare come protected il costruttore di serializzazione di {0}, un tipo unsealed. - - - - Implement serialization constructors - Implementare costruttori di serializzazione - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Un metodo che gestisce un evento di serializzazione non include valori corretti per visibilità, tipo restituito o firma. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Dal momento che {0} è contrassegnato con OnSerializing, OnSerialized, OnDeserializing o OnDeserialized, modificare la firma in modo che non sia più generica - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Dal momento che {0} è contrassegnato con OnSerializing, OnSerialized, OnDeserializing o OnDeserialized, modificare la firma in modo che accetti un solo parametro di tipo 'System.Runtime.Serialization.StreamingContext' - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Dal momento che {0} è contrassegnato con OnSerializing, OnSerialized, OnDeserializing o OnDeserialized, modificare il tipo restituito da {1} in void (Sub in Visual Basic) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Dal momento che {0} è contrassegnato con OnSerializing, OnSerialized, OnDeserializing o OnDeserialized, modificarlo da statico (Shared in Visual Basic) in un metodo di istanza - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Dal momento che {0} è contrassegnato con OnSerializing, OnSerialized, OnDeserializing o OnDeserialized, modificarne l'accessibilità in private - - - - Implement serialization methods correctly - Implementare correttamente i metodi di serializzazione - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}' implementa l’interfaccia di anteprima '{1}' e deve quindi acconsentire esplicitamente alle funzionalità di anteprima. Per altre informazioni, vedere {2}. @@ -2303,26 +2213,6 @@ L'ampliamento e le conversioni definite dall'utente non sono supportate con tipi Fornire gli argomenti corretti ai metodi di formattazione - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Un tipo include un campo contrassegnato usando l'attributo System.Runtime.Serialization.OptionalFieldAttribute e non fornisce metodi di gestione degli eventi di deserializzazione. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Aggiungere un metodo 'private void OnDeserialized(StreamingContext)' al tipo {0} e impostarvi l'attributo System.Runtime.Serialization.OnDeserializedAttribute - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Aggiungere un metodo 'private void OnDeserializing(StreamingContext)' al tipo {0} e impostarvi l'attributo System.Runtime.Serialization.OnDeserializingAttribute - - - - Provide deserialization methods for optional fields - Fornire metodi di deserializzazione per i campi facoltativi - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. La specifica di un costruttore senza parametri visibile come tipo che lo contiene per un tipo derivato da 'System.Runtime.InteropServices.SafeHandle' offre prestazioni migliori e ne consente l'utilizzo in soluzioni di interoperabilità generate da origini. 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 157c639229..6e5a108de4 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ja.xlf @@ -1333,101 +1333,11 @@ Enumerable.OfType<T> で使用されるジェネリック型チェック ( 正しい種類のパラメーターを使用する - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - このルールの違反を修正するには、GetObjectData メソッドを参照可能およびオーバーライド可能にして、すべてのインスタンス フィールドがシリアル化プロセスに含まれるか、NonSerializedAttribute 属性を使用して明示的にマークされるようにしてください。 - - - - Add an implementation of GetObjectData to type {0} - GetObjectData の実装を型 {0} に追加してください - - - - Make {0}.GetObjectData virtual and overridable - {0}.GetObjectData を仮想およびオーバーライド可能にしてください - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - 派生型に公開するため、{0}.GetObjectData のアクセシビリティを上げてください - - - - Implement ISerializable correctly - ISerializable を正しく実装します - - Implement inherited interfaces 継承されたインターフェイスを実装する - - Implement Serialization constructor - シリアル化コンストラクターを実装する - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - このルールの違反を修正するには、シリアル化コンストラクターを実装します。シール クラスの場合はコンストラクターを private にします。そうでない場合、protected にします。 - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - 次のシグネチャと共にコンストラクターを {0} に追加します: 'protected {0}(SerializationInfo 情報、StreamingContext コンテキスト)' - - - - Declare the serialization constructor of {0}, a sealed type, as private. - シールド型である {0} のシリアル化コンストラクターを private として宣言します。 - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - アンシールド型である {0} のシリアル化コンストラクターを protected として宣言します。 - - - - Implement serialization constructors - シリアル化コンストラクターを実装します - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - シリアル化イベントを処理するメソッドには、正しいシグネチャ、戻り値の型、または可視性がありません。 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - {0} は OnSerializing、OnSerialized、OnDeserializing、または OnDeserialized に設定されているため、ジェネリックにならないようにシグネチャを変更してください - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - {0} は OnSerializing、OnSerialized、OnDeserializing、または OnDeserialized に設定されているため、'System.Runtime.Serialization.StreamingContext' という型の単一のパラメーターを受け取るようにシグネチャを変更してください - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - {0} は OnSerializing、OnSerialized、OnDeserializing、または OnDeserialized に設定されているため、戻り値の型を {1} から void (Visual Basic では Sub) に変更してください - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - {0} は OnSerializing、OnSerialized、OnDeserializing、または OnDeserialized に設定されているため、静的 (Visual Basic では共有) からインスタンス メソッドに変更してください - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - {0} は OnSerializing、OnSerialized、OnDeserializing、または OnDeserialized に設定されているため、アクセシビリティをプライベートに変更してください - - - - Implement serialization methods correctly - シリアル化メソッドを正しく実装します - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}' はプレビュー インターフェイス '{1}' を実装しているため、プレビュー機能を選択する必要があります。詳細については、「{2}」を参照してください。 @@ -2303,26 +2213,6 @@ Enumerable.OfType<T> で使用されるジェネリック型チェック ( 書式設定メソッドに正しい引数を指定します - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - 型には System.Runtime.Serialization.OptionalFieldAttribute 属性を使用してマークされているフィールドがあり、型は逆シリアル化イベントの処理メソッドを提供しません。 - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - 'private void OnDeserialized(StreamingContext)' メソッドを型 {0} に追加し、System.Runtime.Serialization.OnDeserializedAttribute に属性指定してください - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - 'private void OnDeserializing(StreamingContext)' メソッドを型 {0} に追加し、System.Runtime.Serialization.OnDeserializingAttribute に属性指定してください - - - - Provide deserialization methods for optional fields - 省略可能なフィールドに、逆シリアル化メソッドを指定します - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. 'System.Runtime.InteropServices.SafeHandle' から派生した型の包含型と同じように見えるパラメーターなしのコンストラクターを指定すると、ソース生成相互運用ソリューションのパフォーマンスと使用方法が向上します。 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 c51c4b7520..2cb8927d8b 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ko.xlf @@ -1333,101 +1333,11 @@ Enumerable.OfType<T>에서 사용하는 제네릭 형식 검사(C# 'is' 올바른 형식 매개 변수 사용 - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - 이 규칙 위반 문제를 해결하려면 GetObjectData 메서드를 visible 및 overridable로 설정하고 모든 인스턴스 필드가 serialization 프로세스에 포함되거나 NonSerializedAttribute 특성을 사용하여 명시적으로 표시되도록 합니다. - - - - Add an implementation of GetObjectData to type {0} - {0} 형식에 GetObjectData 구현을 추가하세요. - - - - Make {0}.GetObjectData virtual and overridable - {0}.GetObjectData를 재정의 가능한 가상 메서드로 설정하세요. - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - 파생 형식에 표시되도록 {0}.GetObjectData의 접근성을 높이세요. - - - - Implement ISerializable correctly - ISerializable을 올바르게 구현하십시오. - - Implement inherited interfaces 상속된 인터페이스 구현 - - Implement Serialization constructor - Serialization 생성자 구현 - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - 이 규칙 위반 문제를 해결하려면 serialization 생성자를 구현합니다. sealed 클래스의 경우 생성자를 private으로 설정하고, 그렇지 않으면 protected로 설정합니다. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - 다음 시그니처를 사용하여 생성자를 {0}에 추가하십시오. 'protected {0}(SerializationInfo info, StreamingContext context)' - - - - Declare the serialization constructor of {0}, a sealed type, as private. - sealed 형식의 {0} serialization 생성자를 private으로 선언하세요. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - unsealed 형식의 {0} serialization 생성자를 protected로 선언하세요. - - - - Implement serialization constructors - serialization 생성자를 구현하십시오. - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - serialization 이벤트를 처리하는 메서드에 올바른 시그니처, 반환 형식 또는 표시 여부가 없습니다. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - {0}이(가) OnSerializing, OnSerialized, OnDeserializing 또는 OnDeserialized로 표시되어 있으므로 제네릭이 되지 않도록 시그니처를 변경하세요. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - {0}이(가) OnSerializing, OnSerialized, OnDeserializing 또는 OnDeserialized로 표시되어 있으므로 'System.Runtime.Serialization.StreamingContext' 형식의 단일 매개 변수를 사용하도록 시그니처를 변경하세요. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - {0}이(가) OnSerializing, OnSerialized, OnDeserializing 또는 OnDeserialized로 표시되어 있으므로 반환 형식을 {1}에서 void(Visual Basic의 경우 Sub)로 변경하세요. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - {0}이(가) OnSerializing, OnSerialized, OnDeserializing 또는 OnDeserialized로 표시되어 있으므로 static(Visual Basic의 경우 Shared)에서 인스턴스 메서드로 변경하세요. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - {0}이(가) OnSerializing, OnSerialized, OnDeserializing 또는 OnDeserialized로 표시되어 있으므로 접근성을 private으로 변경하세요. - - - - Implement serialization methods correctly - serialization 메서드를 올바르게 구현하십시오. - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}'은(는) 미리 보기 인터페이스 '{1}'를 구현하므로 미리 보기 기능을 선택해야 합니다. 자세한 내용은 {2}을(를) 참조하세요. @@ -2303,26 +2213,6 @@ Enumerable.OfType<T>에서 사용하는 제네릭 형식 검사(C# 'is' 서식 지정 메서드에 올바른 인수를 제공하세요. - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - 형식에 System.Runtime.Serialization.OptionalFieldAttribute 특성을 사용하여 표시된 필드가 있으면 해당 형식은 deserialization 이벤트 처리 메서드를 제공하지 않습니다. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - 'private void OnDeserialized(StreamingContext)' 메서드를 {0} 형식에 추가하고 System.Runtime.Serialization.OnDeserializedAttribute 특성을 사용하세요. - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - 'private void OnDeserializing(StreamingContext)' 메서드를 {0} 형식에 추가하고 System.Runtime.Serialization.OnDeserializingAttribute 특성을 사용하세요. - - - - Provide deserialization methods for optional fields - 선택적 필드에 deserialization 메서드를 제공하십시오. - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. 'System.Runtime.InteropServices.SafeHandle'에서 파생된 형식에 대한 포함 형식만큼 표시되는 매개 변수 없는 생성자를 제공하면 원본 생성 interop 솔루션의 성능과 사용이 향상됩니다. 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 6716383b08..b5a80ebbf3 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.pl.xlf @@ -1333,101 +1333,11 @@ Konwersje poszerzane i zdefiniowane przez użytkownika nie są obsługiwane w pr Użyj poprawnego parametru typu - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Aby naprawić naruszenie tej reguły, ustaw metodę GetObjectData jako widoczną i możliwą do przesłonięcia oraz upewnij się, że wszystkie pola wystąpienia są uwzględnione w procesie serializacji lub jawnie oznaczone atrybutem NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Dodaj implementację metody GetObjectData do typu {0} - - - - Make {0}.GetObjectData virtual and overridable - Przekształć metodę {0}.GetObjectData w wirtualną i możliwą do przesłonięcia - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Zwiększ dostępność metody {0}.GetObjectData, aby była widoczna dla typów pochodnych - - - - Implement ISerializable correctly - Poprawnie zaimplementuj interfejs ISerializable - - Implement inherited interfaces Implementuj interfejsy dziedziczone - - Implement Serialization constructor - Zaimplementuj konstruktor serializacji - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Aby naprawić naruszenie tej reguły, zaimplementuj konstruktor serializacji. W przypadku klasy zapieczętowanej ustaw konstruktor jako prywatny. W przeciwnym razie ustaw go jako chroniony. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Dodaj konstruktor do elementu {0} z następującą sygnaturą: protected {0}(SerializationInfo info, StreamingContext context). - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Zadeklaruj konstruktor serializacji zapieczętowanego typu {0} jako prywatny. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Zadeklaruj konstruktor serializacji niezapieczętowanego typu {0} jako chroniony. - - - - Implement serialization constructors - Zaimplementuj konstruktory serializacji - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Metoda, która obsługuje zdarzenie serializacji, nie ma poprawnej sygnatury, zwracanego typu lub widoczności. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Ponieważ metoda {0} jest oznaczona atrybutem OnSerializing, OnSerialized, OnDeserializing lub OnDeserialized, zmień jej sygnaturę tak, aby już nie była ogólna - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Ponieważ metoda {0} jest oznaczona atrybutem OnSerializing, OnSerialized, OnDeserializing lub OnDeserialized, zmień jej sygnaturę tak, aby przyjmowała jeden parametr typu „System.Runtime.Serialization.StreamingContext” - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Ponieważ metoda {0} jest oznaczona atrybutem OnSerializing, OnSerialized, OnDeserializing lub OnDeserialized, zmień jej typ zwracany z {1} na void (Sub w języku Visual Basic) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Ponieważ metoda {0} jest oznaczona atrybutem OnSerializing, OnSerialized, OnDeserializing lub OnDeserialized, zmień ją ze statycznej (Shared w języku Visual Basic) na metodę wystąpienia - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Ponieważ metoda {0} jest oznaczona atrybutem OnSerializing, OnSerialized, OnDeserializing lub OnDeserialized, zmień jej dostępność na prywatną - - - - Implement serialization methods correctly - Poprawnie implementuj metody serializacji - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. „{0}” ma zaimplementowany interfejs w wersji zapoznawczej „{1}” i dlatego wymaga wyrażenia zgody na korzystanie z funkcji w wersji zapoznawczej. Aby uzyskać więcej informacji, zobacz {2}. @@ -2303,26 +2213,6 @@ Konwersje poszerzane i zdefiniowane przez użytkownika nie są obsługiwane w pr Określ poprawne argumenty dla metod formatujących - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Typ ma pole, które jest oznaczone za pomocą atrybutu System.Runtime.Serialization.OptionalFieldAttribute, a typ nie zapewnia metod obsługi zdarzeń deserializacji. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Dodaj metodę private void OnDeserialized(StreamingContext) do typu {0} i oznacz ją atrybutem System.Runtime.Serialization.OnDeserializedAttribute - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Dodaj metodę private void OnDeserializing(StreamingContext) do typu {0} i oznacz ją atrybutem System.Runtime.Serialization.OnDeserializingAttribute - - - - Provide deserialization methods for optional fields - Udostępnij metody deserializacji dla pól opcjonalnych - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Udostępnienie konstruktora bez parametrów, który jest tak widoczny jak typ zawierający dla typu pochodzącego z elementu „System.Runtime.InteropServices.SafeHandle”, zapewnia lepszą wydajność i użycie dzięki wygenerowanym przez źródło rozwiązaniom międzyoperacyjnym. 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 1158c1feea..18278dd817 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 @@ -1333,101 +1333,11 @@ Ampliação e conversões definidas pelo usuário não são compatíveis com tip Usar o parâmetro de tipo correto - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Para corrigir uma violação desta regra, faça com que o método GetObjectData seja visível e substituível e verifique se todos os campos da instância estão incluídos no processo de serialização ou marcados explicitamente usando o atributo NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Adicione uma implementação de GetObjectData ao tipo {0} - - - - Make {0}.GetObjectData virtual and overridable - Torne o {0}.GetObjectData virtual e substituível - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Aumente a acessibilidade de {0}.GetObjectData para que ele seja visível para tipos derivados - - - - Implement ISerializable correctly - Implementar ISerializable corretamente - - Implement inherited interfaces Implementar interfaces herdadas - - Implement Serialization constructor - Implementar um construtor de Serialização - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Para corrigir uma violação desta regra, implemente o construtor de serialização. Para uma classe selada, faça com que o Construtor seja privado, para outros casos, faça com que ele seja protegido. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Adicione um construtor a {0} com a seguinte assinatura: 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Declare o construtor de serialização de {0}, um tipo selado, como privado. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Declare o construtor de serialização de {0}, um tipo não selado, como protegido. - - - - Implement serialization constructors - Implementar construtores de serialização - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Um método que manipula um evento de serialização não tem a assinatura, o tipo de retorno ou a visibilidade correta. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Como {0} está marcado com OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, altere a assinatura para que ele não seja mais genérico - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Como {0} está marcado com OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, altere a assinatura para que ele receba um parâmetro do tipo 'System.Runtime.Serialization.StreamingContext' - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Como {0} está marcado com OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, altere o tipo de retorno de {1} para void (Sub no Visual Basic) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Como {0} está marcado com OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, altere-o de static (Shared no Visual Basic) para um método de instância - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Como {0} está marcado com OnSerializing, OnSerialized, OnDeserializing ou OnDeserialized, altere a acessibilidade para particular - - - - Implement serialization methods correctly - Implementar métodos de serialização corretamente - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. “{0}” implementa a interface de visualização “{1}” e, portanto, precisa aceitar os recursos de visualização. Consulte {2} para obter mais informações. @@ -2303,26 +2213,6 @@ Ampliação e conversões definidas pelo usuário não são compatíveis com tip Fornecer os argumentos corretos para métodos de formatação - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Um tipo tem um campo que está marcado usando o atributo System.Runtime.Serialization.OptionalFieldAttribute, mas o tipo não fornece os métodos de manipulação de eventos de desserialização. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Adicionar um método 'private void OnDeserialized(StreamingContext)' ao tipo {0} e atribuí-lo com System.Runtime.Serialization.OnDeserializedAttribute - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Adicionar um método 'private void OnDeserializing(StreamingContext)' ao tipo {0} e atribuí-lo com System.Runtime.Serialization.OnDeserializingAttribute - - - - Provide deserialization methods for optional fields - Fornecer métodos de desserialização para campos opcionais - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Fornecer um construtor sem parâmetros que é tão visível quanto o tipo que contém um tipo derivado de 'System.Runtime.InteropServices.SafeHandle' permite um melhor desempenho e uso com soluções de interoperabilidade geradas pela origem. 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 2fc84e2559..333c09d2c6 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.ru.xlf @@ -1333,101 +1333,11 @@ Widening and user defined conversions are not supported with generic types.Используйте правильный параметр типа - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Чтобы устранить нарушение этого правила, сделайте метод GetObjectData видимым и переопределяемым и убедитесь, что все поля экземпляра включены в процесс сериализации или явно помечены атрибутом NonSerializedAttribute. - - - - Add an implementation of GetObjectData to type {0} - Добавьте реализацию GetObjectData к типу {0}. - - - - Make {0}.GetObjectData virtual and overridable - Сделайте {0}.GetObjectData виртуальным и переопределяемым. - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - Увеличьте уровень доступности {0}.GetObjectData, чтобы он был видим для производных типов. - - - - Implement ISerializable correctly - Правильно реализуйте ISerializable - - Implement inherited interfaces Реализация унаследованных интерфейсов - - Implement Serialization constructor - Реализовать конструктор сериализации - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Чтобы устранить нарушение этого правила, реализуйте конструктор сериализации. Для запечатанного класса сделайте конструктор закрытым; в противном случае сделайте его защищенным. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - Добавьте конструктор к {0} со следующей сигнатурой: "protected {0}(SerializationInfo info, StreamingContext context)". - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Объявите конструктор сериализации {0} запечатанного типа как частный. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Объявите конструктор сериализации {0} незапечатанного типа как защищенный. - - - - Implement serialization constructors - Реализуйте конструкторы сериализации - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - У метода, обрабатывающего событие сериализации, нет правильной сигнатуры, типа возвращаемого значения или видимости. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - Так как {0} помечен как OnSerializing, OnSerialized, OnDeserializing или OnDeserialized, измените его сигнатуру так, чтобы он более не был универсальным. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - Так как {0} помечен как OnSerializing, OnSerialized, OnDeserializing или OnDeserialized, измените его сигнатуру так, чтобы он принимал единственный параметр типа "System.Runtime.Serialization.StreamingContext". - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - Так как {0} помечен как OnSerializing, OnSerialized, OnDeserializing или OnDeserialized, замените тип его возвращаемого значения с {1} на void (Sub в Visual Basic). - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - Так как {0} помечен как OnSerializing, OnSerialized, OnDeserializing или OnDeserialized, сделайте его не статическим методом (Shared в Visual Basic), а методом экземпляра. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - Так как {0} помечен как OnSerializing, OnSerialized, OnDeserializing или OnDeserialized, замените его доступность частной. - - - - Implement serialization methods correctly - Правильно реализуйте методы сериализации - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. "{0}" реализует предварительную версию интерфейса "{1}", поэтому требуется согласие на использование предварительных версий функций. Дополнительные сведения см. в разделе {2}. @@ -2303,26 +2213,6 @@ Widening and user defined conversions are not supported with generic types.Задайте правильные аргументы для методов форматирования - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Тип имеет поле, помеченное атрибутом System.Runtime.Serialization.OptionalFieldAttribute, и не предоставляет методы для обработки событий десериализации. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - Добавьте метод "private void OnDeserialized(StreamingContext)" к типу {0} и присвойте ему атрибут System.Runtime.Serialization.OnDeserializedAttribute. - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - Добавьте метод "private void OnDeserializing(StreamingContext)" к типу {0} и присвойте ему атрибут System.Runtime.Serialization.OnDeserializingAttribute. - - - - Provide deserialization methods for optional fields - Обеспечьте наличие методов десериализации в необязательных полях - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. Предоставление конструктора без параметров, который отображается как содержащий тип для типа, производного от "System.Runtime.InteropServices.SafeHandle", обеспечивает улучшенную производительность и использование в решениях взаимодействия, созданных источником. 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 dc915b4ce8..f4700b6a05 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.tr.xlf @@ -1333,101 +1333,11 @@ Genel türlerde genişletme ve kullanıcı tanımlı dönüştürmeler desteklen Doğru tür parametresini kullanın - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - Bu kural ihlalini düzeltmek için GetObjectData metodunu görünür ve geçersiz kılınabilir hale getirin ve tüm örnek alanlarının serileştirme işlemine dahil edildiğinden veya NonSerializedAttribute özniteliği kullanılarak açıkça işaretlendiğinden emin olun. - - - - Add an implementation of GetObjectData to type {0} - {0} türüne GetObjectData'nın bir uygulamasını ekleyin - - - - Make {0}.GetObjectData virtual and overridable - {0}.GetObjectData'yı sanal ve geçersiz kılınabilir yapın - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - {0}.GetObjectData erişilebilirliğini türetilmiş türlere görünür olacak şekilde artırın - - - - Implement ISerializable correctly - ISerializable'ı doğru uygulayın - - Implement inherited interfaces Devralınan arabirimleri uygulayın - - Implement Serialization constructor - Serileştirme oluşturucusunu uygulayın - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - Bu kural ihlalini düzeltmek için serileştirme oluşturucusunu uygulayın. Mühürlü bir sınıf için oluşturucuyu özel yapın. Aksi halde korumalı hale getirin. - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - {0} için bu imzayla bir oluşturucu ekleyin: 'protected {0}(SerializationInfo info, StreamingContext context)'. - - - - Declare the serialization constructor of {0}, a sealed type, as private. - Mühürlenmiş bir tür olan {0} için seri hale getirme oluşturucusunu private olarak bildirin. - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - Mühürlenmemiş bir tür olan {0} için seri hale getirme oluşturucusunu protected olarak bildirin. - - - - Implement serialization constructors - Serileştirme oluşturucularını uygulayın - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - Serileştirme olayını işleyen bir metot, doğru imzaya, dönüş türüne veya görünürlüğe sahip değildir. - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - {0} metodu OnSerializing, OnSerialized, OnDeserializing ya da OnDeserialized ile işaretli olduğundan, imzasını genel olmayacak şekilde değiştirin - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - {0} metodu OnSerializing, OnSerialized, OnDeserializing ya da OnDeserialized ile işaretli olduğundan, imzasını 'System.Runtime.Serialization.StreamingContext' türünde tek bir parametre alacak şekilde değiştirin - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - {0} metodu OnSerializing, OnSerialized, OnDeserializing ya da OnDeserialized ile işaretli olduğundan, dönüş türünü {1} yerine void (Visual Basic'te Sub) olarak değiştirin - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - {0} metodu OnSerializing, OnSerialized, OnDeserializing ya da OnDeserialized ile işaretli olduğundan, statik (Visual Basic'te Shared) yerine bir örnek metoduna değiştirin - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - {0} metodu OnSerializing, OnSerialized, OnDeserializing ya da OnDeserialized ile işaretli olduğundan, erişilebilirliğini private olarak değiştirin - - - - Implement serialization methods correctly - Serileştirme yöntemlerini doğru uygulayın - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}', '{1}' önizleme arabirimini uyguladığından önizleme özelliklerini kabul etmesi gerekir. Daha fazla bilgi için bkz. {2}. @@ -2303,26 +2213,6 @@ Genel türlerde genişletme ve kullanıcı tanımlı dönüştürmeler desteklen Biçimlendirme yöntemlerine doğru bağımsız değişkenleri sağlayın - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - Tür, System.Runtime.Serialization.OptionalFieldAttribute özniteliği kullanılarak işaretlenen bir alana sahip ve tür, seri durumdan çıkarma olayı işleme metotlarını sağlamıyor. - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - {0} türüne 'private void OnDeserialized(StreamingContext)' metodunu ekleyin ve System.Runtime.Serialization.OnDeserializedAttribute ile özniteliğini belirleyin - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - {0} türüne 'private void OnDeserializing(StreamingContext)' metodunu ekleyin ve System.Runtime.Serialization.OnDeserializingAttribute ile özniteliğini belirleyin - - - - Provide deserialization methods for optional fields - İsteğe bağlı yöntemler için serileştirme kaldırma yöntemler sağlayın - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. 'System.Runtime.InteropServices.SafeHandle'dan türetilmiş bir tür için kapsayan tür kadar görülebilen parametresiz bir oluşturucu sağlamak, kaynak tarafından oluşturulan birlikte çalışma çözümleriyle daha iyi performans ve kullanım olanağı sağlar. 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 7c3ee317d2..b9fc322c91 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 @@ -1333,101 +1333,11 @@ Enumerable.OfType<T> 使用的泛型类型检查 (C# 'is' operator/IL 'isi 使用正确的类型参数 - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - 若要修复此规则的违规行为,将 GetObjectData 方法设置为可见并可重写,并确保所有实例字段都包含在序列化进程中或使用 NonSerializedAttribute 特性显式标记所有实例字段。 - - - - Add an implementation of GetObjectData to type {0} - 向类型 {0} 中添加对 GetObjectData 的实现 - - - - Make {0}.GetObjectData virtual and overridable - 将 {0}.GetObjectData 设置为虚拟的和可重写的 - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - 提高 {0}.GetObjectData 的可访问性以便它对于派生类型可见 - - - - Implement ISerializable correctly - 正确实现 ISerializable - - Implement inherited interfaces 实现继承的接口 - - Implement Serialization constructor - 实现序列化构造函数 - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - 若要修复此规则的违规行为,请实现序列化构造函数。对于密封类,请将构造函数设为专用;否则,使它处于受保护状态。 - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - 使用以下签名向 {0} 添加构造函数: “protected {0} (SerializationInfo info, StreamingContext context)”。 - - - - Declare the serialization constructor of {0}, a sealed type, as private. - 将密封类型 {0} 的序列化构造函数声明为 private。 - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - 将非密封类型 {0} 的序列化构造函数声明为 protected。 - - - - Implement serialization constructors - 实现序列化构造函数 - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - 处理序列化事件的方法没有正确的签名、返回类型或可见性。 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - 由于 {0} 标记有 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,因此请更改它的签名,使它不再是泛型的 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - 由于 {0} 标记有 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,因此请更改它的签名,使它采用类型为“System.Runtime.Serialization.StreamingContext”的单个参数 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - 由于 {0} 标记有 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,因此请将它的返回类型从 {1} 改为 void (Visual Basic 中为 Sub) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - 由于 {0} 标记有 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,因此请将它从 static (Visual Basic 中为 Shared)改为实例方法 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - 由于 {0} 标记有 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,因此请将它的可访问性改为 private - - - - Implement serialization methods correctly - 正确实现序列化方法 - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. “{0}”实现预览界面“{1}”,因此需要选择加入预览功能。有关详细信息,请参阅 {2}。 @@ -2303,26 +2213,6 @@ Enumerable.OfType<T> 使用的泛型类型检查 (C# 'is' operator/IL 'isi 为格式化方法提供正确的参数 - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - 类型具有使用 System.Runtime.Serialization.OptionalFieldAttribute 特性标记的字段,并且该类型不提供反序列化事件处理方法。 - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - 向类型 {0} 中添加“private void OnDeserialized(StreamingContext)”方法并使其具有 System.Runtime.Serialization.OnDeserializedAttribute 特性 - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - 向类型 {0} 中添加“private void OnDeserializing(StreamingContext)”方法并使其具有 System.Runtime.Serialization.OnDeserializingAttribute 特性 - - - - Provide deserialization methods for optional fields - 为可选字段提供反序列化方法 - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. 提供与派生自 “System.Runtime.InteropServices.SafeHandle” 的类型的包含类型一样可见的无参数构造函数可改进源生成的互操作解决方案的性能和使用情况。 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 856cc16550..09dc41c4fa 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 @@ -1333,101 +1333,11 @@ Enumerable.OfType<T> 使用的一般型別檢查 (C# 'is' operator/IL 'isi 使用正確的類型參數 - - To fix a violation of this rule, make the GetObjectData method visible and overridable, and make sure that all instance fields are included in the serialization process or explicitly marked by using the NonSerializedAttribute attribute. - 若要修正此規則違規,請將 GetObjectData 方法設定為可見且可覆寫,並確定所有執行個體欄位都包含在序列化程序中,或是使用 NonSerializedAttribute 屬性明確地標記。 - - - - Add an implementation of GetObjectData to type {0} - 將 GetObjectData 的實作加入型別 {0} - - - - Make {0}.GetObjectData virtual and overridable - 請將 {0}.GetObjectData 設定成虛擬和可覆寫 - - - - Increase the accessibility of {0}.GetObjectData so that it is visible to derived types - 增大 {0}.GetObjectData 的存取範圍,讓它對衍生型別而言為可見的 - - - - Implement ISerializable correctly - 必須正確實作 ISerializable - - Implement inherited interfaces 實作繼承的介面 - - Implement Serialization constructor - 實作序列化建構函式 - - - - To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - 若要修正此規則違規,請實作序列化建構函式。若是密封類別,請將其設定為私人建構函式; 否則,請將其設定為受保護。 - - - - Add a constructor to {0} with the following signature: 'protected {0}(SerializationInfo info, StreamingContext context)'. - 使用下列簽章將建構函式加入 {0}: 'protected {0}(SerializationInfo info, StreamingContext context)'。 - - - - Declare the serialization constructor of {0}, a sealed type, as private. - 將 {0} 的序列化建構函式 (sealed 類型) 宣告為 private。 - - - - Declare the serialization constructor of {0}, an unsealed type, as protected. - 將 {0} 的序列化建構函式 (unsealed 類型) 宣告為 protected。 - - - - Implement serialization constructors - 必須實作序列化建構函式 - - - - A method that handles a serialization event does not have the correct signature, return type, or visibility. - 處理序列化事件的方法,沒有正確的簽章、傳回型別或可見度。 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it is no longer generic - 因為 {0} 標記著 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,請變更其特徵標記,使其不再是泛型 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its signature so that it takes a single parameter of type 'System.Runtime.Serialization.StreamingContext' - 因為 {0} 標記著 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,請變更其特徵標記,使其接受 'System.Runtime.Serialization.StreamingContext' 型別的單一參數 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its return type from {1} to void (Sub in Visual Basic) - 因為 {0} 標記著 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,請將它的傳回型別從 {1} 變更成 void (Visual Basic 中為 Sub) - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change it from static (Shared in Visual Basic) to an instance method - 因為 {0} 標記著 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,請將它從 static (Visual Basic 中為 Shared) 變更成執行個體方法 - - - - Because {0} is marked with OnSerializing, OnSerialized, OnDeserializing, or OnDeserialized, change its accessibility to private - 因為 {0} 標記著 OnSerializing、OnSerialized、OnDeserializing 或 OnDeserialized,請將其存取範圍變更成 private - - - - Implement serialization methods correctly - 必須正確實作序列化方法 - - '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See {2} for more information. '{0}' 會實作預覽介面 '{1}',因此必須加入預覽功能。如需詳細資訊,請參閱 {2}。 @@ -2303,26 +2213,6 @@ Enumerable.OfType<T> 使用的一般型別檢查 (C# 'is' operator/IL 'isi 為格式化方法提供正確的引數 - - A type has a field that is marked by using the System.Runtime.Serialization.OptionalFieldAttribute attribute, and the type does not provide deserialization event handling methods. - 類型的欄位已使用 System.Runtime.Serialization.OptionalFieldAttribute 屬性進行標記,但該類型不提供還原序列化事件處理方法。 - - - - Add a 'private void OnDeserialized(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializedAttribute - 將 'private void OnDeserialized(StreamingContext)' 方法加入類型 {0},並為其加上 System.Runtime.Serialization.OnDeserializedAttribute 屬性 - - - - Add a 'private void OnDeserializing(StreamingContext)' method to type {0} and attribute it with the System.Runtime.Serialization.OnDeserializingAttribute - 將 'private void OnDeserializing(StreamingContext)' 方法加入型別 {0},並為其加上 System.Runtime.Serialization.OnDeserializingAttribute 屬性 - - - - Provide deserialization methods for optional fields - 必須為選擇性欄位提供還原序列化方法 - - Providing a parameterless constructor that is as visible as the containing type for a type derived from 'System.Runtime.InteropServices.SafeHandle' enables better performance and usage with source-generated interop solutions. 提供一種無參數的建構函式,與衍生自 'System.Runtime.InteropServices.SafeHandle' 之類型的包含類型一樣可見,使用原始檔產生的 interop 解決方案可提高效能及使用量。 diff --git a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md index ef63ae6f98..3679a4482a 100644 --- a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md +++ b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md @@ -2238,18 +2238,6 @@ A writable collection property allows a user to replace the collection with a di |CodeFix|False| --- -## [CA2229](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2229): Implement serialization constructors - -To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected. - -|Item|Value| -|-|-| -|Category|Usage| -|Enabled|True| -|Severity|Hidden| -|CodeFix|True| ---- - ## [CA2231](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2231): Overload operator equals on overriding value type Equals In most programming languages there is no default implementation of the equality operator (==) for value types. If your programming language supports operator overloads, you should consider implementing the equality operator. Its behavior should be identical to that of Equals. diff --git a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif index 898aa5c4d7..a8749e9830 100644 --- a/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif +++ b/src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.sarif @@ -3954,27 +3954,6 @@ ] } }, - "CA2229": { - "id": "CA2229", - "shortDescription": "Implement serialization constructors", - "fullDescription": "To fix a violation of this rule, implement the serialization constructor. For a sealed class, make the constructor private; otherwise, make it protected.", - "defaultLevel": "hidden", - "helpUri": "https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2229", - "properties": { - "category": "Usage", - "isEnabledByDefault": true, - "typeName": "SerializationRulesDiagnosticAnalyzer", - "languages": [ - "C#", - "Visual Basic" - ], - "tags": [ - "PortedFromFxCop", - "Telemetry", - "EnabledRuleInAggressiveMode" - ] - } - }, "CA2231": { "id": "CA2231", "shortDescription": "Overload operator equals on overriding value type Equals", diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectlyTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectlyTests.cs deleted file mode 100644 index 46089b0a27..0000000000 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectlyTests.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -namespace Microsoft.NetCore.Analyzers.Runtime.UnitTests -{ - public class ImplementISerializableCorrectlyTests - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.Fixer.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.Fixer.cs deleted file mode 100644 index 4b1aa3482c..0000000000 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.Fixer.cs +++ /dev/null @@ -1,244 +0,0 @@ -// 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.Analyzers.Runtime.SerializationRulesDiagnosticAnalyzer, - Microsoft.NetCore.Analyzers.Runtime.ImplementSerializationConstructorsFixer>; -using VerifyVB = Test.Utilities.VisualBasicCodeFixVerifier< - Microsoft.NetCore.Analyzers.Runtime.SerializationRulesDiagnosticAnalyzer, - Microsoft.NetCore.Analyzers.Runtime.ImplementSerializationConstructorsFixer>; - -namespace Microsoft.NetCore.Analyzers.Runtime.UnitTests -{ - public partial class ImplementSerializationConstructorsFixerTests - { - [Fact] - public async Task CA2229NoConstructorFixAsync() - { - await VerifyCS.VerifyCodeFixAsync(@" -using System; -using System.Runtime.Serialization; -[Serializable] -public class CA2229NoConstructor : ISerializable -{ - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } -}", - GetCA2229DefaultCSharpResultAt(5, 14, "CA2229NoConstructor"), -@" -using System; -using System.Runtime.Serialization; -[Serializable] -public class CA2229NoConstructor : ISerializable -{ - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - - protected CA2229NoConstructor(SerializationInfo serializationInfo, StreamingContext streamingContext) - { - throw new NotImplementedException(); - } -}"); - - await VerifyVB.VerifyCodeFixAsync(@" -Imports System -Imports System.Runtime.Serialization - -Public Class CA2229NoConstructor - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub -End Class", - GetCA2229DefaultBasicResultAt(5, 14, "CA2229NoConstructor"), -@" -Imports System -Imports System.Runtime.Serialization - -Public Class CA2229NoConstructor - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - - Protected Sub New(serializationInfo As SerializationInfo, streamingContext As StreamingContext) - Throw New NotImplementedException() - End Sub -End Class"); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibilityFixAsync() - { - await VerifyCS.VerifyCodeFixAsync(@" -using System; -using System.Runtime.Serialization; -[Serializable] -public class CA2229HasConstructorWrongAccessibility : ISerializable -{ - public CA2229HasConstructorWrongAccessibility(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } -}", - GetCA2229UnsealedCSharpResultAt(7, 12, "CA2229HasConstructorWrongAccessibility"), -@" -using System; -using System.Runtime.Serialization; -[Serializable] -public class CA2229HasConstructorWrongAccessibility : ISerializable -{ - protected CA2229HasConstructorWrongAccessibility(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } -}"); - - await VerifyVB.VerifyCodeFixAsync(@" -Imports System -Imports System.Runtime.Serialization - -Public Class CA2229HasConstructorWrongAccessibility - Implements ISerializable - - Public Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub -End Class", - GetCA2229UnsealedBasicResultAt(8, 16, "CA2229HasConstructorWrongAccessibility"), -@" -Imports System -Imports System.Runtime.Serialization - -Public Class CA2229HasConstructorWrongAccessibility - Implements ISerializable - - Protected Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub -End Class"); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibility2FixAsync() - { - await VerifyCS.VerifyCodeFixAsync(@" -using System; -using System.Runtime.Serialization; -[Serializable] -public sealed class CA2229HasConstructorWrongAccessibility2 : ISerializable -{ - protected internal CA2229HasConstructorWrongAccessibility2(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } -}", - GetCA2229SealedCSharpResultAt(7, 24, "CA2229HasConstructorWrongAccessibility2"), -@" -using System; -using System.Runtime.Serialization; -[Serializable] -public sealed class CA2229HasConstructorWrongAccessibility2 : ISerializable -{ - private CA2229HasConstructorWrongAccessibility2(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } -}"); - - await VerifyVB.VerifyCodeFixAsync(@" -Imports System -Imports System.Runtime.Serialization - -Public NotInheritable Class CA2229HasConstructorWrongAccessibility2 - Implements ISerializable - - Protected Friend Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub -End Class", - GetCA2229SealedBasicResultAt(8, 26, "CA2229HasConstructorWrongAccessibility2"), -@" -Imports System -Imports System.Runtime.Serialization - -Public NotInheritable Class CA2229HasConstructorWrongAccessibility2 - Implements ISerializable - - Private Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub -End Class"); - } - - private static DiagnosticResult GetCA2229DefaultCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229DefaultBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229SealedCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Sealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229SealedBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Sealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229UnsealedCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Unsealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229UnsealedBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Unsealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - } -} diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.cs deleted file mode 100644 index 839a7b0c72..0000000000 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationConstructorsTests.cs +++ /dev/null @@ -1,388 +0,0 @@ -// 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.Analyzers.Runtime.SerializationRulesDiagnosticAnalyzer, - Microsoft.NetCore.Analyzers.Runtime.ImplementSerializationConstructorsFixer>; -using VerifyVB = Test.Utilities.VisualBasicCodeFixVerifier< - Microsoft.NetCore.Analyzers.Runtime.SerializationRulesDiagnosticAnalyzer, - Microsoft.NetCore.Analyzers.Runtime.ImplementSerializationConstructorsFixer>; - -namespace Microsoft.NetCore.Analyzers.Runtime.UnitTests -{ - public partial class ImplementSerializationConstructorsTests - { - [Fact] - public async Task CA2229NoConstructorAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229NoConstructor : ISerializable - { - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229CSharpResultAt(5, 30, "CA2229NoConstructor")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229NoConstructor - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229BasicResultAt(5, 30, "CA2229NoConstructor")); - } - - [Fact] - public async Task CA2229NoConstructorInternalAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - internal class CA2229NoConstructorInternal : ISerializable - { - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }"); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Friend Class CA2229NoConstructorInternal - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class"); - } - - [Fact] - public async Task CA2229HasConstructorAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229HasConstructor : ISerializable - { - protected CA2229HasConstructor(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }"); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229HasConstructor - Implements ISerializable - - Protected Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class"); - } - - [Fact] - public async Task CA2229HasConstructor1Async() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public sealed class CA2229HasConstructor1 : ISerializable - { - private CA2229HasConstructor1(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }"); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public NotInheritable Class CA2229HasConstructor1 - Implements ISerializable - - Private Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class"); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibilityAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229HasConstructorWrongAccessibility : ISerializable - { - public CA2229HasConstructorWrongAccessibility(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229UnsealedCSharpResultAt(7, 28, "CA2229HasConstructorWrongAccessibility")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229HasConstructorWrongAccessibility - Implements ISerializable - - Public Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229UnsealedBasicResultAt(8, 32, "CA2229HasConstructorWrongAccessibility")); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibility1Async() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229HasConstructorWrongAccessibility1 : ISerializable - { - internal CA2229HasConstructorWrongAccessibility1(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229UnsealedCSharpResultAt(7, 30, "CA2229HasConstructorWrongAccessibility1")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229HasConstructorWrongAccessibility1 - Implements ISerializable - - Friend Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229UnsealedBasicResultAt(8, 32, "CA2229HasConstructorWrongAccessibility1")); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibility2Async() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public sealed class CA2229HasConstructorWrongAccessibility2 : ISerializable - { - protected internal CA2229HasConstructorWrongAccessibility2(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229SealedCSharpResultAt(7, 40, "CA2229HasConstructorWrongAccessibility2")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public NotInheritable Class CA2229HasConstructorWrongAccessibility2 - Implements ISerializable - - Protected Friend Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229SealedBasicResultAt(8, 42, "CA2229HasConstructorWrongAccessibility2")); - } - - [Fact] - public async Task CA2229HasConstructorWrongAccessibility3Async() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229HasConstructorWrongAccessibility3 : ISerializable - { - protected internal CA2229HasConstructorWrongAccessibility3(SerializationInfo info, StreamingContext context) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229UnsealedCSharpResultAt(7, 40, "CA2229HasConstructorWrongAccessibility3")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229HasConstructorWrongAccessibility3 - Implements ISerializable - - Protected Friend Sub New(info As SerializationInfo, context As StreamingContext) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229UnsealedBasicResultAt(8, 42, "CA2229HasConstructorWrongAccessibility3")); - } - - [Fact] - public async Task CA2229HasConstructorWrongOrderAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229HasConstructorWrongOrder : ISerializable - { - protected CA2229HasConstructorWrongOrder(StreamingContext context, SerializationInfo info) { } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229CSharpResultAt(5, 30, "CA2229HasConstructorWrongOrder")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229HasConstructorWrongOrder - Implements ISerializable - - Protected Sub New(context As StreamingContext, info As SerializationInfo) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229BasicResultAt(5, 30, "CA2229HasConstructorWrongOrder")); - } - - [Fact] - public async Task CA2229SerializableProperAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - [Serializable] - public class CA2229SerializableProper : ISerializable - { - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229CSharpResultAt(5, 30, "CA2229SerializableProper")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Public Class CA2229SerializableProper - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229BasicResultAt(5, 30, "CA2229SerializableProper")); - } - - private static DiagnosticResult GetCA2229CSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229BasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229SealedCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Sealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229SealedBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Sealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229UnsealedCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Unsealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229UnsealedBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Unsealed) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - } -} diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectlyTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectlyTests.cs deleted file mode 100644 index f52cb1a3bf..0000000000 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/ImplementSerializationMethodsCorrectlyTests.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -namespace Microsoft.NetCore.Analyzers.Runtime.UnitTests -{ - public class ImplementSerializationMethodsCorrectlyTests - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.Fixer.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.Fixer.cs index 7a9ba689f3..43c84e5e42 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.Fixer.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.Fixer.cs @@ -56,10 +56,6 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) } }", }, - ExpectedDiagnostics = - { - GetCA2229DefaultCSharpResultAt(6, 14, "CA2237SerializableMissingAttr"), - }, } }.RunAsync(); @@ -108,10 +104,6 @@ Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) End Sub End Class" }, - ExpectedDiagnostics = - { - GetCA2229DefaultBasicResultAt(6, 14, "CA2237SerializableMissingAttr"), - }, }, }.RunAsync(); } @@ -127,20 +119,6 @@ private static DiagnosticResult GetCA2237BasicResultAt(int line, int column, str #pragma warning disable RS0030 // Do not use banned APIs VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2237) .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229DefaultCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229DefaultBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) #pragma warning restore RS0030 // Do not use banned APIs .WithArguments(objectName); } diff --git a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.cs b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.cs index 82201e992e..0986fc232c 100644 --- a/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.cs +++ b/src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.cs @@ -74,57 +74,6 @@ End Sub End Class"); } - [Fact] - public async Task CA2237SerializableProperWithScopeAsync() - { - await VerifyCS.VerifyAnalyzerAsync(@" - using System; - using System.Runtime.Serialization; - - class CA2237SerializableInternal : ISerializable - { - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - } - - [Serializable] - public class CA2237SerializableProper : ISerializable - { - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new NotImplementedException(); - } - }", - GetCA2229DefaultCSharpResultAt(14, 30, "CA2237SerializableProper")); - - await VerifyVB.VerifyAnalyzerAsync(@" - Imports System - Imports System.Runtime.Serialization - - Friend Class CA2237SerializableInternal - Implements ISerializable - - Protected Sub New(context As StreamingContext, info As SerializationInfo) - End Sub - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class - - - Public Class CA2237SerializableProper - Implements ISerializable - - Public Sub GetObjectData(info as SerializationInfo, context as StreamingContext) Implements ISerializable.GetObjectData - throw new NotImplementedException() - End Sub - End Class", - GetCA2229DefaultBasicResultAt(17, 30, "CA2237SerializableProper")); - } - [Fact] public async Task CA2237SerializableWithBaseAsync() { @@ -239,20 +188,6 @@ private static DiagnosticResult GetCA2237BasicResultAt(int line, int column, str #pragma warning disable RS0030 // Do not use banned APIs VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2237) .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229DefaultCSharpResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyCS.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) -#pragma warning restore RS0030 // Do not use banned APIs - .WithArguments(objectName); - - private static DiagnosticResult GetCA2229DefaultBasicResultAt(int line, int column, string objectName) => -#pragma warning disable RS0030 // Do not use banned APIs - VerifyVB.Diagnostic(SerializationRulesDiagnosticAnalyzer.RuleCA2229Default) - .WithLocation(line, column) #pragma warning restore RS0030 // Do not use banned APIs .WithArguments(objectName); } diff --git a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.Fixer.vb b/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.Fixer.vb deleted file mode 100644 index 6d4a99e78d..0000000000 --- a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.Fixer.vb +++ /dev/null @@ -1,17 +0,0 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -Imports System.Composition -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.CodeFixes -Imports Microsoft.NetCore.Analyzers.Runtime - -Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime - ''' - ''' CA2238: Implement serialization methods correctly - ''' - - Public NotInheritable Class BasicImplementSerializationMethodsCorrectlyFixer - Inherits ImplementSerializationMethodsCorrectlyFixer - - End Class -End Namespace diff --git a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.vb b/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.vb deleted file mode 100644 index 162835d651..0000000000 --- a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementSerializationMethodsCorrectly.vb +++ /dev/null @@ -1,16 +0,0 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Diagnostics -Imports Microsoft.NetCore.Analyzers.Runtime - -Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime - ''' - ''' CA2238: Implement serialization methods correctly - ''' - - Public NotInheritable Class BasicImplementSerializationMethodsCorrectlyAnalyzer - Inherits ImplementSerializationMethodsCorrectlyAnalyzer - - End Class -End Namespace \ No newline at end of file From 79d99b3b8452e949790576dacd6806ca1f2ae886 Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Tue, 5 Sep 2023 15:42:05 -0700 Subject: [PATCH 2/3] Remove unimplmented analyzer files for CA2240 --- ...rpImplementISerializableCorrectly.Fixer.cs | 17 ----- .../CSharpImplementISerializableCorrectly.cs | 16 ----- .../ImplementISerializableCorrectly.Fixer.cs | 29 --------- .../ImplementISerializableCorrectly.cs | 65 ------------------- ...icImplementISerializableCorrectly.Fixer.vb | 17 ----- .../BasicImplementISerializableCorrectly.vb | 16 ----- 6 files changed, 160 deletions(-) delete mode 100644 src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.Fixer.cs delete mode 100644 src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.cs delete mode 100644 src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.Fixer.cs delete mode 100644 src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.cs delete mode 100644 src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.Fixer.vb delete mode 100644 src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.vb diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.Fixer.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.Fixer.cs deleted file mode 100644 index 7d88ddcec4..0000000000 --- a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.Fixer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Composition; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.NetCore.Analyzers.Runtime; - -namespace Microsoft.NetCore.CSharp.Analyzers.Runtime -{ - /// - /// CA2240: Implement ISerializable correctly - /// - [ExportCodeFixProvider(LanguageNames.CSharp), Shared] - public class CSharpImplementISerializableCorrectlyFixer : ImplementISerializableCorrectlyFixer - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.cs b/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.cs deleted file mode 100644 index c17c3cb3be..0000000000 --- a/src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Runtime/CSharpImplementISerializableCorrectly.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.NetCore.Analyzers.Runtime; - -namespace Microsoft.NetCore.CSharp.Analyzers.Runtime -{ - /// - /// CA2240: Implement ISerializable correctly - /// - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public sealed class CSharpImplementISerializableCorrectlyAnalyzer : ImplementISerializableCorrectlyAnalyzer - { - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.Fixer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.Fixer.cs deleted file mode 100644 index 5b74beee01..0000000000 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.Fixer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis.CodeFixes; -using System.Collections.Immutable; -using System.Threading.Tasks; - -namespace Microsoft.NetCore.Analyzers.Runtime -{ - /// - /// CA2240: Implement ISerializable correctly - /// - public abstract class ImplementISerializableCorrectlyFixer : CodeFixProvider - { - public sealed override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Empty; - - public sealed override FixAllProvider GetFixAllProvider() - { - // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for more information on Fix All Providers - return WellKnownFixAllProviders.BatchFixer; - } - - public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) - { - // Fixer not yet implemented. - return Task.CompletedTask; - - } - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.cs deleted file mode 100644 index b1af08359a..0000000000 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ImplementISerializableCorrectly.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Collections.Immutable; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace Microsoft.NetCore.Analyzers.Runtime -{ - /// - /// CA2240: Implement ISerializable correctly - /// - public abstract class ImplementISerializableCorrectlyAnalyzer : DiagnosticAnalyzer - { - internal const string RuleId = "CA2240"; - - /*private static readonly LocalizableString s_localizableTitle = CreateLocalizableResourceString(nameof(ImplementISerializableCorrectlyTitle)); - private static readonly LocalizableString s_localizableDescription = CreateLocalizableResourceString(nameof(ImplementISerializableCorrectlyDescription)); - - internal static readonly DiagnosticDescriptor DefaultRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementISerializableCorrectlyMessageDefault)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor MakeVisibleRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementISerializableCorrectlyMessageMakeVisible)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false); - - internal static readonly DiagnosticDescriptor MakeOverridableRule = DiagnosticDescriptorHelper.Create( - RuleId, - s_localizableTitle, - CreateLocalizableResourceString(nameof(ImplementISerializableCorrectlyMessageMakeOverridable)), - DiagnosticCategory.Usage, - RuleLevel.Disabled, - description: s_localizableDescription, - isPortedFxCopRule: true, - isDataflowRule: false, - isEnabledByDefaultInFxCopAnalyzers: false);*/ - - public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Empty; - //DiagnosticHelpers.EnabledByDefaultIfNotBuildingVSIX ? ImmutableArray.Create(DefaultRule, MakeVisibleRule, MakeOverridableRule) : ImmutableArray.Empty; - -#pragma warning disable RS1025 // Configure generated code analysis - public override void Initialize(AnalysisContext context) -#pragma warning restore RS1025 // Configure generated code analysis - { - context.EnableConcurrentExecution(); - - // TODO: Configure generated code analysis. - //analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); - } - } -} \ No newline at end of file diff --git a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.Fixer.vb b/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.Fixer.vb deleted file mode 100644 index 6c9eceb8a8..0000000000 --- a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.Fixer.vb +++ /dev/null @@ -1,17 +0,0 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -Imports System.Composition -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.CodeFixes -Imports Microsoft.NetCore.Analyzers.Runtime - -Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime - ''' - ''' CA2240: Implement ISerializable correctly - ''' - - Public NotInheritable Class BasicImplementISerializableCorrectlyFixer - Inherits ImplementISerializableCorrectlyFixer - - End Class -End Namespace diff --git a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.vb b/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.vb deleted file mode 100644 index a4dfda8c15..0000000000 --- a/src/NetAnalyzers/VisualBasic/Microsoft.NetCore.Analyzers/Runtime/BasicImplementISerializableCorrectly.vb +++ /dev/null @@ -1,16 +0,0 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. - -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Diagnostics -Imports Microsoft.NetCore.Analyzers.Runtime - -Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime - ''' - ''' CA2240: Implement ISerializable correctly - ''' - - Public NotInheritable Class BasicImplementISerializableCorrectlyAnalyzer - Inherits ImplementISerializableCorrectlyAnalyzer - - End Class -End Namespace \ No newline at end of file From dfe84bb3dfeb1e3c157f7ecc603eb67e19ed2cbe Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Wed, 6 Sep 2023 12:11:51 -0700 Subject: [PATCH 3/3] Update the Severity to Disabled --- src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md index 5a88cc2d89..cb52bd1f99 100644 --- a/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md +++ b/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md @@ -30,4 +30,4 @@ CA2021 | Reliability | Warning | DoNotCallEnumerableCastOrOfTypeWithIncompatible Rule ID | Category | Severity | Notes --------|----------|----------|------- CA2109 | Security | Disabled | ReviewVisibleEventHandlersAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2109) -CA2229 | Usage | Hidden | SerializationRulesDiagnosticAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2229) +CA2229 | Usage | Disabled | SerializationRulesDiagnosticAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2229)