From 883c9f021a9dea339393010a1c329c12ccb44e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20L=C3=B6ffelmann?= Date: Thu, 9 May 2024 16:01:02 -0700 Subject: [PATCH 01/25] Refactor existing Analyzers in prep. to add VB Project. --- ...tors.cs => CSharpDiagnosticDescriptors.cs} | 4 +- ...stem.Windows.Forms.Analyzers.CSharp.csproj | 10 ++-- .../ApplicationConfigurationGenerator.cs | 3 +- .../Forms/Generators/ProjectFileReader.cs | 7 +-- ...indows.Forms.Analyzers.CSharp.Tests.csproj | 4 +- .../ApplicationConfigurationGeneratorTests.cs | 2 +- .../Generators/ProjectFileReaderTests.cs | 7 +-- .../src/DiagnosticDescriptors.cs | 6 ++- .../src/Properties/AssemblyInfo.cs | 2 + .../src/System.Windows.Forms.Analyzers.csproj | 1 - .../System/Windows/Forms/ApplicationConfig.cs | 52 ++++++++----------- .../System/Windows/Forms/IsExternalInit.cs | 9 ++++ 12 files changed, 57 insertions(+), 50 deletions(-) rename src/System.Windows.Forms.Analyzers.CSharp/src/{DiagnosticDescriptors.cs => CSharpDiagnosticDescriptors.cs} (95%) create mode 100644 src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs similarity index 95% rename from src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs index d4754eff009..cb4a7ac4a8d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs @@ -3,9 +3,9 @@ using Microsoft.CodeAnalysis; -namespace System.Windows.Forms.Analyzers; +namespace System.Windows.Forms.Analyzers.CSharp; -internal static class DiagnosticDescriptors +internal static class CSharpDiagnosticDescriptors { private const string Category = "ApplicationConfiguration"; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index ebf9ca26f2d..4818d27df60 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -10,12 +10,6 @@ - - - - - - @@ -28,6 +22,10 @@ + + + + true diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs index 42bcefedd46..5dc3f4eb46b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; +using System.Windows.Forms.Analyzers.CSharp; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -39,7 +40,7 @@ private static void Execute( // https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/automatically-infer-winexe-output-type and not OutputKind.ConsoleApplication) { - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.s_errorUnsupportedProjectType, Location.None, nameof(OutputKind.WindowsApplication))); + context.ReportDiagnostic(Diagnostic.Create(CSharpDiagnosticDescriptors.s_errorUnsupportedProjectType, Location.None, nameof(OutputKind.WindowsApplication))); return; } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs index 6b74a36189b..7555da2c1b7 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; +using System.Windows.Forms.Analyzers.CSharp; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using static System.Windows.Forms.Analyzers.ApplicationConfig; @@ -45,7 +46,7 @@ private static bool TryReadBool(AnalyzerConfigOptionsProvider configOptions, str if (!bool.TryParse(rawValue, out value)) { - diagnostic = Diagnostic.Create(DiagnosticDescriptors.s_propertyCantBeSetToValue, + diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, Location.None, propertyName, rawValue); @@ -80,7 +81,7 @@ private static bool TryReadFont(AnalyzerConfigOptionsProvider configOptions, out } catch (Exception ex) { - diagnostic = Diagnostic.Create(DiagnosticDescriptors.s_propertyCantBeSetToValueWithReason, + diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValueWithReason, Location.None, PropertyNameCSharp.DefaultFont, rawValue, @@ -105,7 +106,7 @@ private static bool TryReadHighDpiMode(AnalyzerConfigOptionsProvider configOptio if (!Enum.TryParse(rawValue, true, out highDpiMode) || !Enum.IsDefined(typeof(HighDpiMode), highDpiMode)) { - diagnostic = Diagnostic.Create(DiagnosticDescriptors.s_propertyCantBeSetToValue, + diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, Location.None, PropertyNameCSharp.HighDpiMode, rawValue); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj index 53b7a42f399..59ab1c4664e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj @@ -1,4 +1,4 @@ - + enable @@ -9,6 +9,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -20,6 +21,7 @@ + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index d9ba63add69..eb6300efa5c 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -21,7 +21,7 @@ class Program static void Main() { ApplicationConfiguration.Initialize(); - } + }P } }"; private const string SourceCompilationFailed = @" diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs index e9007c09a55..8e9a6f8a3e7 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.Globalization; using System.Windows.Forms.Analyzers; +using System.Windows.Forms.Analyzers.CSharp; using System.Windows.Forms.Analyzers.Tests; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -54,7 +55,7 @@ public void ProjectFileReader_TryReadBool_value_invalid(string value) Assert.False(result); Assert.False(returnedValue); Assert.NotNull(diagnostic); - Assert.Equal(DiagnosticDescriptors.s_propertyCantBeSetToValue, diagnostic!.Descriptor); + Assert.Equal(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, diagnostic!.Descriptor); _output.WriteLine(diagnostic.ToString()); } @@ -118,7 +119,7 @@ public void ProjectFileReader_TryReadFont_value_invalid(string font) Assert.False(result); Assert.Null(returnedValue); Assert.NotNull(diagnostic); - Assert.Equal(DiagnosticDescriptors.s_propertyCantBeSetToValueWithReason, diagnostic!.Descriptor); + Assert.Equal(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValueWithReason, diagnostic!.Descriptor); _output.WriteLine(diagnostic.ToString()); } @@ -177,7 +178,7 @@ public void ProjectFileReader_TryReadHighDpiMode_value_invalid(string value) Assert.False(result); Assert.Equal(PropertyDefaultValue.DpiMode, returnedValue); Assert.NotNull(diagnostic); - Assert.Equal(DiagnosticDescriptors.s_propertyCantBeSetToValue, diagnostic!.Descriptor); + Assert.Equal(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, diagnostic!.Descriptor); _output.WriteLine(diagnostic.ToString()); } diff --git a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs index 7106437ba1b..25673fd173e 100644 --- a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs @@ -1,11 +1,12 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Windows.Forms.Analyzers.Resources; using Microsoft.CodeAnalysis; namespace System.Windows.Forms.Analyzers; -internal static class DiagnosticDescriptors +internal static partial class DiagnosticDescriptors { private const string Category = "ApplicationConfiguration"; @@ -23,6 +24,7 @@ internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_CSharp category: Category, defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); + internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_VB = new(id: "WFAC010", title: s_localizableWFAC010Title, diff --git a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs index ba34ad5403a..05d1a5f1d7d 100644 --- a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs @@ -4,3 +4,5 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.Csharp, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] diff --git a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj index f7a4ba390b4..8d9f8c3daf0 100644 --- a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj +++ b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj @@ -25,7 +25,6 @@ true - System diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs index 3d97028fae6..4d77c4ebdf0 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs @@ -1,41 +1,33 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -namespace System.Runtime.CompilerServices +namespace System.Windows.Forms.Analyzers; + +internal partial record ApplicationConfig( + bool EnableVisualStyles, + string? DefaultFont, + HighDpiMode HighDpiMode, + bool UseCompatibleTextRendering) { - internal static class IsExternalInit + public static class PropertyNameCSharp { + public const string EnableVisualStyles = "ApplicationVisualStyles"; + public const string DefaultFont = "ApplicationDefaultFont"; + public const string HighDpiMode = "ApplicationHighDpiMode"; + public const string UseCompatibleTextRendering = "ApplicationUseCompatibleTextRendering"; } -} -namespace System.Windows.Forms.Analyzers -{ - internal partial record ApplicationConfig( - bool EnableVisualStyles, - string? DefaultFont, - HighDpiMode HighDpiMode, - bool UseCompatibleTextRendering) + public static class PropertyNameVisualBasic { - public static class PropertyNameCSharp - { - public const string EnableVisualStyles = "ApplicationVisualStyles"; - public const string DefaultFont = "ApplicationDefaultFont"; - public const string HighDpiMode = "ApplicationHighDpiMode"; - public const string UseCompatibleTextRendering = "ApplicationUseCompatibleTextRendering"; - } - - public static class PropertyNameVisualBasic - { - public const string EnableVisualStyles = "EnableVisualStyles"; - public const string HighDpiMode = "HighDpiMode"; - } + public const string EnableVisualStyles = "EnableVisualStyles"; + public const string HighDpiMode = "HighDpiMode"; + } - public static class PropertyDefaultValue - { - public const bool EnableVisualStyles = true; - public const float FontSize = 9f; - public const HighDpiMode DpiMode = HighDpiMode.SystemAware; - public const bool UseCompatibleTextRendering = false; - } + public static class PropertyDefaultValue + { + public const bool EnableVisualStyles = true; + public const float FontSize = 9f; + public const HighDpiMode DpiMode = HighDpiMode.SystemAware; + public const bool UseCompatibleTextRendering = false; } } diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs new file mode 100644 index 00000000000..4590fd1d388 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit + { + } +} From 0ef828f2555cb1341871c5ac1ddffda9b18918cd Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 4 Jun 2024 23:23:56 -0700 Subject: [PATCH 02/25] Introduce first c# security analyzer and refactor projects accordingly. --- .../src/Resources/SR.resx | 68 ++++++++++++++ .../src/Resources/xlf/SR.cs.xlf | 15 ++++ .../src/Resources/xlf/SR.de.xlf | 15 ++++ .../src/Resources/xlf/SR.es.xlf | 15 ++++ .../src/Resources/xlf/SR.fr.xlf | 15 ++++ .../src/Resources/xlf/SR.it.xlf | 15 ++++ .../src/Resources/xlf/SR.ja.xlf | 15 ++++ .../src/Resources/xlf/SR.ko.xlf | 15 ++++ .../src/Resources/xlf/SR.pl.xlf | 15 ++++ .../src/Resources/xlf/SR.pt-BR.xlf | 15 ++++ .../src/Resources/xlf/SR.ru.xlf | 15 ++++ .../src/Resources/xlf/SR.tr.xlf | 15 ++++ .../src/Resources/xlf/SR.zh-Hans.xlf | 15 ++++ .../src/Resources/xlf/SR.zh-Hant.xlf | 15 ++++ ...stem.Windows.Forms.Analyzers.CSharp.csproj | 4 + .../Analyzers}/CSharpDiagnosticDescriptors.cs | 13 ++- ...PropertySerializationDiagnosticAnalyzer.cs | 90 +++++++++++++++++++ .../ApplicationConfigurationGenerator.cs | 64 +++++++------ ...plicationConfigurationInitializeBuilder.cs | 2 +- .../ProjectFileReader.FontConverter.cs | 2 +- .../ProjectFileReader.cs | 22 +++-- .../ApplicationConfigurationGeneratorTests.cs | 1 + .../ProjectFileReaderTests.FontConverter.cs | 2 +- .../Generators/ProjectFileReaderTests.cs | 3 +- .../src/System.Windows.Forms.Analyzers.csproj | 2 +- ...AnalyzerConfigOptionsProviderExtensions.cs | 4 +- .../{ => Analyzers}/AppManifestAnalyzer.cs | 39 ++++---- .../ApplicationConfig.FontDescriptor.cs | 0 .../ApplicationConfig.FontStyle.cs | 4 + .../ApplicationConfig.GraphicsUnit.cs | 6 ++ .../{ => Analyzers}/ApplicationConfig.cs | 0 .../Diagnostics}/DiagnosticDescriptors.cs | 8 +- .../Analyzers/Diagnostics/DiagnosticIDs.cs | 9 ++ .../Forms/{ => Analyzers}/IsExternalInit.cs | 0 .../Analyzers/AppManifestAnalyzerTests.cs | 1 + .../UserControlWithFontNameEditor.cs | 8 ++ .../UserControlWithObjectCollectionEditor.cs | 1 + 37 files changed, 482 insertions(+), 66 deletions(-) rename src/System.Windows.Forms.Analyzers.CSharp/src/{ => System/Windows/Forms/CSharp/Analyzers}/CSharpDiagnosticDescriptors.cs (89%) create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs rename src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/{Generators => CSharp/Generators/ApplicationConfiguration}/ApplicationConfigurationGenerator.cs (61%) rename src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/{Generators => CSharp/Generators/ApplicationConfiguration}/ApplicationConfigurationInitializeBuilder.cs (97%) rename src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/{Generators => CSharp/Generators/ApplicationConfiguration}/ProjectFileReader.FontConverter.cs (98%) rename src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/{Generators => CSharp/Generators/ApplicationConfiguration}/ProjectFileReader.cs (86%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/AnalyzerConfigOptionsProviderExtensions.cs (85%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/AppManifestAnalyzer.cs (68%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/ApplicationConfig.FontDescriptor.cs (100%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/ApplicationConfig.FontStyle.cs (99%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/ApplicationConfig.GraphicsUnit.cs (99%) rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/ApplicationConfig.cs (100%) rename src/System.Windows.Forms.Analyzers/src/{ => System/Windows/Forms/Analyzers/Diagnostics}/DiagnosticDescriptors.cs (90%) create mode 100644 src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs rename src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/{ => Analyzers}/IsExternalInit.cs (100%) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx index ab1ebe5e0da..fe98c5f747b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx @@ -1,5 +1,64 @@  + @@ -85,4 +144,13 @@ Only TrueType fonts are supported. '{0}' is not a TrueType font. + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + Missing property content code-generation configuration. + + + Property '{0}' does not configure its property content code-generation. + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf index af6b542d46d..a71ea55a6fb 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf @@ -47,6 +47,21 @@ Nepodporovaná hodnota vlastnosti + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf index 0cfa8aa8e2c..5df46dabf62 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf @@ -47,6 +47,21 @@ Nicht unterstützter Eigenschaftswert + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf index 2a1fa1e3604..0379ee03073 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf @@ -47,6 +47,21 @@ Valor de propiedad no admitido + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf index 87dc6c91f7b..5d6494eb134 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf @@ -47,6 +47,21 @@ Valeur de propriété non prise en charge + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf index bf2c832aa7c..5453a262183 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf @@ -47,6 +47,21 @@ Valore di proprietà non supportato + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf index 3401eb36eaa..1dbeec8f00f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf @@ -47,6 +47,21 @@ サポートされていないプロパティの値 + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf index 84db4db0686..19faff7feae 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf @@ -47,6 +47,21 @@ 지원되지 않는 속성 값 + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf index c87c66a4637..04b8aa2c7dd 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf @@ -47,6 +47,21 @@ Nieobsługiwana wartość właściwości + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf index 7bbb40bb5bd..6d9b9ce1bc8 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf @@ -47,6 +47,21 @@ Valor de propriedade não suportado + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf index 61ea40a78e4..64d8df0e25b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf @@ -47,6 +47,21 @@ Не поддерживаемое значение свойства + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf index 7d9627c26e0..6996a2bce0f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf @@ -47,6 +47,21 @@ Desteklenmeyen özellik değeri + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf index 388b6508ecd..2a9b7efbc39 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf @@ -47,6 +47,21 @@ 不支持的属性值 + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf index 5e2f1751dec..94dbd73e80a 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf @@ -47,6 +47,21 @@ 不支援的屬性值 + + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + + + + Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure its property content code-generation. + + + + Missing property content code-generation configuration. + Missing property content code-generation configuration. + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index 4818d27df60..713de6ab817 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -33,4 +33,8 @@ + + + + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs similarity index 89% rename from src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs index cb4a7ac4a8d..a3084abf340 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs @@ -1,9 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Windows.Forms.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; -namespace System.Windows.Forms.Analyzers.CSharp; +namespace System.Windows.Forms.CSharp.Analyzers; internal static class CSharpDiagnosticDescriptors { @@ -11,17 +12,21 @@ internal static class CSharpDiagnosticDescriptors private static readonly LocalizableString s_localizableWFAC001Title = new LocalizableResourceString(nameof(SR.WFAC001Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC001Message = new LocalizableResourceString(nameof(SR.WFAC001Message), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC002Title = new LocalizableResourceString(nameof(SR.WFAC002Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC002Message = new LocalizableResourceString(nameof(SR.WFAC002Message), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC002MessageWithReason = new LocalizableResourceString(nameof(SR.WFAC002MessageWithReason), SR.ResourceManager, typeof(SR)); public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType - = new(id: "WFAC001", + = new(id: DiagnosticIDs.UnsupportedProjectType, title: s_localizableWFAC001Title, messageFormat: s_localizableWFAC001Message, category: Category, @@ -29,7 +34,7 @@ public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType isEnabledByDefault: true); public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue - = new(id: "WFAC002", + = new(id: DiagnosticIDs.PropertyCantBeSetToValue, title: s_localizableWFAC002Title, messageFormat: s_localizableWFAC002Message, category: Category, @@ -37,7 +42,7 @@ public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue isEnabledByDefault: true); public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason - = new(id: "WFAC002", + = new(id: DiagnosticIDs.PropertyCantBeSetToValue, title: s_localizableWFAC002Title, #pragma warning disable RS1032 // Define diagnostic message correctly. Justification - exception messages end with a comma. messageFormat: s_localizableWFAC002MessageWithReason, diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs new file mode 100644 index 00000000000..3f8c1a0dcd6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -0,0 +1,90 @@ +using System.Collections.Immutable; +using System.ComponentModel; +using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization; + +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public class ControlPropertySerializationDiagnosticAnalyzer : DiagnosticAnalyzer +{ + // You can change these strings in the Resources.resx file. If you do not want your analyzer to be localize-able, you can use regular strings for Title and MessageFormat. + // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Localizing%20Analyzers.md for more on localization + + private const string Category = "WinForms Security"; + + private static readonly DiagnosticDescriptor s_rule = new( + id: DiagnosticIDs.ControlPropertySerialization, + title: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerTitle), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), + category: Category, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerDescription), SR.ResourceManager, typeof(SR))); + + public override ImmutableArray SupportedDiagnostics + => ImmutableArray.Create(s_rule); + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterSymbolAction(AnalyzeSymbol, SymbolKind.Property); + } + + private static void AnalyzeSymbol(SymbolAnalysisContext context) + { + // We analyze only properties. + var propertySymbol = (IPropertySymbol)context.Symbol; + + // Does the property belong to a class which derives from Component? + if (propertySymbol.ContainingType is null + || !propertySymbol + .ContainingType + .AllInterfaces + .Any(i => i.Name == nameof(IComponent))) + { + return; + } + + // Is the read/write and at least internal? + if (propertySymbol.SetMethod is null + || propertySymbol.DeclaredAccessibility < Accessibility.Internal) + { + return; + } + + // Is the property attributed with DesignerSerializationVisibility or DefaultValue? + if (propertySymbol.GetAttributes() + .Any(a => a.AttributeClass.Name is (nameof(DesignerSerializationVisibilityAttribute)) + or (nameof(DefaultValueAttribute)))) + { + return; + } + + // Now, it get's a bit more tedious: + // If the Serialization is managed via ShouldSerialize and Reset methods, we are also fine, + // so let's check for that. First, let's get the class of the property: + var classSymbol = propertySymbol.ContainingType; + + // Now, let's check if the class has a method ShouldSerialize method: + var shouldSerializeMethod = classSymbol + .GetMembers() + .OfType() + .FirstOrDefault(m => m.Name == $"ShouldSerialize{propertySymbol.Name}"); + + // Let's make sure the method returns a bool and has no parameters: + if (shouldSerializeMethod is null + || shouldSerializeMethod.ReturnType.SpecialType != SpecialType.System_Boolean + || shouldSerializeMethod.Parameters.Length > 0) + { + + // For ALL such other symbols, produce a diagnostic. + var diagnostic = Diagnostic.Create(s_rule, propertySymbol.Locations[0], propertySymbol.Name); + + context.ReportDiagnostic(diagnostic); + } + } +} diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs similarity index 61% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs index 5dc3f4eb46b..02d26ec5d53 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs @@ -2,11 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; -using System.Windows.Forms.Analyzers.CSharp; +using System.Windows.Forms.CSharp.Analyzers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace System.Windows.Forms.Generators; +namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; [Generator(LanguageNames.CSharp)] internal class ApplicationConfigurationGenerator : IIncrementalGenerator @@ -40,11 +40,15 @@ private static void Execute( // https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/automatically-infer-winexe-output-type and not OutputKind.ConsoleApplication) { - context.ReportDiagnostic(Diagnostic.Create(CSharpDiagnosticDescriptors.s_errorUnsupportedProjectType, Location.None, nameof(OutputKind.WindowsApplication))); + context.ReportDiagnostic(Diagnostic.Create( + CSharpDiagnosticDescriptors.s_errorUnsupportedProjectType, + Location.None, nameof(OutputKind.WindowsApplication))); + return; } string? code = ApplicationConfigurationInitializeBuilder.GenerateInitialize(projectNamespace, applicationConfig); + if (code is not null) { context.AddSource("ApplicationConfiguration.g.cs", code); @@ -55,7 +59,9 @@ private static void Execute( { string? ns = null; - if (node.Ancestors().FirstOrDefault(a => a is NamespaceDeclarationSyntax) is NamespaceDeclarationSyntax namespaceSyntax) + if (node + .Ancestors() + .FirstOrDefault(a => a is NamespaceDeclarationSyntax) is NamespaceDeclarationSyntax namespaceSyntax) { ns = namespaceSyntax.Name.ToString(); } @@ -65,53 +71,61 @@ private static void Execute( public void Initialize(IncrementalGeneratorInitializationContext context) { - var outputKindProvider = context.CompilationProvider.Select((compilation, _) => compilation.Options.OutputKind); - var syntaxProvider = context.SyntaxProvider.CreateSyntaxProvider( + IncrementalValueProvider outputKindProvider = context.CompilationProvider.Select((compilation, _) + => compilation.Options.OutputKind); + + IncrementalValuesProvider syntaxProvider = context.SyntaxProvider.CreateSyntaxProvider( predicate: static (syntaxNode, _) => IsSupportedSyntaxNode(syntaxNode), transform: static (generatorSyntaxContext, _) => GetUserProjectNamespace(generatorSyntaxContext.Node)); - var globalConfig = ProjectFileReader.ReadApplicationConfig(context.AnalyzerConfigOptionsProvider); + IncrementalValueProvider<(ApplicationConfig? ApplicationConfig, Diagnostic? Diagnostic)> globalConfig + = ProjectFileReader.ReadApplicationConfig(context.AnalyzerConfigOptionsProvider); - var inputs = outputKindProvider + IncrementalValueProvider<(OutputKind OutputKind, Collections.Immutable.ImmutableArray ProjectNamespaces, ApplicationConfig? ApplicationConfig, Diagnostic? ApplicationConfigDiagnostics)> inputs + = outputKindProvider .Combine(syntaxProvider.Collect()) .Combine(globalConfig) .Select((data, cancellationToken) => (OutputKind: data.Left.Left, ProjectNamespaces: data.Left.Right, - ApplicationConfig: data.Right.ApplicationConfig, + data.Right.ApplicationConfig, ApplicationConfigDiagnostics: data.Right.Diagnostic)); context.RegisterSourceOutput( inputs, - (context, source) => Execute(context, source.ProjectNamespaces.Length > 0, source.ProjectNamespaces.Length > 0 ? source.ProjectNamespaces[0] : null, source.OutputKind, source.ApplicationConfig, source.ApplicationConfigDiagnostics)); + (context, source) + => Execute( + context: context, + hasSupportedSyntaxNode: source.ProjectNamespaces.Length > 0, + projectNamespace: source.ProjectNamespaces.Length > 0 + ? source.ProjectNamespaces[0] + : null, + outputKind: source.OutputKind, + applicationConfig: source.ApplicationConfig, + applicationConfigDiagnostics: source.ApplicationConfigDiagnostics)); } public static bool IsSupportedSyntaxNode(SyntaxNode syntaxNode) { -#pragma warning disable SA1513 // Closing brace should be followed by blank line - if (syntaxNode is InvocationExpressionSyntax + return syntaxNode is InvocationExpressionSyntax + { + ArgumentList.Arguments.Count: 0, + Expression: MemberAccessExpressionSyntax { - ArgumentList.Arguments.Count: 0, - Expression: MemberAccessExpressionSyntax - { - Name.Identifier.ValueText: "Initialize", - Expression: + Name.Identifier.ValueText: "Initialize", + Expression: MemberAccessExpressionSyntax // For: SourceGenerated.ApplicationConfiguration.Initialize() { Name.Identifier.ValueText: "ApplicationConfiguration" } + or + IdentifierNameSyntax // For: ApplicationConfiguration.Initialize() with a using statement { Identifier.ValueText: "ApplicationConfiguration" } - } - }) - { - return true; - } -#pragma warning restore SA1513 // Closing brace should be followed by blank line - - return false; + } + }; } } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationInitializeBuilder.cs similarity index 97% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationInitializeBuilder.cs index fdb9d7ae931..0e11caa168c 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationInitializeBuilder.cs @@ -4,7 +4,7 @@ using System.Text; using System.Windows.Forms.Analyzers; -namespace System.Windows.Forms.Generators; +namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; internal static class ApplicationConfigurationInitializeBuilder { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs similarity index 98% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs index 66929f17079..ffafd7067f8 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs @@ -5,7 +5,7 @@ using System.Globalization; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators; +namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; internal static partial class ProjectFileReader { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs similarity index 86% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs index 7555da2c1b7..42b0676fae0 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; -using System.Windows.Forms.Analyzers.CSharp; +using System.Windows.Forms.CSharp.Analyzers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators; +namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; internal static partial class ProjectFileReader { @@ -15,20 +15,24 @@ internal static partial class ProjectFileReader => configOptionsProvider.Select( (analyzerConfigOptions, cancellationToken) => { - Diagnostic? diagnostic; if (!TryReadBool(analyzerConfigOptions, PropertyNameCSharp.EnableVisualStyles, defaultValue: PropertyDefaultValue.EnableVisualStyles, - out bool enableVisualStyles, out diagnostic) || - !TryReadBool(analyzerConfigOptions, PropertyNameCSharp.UseCompatibleTextRendering, + out bool enableVisualStyles, out Diagnostic? diagnostic) + || !TryReadBool(analyzerConfigOptions, PropertyNameCSharp.UseCompatibleTextRendering, defaultValue: PropertyDefaultValue.UseCompatibleTextRendering, - out bool useCompatibleTextRendering, out diagnostic) || - !TryReadFont(analyzerConfigOptions, out FontDescriptor? font, out diagnostic) || - !TryReadHighDpiMode(analyzerConfigOptions, out HighDpiMode highDpiMode, out diagnostic)) + out bool useCompatibleTextRendering, out diagnostic) + || !TryReadFont(analyzerConfigOptions, out FontDescriptor? font, out diagnostic) + || !TryReadHighDpiMode(analyzerConfigOptions, out HighDpiMode highDpiMode, out diagnostic)) { return ((ApplicationConfig?)null, diagnostic); } - ApplicationConfig projectConfig = new(enableVisualStyles, font?.ToString(), highDpiMode, useCompatibleTextRendering); + ApplicationConfig projectConfig = new( + EnableVisualStyles: enableVisualStyles, + DefaultFont: font?.ToString(), + HighDpiMode: highDpiMode, + UseCompatibleTextRendering: useCompatibleTextRendering); + return (projectConfig, null); }); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index eb6300efa5c..a17c1da4e95 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -4,6 +4,7 @@ using System.Text; using System.Windows.Forms.Analyzers; using System.Windows.Forms.Analyzers.Tests; +using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs index 86dff73254b..2a432895264 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs @@ -4,7 +4,7 @@ using System.ComponentModel; using System.Globalization; using static System.Windows.Forms.Analyzers.ApplicationConfig; -using static System.Windows.Forms.Generators.ProjectFileReader; +using static System.Windows.Forms.CSharp.Generators.ApplicationConfiguration.ProjectFileReader; namespace System.Windows.Forms.Generators.Tests; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs index 8e9a6f8a3e7..60a852be5ca 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs @@ -4,8 +4,9 @@ using System.Collections.Immutable; using System.Globalization; using System.Windows.Forms.Analyzers; -using System.Windows.Forms.Analyzers.CSharp; using System.Windows.Forms.Analyzers.Tests; +using System.Windows.Forms.CSharp.Analyzers; +using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Xunit.Abstractions; diff --git a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj index 8d9f8c3daf0..15a4c8186c1 100644 --- a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj +++ b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AnalyzerConfigOptionsProviderExtensions.cs similarity index 85% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AnalyzerConfigOptionsProviderExtensions.cs index 9495f028900..6b75e96b8d8 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AnalyzerConfigOptionsProviderExtensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.CodeAnalysis.Diagnostics; @@ -10,7 +10,7 @@ internal static class AnalyzerConfigOptionsProviderExtensions /// /// Attempts to read a value for the requested MSBuild property. /// - /// The global optins. + /// The global options. /// The name of the property to read the value for. /// The property's value. /// if the property is present; otherwise . diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs similarity index 68% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs index aa504c345aa..8f0aa3a6592 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Immutable; +using System.Windows.Forms.Analyzers.Diagnostics; using System.Xml; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -10,17 +11,19 @@ namespace System.Windows.Forms.Analyzers; [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] -public partial class AppManifestAnalyzer : DiagnosticAnalyzer +internal partial class AppManifestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray SupportedDiagnostics - => ImmutableArray.Create(DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, - DiagnosticDescriptors.s_migrateHighDpiSettings_VB); + => ImmutableArray.Create( + DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, + DiagnosticDescriptors.s_migrateHighDpiSettings_VB); public override void Initialize(AnalysisContext context) { - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); - context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze + | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.EnableConcurrentExecution(); context.RegisterAdditionalFileAction(AdditionalFileAction); } @@ -30,8 +33,6 @@ private void AdditionalFileAction(AdditionalFileAnalysisContext context) { VerifyAppManifest(context, context.AdditionalFile); } - - // TODO: look for app.config? } private static void VerifyAppManifest(AdditionalFileAnalysisContext context, AdditionalText appManifest) @@ -54,27 +55,29 @@ private static void VerifyAppManifest(AdditionalFileAnalysisContext context, Add return; } - XmlNamespaceManager nsmgr = new(doc.NameTable); - nsmgr.AddNamespace("v1", "urn:schemas-microsoft-com:asm.v1"); - nsmgr.AddNamespace("v3", "urn:schemas-microsoft-com:asm.v3"); - nsmgr.AddNamespace("v3ws", "http://schemas.microsoft.com/SMI/2005/WindowsSettings"); + XmlNamespaceManager nsMgr = new(doc.NameTable); + nsMgr.AddNamespace("v1", "urn:schemas-microsoft-com:asm.v1"); + nsMgr.AddNamespace("v3", "urn:schemas-microsoft-com:asm.v3"); + nsMgr.AddNamespace("v3ws", "http://schemas.microsoft.com/SMI/2005/WindowsSettings"); - if (doc.DocumentElement.SelectSingleNode("//v3:application/v3:windowsSettings/v3ws:dpiAware", nsmgr) is not null) + if (doc.DocumentElement.SelectSingleNode("//v3:application/v3:windowsSettings/v3ws:dpiAware", nsMgr) is not null) { switch (context.Compilation.Language) { case LanguageNames.CSharp: context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, - Location.None, - appManifest.Path, - ApplicationConfig.PropertyNameCSharp.HighDpiMode)); + Location.None, + appManifest.Path, + ApplicationConfig.PropertyNameCSharp.HighDpiMode)); break; + case LanguageNames.VisualBasic: context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.s_migrateHighDpiSettings_VB, - Location.None, - appManifest.Path, - ApplicationConfig.PropertyNameVisualBasic.HighDpiMode)); + Location.None, + appManifest.Path, + ApplicationConfig.PropertyNameVisualBasic.HighDpiMode)); break; + default: throw new NotSupportedException(); } diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.FontDescriptor.cs similarity index 100% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.FontDescriptor.cs diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.FontStyle.cs similarity index 99% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.FontStyle.cs index f5af959ce99..f283070732a 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.FontStyle.cs @@ -13,18 +13,22 @@ public enum FontStyle /// Normal text. /// Regular = 0, + /// /// Bold text. /// Bold = 1, + /// /// Italic text. /// Italic = 2, + /// /// Underlined text. /// Underline = 4, + /// /// Text with a line through the middle. /// diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.GraphicsUnit.cs similarity index 99% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.GraphicsUnit.cs index 22dce2e37f6..693f8a2a9ac 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.GraphicsUnit.cs @@ -12,26 +12,32 @@ public enum GraphicsUnit /// Specifies the world unit as the unit of measure. /// World = 0, + /// /// Specifies 1/75 inch as the unit of measure. /// Display = 1, + /// /// Specifies a device pixel as the unit of measure. /// Pixel = 2, + /// /// Specifies a printer's point (1/72 inch) as the unit of measure. /// Point = 3, + /// /// Specifies the inch as the unit of measure. /// Inch = 4, + /// /// Specifies the document unit (1/300 inch) as the unit of measure. /// Document = 5, + /// /// Specifies the millimeter as the unit of measure. /// diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.cs similarity index 100% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/ApplicationConfig.cs diff --git a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs similarity index 90% rename from src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs index 25673fd173e..12d389f911f 100644 --- a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs @@ -4,7 +4,7 @@ using System.Windows.Forms.Analyzers.Resources; using Microsoft.CodeAnalysis; -namespace System.Windows.Forms.Analyzers; +namespace System.Windows.Forms.Analyzers.Diagnostics; internal static partial class DiagnosticDescriptors { @@ -12,13 +12,15 @@ internal static partial class DiagnosticDescriptors private static readonly LocalizableString s_localizableWFAC010Title = new LocalizableResourceString(nameof(SR.WFAC010Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC010Message_CS = new LocalizableResourceString(nameof(SR.WFAC010Message_CS), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFAC010Message_VB = new LocalizableResourceString(nameof(SR.WFAC010Message_VB), SR.ResourceManager, typeof(SR)); internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_CSharp - = new(id: "WFAC010", + = new(id: DiagnosticIDs.MigrateHighDpiSettings, title: s_localizableWFAC010Title, messageFormat: s_localizableWFAC010Message_CS, category: Category, @@ -26,7 +28,7 @@ internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_CSharp isEnabledByDefault: true); internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_VB - = new(id: "WFAC010", + = new(id: DiagnosticIDs.MigrateHighDpiSettings, title: s_localizableWFAC010Title, messageFormat: s_localizableWFAC010Message_VB, category: Category, diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs new file mode 100644 index 00000000000..62bf84022e6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -0,0 +1,9 @@ +namespace System.Windows.Forms.Analyzers.Diagnostics; + +internal static class DiagnosticIDs +{ + public const string UnsupportedProjectType = "WFAC001"; + public const string PropertyCantBeSetToValue = "WFAC002"; + public const string ControlPropertySerialization = "WFAC003"; + public const string MigrateHighDpiSettings = "WFAC010"; +} diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs similarity index 100% rename from src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/IsExternalInit.cs rename to src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index 800eaf6ee0c..6cb4165f0be 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Windows.Forms.Analyzers.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using Xunit; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithFontNameEditor.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithFontNameEditor.cs index bc19a4be9eb..a1cad24ff14 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithFontNameEditor.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithFontNameEditor.cs @@ -19,6 +19,7 @@ public UserControlWithFontNameEditor() [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameBold { get { return "Arial Black"; } @@ -29,6 +30,7 @@ public string FontNameBold [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameBoldItalic { get { return "Forte"; } @@ -39,6 +41,7 @@ public string FontNameBoldItalic [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameEmpty { get { return ""; } @@ -49,6 +52,7 @@ public string FontNameEmpty [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public int FontNameInt { get { return -1345; } @@ -59,6 +63,7 @@ public int FontNameInt [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameInvalid { get { return "some invalid font family"; } @@ -69,6 +74,7 @@ public string FontNameInvalid [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameNull { get { return null; } @@ -79,6 +85,7 @@ public string FontNameNull [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameItalics { get { return "Lucida Handwriting"; } @@ -89,6 +96,7 @@ public string FontNameItalics [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [Category(Category)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string FontNameRegular { get { return "Arial"; } diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithObjectCollectionEditor.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithObjectCollectionEditor.cs index afd6faca6c7..de71818e490 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithObjectCollectionEditor.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/UserControls/UserControlWithObjectCollectionEditor.cs @@ -20,6 +20,7 @@ public UserControlWithObjectCollectionEditor() [EditorBrowsable(EditorBrowsableState.Always)] [Category("Accessibility")] [TypeConverter(typeof(SomeCollectionTypeConverter))] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public IList AAAAAFirstCollection { get { return new List(new int[] { 1, 2, 3 }); } From 8fd4dc62e6985af94556c88cd2924a2b8d6abd6d Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Thu, 6 Jun 2024 11:02:05 -0700 Subject: [PATCH 03/25] Bump up Roslyn/Analyzer NuGet package versions. --- .../src/Resources/SR.resx | 9 +- .../src/Resources/xlf/SR.cs.xlf | 17 ++- .../src/Resources/xlf/SR.de.xlf | 17 ++- .../src/Resources/xlf/SR.es.xlf | 17 ++- .../src/Resources/xlf/SR.fr.xlf | 17 ++- .../src/Resources/xlf/SR.it.xlf | 17 ++- .../src/Resources/xlf/SR.ja.xlf | 17 ++- .../src/Resources/xlf/SR.ko.xlf | 17 ++- .../src/Resources/xlf/SR.pl.xlf | 17 ++- .../src/Resources/xlf/SR.pt-BR.xlf | 17 ++- .../src/Resources/xlf/SR.ru.xlf | 17 ++- .../src/Resources/xlf/SR.tr.xlf | 17 ++- .../src/Resources/xlf/SR.zh-Hans.xlf | 17 ++- .../src/Resources/xlf/SR.zh-Hant.xlf | 17 ++- ...stem.Windows.Forms.Analyzers.CSharp.csproj | 10 +- .../Analyzers/CSharpDiagnosticDescriptors.cs | 2 - ...PropertySerializationDiagnosticAnalyzer.cs | 7 +- ...rSerializationVisibilityCodeFixProvider.cs | 106 ++++++++++++++++++ .../Analyzers/Diagnostics/DiagnosticIDs.cs | 8 +- ...ystem.Windows.Forms.Analyzers.Tests.csproj | 6 +- 20 files changed, 271 insertions(+), 98 deletions(-) create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx index fe98c5f747b..9cd12f7cd9d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx @@ -145,12 +145,15 @@ Only TrueType fonts are supported. '{0}' is not a TrueType font. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Missing property content code-generation configuration. + Missing code serialization configuration for property content - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + + + Add DesignerSerializationVisibilityAttribute to property diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf index a71ea55a6fb..f58b4bcc0aa 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Písmo {0} nebylo nalezeno. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf index 5df46dabf62..41a1917dc66 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Die Schriftart {0} kann nicht gefunden werden. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf index 0379ee03073..7d0b03da9ae 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. No se puede encontrar la fuente '{0}'. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf index 5d6494eb134..467aa1b0bdb 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Impossible de trouver la police '{0}'. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf index 5453a262183..aa35e091cad 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Impossibile trovare il tipo di carattere '{0}'. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf index 1dbeec8f00f..73cb5f6b615 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. フォント '{0}' が見つかりません。 @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf index 19faff7feae..2cc1b69a376 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. '{0}' 글꼴을 찾을 수 없습니다. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf index 04b8aa2c7dd..250fa61c49b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Nie można odnaleźć czcionki „{0}”. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf index 6d9b9ce1bc8..f257da1083e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. A fonte '{0}' não pode ser encontrada. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf index 64d8df0e25b..0adcf7b6bba 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. Шрифт '{0}' не найден. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf index 6996a2bce0f..0056a61da20 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. '{0}' yazı tipi bulunamıyor. @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf index 2a9b7efbc39..c57cf319e0e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. 无法找到字体“{0}”。 @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf index 94dbd73e80a..6774587a7b9 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + Font '{0}' cannot be found. 找不到字型 '{0}'。 @@ -48,18 +53,18 @@ - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. - When a property does not have it property content code-generation strategy configured, the Designer will automatically try to generate code into InitializeComponent to rebuild the property content at runtime or even binary-serialize it into Resource files, which can accidentelly leak data or lead to other security issues. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - Property '{0}' does not configure its property content code-generation. - Property '{0}' does not configure its property content code-generation. + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content - Missing property content code-generation configuration. - Missing property content code-generation configuration. + Missing code serialization configuration for property content + Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index 713de6ab817..423e74962a7 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -15,8 +15,12 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + @@ -33,8 +37,4 @@ - - - - diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs index a3084abf340..387f3aa7a48 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs @@ -44,9 +44,7 @@ public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason = new(id: DiagnosticIDs.PropertyCantBeSetToValue, title: s_localizableWFAC002Title, -#pragma warning disable RS1032 // Define diagnostic message correctly. Justification - exception messages end with a comma. messageFormat: s_localizableWFAC002MessageWithReason, -#pragma warning restore RS1032 // Define diagnostic message correctly category: Category, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs index 3f8c1a0dcd6..6874dadb344 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -30,7 +30,6 @@ public override void Initialize(AnalysisContext context) { context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSymbolAction(AnalyzeSymbol, SymbolKind.Property); } @@ -58,7 +57,7 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) // Is the property attributed with DesignerSerializationVisibility or DefaultValue? if (propertySymbol.GetAttributes() - .Any(a => a.AttributeClass.Name is (nameof(DesignerSerializationVisibilityAttribute)) + .Any(a => a?.AttributeClass?.Name is (nameof(DesignerSerializationVisibilityAttribute)) or (nameof(DefaultValueAttribute)))) { return; @@ -67,10 +66,10 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) // Now, it get's a bit more tedious: // If the Serialization is managed via ShouldSerialize and Reset methods, we are also fine, // so let's check for that. First, let's get the class of the property: - var classSymbol = propertySymbol.ContainingType; + INamedTypeSymbol classSymbol = propertySymbol.ContainingType; // Now, let's check if the class has a method ShouldSerialize method: - var shouldSerializeMethod = classSymbol + IMethodSymbol? shouldSerializeMethod = classSymbol .GetMembers() .OfType() .FirstOrDefault(m => m.Name == $"ShouldSerialize{propertySymbol.Name}"); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs new file mode 100644 index 00000000000..dfc43892b93 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.CSharp; +using System.Collections.Immutable; +using System.Composition; +using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis.Text; + +namespace System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility; + +[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AddDesignerSerializationVisibilityCodeFixProvider)), Shared] +internal class AddDesignerSerializationVisibilityCodeFixProvider : CodeFixProvider +{ + private const string SystemComponentModelName = "System.ComponentModel"; + + public sealed override ImmutableArray FixableDiagnosticIds + => ImmutableArray.Create(DiagnosticIDs.ControlPropertySerialization); + + public sealed override FixAllProvider GetFixAllProvider() + => WellKnownFixAllProviders.BatchFixer; + + public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) + { + // Cannot be null - otherwise we wouldn't have a diagnostic of that ID. + SyntaxNode root = (await context + .Document + .GetSyntaxRootAsync(context.CancellationToken) + .ConfigureAwait(false))!; + + Diagnostic diagnostic = context.Diagnostics.First(); + TextSpan diagnosticSpan = diagnostic.Location.SourceSpan; + + // Find the type declaration identified by the diagnostic. + PropertyDeclarationSyntax? propertyDeclaration = root.FindToken(diagnosticSpan.Start) + .Parent! + .AncestorsAndSelf() + .OfType() + .First(); + + // Register a code action that will invoke the fix. + context.RegisterCodeFix( + CodeAction.Create( + title: SR.AddDesignerSerializationVisibilityCodeFixTitle, + createChangedDocument: c => AddDesignerSerializationAttribute(context.Document, propertyDeclaration, c), + equivalenceKey: nameof(SR.AddDesignerSerializationVisibilityCodeFixTitle)), + diagnostic); + } + + private static async Task AddDesignerSerializationAttribute( + Document document, + PropertyDeclarationSyntax propertyDeclarationSyntax, + CancellationToken cancellationToken) + { + if (propertyDeclarationSyntax is null) + { + return document; + } + + // Generate the Attribute we need to put on the property + AttributeSyntax designerSerializationVisibilityAttribute = SyntaxFactory.Attribute( + SyntaxFactory.ParseName("DesignerSerializationVisibility"), + SyntaxFactory.ParseAttributeArgumentList("(DesignerSerializationVisibility.Hidden)")); + + // Make sure, we keep the white spaces before and after the property + SyntaxTriviaList leadingTrivia = propertyDeclarationSyntax.GetLeadingTrivia(); + SyntaxTriviaList trailingTrivia = propertyDeclarationSyntax.GetTrailingTrivia(); + + // Add the attribute to the property: + PropertyDeclarationSyntax newProperty = propertyDeclarationSyntax + .AddAttributeLists( + SyntaxFactory.AttributeList( + SyntaxFactory.SingletonSeparatedList(designerSerializationVisibilityAttribute))); + + // Let's restore the trivia: + newProperty = newProperty.WithLeadingTrivia(leadingTrivia); + newProperty = newProperty.WithTrailingTrivia(trailingTrivia); + + var usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(SystemComponentModelName)); + + // Let's check, if we already have the using directive or if we need to add it: + // (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) + SyntaxNode root = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false))!; + + // Let's check if we already have the using directive: + if (!root.DescendantNodes() + .OfType() + .Any(u => u?.Name?.ToString() == SystemComponentModelName)) + { + // We need to add the using directive: + SyntaxNode firstNode = root.DescendantNodes().First(); + root = root.InsertNodesBefore(firstNode, [usingDirective]); + } + + // Produce a new root: + SyntaxNode originalRoot = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false))!; + SyntaxNode newRoot = originalRoot.ReplaceNode(propertyDeclarationSyntax, newProperty); + + // Generate the new document: + return document.WithSyntaxRoot(newRoot); + } +} diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs index 62bf84022e6..90b0ba7285b 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -2,8 +2,14 @@ internal static class DiagnosticIDs { + // Application Configuration public const string UnsupportedProjectType = "WFAC001"; public const string PropertyCantBeSetToValue = "WFAC002"; - public const string ControlPropertySerialization = "WFAC003"; public const string MigrateHighDpiSettings = "WFAC010"; + + // Security + public const string ControlPropertySerialization = "WFAC100"; + + // Memory Management + public const string DisposeModalDialog = "WFAC200"; } diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System.Windows.Forms.Analyzers.Tests.csproj b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System.Windows.Forms.Analyzers.Tests.csproj index 45d417503e7..949bc02cc24 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System.Windows.Forms.Analyzers.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System.Windows.Forms.Analyzers.Tests.csproj @@ -11,11 +11,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + From ac2be21cac3370193c06748d00022e8bfdbdb418 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Thu, 6 Jun 2024 18:46:31 -0700 Subject: [PATCH 04/25] Fix formatting in resource files and inconsistencies in unshipped files. --- .../src/Resources/SR.resx | 4 ++-- .../src/Resources/xlf/SR.cs.xlf | 8 ++++---- .../src/Resources/xlf/SR.de.xlf | 8 ++++---- .../src/Resources/xlf/SR.es.xlf | 8 ++++---- .../src/Resources/xlf/SR.fr.xlf | 8 ++++---- .../src/Resources/xlf/SR.it.xlf | 8 ++++---- .../src/Resources/xlf/SR.ja.xlf | 8 ++++---- .../src/Resources/xlf/SR.ko.xlf | 8 ++++---- .../src/Resources/xlf/SR.pl.xlf | 8 ++++---- .../src/Resources/xlf/SR.pt-BR.xlf | 8 ++++---- .../src/Resources/xlf/SR.ru.xlf | 8 ++++---- .../src/Resources/xlf/SR.tr.xlf | 8 ++++---- .../src/Resources/xlf/SR.zh-Hans.xlf | 8 ++++---- .../src/Resources/xlf/SR.zh-Hant.xlf | 8 ++++---- .../ControlPropertySerializationDiagnosticAnalyzer.cs | 8 +++++--- .../AddDesignerSerializationVisibilityCodeFixProvider.cs | 2 +- .../Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs | 5 ++++- 17 files changed, 64 insertions(+), 59 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx index 9cd12f7cd9d..e282a7adda2 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx @@ -130,7 +130,7 @@ ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. Text "{0}" cannot be parsed. The expected text format is "{1}". @@ -145,7 +145,7 @@ Only TrueType fonts are supported. '{0}' is not a TrueType font. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf index f58b4bcc0aa..dbd1d036602 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf index 41a1917dc66..445c2fd6f57 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf index 7d0b03da9ae..38ad0b99ceb 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf index 467aa1b0bdb..4b73e09f48e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf index aa35e091cad..5e5e33518ea 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf index 73cb5f6b615..ff534d21ace 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf index 2cc1b69a376..46f7155c042 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf index 250fa61c49b..4bc6b7359e6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf index f257da1083e..d1aeee4385b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf index 0adcf7b6bba..3ed53517a4b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf index 0056a61da20..c57977774e9 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf index c57cf319e0e..d14f151ac66 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf index 6774587a7b9..32d4caaa341 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf @@ -43,8 +43,8 @@ - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2} - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} @@ -53,8 +53,8 @@ - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs index 6874dadb344..f98edfc5e52 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -1,4 +1,7 @@ -using System.Collections.Immutable; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; using System.ComponentModel; using System.Windows.Forms.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; @@ -24,7 +27,7 @@ public class ControlPropertySerializationDiagnosticAnalyzer : DiagnosticAnalyzer description: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerDescription), SR.ResourceManager, typeof(SR))); public override ImmutableArray SupportedDiagnostics - => ImmutableArray.Create(s_rule); + => [s_rule]; public override void Initialize(AnalysisContext context) { @@ -79,7 +82,6 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) || shouldSerializeMethod.ReturnType.SpecialType != SpecialType.System_Boolean || shouldSerializeMethod.Parameters.Length > 0) { - // For ALL such other symbols, produce a diagnostic. var diagnostic = Diagnostic.Create(s_rule, propertySymbol.Locations[0], propertySymbol.Name); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index dfc43892b93..079bf351f0d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -19,7 +19,7 @@ internal class AddDesignerSerializationVisibilityCodeFixProvider : CodeFixProvid private const string SystemComponentModelName = "System.ComponentModel"; public sealed override ImmutableArray FixableDiagnosticIds - => ImmutableArray.Create(DiagnosticIDs.ControlPropertySerialization); + => [DiagnosticIDs.ControlPropertySerialization]; public sealed override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs index 90b0ba7285b..aa3286b0c4e 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -1,4 +1,7 @@ -namespace System.Windows.Forms.Analyzers.Diagnostics; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Analyzers.Diagnostics; internal static class DiagnosticIDs { From ed8e0993360b743fa8d465ea4314d2ccd11c155b Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sat, 8 Jun 2024 00:09:32 -0700 Subject: [PATCH 05/25] Setup remaining analyzer projects. --- Winforms.sln | 57 +++++++ ...stem.Windows.Forms.Analyzers.CSharp.csproj | 1 - .../Resources/SR.resx | 159 ++++++++++++++++++ .../Resources/xlf/SR.cs.xlf | 72 ++++++++ .../Resources/xlf/SR.de.xlf | 72 ++++++++ .../Resources/xlf/SR.es.xlf | 72 ++++++++ .../Resources/xlf/SR.fr.xlf | 72 ++++++++ .../Resources/xlf/SR.it.xlf | 72 ++++++++ .../Resources/xlf/SR.ja.xlf | 72 ++++++++ .../Resources/xlf/SR.ko.xlf | 72 ++++++++ .../Resources/xlf/SR.pl.xlf | 72 ++++++++ .../Resources/xlf/SR.pt-BR.xlf | 72 ++++++++ .../Resources/xlf/SR.ru.xlf | 72 ++++++++ .../Resources/xlf/SR.tr.xlf | 72 ++++++++ .../Resources/xlf/SR.zh-Hans.xlf | 72 ++++++++ .../Resources/xlf/SR.zh-Hant.xlf | 72 ++++++++ ...ws.Forms.Analyzers.CodeFixes.CSharp.csproj | 32 ++++ ...rSerializationVisibilityCodeFixProvider.cs | 10 +- ...rms.Analyzers.CodeFixes.VisualBasic.vbproj | 12 ++ .../AnalyzerReleases.Shipped.md | 11 ++ .../AnalyzerReleases.Unshipped.md | 6 + .../Resources/SR.resx | 129 ++++++++++++++ .../Resources/xlf/SR.cs.xlf | 22 +++ .../Resources/xlf/SR.de.xlf | 22 +++ .../Resources/xlf/SR.es.xlf | 22 +++ .../Resources/xlf/SR.fr.xlf | 22 +++ .../Resources/xlf/SR.it.xlf | 22 +++ .../Resources/xlf/SR.ja.xlf | 22 +++ .../Resources/xlf/SR.ko.xlf | 22 +++ .../Resources/xlf/SR.pl.xlf | 22 +++ .../Resources/xlf/SR.pt-BR.xlf | 22 +++ .../Resources/xlf/SR.ru.xlf | 22 +++ .../Resources/xlf/SR.tr.xlf | 22 +++ .../Resources/xlf/SR.zh-Hans.xlf | 22 +++ .../Resources/xlf/SR.zh-Hant.xlf | 22 +++ ...Windows.Forms.Analyzers.VisualBasic.vbproj | 30 ++++ .../src/Properties/AssemblyInfo.cs | 5 +- 37 files changed, 1667 insertions(+), 7 deletions(-) create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj rename src/{System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp => System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms}/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs (98%) create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj diff --git a/Winforms.sln b/Winforms.sln index 0ac5ab2ac2f..4100178de35 100644 --- a/Winforms.sln +++ b/Winforms.sln @@ -177,6 +177,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimTestBinaryDeserializati EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BinaryFormatTests", "src\System.Private.Windows.Core\tests\BinaryFormatTests\BinaryFormatTests.csproj", "{57EC5288-9513-46CF-8FB7-626199690D90}" EndProject +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.VisualBasic", "src\System.Windows.Forms.Analyzers.VisualBasic\System.Windows.Forms.Analyzers.VisualBasic.vbproj", "{FF211812-FCCC-4B6B-B536-C4D754195750}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Analyzers.CodeFixes.CSharp", "src\System.Windows.Forms.Analyzers.CodeFixes.CSharp\System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj", "{1F836B14-D13D-42E0-BEAF-A821DD75DE49}" +EndProject +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.CodeFixes.VisualBasic", "src\System.Windows.Forms.Analyzers.CodeFixes.VisualBasic\System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj", "{C4C031D5-F79A-44B6-811E-0797E7D5C1C1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -981,6 +987,54 @@ Global {57EC5288-9513-46CF-8FB7-626199690D90}.Release|x64.Build.0 = Release|Any CPU {57EC5288-9513-46CF-8FB7-626199690D90}.Release|x86.ActiveCfg = Release|Any CPU {57EC5288-9513-46CF-8FB7-626199690D90}.Release|x86.Build.0 = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|arm64.ActiveCfg = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|arm64.Build.0 = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|x64.ActiveCfg = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|x64.Build.0 = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|x86.ActiveCfg = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Debug|x86.Build.0 = Debug|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|Any CPU.Build.0 = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|arm64.ActiveCfg = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|arm64.Build.0 = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|x64.ActiveCfg = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|x64.Build.0 = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|x86.ActiveCfg = Release|Any CPU + {FF211812-FCCC-4B6B-B536-C4D754195750}.Release|x86.Build.0 = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|arm64.ActiveCfg = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|arm64.Build.0 = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|x64.ActiveCfg = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|x64.Build.0 = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|x86.ActiveCfg = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Debug|x86.Build.0 = Debug|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|Any CPU.Build.0 = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|arm64.ActiveCfg = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|arm64.Build.0 = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|x64.ActiveCfg = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|x64.Build.0 = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|x86.ActiveCfg = Release|Any CPU + {1F836B14-D13D-42E0-BEAF-A821DD75DE49}.Release|x86.Build.0 = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|arm64.ActiveCfg = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|arm64.Build.0 = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|x64.Build.0 = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Debug|x86.Build.0 = Debug|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|Any CPU.Build.0 = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|arm64.ActiveCfg = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|arm64.Build.0 = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x64.ActiveCfg = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x64.Build.0 = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x86.ActiveCfg = Release|Any CPU + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1044,6 +1098,9 @@ Global {55F3174F-C1FE-4C8F-AF71-2512630088F8} = {583F1292-AE8D-4511-B8D8-A81FE4642DDC} {CFBCC732-C988-4FE7-A21B-98A142365374} = {680FB14C-7B0C-4D63-9F1A-18ACCDB0F52A} {57EC5288-9513-46CF-8FB7-626199690D90} = {583F1292-AE8D-4511-B8D8-A81FE4642DDC} + {FF211812-FCCC-4B6B-B536-C4D754195750} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} + {1F836B14-D13D-42E0-BEAF-A821DD75DE49} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} + {C4C031D5-F79A-44B6-811E-0797E7D5C1C1} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136} diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index 423e74962a7..8918f42ea2a 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -20,7 +20,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx new file mode 100644 index 00000000000..e282a7adda2 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Unsupported project type + + + Only projects with 'OutputType={0}' supported + + + Unsupported property value + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + + + Value of '{0}' is not valid for font size unit. + + + Font '{0}' cannot be found. + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + Missing code serialization configuration for property content + + + Property '{0}' does not configure the code serialization for its property content + + + Add DesignerSerializationVisibilityAttribute to property + + diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf new file mode 100644 index 00000000000..dbd1d036602 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Písmo {0} nebylo nalezeno. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Podporována jsou pouze písma TrueType. Písmo {0} není typu TrueType. + + + + Value of '{0}' is not valid for font size unit. + Hodnota {0} není platnou jednotkou velikosti písma. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. + + + + Only projects with 'OutputType={0}' supported + Podporované jsou jen projekty, kde OutputType={0}. + + + + Unsupported project type + Nepodporovaný typ projektu + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} + + + + Unsupported property value + Nepodporovaná hodnota vlastnosti + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf new file mode 100644 index 00000000000..445c2fd6f57 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Die Schriftart {0} kann nicht gefunden werden. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Es werden nur TrueType-Schriftarten unterstützt. {0} ist keine TrueType-Schriftart. + + + + Value of '{0}' is not valid for font size unit. + Der Wert von "{0}" ist für die Schriftgradeinheit ungültig. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. + + + + Only projects with 'OutputType={0}' supported + Nur Projekte mit "OutputType={0}" werden unterstützt. + + + + Unsupported project type + Nicht unterstützter Projekttyp + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} + + + + Unsupported property value + Nicht unterstützter Eigenschaftswert + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf new file mode 100644 index 00000000000..38ad0b99ceb --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + No se puede encontrar la fuente '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Sólo son compatibles las fuentes TrueType. '{0}' no es una fuente TrueType. + + + + Value of '{0}' is not valid for font size unit. + El valor de '{0}' no es válido para la unidad de tamaño de fuente. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". + + + + Only projects with 'OutputType={0}' supported + Solo se admiten proyectos con "OutputType={0}". + + + + Unsupported project type + Tipo de proyecto incompatible + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} + + + + Unsupported property value + Valor de propiedad no admitido + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf new file mode 100644 index 00000000000..4b73e09f48e --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Impossible de trouver la police '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Seules les polices TrueType sont prises en charge. '{0}' n'est pas une police TrueType. + + + + Value of '{0}' is not valid for font size unit. + La valeur de «{0}» n’est pas valide pour l’unité de taille de police. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". + + + + Only projects with 'OutputType={0}' supported + Seuls les projets avec «OutputType={0}» pris en charge + + + + Unsupported project type + Type de projet non pris en charge + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}» + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} + + + + Unsupported property value + Valeur de propriété non prise en charge + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf new file mode 100644 index 00000000000..5e5e33518ea --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Impossibile trovare il tipo di carattere '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Sono supportati solo i tipi di carattere TrueType. '{0}' non è un carattere TrueType. + + + + Value of '{0}' is not valid for font size unit. + Il valore di '{0}' non è valido per l'unità delle dimensioni del carattere. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". + + + + Only projects with 'OutputType={0}' supported + Sono supportati solo i progetti con 'OutputType={0}' + + + + Unsupported project type + Tipo di progetto non supportato + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} + + + + Unsupported property value + Valore di proprietà non supportato + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf new file mode 100644 index 00000000000..ff534d21ace --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + フォント '{0}' が見つかりません。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + TrueType フォントのみがサポートされています。'{0}' は TrueType フォントではありません。 + + + + Value of '{0}' is not valid for font size unit. + '{0}' の値は、フォント サイズの単位として有効ではありません。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 + + + + Only projects with 'OutputType={0}' supported + 'OutputType ={0}' のプロジェクトのみがサポートされています + + + + Unsupported project type + サポートされていないプロジェクトの種類 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} + + + + Unsupported property value + サポートされていないプロパティの値 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf new file mode 100644 index 00000000000..46f7155c042 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + '{0}' 글꼴을 찾을 수 없습니다. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 트루타입 글꼴만 지원됩니다. '{0}'은(는) 트루타입 글꼴이 아닙니다. + + + + Value of '{0}' is not valid for font size unit. + '{0}' 값은 글꼴 크기 단위에 대해 유효하지 않습니다. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. + + + + Only projects with 'OutputType={0}' supported + 'OutputType={0}'인 프로젝트만 지원됨 + + + + Unsupported project type + 지원되지 않는 프로젝트 유형 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없음 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} + + + + Unsupported property value + 지원되지 않는 속성 값 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf new file mode 100644 index 00000000000..4bc6b7359e6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Nie można odnaleźć czcionki „{0}”. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Obsługiwane są tylko czcionki TrueType. Element „{0}” nie jest czcionką TrueType. + + + + Value of '{0}' is not valid for font size unit. + Wartość „{0}” jest nieprawidłowa dla jednostki rozmiaru czcionki. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. + + + + Only projects with 'OutputType={0}' supported + Obsługiwane są tylko projekty z parametrem „OutputType={0}” + + + + Unsupported project type + Nieobsługiwany typ projektu + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}” + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} + + + + Unsupported property value + Nieobsługiwana wartość właściwości + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf new file mode 100644 index 00000000000..d1aeee4385b --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + A fonte '{0}' não pode ser encontrada. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Só há suporte para fontes TrueType. '{0}' não é uma fonte TrueType. + + + + Value of '{0}' is not valid for font size unit. + O valor de '{0}' não é válido para a unidade de tamanho da fonte. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". + + + + Only projects with 'OutputType={0}' supported + Apenas projetos com 'OutputType={0}' suportados + + + + Unsupported project type + Tipo de projeto não suportado + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} + + + + Unsupported property value + Valor de propriedade não suportado + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf new file mode 100644 index 00000000000..3ed53517a4b --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Шрифт '{0}' не найден. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Поддерживаются только шрифты TrueType. '{0}' не является шрифтом TrueType. + + + + Value of '{0}' is not valid for font size unit. + Значение "{0}" недопустимо для единицы размера шрифта. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". + + + + Only projects with 'OutputType={0}' supported + Поддерживаются только проекты с "OutputType ={0}" + + + + Unsupported project type + Неподдерживаемый тип проекта + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: свойство проекта "{0}" не может иметь значение "{1}" + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} + + + + Unsupported property value + Не поддерживаемое значение свойства + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf new file mode 100644 index 00000000000..c57977774e9 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + '{0}' yazı tipi bulunamıyor. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Yalnızca TrueType yazı tipleri destekleniyor. '{0}' TrueType yazı tipi değil. + + + + Value of '{0}' is not valid for font size unit. + '{0}' değeri yazı tipi boyutu birimi için geçerli değil. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". + + + + Only projects with 'OutputType={0}' supported + Yalnızca 'OutputType={0}' çıkış türüne sahip projeler destekleniyor + + + + Unsupported project type + Desteklenmeyen proje türü + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} + + + + Unsupported property value + Desteklenmeyen özellik değeri + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf new file mode 100644 index 00000000000..d14f151ac66 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + 无法找到字体“{0}”。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 只支持 TrueType 字体。“{0}”不是 TrueType 字体。 + + + + Value of '{0}' is not valid for font size unit. + “{0}”的值对于字体大小单位无效。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 无法分析文本“{0}”。文本格式应为“{1}”。 + + + + Only projects with 'OutputType={0}' supported + 仅支持“OutputType={0}”的项目 + + + + Unsupported project type + 不支持的项目类型 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 无法将项目属性“{0}”设置为“{1}” + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} + + + + Unsupported property value + 不支持的属性值 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf new file mode 100644 index 00000000000..32d4caaa341 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + 找不到字型 '{0}'。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 僅支援 TrueType 字型。'{0}' 不是 TrueType 字型。 + + + + Value of '{0}' is not valid for font size unit. + '{0}' 不是有效的字型大小單位值。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 + + + + Only projects with 'OutputType={0}' supported + 只支援 'OutputType={0}' 的專案 + + + + Unsupported project type + 不支援的專案類型 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} + + + + Unsupported property value + 不支援的屬性值 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj new file mode 100644 index 00000000000..8ddfb79aab6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj @@ -0,0 +1,32 @@ + + + + System.Windows.Forms.Analyzers + netstandard2.0 + Preview + enable + $(NoWarn);RS2007 + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + true + System + + + + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs similarity index 98% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs rename to src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index 079bf351f0d..80c5a09cfd7 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -1,20 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Collections.Immutable; +using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp; -using System.Collections.Immutable; -using System.Composition; -using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; +using System.Windows.Forms.Analyzers.Diagnostics; namespace System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility; [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AddDesignerSerializationVisibilityCodeFixProvider)), Shared] -internal class AddDesignerSerializationVisibilityCodeFixProvider : CodeFixProvider +internal sealed class AddDesignerSerializationVisibilityCodeFixProvider : CodeFixProvider { private const string SystemComponentModelName = "System.ComponentModel"; diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj new file mode 100644 index 00000000000..c70a2516ea8 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj @@ -0,0 +1,12 @@ + + + + System.Windows.Forms.Analyzers + netstandard2.0 + true + + 15.0 + None + + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md new file mode 100644 index 00000000000..a53bdf80ee0 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md @@ -0,0 +1,11 @@ +; Shipped analyzer releases +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +## Release .NET 6.0 RC2 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|-------------------- +WFAC001 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) +WFAC002 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md new file mode 100644 index 00000000000..6640189c3f3 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md @@ -0,0 +1,6 @@ +; Unshipped analyzer release +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +### New Rules +Rule ID | Category | Severity | Notes +--------|----------|----------|------- diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx new file mode 100644 index 00000000000..d85856a1f64 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + Missing code serialization configuration for property content + + + Property '{0}' does not configure the code serialization for its property content + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf new file mode 100644 index 00000000000..590239fdaed --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf new file mode 100644 index 00000000000..0d323cd5ca2 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf new file mode 100644 index 00000000000..49982ba613d --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf new file mode 100644 index 00000000000..9074aca1b4b --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf new file mode 100644 index 00000000000..91c04435a61 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf new file mode 100644 index 00000000000..97cb52f8bfb --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf new file mode 100644 index 00000000000..5c7348d20c8 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf new file mode 100644 index 00000000000..313f9028618 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf new file mode 100644 index 00000000000..53040e2b168 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf new file mode 100644 index 00000000000..be84174fdf7 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf new file mode 100644 index 00000000000..3fabd64b1ff --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf new file mode 100644 index 00000000000..e40c447063c --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf new file mode 100644 index 00000000000..64e877486d1 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf @@ -0,0 +1,22 @@ + + + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj new file mode 100644 index 00000000000..7b9ff80640d --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj @@ -0,0 +1,30 @@ + + + + System.Windows.Forms.Analyzers + netstandard2.0 + true + + 15.0 + None + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + true + System + + + + diff --git a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs index 05d1a5f1d7d..8fb9954a11e 100644 --- a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] -[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.Csharp, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CodeFixes.CSharp, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CodeFixes.VisualBasic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] From 770ec0def3d8569ad653375332337df30916e744 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sun, 9 Jun 2024 01:20:05 -0700 Subject: [PATCH 06/25] Finalize analyzer configuration. --- .../src/AnalyzerReleases.Shipped.md | 2 +- .../src/AnalyzerReleases.Unshipped.md | 11 +++ .../src/Resources/SR.resx | 16 ++-- .../src/Resources/xlf/SR.cs.xlf | 26 ++--- .../src/Resources/xlf/SR.de.xlf | 26 ++--- .../src/Resources/xlf/SR.es.xlf | 26 ++--- .../src/Resources/xlf/SR.fr.xlf | 26 ++--- .../src/Resources/xlf/SR.it.xlf | 26 ++--- .../src/Resources/xlf/SR.ja.xlf | 26 ++--- .../src/Resources/xlf/SR.ko.xlf | 26 ++--- .../src/Resources/xlf/SR.pl.xlf | 26 ++--- .../src/Resources/xlf/SR.pt-BR.xlf | 26 ++--- .../src/Resources/xlf/SR.ru.xlf | 26 ++--- .../src/Resources/xlf/SR.tr.xlf | 26 ++--- .../src/Resources/xlf/SR.zh-Hans.xlf | 26 ++--- .../src/Resources/xlf/SR.zh-Hant.xlf | 26 ++--- ...stem.Windows.Forms.Analyzers.CSharp.csproj | 1 - .../Analyzers/CSharpDiagnosticDescriptors.cs | 20 ++-- ...PropertySerializationDiagnosticAnalyzer.cs | 13 +-- .../ProjectFileReader.FontConverter.cs | 5 +- .../ProjectFileReader.cs | 27 +++--- ...ws.Forms.Analyzers.CodeFixes.CSharp.csproj | 2 +- ...rSerializationVisibilityCodeFixProvider.cs | 2 +- ...rms.Analyzers.CodeFixes.VisualBasic.vbproj | 1 + .../AnalyzerReleases.Shipped.md | 9 -- .../AnalyzerReleases.Unshipped.md | 1 + .../GlobalSuppressions.vb | 8 ++ ...Windows.Forms.Analyzers.VisualBasic.vbproj | 6 +- ...PropertySerializationDiagnosticAnalyzer.vb | 96 +++++++++++++++++++ .../src/AnalyzerReleases.Shipped.md | 2 +- .../src/AnalyzerReleases.Unshipped.md | 8 ++ .../src/System.Windows.Forms.Analyzers.csproj | 1 - .../Forms/Analyzers/AppManifestAnalyzer.cs | 4 +- .../Diagnostics/DiagnosticCategories.cs | 10 ++ .../Analyzers/Diagnostics/DiagnosticIDs.cs | 12 +-- 35 files changed, 359 insertions(+), 236 deletions(-) create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb create mode 100644 src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Shipped.md b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Shipped.md index a53bdf80ee0..939253f8758 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Shipped.md +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Shipped.md @@ -1,7 +1,7 @@ ; Shipped analyzer releases ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md -## Release .NET 6.0 RC2 +## Release 6.0.0 ### New Rules diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md index 6640189c3f3..e68e80094e5 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md @@ -1,6 +1,17 @@ ; Unshipped analyzer release ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md +### Removed Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|-------------------- +WFAC001 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) +WFAC002 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) + ### New Rules + Rule ID | Category | Severity | Notes --------|----------|----------|------- +WFCA001 | ApplicationConfiguration | Error | CSharpDiagnosticDescriptors +WFCA002 | ApplicationConfiguration | Error | CSharpDiagnosticDescriptors +WFCA100 | WinForms Security | Error | ControlPropertySerializationDiagnosticAnalyzer diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx index e282a7adda2..60f399c4c10 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx @@ -117,19 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Unsupported project type - + Only projects with 'OutputType={0}' supported - + Unsupported property value - + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. @@ -144,13 +144,13 @@ Only TrueType fonts are supported. '{0}' is not a TrueType font. - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Missing code serialization configuration for property content - + Property '{0}' does not configure the code serialization for its property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf index dbd1d036602..249a85ac442 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf @@ -27,42 +27,42 @@ Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. - + Only projects with 'OutputType={0}' supported - Podporované jsou jen projekty, kde OutputType={0}. + Only projects with 'OutputType={0}' supported - + Unsupported project type - Nepodporovaný typ projektu + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Nepodporovaná hodnota vlastnosti + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf index 445c2fd6f57..3dc8044402e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf @@ -27,42 +27,42 @@ Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. - + Only projects with 'OutputType={0}' supported - Nur Projekte mit "OutputType={0}" werden unterstützt. + Only projects with 'OutputType={0}' supported - + Unsupported project type - Nicht unterstützter Projekttyp + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Nicht unterstützter Eigenschaftswert + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf index 38ad0b99ceb..601be66163c 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf @@ -27,42 +27,42 @@ No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". - + Only projects with 'OutputType={0}' supported - Solo se admiten proyectos con "OutputType={0}". + Only projects with 'OutputType={0}' supported - + Unsupported project type - Tipo de proyecto incompatible + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}' + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Valor de propiedad no admitido + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf index 4b73e09f48e..1b748c4d6f2 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf @@ -27,42 +27,42 @@ Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". - + Only projects with 'OutputType={0}' supported - Seuls les projets avec «OutputType={0}» pris en charge + Only projects with 'OutputType={0}' supported - + Unsupported project type - Type de projet non pris en charge + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}» + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Valeur de propriété non prise en charge + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf index 5e5e33518ea..88b20d7f8e4 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf @@ -27,42 +27,42 @@ Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". - + Only projects with 'OutputType={0}' supported - Sono supportati solo i progetti con 'OutputType={0}' + Only projects with 'OutputType={0}' supported - + Unsupported project type - Tipo di progetto non supportato + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}' + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Valore di proprietà non supportato + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf index ff534d21ace..443872ed467 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf @@ -27,42 +27,42 @@ テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 - + Only projects with 'OutputType={0}' supported - 'OutputType ={0}' のプロジェクトのみがサポートされています + Only projects with 'OutputType={0}' supported - + Unsupported project type - サポートされていないプロジェクトの種類 + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - サポートされていないプロパティの値 + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf index 46f7155c042..88c220db991 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf @@ -27,42 +27,42 @@ 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. - + Only projects with 'OutputType={0}' supported - 'OutputType={0}'인 프로젝트만 지원됨 + Only projects with 'OutputType={0}' supported - + Unsupported project type - 지원되지 않는 프로젝트 유형 + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없음 + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - 지원되지 않는 속성 값 + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf index 4bc6b7359e6..b654d9dd003 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf @@ -27,42 +27,42 @@ Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. - + Only projects with 'OutputType={0}' supported - Obsługiwane są tylko projekty z parametrem „OutputType={0}” + Only projects with 'OutputType={0}' supported - + Unsupported project type - Nieobsługiwany typ projektu + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}” + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Nieobsługiwana wartość właściwości + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf index d1aeee4385b..f31471d5657 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf @@ -27,42 +27,42 @@ O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". - + Only projects with 'OutputType={0}' supported - Apenas projetos com 'OutputType={0}' suportados + Only projects with 'OutputType={0}' supported - + Unsupported project type - Tipo de projeto não suportado + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}' + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Valor de propriedade não suportado + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf index 3ed53517a4b..c97c97d396b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf @@ -27,42 +27,42 @@ Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". - + Only projects with 'OutputType={0}' supported - Поддерживаются только проекты с "OutputType ={0}" + Only projects with 'OutputType={0}' supported - + Unsupported project type - Неподдерживаемый тип проекта + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}" + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Не поддерживаемое значение свойства + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf index c57977774e9..1207b160ce5 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf @@ -27,42 +27,42 @@ {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". - + Only projects with 'OutputType={0}' supported - Yalnızca 'OutputType={0}' çıkış türüne sahip projeler destekleniyor + Only projects with 'OutputType={0}' supported - + Unsupported project type - Desteklenmeyen proje türü + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - Desteklenmeyen özellik değeri + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf index d14f151ac66..10d8ff7c630 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf @@ -27,42 +27,42 @@ 无法分析文本“{0}”。文本格式应为“{1}”。 - + Only projects with 'OutputType={0}' supported - 仅支持“OutputType={0}”的项目 + Only projects with 'OutputType={0}' supported - + Unsupported project type - 不支持的项目类型 + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 无法将项目属性“{0}”设置为“{1}” + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - 不支持的属性值 + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf index 32d4caaa341..9a93d8a6a35 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf @@ -27,42 +27,42 @@ 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 - + Only projects with 'OutputType={0}' supported - 只支援 'OutputType={0}' 的專案 + Only projects with 'OutputType={0}' supported - + Unsupported project type - 不支援的專案類型 + Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}' + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value - 不支援的屬性值 + Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index 8918f42ea2a..222f3ea1e01 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -5,7 +5,6 @@ netstandard2.0 Preview enable - $(NoWarn);RS2007 true diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs index 387f3aa7a48..f7b272bd960 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs @@ -10,24 +10,24 @@ internal static class CSharpDiagnosticDescriptors { private const string Category = "ApplicationConfiguration"; - private static readonly LocalizableString s_localizableWFAC001Title - = new LocalizableResourceString(nameof(SR.WFAC001Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFCA001Title + = new LocalizableResourceString(nameof(SR.WFCA001Title), SR.ResourceManager, typeof(SR)); private static readonly LocalizableString s_localizableWFAC001Message - = new LocalizableResourceString(nameof(SR.WFAC001Message), SR.ResourceManager, typeof(SR)); + = new LocalizableResourceString(nameof(SR.WFCA001Message), SR.ResourceManager, typeof(SR)); - private static readonly LocalizableString s_localizableWFAC002Title - = new LocalizableResourceString(nameof(SR.WFAC002Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFCA002Title + = new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)); private static readonly LocalizableString s_localizableWFAC002Message - = new LocalizableResourceString(nameof(SR.WFAC002Message), SR.ResourceManager, typeof(SR)); + = new LocalizableResourceString(nameof(SR.WFCA002Message), SR.ResourceManager, typeof(SR)); private static readonly LocalizableString s_localizableWFAC002MessageWithReason - = new LocalizableResourceString(nameof(SR.WFAC002MessageWithReason), SR.ResourceManager, typeof(SR)); + = new LocalizableResourceString(nameof(SR.WFCA002MessageWithReason), SR.ResourceManager, typeof(SR)); public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType = new(id: DiagnosticIDs.UnsupportedProjectType, - title: s_localizableWFAC001Title, + title: s_localizableWFCA001Title, messageFormat: s_localizableWFAC001Message, category: Category, defaultSeverity: DiagnosticSeverity.Error, @@ -35,7 +35,7 @@ public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: s_localizableWFAC002Title, + title: s_localizableWFCA002Title, messageFormat: s_localizableWFAC002Message, category: Category, defaultSeverity: DiagnosticSeverity.Error, @@ -43,7 +43,7 @@ public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: s_localizableWFAC002Title, + title: s_localizableWFCA002Title, messageFormat: s_localizableWFAC002MessageWithReason, category: Category, defaultSeverity: DiagnosticSeverity.Error, diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs index f98edfc5e52..7c466af174a 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -12,19 +12,14 @@ namespace System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization; [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ControlPropertySerializationDiagnosticAnalyzer : DiagnosticAnalyzer { - // You can change these strings in the Resources.resx file. If you do not want your analyzer to be localize-able, you can use regular strings for Title and MessageFormat. - // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Localizing%20Analyzers.md for more on localization - - private const string Category = "WinForms Security"; - private static readonly DiagnosticDescriptor s_rule = new( id: DiagnosticIDs.ControlPropertySerialization, - title: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerTitle), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), - category: Category, + title: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerTitle), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.WinFormsSecurity, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(SR.WFAC003AnalyzerDescription), SR.ResourceManager, typeof(SR))); + description: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerDescription), SR.ResourceManager, typeof(SR))); public override ImmutableArray SupportedDiagnostics => [s_rule]; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs index ffafd7067f8..f100d4cc465 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs @@ -78,8 +78,8 @@ internal static class FontConverter { // Exception from converter is too generic. throw new ArgumentException(string.Format(SR.TextParseFailedFormat, - font, - $"name{separator} size[units[{separator} style=style1[{separator} style2{separator} ...]]]")); + font, + $"name{separator} size[units[{separator} style=style1[{separator} style2{separator} ...]]]")); } } @@ -157,6 +157,7 @@ private static (string?, string?) ParseSizeTokens(string text, char separator) if (splitPoint > 0) { size = text.Substring(0, splitPoint); + // Trimming spaces between size and units. size = size.Trim(trimChars); } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs index 42b0676fae0..43822ab43be 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs @@ -11,16 +11,16 @@ namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; internal static partial class ProjectFileReader { - public static IncrementalValueProvider<(ApplicationConfig? ApplicationConfig, Diagnostic? Diagnostic)> ReadApplicationConfig(IncrementalValueProvider configOptionsProvider) - => configOptionsProvider.Select( + public static IncrementalValueProvider<(ApplicationConfig? ApplicationConfig, Diagnostic? Diagnostic)> ReadApplicationConfig(IncrementalValueProvider configOptionsProvider) => + configOptionsProvider.Select( (analyzerConfigOptions, cancellationToken) => { if (!TryReadBool(analyzerConfigOptions, PropertyNameCSharp.EnableVisualStyles, - defaultValue: PropertyDefaultValue.EnableVisualStyles, - out bool enableVisualStyles, out Diagnostic? diagnostic) + defaultValue: PropertyDefaultValue.EnableVisualStyles, + out bool enableVisualStyles, out Diagnostic? diagnostic) || !TryReadBool(analyzerConfigOptions, PropertyNameCSharp.UseCompatibleTextRendering, - defaultValue: PropertyDefaultValue.UseCompatibleTextRendering, - out bool useCompatibleTextRendering, out diagnostic) + defaultValue: PropertyDefaultValue.UseCompatibleTextRendering, + out bool useCompatibleTextRendering, out diagnostic) || !TryReadFont(analyzerConfigOptions, out FontDescriptor? font, out diagnostic) || !TryReadHighDpiMode(analyzerConfigOptions, out HighDpiMode highDpiMode, out diagnostic)) { @@ -86,10 +86,10 @@ private static bool TryReadFont(AnalyzerConfigOptionsProvider configOptions, out catch (Exception ex) { diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValueWithReason, - Location.None, - PropertyNameCSharp.DefaultFont, - rawValue, - ex.Message); + Location.None, + PropertyNameCSharp.DefaultFont, + rawValue, + ex.Message); } return false; @@ -111,9 +111,10 @@ private static bool TryReadHighDpiMode(AnalyzerConfigOptionsProvider configOptio !Enum.IsDefined(typeof(HighDpiMode), highDpiMode)) { diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, - Location.None, - PropertyNameCSharp.HighDpiMode, - rawValue); + Location.None, + PropertyNameCSharp.HighDpiMode, + rawValue); + highDpiMode = PropertyDefaultValue.DpiMode; return false; } diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj index 8ddfb79aab6..f64ea50ef5c 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj @@ -5,7 +5,7 @@ netstandard2.0 Preview enable - $(NoWarn);RS2007 + $(NoWarn);CA1812 true diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index 80c5a09cfd7..c9201771533 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -80,7 +80,7 @@ private static async Task AddDesignerSerializationAttribute( newProperty = newProperty.WithLeadingTrivia(leadingTrivia); newProperty = newProperty.WithTrailingTrivia(trailingTrivia); - var usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(SystemComponentModelName)); + UsingDirectiveSyntax usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(SystemComponentModelName)); // Let's check, if we already have the using directive or if we need to add it: // (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj index c70a2516ea8..f1268722c61 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj @@ -7,6 +7,7 @@ 15.0 None + $(NoWarn);CA1812 diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md index a53bdf80ee0..180738cfdec 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md @@ -1,11 +1,2 @@ ; Shipped analyzer releases ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md - -## Release .NET 6.0 RC2 - -### New Rules - -Rule ID | Category | Severity | Notes ---------|----------|----------|-------------------- -WFAC001 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) -WFAC002 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md index 6640189c3f3..801e45de58e 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md @@ -4,3 +4,4 @@ ### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- +WFCA100 | WinForms Security | Error | ControlPropertySerializationDiagnosticAnalyzer diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb new file mode 100644 index 00000000000..7f2bb2317a5 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb @@ -0,0 +1,8 @@ +' This file is used by Code Analysis to maintain SuppressMessage +' attributes that are applied to this project. +' Project-level suppressions either have no target or are given +' a specific target and scoped to a namespace, type, member, etc. + +Imports System.Diagnostics.CodeAnalysis + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj index 7b9ff80640d..4429621c499 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj @@ -6,7 +6,7 @@ true 15.0 - None + true @@ -20,6 +20,10 @@ + + + + true diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb new file mode 100644 index 00000000000..03456cb5f9f --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb @@ -0,0 +1,96 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.Collections.Immutable +Imports System.ComponentModel +Imports System.Windows.Forms.Analyzers.Diagnostics +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Diagnostics + +' This is not really a VB-specific diagnostic, since they are not language agnostic. +' We want to stay consistent with the C# version, though, so we rename the class to keep using the variable name. +' (VB is not case-sensitive, so we can't have the same names in a code file, even if the casing is different.) +Imports VBDiagnostic = Microsoft.CodeAnalysis.Diagnostic + +Namespace System.Windows.Forms.VisualBasic.Analyzers.ControlPropertySerialization + + + Public Class ControlPropertySerializationDiagnosticAnalyzer + Inherits DiagnosticAnalyzer + + Private Shared ReadOnly s_rule As New DiagnosticDescriptor( + id:=DiagnosticIDs.ControlPropertySerialization, + title:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerTitle), SR.ResourceManager, GetType(SR)), + messageFormat:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), + category:=DiagnosticCategories.WinFormsSecurity, + defaultSeverity:=DiagnosticSeverity.Error, + isEnabledByDefault:=True, + description:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerDescription), SR.ResourceManager, GetType(SR)) + ) + + Public Overrides ReadOnly Property SupportedDiagnostics As ImmutableArray(Of DiagnosticDescriptor) + Get + Return ImmutableArray.Create(s_rule) + End Get + End Property + + Public Overrides Sub Initialize(context As AnalysisContext) + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None) + context.EnableConcurrentExecution() + context.RegisterSymbolAction(AddressOf AnalyzeSymbol, SymbolKind.Property) + End Sub + + Private Shared Sub AnalyzeSymbol(context As SymbolAnalysisContext) + + ' We analyze only properties. + Dim propertySymbol = DirectCast(context.Symbol, IPropertySymbol) + + ' Does the property belong to a class which derives from Component? + If propertySymbol.ContainingType Is Nothing _ + OrElse Not propertySymbol _ + .ContainingType _ + .AllInterfaces _ + .Any(Function(i) i.Name = NameOf(IComponent)) Then + + Return + End If + + ' Is the read/write and at least internal? + If propertySymbol.SetMethod Is Nothing _ + OrElse propertySymbol.DeclaredAccessibility < Accessibility.Internal Then + + Return + End If + + ' Is the property attributed with DesignerSerializationVisibility or DefaultValue? + If propertySymbol _ + .GetAttributes() _ + .Any(Function(a) a?.AttributeClass?.Name = NameOf(DesignerSerializationVisibilityAttribute) _ + OrElse a?.AttributeClass?.Name = NameOf(DefaultValueAttribute)) Then + + Return + End If + + ' Now, it gets a bit more tedious: + ' If the Serialization is managed via ShouldSerialize and Reset methods, we are also fine, + ' so let's check for that. First, let's get the class of the property: + Dim classSymbol As INamedTypeSymbol = propertySymbol.ContainingType + + ' Now, let's check if the class has a method ShouldSerialize method: + Dim shouldSerializeMethod As IMethodSymbol = classSymbol _ + .GetMembers() _ + .OfType(Of IMethodSymbol)() _ + .FirstOrDefault(Function(m) m.Name = $"ShouldSerialize{propertySymbol.Name}") + + ' Let's make sure the method returns a bool and has no parameters: + If shouldSerializeMethod Is Nothing _ + OrElse shouldSerializeMethod.ReturnType.SpecialType <> SpecialType.System_Boolean _ + OrElse shouldSerializeMethod.Parameters.Length > 0 Then + + ' For ALL such other symbols, produce a diagnostic. + Dim diagnostic = VBDiagnostic.Create(s_rule, propertySymbol.Locations(0), propertySymbol.Name) + context.ReportDiagnostic(diagnostic) + End If + End Sub + End Class +End Namespace diff --git a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Shipped.md b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Shipped.md index 56804e0f287..b8d4f9becf4 100644 --- a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Shipped.md +++ b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Shipped.md @@ -1,7 +1,7 @@ ; Shipped analyzer releases ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md -## Release .NET 6.0 RC2 +## Release 6.0.0 ### New Rules diff --git a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md index 6640189c3f3..bc04bfcac5a 100644 --- a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md @@ -1,6 +1,14 @@ ; Unshipped analyzer release ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md +### Removed Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +WFAC010 | ApplicationConfiguration | Warning | DiagnosticDescriptors + ### New Rules + Rule ID | Category | Severity | Notes --------|----------|----------|------- +WFCA010 | ApplicationConfiguration | Warning | DiagnosticDescriptors diff --git a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj index 15a4c8186c1..f78c0aa31a6 100644 --- a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj +++ b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj @@ -4,7 +4,6 @@ netstandard2.0 Preview enable - $(NoWarn);RS2007 true diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs index 8f0aa3a6592..08979134f64 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs @@ -14,9 +14,7 @@ namespace System.Windows.Forms.Analyzers; internal partial class AppManifestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray SupportedDiagnostics - => ImmutableArray.Create( - DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, - DiagnosticDescriptors.s_migrateHighDpiSettings_VB); + => [DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, DiagnosticDescriptors.s_migrateHighDpiSettings_VB]; public override void Initialize(AnalysisContext context) { diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs new file mode 100644 index 00000000000..55128aaa978 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Analyzers.Diagnostics; + +internal static class DiagnosticCategories +{ + public const string WinFormsSecurity = "WinForms Security"; + public const string WinFormsUsage = "WinForms Usage"; +} diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs index aa3286b0c4e..be5b3c1a354 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -6,13 +6,13 @@ namespace System.Windows.Forms.Analyzers.Diagnostics; internal static class DiagnosticIDs { // Application Configuration - public const string UnsupportedProjectType = "WFAC001"; - public const string PropertyCantBeSetToValue = "WFAC002"; - public const string MigrateHighDpiSettings = "WFAC010"; + public const string UnsupportedProjectType = "WFCA001"; + public const string PropertyCantBeSetToValue = "WFCA002"; + public const string MigrateHighDpiSettings = "WFCA010"; // Security - public const string ControlPropertySerialization = "WFAC100"; + public const string ControlPropertySerialization = "WFCA100"; - // Memory Management - public const string DisposeModalDialog = "WFAC200"; + // WinForms Usage + public const string DisposeModalDialog = "WFCA500"; } From 18451a6e6869787061818ff8cd5fbe4c915540b4 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sun, 9 Jun 2024 23:00:21 -0700 Subject: [PATCH 07/25] Add VB CodeFixes project, correct namespaces. --- ...rSerializationVisibilityCodeFixProvider.cs | 0 .../Resources/SR.resx | 159 ++++++++++++++++++ .../Resources/xlf/SR.cs.xlf | 72 ++++++++ .../Resources/xlf/SR.de.xlf | 72 ++++++++ .../Resources/xlf/SR.es.xlf | 72 ++++++++ .../Resources/xlf/SR.fr.xlf | 72 ++++++++ .../Resources/xlf/SR.it.xlf | 72 ++++++++ .../Resources/xlf/SR.ja.xlf | 72 ++++++++ .../Resources/xlf/SR.ko.xlf | 72 ++++++++ .../Resources/xlf/SR.pl.xlf | 72 ++++++++ .../Resources/xlf/SR.pt-BR.xlf | 72 ++++++++ .../Resources/xlf/SR.ru.xlf | 72 ++++++++ .../Resources/xlf/SR.tr.xlf | 72 ++++++++ .../Resources/xlf/SR.zh-Hans.xlf | 72 ++++++++ .../Resources/xlf/SR.zh-Hant.xlf | 72 ++++++++ ...rms.Analyzers.CodeFixes.VisualBasic.vbproj | 22 ++- ...rSerializationVisibilityCodeFixProvider.vb | 121 +++++++++++++ ...PropertySerializationDiagnosticAnalyzer.vb | 0 18 files changed, 1237 insertions(+), 1 deletion(-) rename src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/{ => CSharp}/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs (100%) create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb rename src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/{Analyzers => VisualBasic/Analyzers/ControlPropertySerialization}/ControlPropertySerializationDiagnosticAnalyzer.vb (100%) diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs similarity index 100% rename from src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs rename to src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx new file mode 100644 index 00000000000..e282a7adda2 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Unsupported project type + + + Only projects with 'OutputType={0}' supported + + + Unsupported property value + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + + + Value of '{0}' is not valid for font size unit. + + + Font '{0}' cannot be found. + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + Missing code serialization configuration for property content + + + Property '{0}' does not configure the code serialization for its property content + + + Add DesignerSerializationVisibilityAttribute to property + + diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf new file mode 100644 index 00000000000..dbd1d036602 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Písmo {0} nebylo nalezeno. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Podporována jsou pouze písma TrueType. Písmo {0} není typu TrueType. + + + + Value of '{0}' is not valid for font size unit. + Hodnota {0} není platnou jednotkou velikosti písma. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. + + + + Only projects with 'OutputType={0}' supported + Podporované jsou jen projekty, kde OutputType={0}. + + + + Unsupported project type + Nepodporovaný typ projektu + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} + + + + Unsupported property value + Nepodporovaná hodnota vlastnosti + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf new file mode 100644 index 00000000000..445c2fd6f57 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Die Schriftart {0} kann nicht gefunden werden. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Es werden nur TrueType-Schriftarten unterstützt. {0} ist keine TrueType-Schriftart. + + + + Value of '{0}' is not valid for font size unit. + Der Wert von "{0}" ist für die Schriftgradeinheit ungültig. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. + + + + Only projects with 'OutputType={0}' supported + Nur Projekte mit "OutputType={0}" werden unterstützt. + + + + Unsupported project type + Nicht unterstützter Projekttyp + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} + + + + Unsupported property value + Nicht unterstützter Eigenschaftswert + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf new file mode 100644 index 00000000000..38ad0b99ceb --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + No se puede encontrar la fuente '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Sólo son compatibles las fuentes TrueType. '{0}' no es una fuente TrueType. + + + + Value of '{0}' is not valid for font size unit. + El valor de '{0}' no es válido para la unidad de tamaño de fuente. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". + + + + Only projects with 'OutputType={0}' supported + Solo se admiten proyectos con "OutputType={0}". + + + + Unsupported project type + Tipo de proyecto incompatible + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} + + + + Unsupported property value + Valor de propiedad no admitido + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf new file mode 100644 index 00000000000..4b73e09f48e --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Impossible de trouver la police '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Seules les polices TrueType sont prises en charge. '{0}' n'est pas une police TrueType. + + + + Value of '{0}' is not valid for font size unit. + La valeur de «{0}» n’est pas valide pour l’unité de taille de police. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". + + + + Only projects with 'OutputType={0}' supported + Seuls les projets avec «OutputType={0}» pris en charge + + + + Unsupported project type + Type de projet non pris en charge + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}» + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} + + + + Unsupported property value + Valeur de propriété non prise en charge + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf new file mode 100644 index 00000000000..5e5e33518ea --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Impossibile trovare il tipo di carattere '{0}'. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Sono supportati solo i tipi di carattere TrueType. '{0}' non è un carattere TrueType. + + + + Value of '{0}' is not valid for font size unit. + Il valore di '{0}' non è valido per l'unità delle dimensioni del carattere. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". + + + + Only projects with 'OutputType={0}' supported + Sono supportati solo i progetti con 'OutputType={0}' + + + + Unsupported project type + Tipo di progetto non supportato + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} + + + + Unsupported property value + Valore di proprietà non supportato + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf new file mode 100644 index 00000000000..ff534d21ace --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + フォント '{0}' が見つかりません。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + TrueType フォントのみがサポートされています。'{0}' は TrueType フォントではありません。 + + + + Value of '{0}' is not valid for font size unit. + '{0}' の値は、フォント サイズの単位として有効ではありません。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 + + + + Only projects with 'OutputType={0}' supported + 'OutputType ={0}' のプロジェクトのみがサポートされています + + + + Unsupported project type + サポートされていないプロジェクトの種類 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} + + + + Unsupported property value + サポートされていないプロパティの値 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf new file mode 100644 index 00000000000..46f7155c042 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + '{0}' 글꼴을 찾을 수 없습니다. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 트루타입 글꼴만 지원됩니다. '{0}'은(는) 트루타입 글꼴이 아닙니다. + + + + Value of '{0}' is not valid for font size unit. + '{0}' 값은 글꼴 크기 단위에 대해 유효하지 않습니다. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. + + + + Only projects with 'OutputType={0}' supported + 'OutputType={0}'인 프로젝트만 지원됨 + + + + Unsupported project type + 지원되지 않는 프로젝트 유형 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없음 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} + + + + Unsupported property value + 지원되지 않는 속성 값 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf new file mode 100644 index 00000000000..4bc6b7359e6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Nie można odnaleźć czcionki „{0}”. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Obsługiwane są tylko czcionki TrueType. Element „{0}” nie jest czcionką TrueType. + + + + Value of '{0}' is not valid for font size unit. + Wartość „{0}” jest nieprawidłowa dla jednostki rozmiaru czcionki. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. + + + + Only projects with 'OutputType={0}' supported + Obsługiwane są tylko projekty z parametrem „OutputType={0}” + + + + Unsupported project type + Nieobsługiwany typ projektu + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}” + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} + + + + Unsupported property value + Nieobsługiwana wartość właściwości + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf new file mode 100644 index 00000000000..d1aeee4385b --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + A fonte '{0}' não pode ser encontrada. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Só há suporte para fontes TrueType. '{0}' não é uma fonte TrueType. + + + + Value of '{0}' is not valid for font size unit. + O valor de '{0}' não é válido para a unidade de tamanho da fonte. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". + + + + Only projects with 'OutputType={0}' supported + Apenas projetos com 'OutputType={0}' suportados + + + + Unsupported project type + Tipo de projeto não suportado + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} + + + + Unsupported property value + Valor de propriedade não suportado + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf new file mode 100644 index 00000000000..3ed53517a4b --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + Шрифт '{0}' не найден. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Поддерживаются только шрифты TrueType. '{0}' не является шрифтом TrueType. + + + + Value of '{0}' is not valid for font size unit. + Значение "{0}" недопустимо для единицы размера шрифта. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". + + + + Only projects with 'OutputType={0}' supported + Поддерживаются только проекты с "OutputType ={0}" + + + + Unsupported project type + Неподдерживаемый тип проекта + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: свойство проекта "{0}" не может иметь значение "{1}" + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} + + + + Unsupported property value + Не поддерживаемое значение свойства + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf new file mode 100644 index 00000000000..c57977774e9 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + '{0}' yazı tipi bulunamıyor. + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + Yalnızca TrueType yazı tipleri destekleniyor. '{0}' TrueType yazı tipi değil. + + + + Value of '{0}' is not valid for font size unit. + '{0}' değeri yazı tipi boyutu birimi için geçerli değil. + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". + + + + Only projects with 'OutputType={0}' supported + Yalnızca 'OutputType={0}' çıkış türüne sahip projeler destekleniyor + + + + Unsupported project type + Desteklenmeyen proje türü + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} + + + + Unsupported property value + Desteklenmeyen özellik değeri + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf new file mode 100644 index 00000000000..d14f151ac66 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + 无法找到字体“{0}”。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 只支持 TrueType 字体。“{0}”不是 TrueType 字体。 + + + + Value of '{0}' is not valid for font size unit. + “{0}”的值对于字体大小单位无效。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 无法分析文本“{0}”。文本格式应为“{1}”。 + + + + Only projects with 'OutputType={0}' supported + 仅支持“OutputType={0}”的项目 + + + + Unsupported project type + 不支持的项目类型 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 无法将项目属性“{0}”设置为“{1}” + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} + + + + Unsupported property value + 不支持的属性值 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf new file mode 100644 index 00000000000..32d4caaa341 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf @@ -0,0 +1,72 @@ + + + + + + Add DesignerSerializationVisibilityAttribute to property + Add DesignerSerializationVisibilityAttribute to property + + + + Font '{0}' cannot be found. + 找不到字型 '{0}'。 + + + + Only TrueType fonts are supported. '{0}' is not a TrueType font. + 僅支援 TrueType 字型。'{0}' 不是 TrueType 字型。 + + + + Value of '{0}' is not valid for font size unit. + '{0}' 不是有效的字型大小單位值。 + + + + Text "{0}" cannot be parsed. The expected text format is "{1}". + 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 + + + + Only projects with 'OutputType={0}' supported + 只支援 'OutputType={0}' 的專案 + + + + Unsupported project type + 不支援的專案類型 + + + + ArgumentException: Project property '{0}' cannot be set to '{1}' + ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}' + + + + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. + ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} + + + + Unsupported property value + 不支援的屬性值 + + + + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. + + + + Property '{0}' does not configure the code serialization for its property content + Property '{0}' does not configure the code serialization for its property content + + + + Missing code serialization configuration for property content + Missing code serialization configuration for property content + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj index f1268722c61..bda61b8e852 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj @@ -6,8 +6,28 @@ true 15.0 - None $(NoWarn);CA1812 + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + true + System + MSBuild:_GenerateResxSource + + + diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb new file mode 100644 index 00000000000..a11210ddba2 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb @@ -0,0 +1,121 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.Collections.Immutable +Imports System.Composition +Imports System.Threading +Imports System.Windows.Forms.Analyzers.Diagnostics +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.CodeActions +Imports Microsoft.CodeAnalysis.CodeFixes +Imports Microsoft.CodeAnalysis.Text +Imports Microsoft.CodeAnalysis.VisualBasic +Imports Microsoft.CodeAnalysis.VisualBasic.Syntax + +Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializationVisibility + + + <[Shared]> + Friend NotInheritable Class AddDesignerSerializationVisibilityCodeFixProvider + Inherits CodeFixProvider + + Private Const SystemComponentModelName As String = "System.ComponentModel" + + Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String) + Get + Return ImmutableArray.Create(DiagnosticIDs.ControlPropertySerialization) + End Get + End Property + + Public Overrides Function GetFixAllProvider() As FixAllProvider + Return WellKnownFixAllProviders.BatchFixer + End Function + + Public Overrides Async Function RegisterCodeFixesAsync(context As CodeFixContext) As Task + + ' Cannot be null - otherwise we wouldn't have a diagnostic of that ID. + Dim root As SyntaxNode = Await context _ + .Document _ + .GetSyntaxRootAsync(context.CancellationToken) _ + .ConfigureAwait(False) + + Dim diagnostic As Diagnostic = context.Diagnostics.First() + Dim diagnosticSpan As TextSpan = diagnostic.Location.SourceSpan + + ' Find the type declaration identified by the diagnostic. + Dim propertyDeclaration As PropertyStatementSyntax = root _ + .FindToken(diagnosticSpan.Start) _ + .Parent.AncestorsAndSelf() _ + .OfType(Of PropertyStatementSyntax)() _ + .First() + + ' Register a code action that will invoke the fix. + context.RegisterCodeFix( + CodeAction.Create( + title:=SR.AddDesignerSerializationVisibilityCodeFixTitle, + createChangedDocument:=Function(c) AddDesignerSerializationAttribute( + document:=context.Document, + propertyDeclarationSyntax:=propertyDeclaration, + cancellationToken:=c), + equivalenceKey:=NameOf(SR.AddDesignerSerializationVisibilityCodeFixTitle)), + diagnostic) + + End Function + + Private Shared Async Function AddDesignerSerializationAttribute(document As Document, propertyDeclarationSyntax As PropertyStatementSyntax, cancellationToken As CancellationToken) As Task(Of Document) + If propertyDeclarationSyntax Is Nothing Then + Return document + End If + + ' Generate the Attribute we need to put on the property + Dim designerSerializationVisibilityAttribute As AttributeSyntax = + SyntaxFactory.Attribute( + Nothing, + SyntaxFactory.ParseTypeName("DesignerSerializationVisibility"), + SyntaxFactory.ParseArgumentList("(DesignerSerializationVisibility.Hidden)")) + + ' Make sure, we keep the white spaces before and after the property + Dim leadingTrivia As SyntaxTriviaList = propertyDeclarationSyntax.GetLeadingTrivia() + Dim trailingTrivia As SyntaxTriviaList = propertyDeclarationSyntax.GetTrailingTrivia() + + ' Add the attribute to the property: + Dim newProperty As PropertyStatementSyntax = propertyDeclarationSyntax.AddAttributeLists(SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(designerSerializationVisibilityAttribute))) + + ' Let's restore the trivia: + newProperty = newProperty.WithLeadingTrivia(leadingTrivia).WithTrailingTrivia(trailingTrivia) + + ' Let's check, if we already have the using directive or if we need to add it: + ' (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) + Dim root As SyntaxNode = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) + + ' Let's check if we already have the using directive: + If Not root.DescendantNodes().OfType(Of ImportsStatementSyntax)() _ + .Any(Function(u) u?.TryGetInferredMemberName() = SystemComponentModelName) Then + + ' We need to add the using directive: + Dim firstNode As SyntaxNode = root.DescendantNodes().First() + + ' Add the imports directive: + Dim systemComponentModelImportsClauseSyntax As ImportsClauseSyntax = + SyntaxFactory.SimpleImportsClause(SyntaxFactory.IdentifierName(SystemComponentModelName)) + + Dim importsList As SeparatedSyntaxList(Of ImportsClauseSyntax) = + SyntaxFactory.SeparatedList(Of ImportsClauseSyntax)().Add(systemComponentModelImportsClauseSyntax) + + Dim usingDirective As ImportsStatementSyntax = SyntaxFactory.ImportsStatement(importsList) + + root = root.InsertNodesBefore(firstNode, {usingDirective}) + End If + + ' Produce a new root: + Dim originalRoot As SyntaxNode = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) + Dim newRoot As SyntaxNode = originalRoot.ReplaceNode(propertyDeclarationSyntax, newProperty) + + ' Generate the new document: + Return document.WithSyntaxRoot(newRoot) + + End Function + End Class +End Namespace diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzer.vb rename to src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb From 75a310982ea2bc14e324f21827e7bc76b74d6b33 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Mon, 10 Jun 2024 17:43:10 -0700 Subject: [PATCH 08/25] Bump up XUnit NuGets to latest version (fixes unit tests). --- .../Generators/ApplicationConfigurationGeneratorTests.cs | 4 ++-- .../Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index a17c1da4e95..9e0f4a5294d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -22,7 +22,7 @@ class Program static void Main() { ApplicationConfiguration.Initialize(); - }P + } } }"; private const string SourceCompilationFailed = @" @@ -65,7 +65,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_fails_if_ Sources = { SourceCompilationFailed }, ExpectedDiagnostics = { - DiagnosticResult.CompilerError("WFAC001").WithArguments("WindowsApplication"), + DiagnosticResult.CompilerError("WFCA001").WithArguments("WindowsApplication"), } }, }; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs index 530188736a5..1a2759f1c8d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs @@ -18,8 +18,10 @@ public Test() SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId)!.CompilationOptions; + compilationOptions = compilationOptions!.WithSpecificDiagnosticOptions( compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); + solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); return solution; From 6a82b6d9b1bd0c098dd49a488675e645f082d68e Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Mon, 10 Jun 2024 23:46:29 -0700 Subject: [PATCH 09/25] Correct analyzer IDs and clean up resource files. --- ...stem.Windows.Forms.Analyzers.CSharp.csproj | 2 +- .../Analyzers/CSharpDiagnosticDescriptors.cs | 1 + ...PropertySerializationDiagnosticAnalyzer.cs | 1 + .../ProjectFileReader.FontConverter.cs | 1 + ...indows.Forms.Analyzers.CSharp.Tests.csproj | 4 ++ .../Resources/SR.resx | 36 ----------- .../Resources/xlf/SR.cs.xlf | 60 ------------------- .../Resources/xlf/SR.de.xlf | 60 ------------------- .../Resources/xlf/SR.es.xlf | 60 ------------------- .../Resources/xlf/SR.fr.xlf | 60 ------------------- .../Resources/xlf/SR.it.xlf | 60 ------------------- .../Resources/xlf/SR.ja.xlf | 60 ------------------- .../Resources/xlf/SR.ko.xlf | 60 ------------------- .../Resources/xlf/SR.pl.xlf | 60 ------------------- .../Resources/xlf/SR.pt-BR.xlf | 60 ------------------- .../Resources/xlf/SR.ru.xlf | 60 ------------------- .../Resources/xlf/SR.tr.xlf | 60 ------------------- .../Resources/xlf/SR.zh-Hans.xlf | 60 ------------------- .../Resources/xlf/SR.zh-Hant.xlf | 60 ------------------- ...ws.Forms.Analyzers.CodeFixes.CSharp.csproj | 10 ++-- ...rSerializationVisibilityCodeFixProvider.cs | 3 +- .../Resources/SR.resx | 36 ----------- .../Resources/xlf/SR.cs.xlf | 60 ------------------- .../Resources/xlf/SR.de.xlf | 60 ------------------- .../Resources/xlf/SR.es.xlf | 60 ------------------- .../Resources/xlf/SR.fr.xlf | 60 ------------------- .../Resources/xlf/SR.it.xlf | 60 ------------------- .../Resources/xlf/SR.ja.xlf | 60 ------------------- .../Resources/xlf/SR.ko.xlf | 60 ------------------- .../Resources/xlf/SR.pl.xlf | 60 ------------------- .../Resources/xlf/SR.pt-BR.xlf | 60 ------------------- .../Resources/xlf/SR.ru.xlf | 60 ------------------- .../Resources/xlf/SR.tr.xlf | 60 ------------------- .../Resources/xlf/SR.zh-Hans.xlf | 60 ------------------- .../Resources/xlf/SR.zh-Hant.xlf | 60 ------------------- ...rms.Analyzers.CodeFixes.VisualBasic.vbproj | 3 +- ...rSerializationVisibilityCodeFixProvider.vb | 1 + .../Resources/SR.resx | 6 +- .../Resources/xlf/SR.cs.xlf | 6 +- .../Resources/xlf/SR.de.xlf | 6 +- .../Resources/xlf/SR.es.xlf | 6 +- .../Resources/xlf/SR.fr.xlf | 6 +- .../Resources/xlf/SR.it.xlf | 6 +- .../Resources/xlf/SR.ja.xlf | 6 +- .../Resources/xlf/SR.ko.xlf | 6 +- .../Resources/xlf/SR.pl.xlf | 6 +- .../Resources/xlf/SR.pt-BR.xlf | 6 +- .../Resources/xlf/SR.ru.xlf | 6 +- .../Resources/xlf/SR.tr.xlf | 6 +- .../Resources/xlf/SR.zh-Hans.xlf | 6 +- .../Resources/xlf/SR.zh-Hant.xlf | 6 +- ...Windows.Forms.Analyzers.VisualBasic.vbproj | 2 +- ...PropertySerializationDiagnosticAnalyzer.vb | 7 ++- .../src/Resources/SR.resx | 6 +- .../src/Resources/xlf/SR.cs.xlf | 12 ++-- .../src/Resources/xlf/SR.de.xlf | 12 ++-- .../src/Resources/xlf/SR.es.xlf | 12 ++-- .../src/Resources/xlf/SR.fr.xlf | 12 ++-- .../src/Resources/xlf/SR.it.xlf | 12 ++-- .../src/Resources/xlf/SR.ja.xlf | 12 ++-- .../src/Resources/xlf/SR.ko.xlf | 12 ++-- .../src/Resources/xlf/SR.pl.xlf | 12 ++-- .../src/Resources/xlf/SR.pt-BR.xlf | 12 ++-- .../src/Resources/xlf/SR.ru.xlf | 12 ++-- .../src/Resources/xlf/SR.tr.xlf | 12 ++-- .../src/Resources/xlf/SR.zh-Hans.xlf | 12 ++-- .../src/Resources/xlf/SR.zh-Hant.xlf | 12 ++-- .../src/System.Windows.Forms.Analyzers.csproj | 1 + .../Diagnostics/DiagnosticDescriptors.cs | 20 +++---- .../Analyzers/AppManifestAnalyzerTests.cs | 16 +++-- 70 files changed, 166 insertions(+), 1784 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj index 222f3ea1e01..f697a6c7b9c 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System.Windows.Forms.Analyzers.CSharp.csproj @@ -31,7 +31,7 @@ true - System + System.Windows.Forms.Analyzers.CSharp.Resources diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs index f7b272bd960..d6a9c132693 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Windows.Forms.Analyzers.CSharp.Resources; using System.Windows.Forms.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs index 7c466af174a..46630fe4dd5 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.ComponentModel; +using System.Windows.Forms.Analyzers.CSharp.Resources; using System.Windows.Forms.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs index f100d4cc465..67a8da49123 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.FontConverter.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Globalization; +using System.Windows.Forms.Analyzers.CSharp.Resources; using static System.Windows.Forms.Analyzers.ApplicationConfig; namespace System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj index 59ab1c4664e..b77c628d846 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj @@ -32,4 +32,8 @@ + + + + diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx index e282a7adda2..cf5f0ae9db7 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/SR.resx @@ -117,42 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Unsupported project type - - - Only projects with 'OutputType={0}' supported - - - Unsupported property value - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - - - Value of '{0}' is not valid for font size unit. - - - Font '{0}' cannot be found. - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - Missing code serialization configuration for property content - - - Property '{0}' does not configure the code serialization for its property content - Add DesignerSerializationVisibilityAttribute to property diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf index dbd1d036602..a83842a2112 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.cs.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Písmo {0} nebylo nalezeno. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Podporována jsou pouze písma TrueType. Písmo {0} není typu TrueType. - - - - Value of '{0}' is not valid for font size unit. - Hodnota {0} není platnou jednotkou velikosti písma. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. - - - - Only projects with 'OutputType={0}' supported - Podporované jsou jen projekty, kde OutputType={0}. - - - - Unsupported project type - Nepodporovaný typ projektu - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} - - - - Unsupported property value - Nepodporovaná hodnota vlastnosti - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf index 445c2fd6f57..49c8b221cfa 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.de.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Die Schriftart {0} kann nicht gefunden werden. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Es werden nur TrueType-Schriftarten unterstützt. {0} ist keine TrueType-Schriftart. - - - - Value of '{0}' is not valid for font size unit. - Der Wert von "{0}" ist für die Schriftgradeinheit ungültig. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. - - - - Only projects with 'OutputType={0}' supported - Nur Projekte mit "OutputType={0}" werden unterstützt. - - - - Unsupported project type - Nicht unterstützter Projekttyp - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} - - - - Unsupported property value - Nicht unterstützter Eigenschaftswert - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf index 38ad0b99ceb..7380b5cd7bc 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.es.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - No se puede encontrar la fuente '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Sólo son compatibles las fuentes TrueType. '{0}' no es una fuente TrueType. - - - - Value of '{0}' is not valid for font size unit. - El valor de '{0}' no es válido para la unidad de tamaño de fuente. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". - - - - Only projects with 'OutputType={0}' supported - Solo se admiten proyectos con "OutputType={0}". - - - - Unsupported project type - Tipo de proyecto incompatible - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} - - - - Unsupported property value - Valor de propiedad no admitido - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf index 4b73e09f48e..b7cf14b2a10 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.fr.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Impossible de trouver la police '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Seules les polices TrueType sont prises en charge. '{0}' n'est pas une police TrueType. - - - - Value of '{0}' is not valid for font size unit. - La valeur de «{0}» n’est pas valide pour l’unité de taille de police. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". - - - - Only projects with 'OutputType={0}' supported - Seuls les projets avec «OutputType={0}» pris en charge - - - - Unsupported project type - Type de projet non pris en charge - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}» - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} - - - - Unsupported property value - Valeur de propriété non prise en charge - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf index 5e5e33518ea..c0af323b86a 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.it.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Impossibile trovare il tipo di carattere '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Sono supportati solo i tipi di carattere TrueType. '{0}' non è un carattere TrueType. - - - - Value of '{0}' is not valid for font size unit. - Il valore di '{0}' non è valido per l'unità delle dimensioni del carattere. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". - - - - Only projects with 'OutputType={0}' supported - Sono supportati solo i progetti con 'OutputType={0}' - - - - Unsupported project type - Tipo di progetto non supportato - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} - - - - Unsupported property value - Valore di proprietà non supportato - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf index ff534d21ace..338d0fd1fc7 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ja.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - フォント '{0}' が見つかりません。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - TrueType フォントのみがサポートされています。'{0}' は TrueType フォントではありません。 - - - - Value of '{0}' is not valid for font size unit. - '{0}' の値は、フォント サイズの単位として有効ではありません。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 - - - - Only projects with 'OutputType={0}' supported - 'OutputType ={0}' のプロジェクトのみがサポートされています - - - - Unsupported project type - サポートされていないプロジェクトの種類 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} - - - - Unsupported property value - サポートされていないプロパティの値 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf index 46f7155c042..e1690c6d59d 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ko.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - '{0}' 글꼴을 찾을 수 없습니다. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 트루타입 글꼴만 지원됩니다. '{0}'은(는) 트루타입 글꼴이 아닙니다. - - - - Value of '{0}' is not valid for font size unit. - '{0}' 값은 글꼴 크기 단위에 대해 유효하지 않습니다. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. - - - - Only projects with 'OutputType={0}' supported - 'OutputType={0}'인 프로젝트만 지원됨 - - - - Unsupported project type - 지원되지 않는 프로젝트 유형 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없음 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} - - - - Unsupported property value - 지원되지 않는 속성 값 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf index 4bc6b7359e6..dad0b68d4ab 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pl.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Nie można odnaleźć czcionki „{0}”. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Obsługiwane są tylko czcionki TrueType. Element „{0}” nie jest czcionką TrueType. - - - - Value of '{0}' is not valid for font size unit. - Wartość „{0}” jest nieprawidłowa dla jednostki rozmiaru czcionki. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. - - - - Only projects with 'OutputType={0}' supported - Obsługiwane są tylko projekty z parametrem „OutputType={0}” - - - - Unsupported project type - Nieobsługiwany typ projektu - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}” - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} - - - - Unsupported property value - Nieobsługiwana wartość właściwości - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf index d1aeee4385b..6f3842c4160 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.pt-BR.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - A fonte '{0}' não pode ser encontrada. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Só há suporte para fontes TrueType. '{0}' não é uma fonte TrueType. - - - - Value of '{0}' is not valid for font size unit. - O valor de '{0}' não é válido para a unidade de tamanho da fonte. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". - - - - Only projects with 'OutputType={0}' supported - Apenas projetos com 'OutputType={0}' suportados - - - - Unsupported project type - Tipo de projeto não suportado - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} - - - - Unsupported property value - Valor de propriedade não suportado - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf index 3ed53517a4b..90ca9eedf16 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.ru.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Шрифт '{0}' не найден. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Поддерживаются только шрифты TrueType. '{0}' не является шрифтом TrueType. - - - - Value of '{0}' is not valid for font size unit. - Значение "{0}" недопустимо для единицы размера шрифта. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". - - - - Only projects with 'OutputType={0}' supported - Поддерживаются только проекты с "OutputType ={0}" - - - - Unsupported project type - Неподдерживаемый тип проекта - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}" - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} - - - - Unsupported property value - Не поддерживаемое значение свойства - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf index c57977774e9..9dbbad8001d 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.tr.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - '{0}' yazı tipi bulunamıyor. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Yalnızca TrueType yazı tipleri destekleniyor. '{0}' TrueType yazı tipi değil. - - - - Value of '{0}' is not valid for font size unit. - '{0}' değeri yazı tipi boyutu birimi için geçerli değil. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". - - - - Only projects with 'OutputType={0}' supported - Yalnızca 'OutputType={0}' çıkış türüne sahip projeler destekleniyor - - - - Unsupported project type - Desteklenmeyen proje türü - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} - - - - Unsupported property value - Desteklenmeyen özellik değeri - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf index d14f151ac66..f599260bdec 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hans.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - 无法找到字体“{0}”。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 只支持 TrueType 字体。“{0}”不是 TrueType 字体。 - - - - Value of '{0}' is not valid for font size unit. - “{0}”的值对于字体大小单位无效。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 无法分析文本“{0}”。文本格式应为“{1}”。 - - - - Only projects with 'OutputType={0}' supported - 仅支持“OutputType={0}”的项目 - - - - Unsupported project type - 不支持的项目类型 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 无法将项目属性“{0}”设置为“{1}” - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} - - - - Unsupported property value - 不支持的属性值 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf index 32d4caaa341..8cf4f2161cb 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Resources/xlf/SR.zh-Hant.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - 找不到字型 '{0}'。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 僅支援 TrueType 字型。'{0}' 不是 TrueType 字型。 - - - - Value of '{0}' is not valid for font size unit. - '{0}' 不是有效的字型大小單位值。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 - - - - Only projects with 'OutputType={0}' supported - 只支援 'OutputType={0}' 的專案 - - - - Unsupported project type - 不支援的專案類型 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} - - - - Unsupported property value - 不支援的屬性值 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj index f64ea50ef5c..41c0d892c8e 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj @@ -18,14 +18,14 @@ - - - - + + + + true - System + System.Windows.Forms.Analyzers.CodeFixes.Resources diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index c9201771533..c8c6244e32f 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -3,13 +3,14 @@ using System.Collections.Immutable; using System.Composition; +using System.Windows.Forms.Analyzers.Diagnostics; +using System.Windows.Forms.Analyzers.CodeFixes.Resources; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; -using System.Windows.Forms.Analyzers.Diagnostics; namespace System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility; diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx index e282a7adda2..cf5f0ae9db7 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/SR.resx @@ -117,42 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Unsupported project type - - - Only projects with 'OutputType={0}' supported - - - Unsupported property value - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - - - Value of '{0}' is not valid for font size unit. - - - Font '{0}' cannot be found. - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - Missing code serialization configuration for property content - - - Property '{0}' does not configure the code serialization for its property content - Add DesignerSerializationVisibilityAttribute to property diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf index dbd1d036602..a83842a2112 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.cs.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Písmo {0} nebylo nalezeno. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Podporována jsou pouze písma TrueType. Písmo {0} není typu TrueType. - - - - Value of '{0}' is not valid for font size unit. - Hodnota {0} není platnou jednotkou velikosti písma. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. - - - - Only projects with 'OutputType={0}' supported - Podporované jsou jen projekty, kde OutputType={0}. - - - - Unsupported project type - Nepodporovaný typ projektu - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Vlastnost projektu {0} nemůžete nastavit na {1}. Důvod: {2} - - - - Unsupported property value - Nepodporovaná hodnota vlastnosti - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf index 445c2fd6f57..49c8b221cfa 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.de.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Die Schriftart {0} kann nicht gefunden werden. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Es werden nur TrueType-Schriftarten unterstützt. {0} ist keine TrueType-Schriftart. - - - - Value of '{0}' is not valid for font size unit. - Der Wert von "{0}" ist für die Schriftgradeinheit ungültig. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. - - - - Only projects with 'OutputType={0}' supported - Nur Projekte mit "OutputType={0}" werden unterstützt. - - - - Unsupported project type - Nicht unterstützter Projekttyp - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Die Projekteigenschaft "{0}" kann nicht auf "{1}" festgelegt werden. Grund: {2} - - - - Unsupported property value - Nicht unterstützter Eigenschaftswert - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf index 38ad0b99ceb..7380b5cd7bc 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.es.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - No se puede encontrar la fuente '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Sólo son compatibles las fuentes TrueType. '{0}' no es una fuente TrueType. - - - - Value of '{0}' is not valid for font size unit. - El valor de '{0}' no es válido para la unidad de tamaño de fuente. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". - - - - Only projects with 'OutputType={0}' supported - Solo se admiten proyectos con "OutputType={0}". - - - - Unsupported project type - Tipo de proyecto incompatible - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la propiedad de proyecto '{0}' no se puede establecer en '{1}'. Motivo: {2} - - - - Unsupported property value - Valor de propiedad no admitido - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf index 4b73e09f48e..b7cf14b2a10 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.fr.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Impossible de trouver la police '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Seules les polices TrueType sont prises en charge. '{0}' n'est pas une police TrueType. - - - - Value of '{0}' is not valid for font size unit. - La valeur de «{0}» n’est pas valide pour l’unité de taille de police. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". - - - - Only projects with 'OutputType={0}' supported - Seuls les projets avec «OutputType={0}» pris en charge - - - - Unsupported project type - Type de projet non pris en charge - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}» - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException : la propriété de projet «{0}» ne peut pas être définie sur «{1}». Raison : {2} - - - - Unsupported property value - Valeur de propriété non prise en charge - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf index 5e5e33518ea..c0af323b86a 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.it.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Impossibile trovare il tipo di carattere '{0}'. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Sono supportati solo i tipi di carattere TrueType. '{0}' non è un carattere TrueType. - - - - Value of '{0}' is not valid for font size unit. - Il valore di '{0}' non è valido per l'unità delle dimensioni del carattere. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". - - - - Only projects with 'OutputType={0}' supported - Sono supportati solo i progetti con 'OutputType={0}' - - - - Unsupported project type - Tipo di progetto non supportato - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: la proprietà di progetto '{0}' non può essere impostata su '{1}'. Motivo: {2} - - - - Unsupported property value - Valore di proprietà non supportato - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf index ff534d21ace..338d0fd1fc7 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ja.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - フォント '{0}' が見つかりません。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - TrueType フォントのみがサポートされています。'{0}' は TrueType フォントではありません。 - - - - Value of '{0}' is not valid for font size unit. - '{0}' の値は、フォント サイズの単位として有効ではありません。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 - - - - Only projects with 'OutputType={0}' supported - 'OutputType ={0}' のプロジェクトのみがサポートされています - - - - Unsupported project type - サポートされていないプロジェクトの種類 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: プロジェクト プロパティ '{0}' を '{1}' に設定することはできません。理由: {2} - - - - Unsupported property value - サポートされていないプロパティの値 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf index 46f7155c042..e1690c6d59d 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ko.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - '{0}' 글꼴을 찾을 수 없습니다. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 트루타입 글꼴만 지원됩니다. '{0}'은(는) 트루타입 글꼴이 아닙니다. - - - - Value of '{0}' is not valid for font size unit. - '{0}' 값은 글꼴 크기 단위에 대해 유효하지 않습니다. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. - - - - Only projects with 'OutputType={0}' supported - 'OutputType={0}'인 프로젝트만 지원됨 - - - - Unsupported project type - 지원되지 않는 프로젝트 유형 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없음 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 프로젝트 속성 '{0}'을(를) '{1}'(으)로 설정할 수 없습니다. 이유: {2} - - - - Unsupported property value - 지원되지 않는 속성 값 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf index 4bc6b7359e6..dad0b68d4ab 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pl.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Nie można odnaleźć czcionki „{0}”. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Obsługiwane są tylko czcionki TrueType. Element „{0}” nie jest czcionką TrueType. - - - - Value of '{0}' is not valid for font size unit. - Wartość „{0}” jest nieprawidłowa dla jednostki rozmiaru czcionki. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. - - - - Only projects with 'OutputType={0}' supported - Obsługiwane są tylko projekty z parametrem „OutputType={0}” - - - - Unsupported project type - Nieobsługiwany typ projektu - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}” - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: Właściwość projektu „{0}” nie może mieć wartości „{1}”. Przyczyna: {2} - - - - Unsupported property value - Nieobsługiwana wartość właściwości - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf index d1aeee4385b..6f3842c4160 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.pt-BR.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - A fonte '{0}' não pode ser encontrada. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Só há suporte para fontes TrueType. '{0}' não é uma fonte TrueType. - - - - Value of '{0}' is not valid for font size unit. - O valor de '{0}' não é válido para a unidade de tamanho da fonte. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". - - - - Only projects with 'OutputType={0}' supported - Apenas projetos com 'OutputType={0}' suportados - - - - Unsupported project type - Tipo de projeto não suportado - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: A propriedade do projeto '{0}' não pode ser definida como '{1}'. Motivo: {2} - - - - Unsupported property value - Valor de propriedade não suportado - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf index 3ed53517a4b..90ca9eedf16 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.ru.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - Шрифт '{0}' не найден. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Поддерживаются только шрифты TrueType. '{0}' не является шрифтом TrueType. - - - - Value of '{0}' is not valid for font size unit. - Значение "{0}" недопустимо для единицы размера шрифта. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". - - - - Only projects with 'OutputType={0}' supported - Поддерживаются только проекты с "OutputType ={0}" - - - - Unsupported project type - Неподдерживаемый тип проекта - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}" - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: свойство проекта "{0}" не может иметь значение "{1}". Причина: {2} - - - - Unsupported property value - Не поддерживаемое значение свойства - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf index c57977774e9..9dbbad8001d 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.tr.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - '{0}' yazı tipi bulunamıyor. - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - Yalnızca TrueType yazı tipleri destekleniyor. '{0}' TrueType yazı tipi değil. - - - - Value of '{0}' is not valid for font size unit. - '{0}' değeri yazı tipi boyutu birimi için geçerli değil. - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". - - - - Only projects with 'OutputType={0}' supported - Yalnızca 'OutputType={0}' çıkış türüne sahip projeler destekleniyor - - - - Unsupported project type - Desteklenmeyen proje türü - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: '{0}' proje özelliği '{1}' olarak ayarlanamıyor. Neden: {2} - - - - Unsupported property value - Desteklenmeyen özellik değeri - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf index d14f151ac66..f599260bdec 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hans.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - 无法找到字体“{0}”。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 只支持 TrueType 字体。“{0}”不是 TrueType 字体。 - - - - Value of '{0}' is not valid for font size unit. - “{0}”的值对于字体大小单位无效。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 无法分析文本“{0}”。文本格式应为“{1}”。 - - - - Only projects with 'OutputType={0}' supported - 仅支持“OutputType={0}”的项目 - - - - Unsupported project type - 不支持的项目类型 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 无法将项目属性“{0}”设置为“{1}” - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 无法将项目属性“{0}”设置为“{1}”。原因: {2} - - - - Unsupported property value - 不支持的属性值 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf index 32d4caaa341..8cf4f2161cb 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Resources/xlf/SR.zh-Hant.xlf @@ -7,66 +7,6 @@ Add DesignerSerializationVisibilityAttribute to property - - Font '{0}' cannot be found. - 找不到字型 '{0}'。 - - - - Only TrueType fonts are supported. '{0}' is not a TrueType font. - 僅支援 TrueType 字型。'{0}' 不是 TrueType 字型。 - - - - Value of '{0}' is not valid for font size unit. - '{0}' 不是有效的字型大小單位值。 - - - - Text "{0}" cannot be parsed. The expected text format is "{1}". - 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 - - - - Only projects with 'OutputType={0}' supported - 只支援 'OutputType={0}' 的專案 - - - - Unsupported project type - 不支援的專案類型 - - - - ArgumentException: Project property '{0}' cannot be set to '{1}' - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}' - - - - ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - ArgumentException: 專案屬性 '{0}' 不能設定為 '{1}'。理由: {2} - - - - Unsupported property value - 不支援的屬性值 - - - - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - - - - Property '{0}' does not configure the code serialization for its property content - Property '{0}' does not configure the code serialization for its property content - - - - Missing code serialization configuration for property content - Missing code serialization configuration for property content - - \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj index bda61b8e852..1a8df0102c1 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj @@ -25,8 +25,7 @@ true - System - MSBuild:_GenerateResxSource + System.Windows.Forms.Analyzers.CodeFixes.Resources diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb index a11210ddba2..3c22f924d25 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb @@ -5,6 +5,7 @@ Imports System.Collections.Immutable Imports System.Composition Imports System.Threading Imports System.Windows.Forms.Analyzers.Diagnostics +Imports System.Windows.Forms.Analyzers.CodeFixes.Resources Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.CodeActions Imports Microsoft.CodeAnalysis.CodeFixes diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx index d85856a1f64..a869f0de5f0 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Missing code serialization configuration for property content - + Property '{0}' does not configure the code serialization for its property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf index 590239fdaed..ce0b8fe394f 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf index 0d323cd5ca2..19651251fe8 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf index 49982ba613d..fe8d2689547 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf index 9074aca1b4b..5149b0efe83 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf index 91c04435a61..d30cc9a84b1 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf index 97cb52f8bfb..dec4d447d93 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf index 5c7348d20c8..9e07b8c8024 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf index 313f9028618..09c771bf742 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf index 53040e2b168..64d7ad28b04 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf index be84174fdf7..3d3e6c789ae 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf index 3fabd64b1ff..0002b039163 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf index e40c447063c..63ff0091356 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf index 64e877486d1..c8744c8fa57 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj index 4429621c499..9f4d9c63714 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj @@ -27,7 +27,7 @@ true - System + System.Windows.Forms.Analyzers.VisualBasic.Resources diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb index 03456cb5f9f..b4dca61113f 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb @@ -4,6 +4,7 @@ Imports System.Collections.Immutable Imports System.ComponentModel Imports System.Windows.Forms.Analyzers.Diagnostics +Imports System.Windows.Forms.Analyzers.VisualBasic.Resources Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Diagnostics @@ -20,12 +21,12 @@ Namespace System.Windows.Forms.VisualBasic.Analyzers.ControlPropertySerializatio Private Shared ReadOnly s_rule As New DiagnosticDescriptor( id:=DiagnosticIDs.ControlPropertySerialization, - title:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerTitle), SR.ResourceManager, GetType(SR)), - messageFormat:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), + title:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerTitle), SR.ResourceManager, GetType(SR)), + messageFormat:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), category:=DiagnosticCategories.WinFormsSecurity, defaultSeverity:=DiagnosticSeverity.Error, isEnabledByDefault:=True, - description:=New LocalizableResourceString(NameOf(SR.WFAVB003AnalyzerDescription), SR.ResourceManager, GetType(SR)) + description:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerDescription), SR.ResourceManager, GetType(SR)) ) Public Overrides ReadOnly Property SupportedDiagnostics As ImmutableArray(Of DiagnosticDescriptor) diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx index 7a282f6dddf..c7ece20377e 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx @@ -58,13 +58,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Unsupported high DPI configuration - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf index de9ee8fa977..01cce675e9b 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Odeberte z {0} nastavení vysokého rozlišení DPI a použijte ke konfiguraci rozhraní API Application.SetHighDpiMode nebo vlastnost projektu {1}. + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Odeberte z {0} nastavení vysokého rozlišení DPI a použijte ke konfiguraci vlastnost {1} v aplikačním frameworku. + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Nepodporovaná konfigurace vysokého rozlišení DPI + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf index a33b44ac27f..0fc1da645ce 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Entfernen Sie Einstellungen mit hohem DPI-Wert aus {0} und konfigurieren Sie sie über die Application.SetHighDpiMode-API oder die Projekteigenschaft "{1}". + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Entfernen Sie Einstellungen mit hohem DPI-Wert aus {0} und konfigurieren Sie sie über die Eigenschaft "{1}" in Application Framework. + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Nicht unterstützte Konfiguration mit hohem DPI-Wert + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf index 102db0aeca9..db4484a933e 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Quitar la configuración con valores altos de PPP de {0} y configurar a través de la aplicación API SetHighDpiMode o a través de la propiedad del proyecto '{1}'. + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Quitar la configuración con valores altos de PPP de {0} y configurar a través de la propiedad '{1}' en el marco de trabajo de la aplicación + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Configuración de PPP alta no admitida + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf index 8460e887c93..5e3b11379ae 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Supprimez les paramètres haute résolution de {0} et configurez-les via l’API Application.SetHighDpiMode ou la propriété de projet «{1}» + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Supprimer les paramètres haute résolution de {0} et configurer via la propriété «{1}» dans Application Framework + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Configuration haute résolution non prise en charge + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf index 4fcccb79370..6b0edf46eba 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Rimuovere le impostazioni della risoluzione elevata da {0} e configurare tramite l'API Application.SetHighDpiMode o la proprietà di progetto '{1}' + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Rimuovere le impostazioni della risoluzione elevata da {0} e configurare tramite la proprietà '{1}' in Framework applicazione + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Configurazione per risoluzione elevata non supportata + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf index 9ffc947d930..eed0c5b5854 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - 高 DPI 設定を {0} から削除し、Application.SetHighDpiMode API または '{1}' プロジェクト プロパティを使用して構成します + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - 高 DPI 設定を {0} から削除し、アプリケーション フレームワークの '{1}' プロパティを使用して構成します + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - サポートされていない高 DPI 構成 + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf index 8faeb1774be..5e26e25aa77 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - {0}에서 높은 DPI 설정을 제거하고 Application.SetHighDpiMode API 또는 '{1}' 프로젝트 속성을 통해 구성 + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - {0}에서 높은 DPI 설정을 제거하고 Application Framework의 '{1}' 속성을 통해 구성 + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - 지원되지 않는 높은 DPI 구성 + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf index d1c5fef543f..7d89062429d 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Usuń ustawienia wysokiej rozdzielczości DPI z {0}i skonfiguruj za pomocą interfejsu API Application.SetHighDpiMode lub właściwości projektu „{1}” + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Usuń ustawienia wysokiej rozdzielczości DPI z {0}and skonfiguruj za pomocą właściwości „{1}” w programie Application Framework + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Nieobsługiwana konfiguracja wysokiej rozdzielczości DPI + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf index dbb1235ee59..bd2b3c2c614 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Remova as configurações de DPI alto de {0} e configure por meio da API Application.SetHighDpiMode ou da propriedade do projeto '{1}' + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Remova as configurações de DPI alto de {0} e configure por meio da propriedade '{1}' no Application Framework + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Configuração de alta DPI não suportada + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf index 01307e0834e..50cde8cbf4c 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Удалить параметры высокого DPI из "{0}" и настроить через API приложения Application.SetHighDpiMode или свойство проекта "{1}" + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Удалить параметры высокого DPI из {0} и настроить через свойство "{1}" в исполняющей среде + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Неподдерживаемая конфигурация высокого DPI + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf index 0aaf8f804f9..045ee342521 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - Yüksek DPI ayarlarını {0} bileşeninden kaldırın ve Application.SetHighDpiMode API’si veya '{1}' proje özelliği aracılığıyla yapılandırın + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - Yüksek DPI ayarlarını {0} bileşeninden kaldırın ve Uygulama Çerçevesi’ndeki '{1}' özelliği aracılığıyla yapılandırın + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - Desteklenmeyen yüksek DPI yapılandırması + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf index bf16f1a8e80..d703b579395 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - 从 {0} 中删除高 DPI 设置,并通过 Application.SetHighDpiMode API 或“{1}”项目属性进行配置 + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - 从 {0} 中删除高 DPI 设置,并通过应用程序框架中的“{1}”属性进行配置 + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - 不支持的高 DPI 配置 + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf index bbb3f960b82..9124f1e815c 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,19 +2,19 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - 從 {0} 移除高 DPI 設定,並透過Application.SetHighDpiMode API 或 '{1}' 專案屬性進行設定 + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - 從 {0} 移除高 DPI 設定,並透過應用程式架構中的 '{1}' 屬性進行設定 + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration - 不支援的高 DPI 設定 + Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj index f78c0aa31a6..8fcd7ea3fa2 100644 --- a/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj +++ b/src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj @@ -24,6 +24,7 @@ true + System.Windows.Forms.Analyzers.Resources diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs index 12d389f911f..7cb512473df 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs @@ -10,27 +10,27 @@ internal static partial class DiagnosticDescriptors { private const string Category = "ApplicationConfiguration"; - private static readonly LocalizableString s_localizableWFAC010Title - = new LocalizableResourceString(nameof(SR.WFAC010Title), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFCA010Title + = new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)); - private static readonly LocalizableString s_localizableWFAC010Message_CS - = new LocalizableResourceString(nameof(SR.WFAC010Message_CS), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFCA010Message_CS + = new LocalizableResourceString(nameof(SR.WFCA010Message_CS), SR.ResourceManager, typeof(SR)); - private static readonly LocalizableString s_localizableWFAC010Message_VB - = new LocalizableResourceString(nameof(SR.WFAC010Message_VB), SR.ResourceManager, typeof(SR)); + private static readonly LocalizableString s_localizableWFCA010Message_VB + = new LocalizableResourceString(nameof(SR.WFCA010Message_VB), SR.ResourceManager, typeof(SR)); internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_CSharp = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: s_localizableWFAC010Title, - messageFormat: s_localizableWFAC010Message_CS, + title: s_localizableWFCA010Title, + messageFormat: s_localizableWFCA010Message_CS, category: Category, defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_VB = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: s_localizableWFAC010Title, - messageFormat: s_localizableWFAC010Message_VB, + title: s_localizableWFCA010Title, + messageFormat: s_localizableWFCA010Message_VB, category: Category, defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index 6cb4165f0be..f802d7cbdab 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -5,10 +5,12 @@ using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using Xunit; -using VerifyCS = System.Windows.Forms.Analyzers.Tests.CSharpAnalyzerVerifier< - System.Windows.Forms.Analyzers.AppManifestAnalyzer>; -using VerifyVB = System.Windows.Forms.Analyzers.Tests.VisualBasicAnalyzerVerifier< - System.Windows.Forms.Analyzers.AppManifestAnalyzer>; + +using VerifyCS = System.Windows.Forms.Analyzers.Tests + .CSharpAnalyzerVerifier; + +using VerifyVB = System.Windows.Forms.Analyzers.Tests + .VisualBasicAnalyzerVerifier; namespace System.Windows.Forms.Analyzers.Tests; @@ -113,13 +115,14 @@ public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_in { const string manifestFilePath = @"C:\temp\app.manifest"; SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + await new VerifyCS.Test { TestCode = CSharCode, TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) }, - AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFAC010.severity = none") } + AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFCA010.severity = none") } } }.RunAsync(); } @@ -129,13 +132,14 @@ public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_in { const string manifestFilePath = @"C:\temp\app.manifest"; SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + await new VerifyVB.Test { TestCode = VbCode, TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) }, - AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFAC010.severity = none") } + AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFCA010.severity = none") } } }.RunAsync(); } From fc30fa17ca49cca36f606b41aa02463429117a25 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 11 Jun 2024 13:42:44 -0700 Subject: [PATCH 10/25] Patch build props to correctly include new Analyzer projects. --- Directory.Build.props | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 513ce0cde9a..a2e55343c14 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,7 +18,11 @@ false true From 60a7cfb3ec4736e6dd73ba6c8b94aef89e0597af Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 11 Jun 2024 23:59:10 -0700 Subject: [PATCH 11/25] Include new Analyzers in build definition. --- .../Microsoft.Private.Winforms.csproj | 3 +++ .../System.Windows.Forms.FileClassification.props | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj index 2a753eb0bee..1f828214c82 100644 --- a/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj +++ b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj @@ -107,6 +107,9 @@ --> + + + diff --git a/pkg/Microsoft.Private.Winforms/sdk/dotnet-windowsdesktop/System.Windows.Forms.FileClassification.props b/pkg/Microsoft.Private.Winforms/sdk/dotnet-windowsdesktop/System.Windows.Forms.FileClassification.props index 44c1a321336..4bca48e101e 100644 --- a/pkg/Microsoft.Private.Winforms/sdk/dotnet-windowsdesktop/System.Windows.Forms.FileClassification.props +++ b/pkg/Microsoft.Private.Winforms/sdk/dotnet-windowsdesktop/System.Windows.Forms.FileClassification.props @@ -10,12 +10,15 @@ + + + + - From f1ade380a84c4115b59f5de1efddc98616f29ce9 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Thu, 13 Jun 2024 10:19:53 -0700 Subject: [PATCH 12/25] Change language folders in package content targets. --- eng/packageContent.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/packageContent.targets b/eng/packageContent.targets index 1732e129d44..e0f76e7a38d 100644 --- a/eng/packageContent.targets +++ b/eng/packageContent.targets @@ -33,8 +33,8 @@ <_AnalyzerTargetLanguage>$(AssemblyName.Substring($(AssemblyName.LastIndexOf('.')))) - /cs - /vb + /CSharp + /VisualBasic From 1c2ae40a369152f50a908814e5e6f521612acb76 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sat, 15 Jun 2024 18:02:16 -0700 Subject: [PATCH 13/25] Add basic test infra for CSharp Analyzers and CodeFixes. --- ...indows.Forms.Analyzers.CSharp.Tests.csproj | 6 +- ...ertySerializationDiagnosticAnalyzerTest.cs | 58 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 7 +++ .../UnitTests/Properties/AssemblyInfo.cs | 7 +++ 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs create mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj index b77c628d846..103ea05e9d6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj @@ -21,7 +21,9 @@ + + @@ -32,8 +34,4 @@ - - - - diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs new file mode 100644 index 00000000000..d23fd578f83 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; + +using VerifyCS = System.Windows.Forms.Analyzers.Tests + .CSharpCodeFixVerifier< + System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization.ControlPropertySerializationDiagnosticAnalyzer, + System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility.AddDesignerSerializationVisibilityCodeFixProvider>; + +namespace System.Windows.Forms.Analyzers.CSharp.Tests; + +public class ControlPropertySerializationDiagnosticAnalyzer +{ + private const string ProblematicCode = """ + + namespace CSharpControls; + + public class ScalableControlNoSerializationConfiguration : Control + { + public float ScaleFactor { get; set; } = 1.0f; + + public SizeF ScaledSize { get; set; } + + public PointF ScaledLocation { get; set; } + } + + """; + + private const string FixedCode = """ + + using System.ComponentModel; + + namespace CSharpControls; + + public class ScalableControlResolved : Control + { + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public float ScaleFactor { get; set; } = 1.0f; + + [DefaultValue(typeof(SizeF), "0,0")] + public SizeF ScaledSize { get; set; } + + public PointF ScaledLocation { get; set; } + private bool ShouldSerializeScaledSize() => this.ScaledSize != SizeF.Empty; + } + + """; + + [Fact] + public async Task Test_CSharp_AddDesignerSerializationVisibility() + { + var expected = VerifyCS.Diagnostic(nameof(ControlPropertySerializationDiagnosticAnalyzer)); + + await VerifyCS + .VerifyCodeFixAsync(ProblematicCode, expected, FixedCode); + } +} diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..cfb75a1f62a --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +// [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..4785fcee16f --- /dev/null +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +//[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] From 9a41f1293b34a3a96be406e7a1150378c067f623 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sat, 15 Jun 2024 18:12:00 -0700 Subject: [PATCH 14/25] Add tests for ControlPropertySerialization analyzer. --- ...ertySerializationDiagnosticAnalyzerTest.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs index d23fd578f83..07a43dbf26f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Windows.Forms.Analyzers.Diagnostics; using Xunit; using VerifyCS = System.Windows.Forms.Analyzers.Tests @@ -27,7 +28,7 @@ public class ScalableControlNoSerializationConfiguration : Control """; - private const string FixedCode = """ + private const string CorrectCode = """ using System.ComponentModel; @@ -47,10 +48,33 @@ public class ScalableControlResolved : Control """; + private const string FixedCode = """ + + using System.ComponentModel; + + namespace CSharpControls; + + public class ScalableControlResolved : Control + { + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public float ScaleFactor { get; set; } = 1.0f; + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public SizeF ScaledSize { get; set; } + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public PointF ScaledLocation { get; set; } + } + + """; + + [Fact] public async Task Test_CSharp_AddDesignerSerializationVisibility() { - var expected = VerifyCS.Diagnostic(nameof(ControlPropertySerializationDiagnosticAnalyzer)); + var expected = VerifyCS.Diagnostic(DiagnosticIDs.ControlPropertySerialization); + await VerifyCS.VerifyAnalyzerAsync(ProblematicCode, expected); + await VerifyCS.VerifyAnalyzerAsync(CorrectCode); await VerifyCS .VerifyCodeFixAsync(ProblematicCode, expected, FixedCode); From 528fc62889d5699c0d5615b4166212b988bce9ee Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sun, 16 Jun 2024 00:30:28 -0700 Subject: [PATCH 15/25] Bump up XUnit Verifier version and fix breaking changes. --- ...indows.Forms.Analyzers.CSharp.Tests.csproj | 4 +++ ...ertySerializationDiagnosticAnalyzerTest.cs | 2 -- .../ApplicationConfigurationGeneratorTests.cs | 16 +++++------ .../Verifiers/CSharpVerifierHelper.cs | 27 ------------------- .../UnitTests/Properties/AssemblyInfo.cs | 2 +- 5 files changed, 13 insertions(+), 38 deletions(-) delete mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj index 103ea05e9d6..67dc85ab087 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj @@ -34,4 +34,8 @@ + + + + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs index 07a43dbf26f..69d6c3a285d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers.Diagnostics; -using Xunit; using VerifyCS = System.Windows.Forms.Analyzers.Tests .CSharpCodeFixVerifier< @@ -68,7 +67,6 @@ public class ScalableControlResolved : Control """; - [Fact] public async Task Test_CSharp_AddDesignerSerializationVisibility() { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index 9e0f4a5294d..7d38273f96d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -3,7 +3,6 @@ using System.Text; using System.Windows.Forms.Analyzers; -using System.Windows.Forms.Analyzers.Tests; using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; @@ -57,7 +56,8 @@ public static TheoryData UnsupportedProjectTypes_TestData() [MemberData(nameof(UnsupportedProjectTypes_TestData))] public async Task ApplicationConfigurationGenerator_GenerateInitialize_fails_if_project_type_unsupported(OutputKind projectType) { - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -80,7 +80,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_pass_if_s { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -101,7 +101,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_b { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -122,7 +122,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett { SourceText generatedCode = LoadFileContent("GenerateInitialize_user_settings_boilerplate"); - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -156,8 +156,8 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_t "; SourceText generatedCode = LoadFileContent("GenerateInitialize_default_top_level"); - - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -182,7 +182,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett SourceText generatedCode = LoadFileContent("GenerateInitialize_user_top_level"); - var test = new CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs deleted file mode 100644 index 979f076581a..00000000000 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Immutable; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; - -namespace System.Windows.Forms.Analyzers.Tests; - -internal static class CSharpVerifierHelper -{ - /// - /// By default, the compiler reports diagnostics for nullable reference types at - /// , and the analyzer test framework defaults to only validating - /// diagnostics at . This map contains all compiler diagnostic IDs - /// related to nullability mapped to , which is then used to enable all - /// of these warnings for default validation during analyzer and code fix tests. - /// - internal static ImmutableDictionary NullableWarnings { get; } = GetNullableWarningsFromCompiler(); - - private static ImmutableDictionary GetNullableWarningsFromCompiler() - { - string[] args = ["/warnaserror:nullable"]; - var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); - return commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs index 4785fcee16f..cfb75a1f62a 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] -//[assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +// [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] From d66db02184d43e11de0d43c9e6ccd3f246f81be2 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Sun, 16 Jun 2024 01:52:24 -0700 Subject: [PATCH 16/25] Update CSharp Verifier. --- ...ertySerializationDiagnosticAnalyzerTest.cs | 34 +++++-- .../ApplicationConfigurationGeneratorTests.cs | 88 +++++++++++-------- 2 files changed, 74 insertions(+), 48 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs index 69d6c3a285d..7a61cf6ca32 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -2,17 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; -using VerifyCS = System.Windows.Forms.Analyzers.Tests - .CSharpCodeFixVerifier< - System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization.ControlPropertySerializationDiagnosticAnalyzer, - System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility.AddDesignerSerializationVisibilityCodeFixProvider>; +using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixVerifier< + System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization.ControlPropertySerializationDiagnosticAnalyzer, + System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility.AddDesignerSerializationVisibilityCodeFixProvider, + Microsoft.CodeAnalysis.Testing.DefaultVerifier>; namespace System.Windows.Forms.Analyzers.CSharp.Tests; public class ControlPropertySerializationDiagnosticAnalyzer { private const string ProblematicCode = """ + using System.Drawing; + using System.Windows.Forms; namespace CSharpControls; @@ -28,8 +32,9 @@ public class ScalableControlNoSerializationConfiguration : Control """; private const string CorrectCode = """ - using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; namespace CSharpControls; @@ -48,9 +53,10 @@ public class ScalableControlResolved : Control """; private const string FixedCode = """ - using System.ComponentModel; - + using System.Drawing; + using System.Windows.Forms; + namespace CSharpControls; public class ScalableControlResolved : Control @@ -70,8 +76,18 @@ public class ScalableControlResolved : Control [Fact] public async Task Test_CSharp_AddDesignerSerializationVisibility() { - var expected = VerifyCS.Diagnostic(DiagnosticIDs.ControlPropertySerialization); - await VerifyCS.VerifyAnalyzerAsync(ProblematicCode, expected); + DiagnosticDescriptor diagnostic = new( + DiagnosticIDs.ControlPropertySerialization, + "Control property serialization", + "Control property serialization", + "ControlPropertySerialization", + DiagnosticSeverity.Warning, + isEnabledByDefault: true); + + var expected = VerifyCS.Diagnostic(diagnostic); + var expected1 = expected.WithLocation(new LinePosition(7, 17)); + + await VerifyCS.VerifyAnalyzerAsync(ProblematicCode, expected1, expected, expected); await VerifyCS.VerifyAnalyzerAsync(CorrectCode); await VerifyCS diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index 7d38273f96d..90e5e8f3529 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -13,28 +13,33 @@ namespace System.Windows.Forms.Generators.Tests; public partial class ApplicationConfigurationGeneratorTests { - private const string SourceCompilable = @" -namespace MyProject -{ - class Program - { - static void Main() + private const string SourceCompilable = """ + namespace MyProject { - ApplicationConfiguration.Initialize(); + class Program + { + static void Main() + { + ApplicationConfiguration.Initialize(); + } + } } - } -}"; - private const string SourceCompilationFailed = @" -namespace MyProject -{ - class Program - { - static void Main() + + """; + + private const string SourceCompilationFailed = """ + namespace MyProject { - {|CS0103:ApplicationConfiguration|}.Initialize(); + class Program + { + static void Main() + { + {|CS0103:ApplicationConfiguration|}.Initialize(); + } + } } - } -}"; + + """; public static TheoryData UnsupportedProjectTypes_TestData() { @@ -56,7 +61,6 @@ public static TheoryData UnsupportedProjectTypes_TestData() [MemberData(nameof(UnsupportedProjectTypes_TestData))] public async Task ApplicationConfigurationGenerator_GenerateInitialize_fails_if_project_type_unsupported(OutputKind projectType) { - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = @@ -130,13 +134,15 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett Sources = { SourceCompilable }, AnalyzerConfigFiles = { - ("/.globalconfig", $@"is_global = true - -build_property.{PropertyNameCSharp.DefaultFont} = Microsoft Sans Serif, 8.25px -build_property.{PropertyNameCSharp.EnableVisualStyles} = -build_property.{PropertyNameCSharp.HighDpiMode} = {HighDpiMode.DpiUnawareGdiScaled} -build_property.{PropertyNameCSharp.UseCompatibleTextRendering} = true -"), + ("/.globalconfig", + $""" + is_global = true + + build_property.{PropertyNameCSharp.DefaultFont} = Microsoft Sans Serif, 8.25px + build_property.{PropertyNameCSharp.EnableVisualStyles} = + build_property.{PropertyNameCSharp.HighDpiMode} = {HighDpiMode.DpiUnawareGdiScaled} + build_property.{PropertyNameCSharp.UseCompatibleTextRendering} = true + """), }, GeneratedSources = { @@ -151,9 +157,10 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett [Fact] public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_top_level() { - const string source = @" -ApplicationConfiguration.Initialize(); -"; + const string source = + """ + ApplicationConfiguration.Initialize(); + """; SourceText generatedCode = LoadFileContent("GenerateInitialize_default_top_level"); @@ -176,9 +183,10 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_t [Fact] public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_settings_top_level() { - const string source = @" -ApplicationConfiguration.Initialize(); -"; + const string source = + """ + ApplicationConfiguration.Initialize(); + """; SourceText generatedCode = LoadFileContent("GenerateInitialize_user_top_level"); @@ -190,13 +198,15 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett Sources = { source }, AnalyzerConfigFiles = { - ("/.globalconfig", $@"is_global = true - -build_property.{PropertyNameCSharp.DefaultFont} = Microsoft Sans Serif, 8.25px -build_property.{PropertyNameCSharp.EnableVisualStyles} = -build_property.{PropertyNameCSharp.HighDpiMode} = {HighDpiMode.DpiUnawareGdiScaled} -build_property.{PropertyNameCSharp.UseCompatibleTextRendering} = true -"), + ("/.globalconfig", + $""" + is_global = true + + build_property.{PropertyNameCSharp.DefaultFont} = Microsoft Sans Serif, 8.25px + build_property.{PropertyNameCSharp.EnableVisualStyles} = + build_property.{PropertyNameCSharp.HighDpiMode} = {HighDpiMode.DpiUnawareGdiScaled} + build_property.{PropertyNameCSharp.UseCompatibleTextRendering} = true + """), }, GeneratedSources = { From 6ae7deef0172a73bc701f77d70b8ecfd7d706280 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Mon, 17 Jun 2024 10:43:23 -0700 Subject: [PATCH 17/25] Streamline DiagnosticDescriptor factories. --- .../Analyzers/CSharpDiagnosticDescriptors.cs | 52 ------------------- ...PropertySerializationDiagnosticAnalyzer.cs | 19 +++---- .../CSharpDiagnosticDescriptors.cs | 44 ++++++++++++++++ .../Forms/Analyzers/AppManifestAnalyzer.cs | 6 +-- .../Diagnostics/DiagnosticCategories.cs | 1 + .../Diagnostics/DiagnosticDescriptors.cs | 37 ------------- .../SharedDiagnosticDescriptors.cs | 26 ++++++++++ .../Analyzers/AppManifestAnalyzerTests.cs | 4 +- 8 files changed, 82 insertions(+), 107 deletions(-) delete mode 100644 src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs delete mode 100644 src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs create mode 100644 src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs deleted file mode 100644 index d6a9c132693..00000000000 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/CSharpDiagnosticDescriptors.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Windows.Forms.Analyzers.CSharp.Resources; -using System.Windows.Forms.Analyzers.Diagnostics; -using Microsoft.CodeAnalysis; - -namespace System.Windows.Forms.CSharp.Analyzers; - -internal static class CSharpDiagnosticDescriptors -{ - private const string Category = "ApplicationConfiguration"; - - private static readonly LocalizableString s_localizableWFCA001Title - = new LocalizableResourceString(nameof(SR.WFCA001Title), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFAC001Message - = new LocalizableResourceString(nameof(SR.WFCA001Message), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFCA002Title - = new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFAC002Message - = new LocalizableResourceString(nameof(SR.WFCA002Message), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFAC002MessageWithReason - = new LocalizableResourceString(nameof(SR.WFCA002MessageWithReason), SR.ResourceManager, typeof(SR)); - - public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType - = new(id: DiagnosticIDs.UnsupportedProjectType, - title: s_localizableWFCA001Title, - messageFormat: s_localizableWFAC001Message, - category: Category, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true); - - public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue - = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: s_localizableWFCA002Title, - messageFormat: s_localizableWFAC002Message, - category: Category, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true); - - public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason - = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: s_localizableWFCA002Title, - messageFormat: s_localizableWFAC002MessageWithReason, - category: Category, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true); -} diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs index 46630fe4dd5..02cbed02d6e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs @@ -3,8 +3,7 @@ using System.Collections.Immutable; using System.ComponentModel; -using System.Windows.Forms.Analyzers.CSharp.Resources; -using System.Windows.Forms.Analyzers.Diagnostics; +using System.Windows.Forms.CSharp.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -13,17 +12,8 @@ namespace System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization; [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ControlPropertySerializationDiagnosticAnalyzer : DiagnosticAnalyzer { - private static readonly DiagnosticDescriptor s_rule = new( - id: DiagnosticIDs.ControlPropertySerialization, - title: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerTitle), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), - category: DiagnosticCategories.WinFormsSecurity, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerDescription), SR.ResourceManager, typeof(SR))); - public override ImmutableArray SupportedDiagnostics - => [s_rule]; + => [CSharpDiagnosticDescriptors.MissingControlPropertySerializationConfiguration]; public override void Initialize(AnalysisContext context) { @@ -79,7 +69,10 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) || shouldSerializeMethod.Parameters.Length > 0) { // For ALL such other symbols, produce a diagnostic. - var diagnostic = Diagnostic.Create(s_rule, propertySymbol.Locations[0], propertySymbol.Name); + var diagnostic = Diagnostic.Create( + descriptor: CSharpDiagnosticDescriptors.MissingControlPropertySerializationConfiguration, + location: propertySymbol.Locations[0], + messageArgs: propertySymbol.Name); context.ReportDiagnostic(diagnostic); } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs new file mode 100644 index 00000000000..3f6739d0748 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Windows.Forms.Analyzers.CSharp.Resources; +using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis; + +namespace System.Windows.Forms.CSharp.Analyzers.Diagnostics; + +internal static class CSharpDiagnosticDescriptors +{ + public static DiagnosticDescriptor ErrorUnsupportedProjectType { get; } = + new(id: DiagnosticIDs.UnsupportedProjectType, + title: new LocalizableResourceString(nameof(SR.WFCA001Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA001Message), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.ApplicationConfiguration, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static DiagnosticDescriptor PropertyCantBeSetToValue { get; } = + new(id: DiagnosticIDs.PropertyCantBeSetToValue, + title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA002Message), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.ApplicationConfiguration, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static DiagnosticDescriptor PropertyCantBeSetToValueWithReason { get; } = + new(id: DiagnosticIDs.PropertyCantBeSetToValue, + title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA002MessageWithReason), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.ApplicationConfiguration, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static DiagnosticDescriptor MissingControlPropertySerializationConfiguration { get; } = + new(id: DiagnosticIDs.ControlPropertySerialization, + title: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerTitle), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.WinFormsSecurity, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerDescription), SR.ResourceManager, typeof(SR))); +} diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs index 08979134f64..834d10b091b 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs @@ -14,7 +14,7 @@ namespace System.Windows.Forms.Analyzers; internal partial class AppManifestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray SupportedDiagnostics - => [DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, DiagnosticDescriptors.s_migrateHighDpiSettings_VB]; + => [SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings, SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings]; public override void Initialize(AnalysisContext context) { @@ -63,14 +63,14 @@ private static void VerifyAppManifest(AdditionalFileAnalysisContext context, Add switch (context.Compilation.Language) { case LanguageNames.CSharp: - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp, + context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings, Location.None, appManifest.Path, ApplicationConfig.PropertyNameCSharp.HighDpiMode)); break; case LanguageNames.VisualBasic: - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.s_migrateHighDpiSettings_VB, + context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings, Location.None, appManifest.Path, ApplicationConfig.PropertyNameVisualBasic.HighDpiMode)); diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs index 55128aaa978..50753ac0540 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticCategories.cs @@ -5,6 +5,7 @@ namespace System.Windows.Forms.Analyzers.Diagnostics; internal static class DiagnosticCategories { + public const string ApplicationConfiguration = "Application Configuration"; public const string WinFormsSecurity = "WinForms Security"; public const string WinFormsUsage = "WinForms Usage"; } diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs deleted file mode 100644 index 7cb512473df..00000000000 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticDescriptors.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Windows.Forms.Analyzers.Resources; -using Microsoft.CodeAnalysis; - -namespace System.Windows.Forms.Analyzers.Diagnostics; - -internal static partial class DiagnosticDescriptors -{ - private const string Category = "ApplicationConfiguration"; - - private static readonly LocalizableString s_localizableWFCA010Title - = new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFCA010Message_CS - = new LocalizableResourceString(nameof(SR.WFCA010Message_CS), SR.ResourceManager, typeof(SR)); - - private static readonly LocalizableString s_localizableWFCA010Message_VB - = new LocalizableResourceString(nameof(SR.WFCA010Message_VB), SR.ResourceManager, typeof(SR)); - - internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_CSharp - = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: s_localizableWFCA010Title, - messageFormat: s_localizableWFCA010Message_CS, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true); - - internal static readonly DiagnosticDescriptor s_migrateHighDpiSettings_VB - = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: s_localizableWFCA010Title, - messageFormat: s_localizableWFCA010Message_VB, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: true); -} diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs new file mode 100644 index 00000000000..4e2ee28add0 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Windows.Forms.Analyzers.Resources; +using Microsoft.CodeAnalysis; + +namespace System.Windows.Forms.Analyzers.Diagnostics; + +internal static partial class SharedDiagnosticDescriptors +{ + internal static DiagnosticDescriptor CSharpMigrateHighDpiSettings { get; } = + new(id: DiagnosticIDs.MigrateHighDpiSettings, + title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_CS), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.ApplicationConfiguration, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true); + + internal static DiagnosticDescriptor VisualBasicMigrateHighDpiSettings { get; } = + new(id: DiagnosticIDs.MigrateHighDpiSettings, + title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_VB), SR.ResourceManager, typeof(SR)), + category: DiagnosticCategories.ApplicationConfiguration, + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: true); +} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index f802d7cbdab..88533e3972b 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -84,7 +84,7 @@ public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_CSharp( }, ExpectedDiagnostics = { - new DiagnosticResult(DiagnosticDescriptors.s_migrateHighDpiSettings_CSharp) + new DiagnosticResult(SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings) .WithArguments(manifestFilePath, ApplicationConfig.PropertyNameCSharp.HighDpiMode) } }.RunAsync(); @@ -104,7 +104,7 @@ public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_VB() }, ExpectedDiagnostics = { - new DiagnosticResult(DiagnosticDescriptors.s_migrateHighDpiSettings_VB) + new DiagnosticResult(SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings) .WithArguments(manifestFilePath, ApplicationConfig.PropertyNameVisualBasic.HighDpiMode) } }.RunAsync(); From 942527987395627767e6ff76b0400a2d7c91059a Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 18 Jun 2024 01:06:44 -0700 Subject: [PATCH 18/25] Refactor identifier names, namespaces, analyzer tests. --- .../src/AnalyzerReleases.Unshipped.md | 8 +- .../CSharpDiagnosticDescriptors.cs | 10 +- ...ertySerializationConfigurationAnalyzer.cs} | 8 +- .../ApplicationConfigurationGenerator.cs | 2 +- .../ProjectFileReader.cs | 9 +- ...ertySerializationDiagnosticAnalyzerTest.cs | 96 ----------- ...ertySerializationDiagnosticAnalyzerTest.cs | 160 ++++++++++++++++++ .../Generators/ProjectFileReaderTests.cs | 2 +- ...rSerializationVisibilityCodeFixProvider.cs | 2 +- ...rSerializationVisibilityCodeFixProvider.vb | 2 +- .../GlobalSuppressions.vb | 7 +- ...izationConfigurationDiagnosticAnalyzer.vb} | 6 +- .../Analyzers/Diagnostics/DiagnosticIDs.cs | 2 +- 13 files changed, 192 insertions(+), 122 deletions(-) rename src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/{ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs => MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs} (88%) delete mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs rename src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/{ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb => MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb} (94%) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md index e68e80094e5..344e44977c5 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md @@ -5,13 +5,13 @@ Rule ID | Category | Severity | Notes --------|----------|----------|-------------------- -WFAC001 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) -WFAC002 | ApplicationConfiguration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) +WFAC001 | Application Configuration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) +WFAC002 | Application Configuration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) ### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFCA001 | ApplicationConfiguration | Error | CSharpDiagnosticDescriptors -WFCA002 | ApplicationConfiguration | Error | CSharpDiagnosticDescriptors +WFCA001 | Application Configuration | Error | CSharpDiagnosticDescriptors +WFCA002 | Application Configuration | Error | CSharpDiagnosticDescriptors WFCA100 | WinForms Security | Error | ControlPropertySerializationDiagnosticAnalyzer diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs index 3f6739d0748..d8a143d718b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs @@ -9,7 +9,7 @@ namespace System.Windows.Forms.CSharp.Analyzers.Diagnostics; internal static class CSharpDiagnosticDescriptors { - public static DiagnosticDescriptor ErrorUnsupportedProjectType { get; } = + public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType = new(id: DiagnosticIDs.UnsupportedProjectType, title: new LocalizableResourceString(nameof(SR.WFCA001Title), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA001Message), SR.ResourceManager, typeof(SR)), @@ -17,7 +17,7 @@ internal static class CSharpDiagnosticDescriptors defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); - public static DiagnosticDescriptor PropertyCantBeSetToValue { get; } = + public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue = new(id: DiagnosticIDs.PropertyCantBeSetToValue, title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA002Message), SR.ResourceManager, typeof(SR)), @@ -25,7 +25,7 @@ internal static class CSharpDiagnosticDescriptors defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); - public static DiagnosticDescriptor PropertyCantBeSetToValueWithReason { get; } = + public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason = new(id: DiagnosticIDs.PropertyCantBeSetToValue, title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA002MessageWithReason), SR.ResourceManager, typeof(SR)), @@ -33,8 +33,8 @@ internal static class CSharpDiagnosticDescriptors defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); - public static DiagnosticDescriptor MissingControlPropertySerializationConfiguration { get; } = - new(id: DiagnosticIDs.ControlPropertySerialization, + public static readonly DiagnosticDescriptor s_missingPropertySerializationConfiguration = + new(id: DiagnosticIDs.MissingPropertySerializationConfiguration, title: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerTitle), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.WinFormsSecurity, diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs similarity index 88% rename from src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs rename to src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs index 02cbed02d6e..6fdf207a16a 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs @@ -7,13 +7,13 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -namespace System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization; +namespace System.Windows.Forms.CSharp.Analyzers.MissingPropertySerializationConfiguration; [DiagnosticAnalyzer(LanguageNames.CSharp)] -public class ControlPropertySerializationDiagnosticAnalyzer : DiagnosticAnalyzer +public class MissingPropertySerializationConfigurationAnalyzer : DiagnosticAnalyzer { public override ImmutableArray SupportedDiagnostics - => [CSharpDiagnosticDescriptors.MissingControlPropertySerializationConfiguration]; + => [CSharpDiagnosticDescriptors.s_missingPropertySerializationConfiguration]; public override void Initialize(AnalysisContext context) { @@ -70,7 +70,7 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) { // For ALL such other symbols, produce a diagnostic. var diagnostic = Diagnostic.Create( - descriptor: CSharpDiagnosticDescriptors.MissingControlPropertySerializationConfiguration, + descriptor: CSharpDiagnosticDescriptors.s_missingPropertySerializationConfiguration, location: propertySymbol.Locations[0], messageArgs: propertySymbol.Name); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs index 02d26ec5d53..296a564d63b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; -using System.Windows.Forms.CSharp.Analyzers; +using System.Windows.Forms.CSharp.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs index 43822ab43be..8e60cdcbced 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ProjectFileReader.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers; -using System.Windows.Forms.CSharp.Analyzers; +using System.Windows.Forms.CSharp.Analyzers.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using static System.Windows.Forms.Analyzers.ApplicationConfig; @@ -51,9 +51,10 @@ private static bool TryReadBool(AnalyzerConfigOptionsProvider configOptions, str if (!bool.TryParse(rawValue, out value)) { diagnostic = Diagnostic.Create(CSharpDiagnosticDescriptors.s_propertyCantBeSetToValue, - Location.None, - propertyName, - rawValue); + Location.None, + propertyName, + rawValue); + value = defaultValue; return false; } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs deleted file mode 100644 index 7a61cf6ca32..00000000000 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/ControlPropertySerializationDiagnosticAnalyzerTest/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Windows.Forms.Analyzers.Diagnostics; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; - -using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixVerifier< - System.Windows.Forms.CSharp.Analyzers.ControlPropertySerialization.ControlPropertySerializationDiagnosticAnalyzer, - System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility.AddDesignerSerializationVisibilityCodeFixProvider, - Microsoft.CodeAnalysis.Testing.DefaultVerifier>; - -namespace System.Windows.Forms.Analyzers.CSharp.Tests; - -public class ControlPropertySerializationDiagnosticAnalyzer -{ - private const string ProblematicCode = """ - using System.Drawing; - using System.Windows.Forms; - - namespace CSharpControls; - - public class ScalableControlNoSerializationConfiguration : Control - { - public float ScaleFactor { get; set; } = 1.0f; - - public SizeF ScaledSize { get; set; } - - public PointF ScaledLocation { get; set; } - } - - """; - - private const string CorrectCode = """ - using System.ComponentModel; - using System.Drawing; - using System.Windows.Forms; - - namespace CSharpControls; - - public class ScalableControlResolved : Control - { - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public float ScaleFactor { get; set; } = 1.0f; - - [DefaultValue(typeof(SizeF), "0,0")] - public SizeF ScaledSize { get; set; } - - public PointF ScaledLocation { get; set; } - private bool ShouldSerializeScaledSize() => this.ScaledSize != SizeF.Empty; - } - - """; - - private const string FixedCode = """ - using System.ComponentModel; - using System.Drawing; - using System.Windows.Forms; - - namespace CSharpControls; - - public class ScalableControlResolved : Control - { - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public float ScaleFactor { get; set; } = 1.0f; - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public SizeF ScaledSize { get; set; } - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public PointF ScaledLocation { get; set; } - } - - """; - - [Fact] - public async Task Test_CSharp_AddDesignerSerializationVisibility() - { - DiagnosticDescriptor diagnostic = new( - DiagnosticIDs.ControlPropertySerialization, - "Control property serialization", - "Control property serialization", - "ControlPropertySerialization", - DiagnosticSeverity.Warning, - isEnabledByDefault: true); - - var expected = VerifyCS.Diagnostic(diagnostic); - var expected1 = expected.WithLocation(new LinePosition(7, 17)); - - await VerifyCS.VerifyAnalyzerAsync(ProblematicCode, expected1, expected, expected); - await VerifyCS.VerifyAnalyzerAsync(CorrectCode); - - await VerifyCS - .VerifyCodeFixAsync(ProblematicCode, expected, FixedCode); - } -} diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs new file mode 100644 index 00000000000..10b9a02eea9 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -0,0 +1,160 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Windows.Forms.CSharp.Analyzers.MissingPropertySerializationConfiguration; +using System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; + +namespace System.Windows.Forms.Analyzers.MissingControlPropertySerializationConfiguration; + +public class ControlPropertySerializationDiagnosticAnalyzerTest +{ + private const string ProblematicCode = """ + using System.Drawing; + using System.Windows.Forms; + + namespace CSharpControls; + + public static class Program + { + public static void Main() + { + var control = new ScalableControlNoSerializationConfiguration(); + + control.ScaleFactor = 1.5f; + control.ScaledSize = new SizeF(100, 100); + control.ScaledLocation = new PointF(10, 10); + } + } + + public class ScalableControlNoSerializationConfiguration : Control + { + public float [|ScaleFactor|] { get; set; } = 1.0f; + + public SizeF [|ScaledSize|] { get; set; } + + public PointF [|ScaledLocation|] { get; set; } + } + + """; + + private const string CorrectCode = """ + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + namespace CSharpControls; + + public static class Program + { + public static void Main() + { + var control = new ScalableControlNoSerializationConfiguration(); + + control.ScaleFactor = 1.5f; + control.ScaledSize = new SizeF(100, 100); + control.ScaledLocation = new PointF(10, 10); + } + } + + public class ScalableControlResolved : Control + { + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public float ScaleFactor { get; set; } = 1.0f; + + [DefaultValue(typeof(SizeF), "0,0")] + public SizeF ScaledSize { get; set; } + + public PointF ScaledLocation { get; set; } + private bool ShouldSerializeScaledSize() => this.ScaledSize != SizeF.Empty; + } + + """; + + private const string FixedCode = """ + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + namespace CSharpControls; + + public static class Program + { + public static void Main() + { + var control = new ScalableControlNoSerializationConfiguration(); + + control.ScaleFactor = 1.5f; + control.ScaledSize = new SizeF(100, 100); + control.ScaledLocation = new PointF(10, 10); + } + } + + public class ScalableControlResolved : Control + { + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public float ScaleFactor { get; set; } = 1.0f; + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public SizeF ScaledSize { get; set; } + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public PointF ScaledLocation { get; set; } + } + + """; + + // We are testing the analyzer with all versions of the .NET SDK from 6.0 on. + public static IEnumerable GetReferenceAssemblies() + { + yield return [ReferenceAssemblies.Net.Net60Windows]; + yield return [ReferenceAssemblies.Net.Net70Windows]; + yield return [ReferenceAssemblies.Net.Net80Windows]; + yield return [ReferenceAssemblies.Net.Net90Windows]; + } + + [Theory] + [MemberData(nameof(GetReferenceAssemblies))] + public async Task CS_MissingControlPropertySerializationConfigurationAnalyzer(ReferenceAssemblies referenceAssemblies) + { + var context = new CSharpAnalyzerTest + + { + TestCode = ProblematicCode, + TestState = + { + OutputKind = OutputKind.WindowsApplication, + }, + ReferenceAssemblies = referenceAssemblies + }; + + await context.RunAsync(); + + context.TestCode = CorrectCode; + await context.RunAsync(); + } + + [Theory] + [MemberData(nameof(GetReferenceAssemblies))] + public async Task CS_AddDesignerSerializationVisibilityCodeFix(ReferenceAssemblies referenceAssemblies) + { + var context = new CSharpCodeFixTest + + { + TestCode = ProblematicCode, + FixedCode = FixedCode, + TestState = + { + OutputKind = OutputKind.WindowsApplication, + }, + ReferenceAssemblies = referenceAssemblies + }; + + await context.RunAsync(); + } +} diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs index 60a852be5ca..4d1827d28b2 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs @@ -5,7 +5,7 @@ using System.Globalization; using System.Windows.Forms.Analyzers; using System.Windows.Forms.Analyzers.Tests; -using System.Windows.Forms.CSharp.Analyzers; +using System.Windows.Forms.CSharp.Analyzers.Diagnostics; using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index c8c6244e32f..2859e77b663 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -20,7 +20,7 @@ internal sealed class AddDesignerSerializationVisibilityCodeFixProvider : CodeFi private const string SystemComponentModelName = "System.ComponentModel"; public sealed override ImmutableArray FixableDiagnosticIds - => [DiagnosticIDs.ControlPropertySerialization]; + => [DiagnosticIDs.MissingPropertySerializationConfiguration]; public sealed override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer; diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb index 3c22f924d25..d6212350210 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb @@ -26,7 +26,7 @@ Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializa Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String) Get - Return ImmutableArray.Create(DiagnosticIDs.ControlPropertySerialization) + Return ImmutableArray.Create(DiagnosticIDs.MissingPropertySerializationConfiguration) End Get End Property diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb index 7f2bb2317a5..2277f412da7 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb @@ -5,4 +5,9 @@ Imports System.Diagnostics.CodeAnalysis - + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb similarity index 94% rename from src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb rename to src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb index b4dca61113f..1a8aea2d4d0 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/ControlPropertySerialization/ControlPropertySerializationDiagnosticAnalyzer.vb +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb @@ -13,14 +13,14 @@ Imports Microsoft.CodeAnalysis.Diagnostics ' (VB is not case-sensitive, so we can't have the same names in a code file, even if the casing is different.) Imports VBDiagnostic = Microsoft.CodeAnalysis.Diagnostic -Namespace System.Windows.Forms.VisualBasic.Analyzers.ControlPropertySerialization +Namespace System.Windows.Forms.VisualBasic.Analyzers.MissingPropertySerializationConfiguration - Public Class ControlPropertySerializationDiagnosticAnalyzer + Public Class MissingPropertySerializationConfigurationDiagnosticAnalyzer Inherits DiagnosticAnalyzer Private Shared ReadOnly s_rule As New DiagnosticDescriptor( - id:=DiagnosticIDs.ControlPropertySerialization, + id:=DiagnosticIDs.MissingPropertySerializationConfiguration, title:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerTitle), SR.ResourceManager, GetType(SR)), messageFormat:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), category:=DiagnosticCategories.WinFormsSecurity, diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs index be5b3c1a354..4ac22da3f01 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -11,7 +11,7 @@ internal static class DiagnosticIDs public const string MigrateHighDpiSettings = "WFCA010"; // Security - public const string ControlPropertySerialization = "WFCA100"; + public const string MissingPropertySerializationConfiguration = "WFCA100"; // WinForms Usage public const string DisposeModalDialog = "WFCA500"; From 1d830ccc675edf851024c7d136087319c4c89545 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 18 Jun 2024 01:50:02 -0700 Subject: [PATCH 19/25] Fix Analyzer tests. --- ...ertySerializationDiagnosticAnalyzerTest.cs | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs index 10b9a02eea9..159cc8a1b35 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -21,7 +21,7 @@ public static class Program { public static void Main() { - var control = new ScalableControlNoSerializationConfiguration(); + var control = new ScalableControl(); control.ScaleFactor = 1.5f; control.ScaledSize = new SizeF(100, 100); @@ -29,7 +29,7 @@ public static void Main() } } - public class ScalableControlNoSerializationConfiguration : Control + public class ScalableControl : Control { public float [|ScaleFactor|] { get; set; } = 1.0f; @@ -51,7 +51,7 @@ public static class Program { public static void Main() { - var control = new ScalableControlNoSerializationConfiguration(); + var control = new ScalableControl(); control.ScaleFactor = 1.5f; control.ScaledSize = new SizeF(100, 100); @@ -59,7 +59,7 @@ public static void Main() } } - public class ScalableControlResolved : Control + public class ScalableControl : Control { [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public float ScaleFactor { get; set; } = 1.0f; @@ -68,7 +68,7 @@ public class ScalableControlResolved : Control public SizeF ScaledSize { get; set; } public PointF ScaledLocation { get; set; } - private bool ShouldSerializeScaledSize() => this.ScaledSize != SizeF.Empty; + private bool ShouldSerializeScaledLocation() => this.ScaledLocation != PointF.Empty; } """; @@ -84,7 +84,7 @@ public static class Program { public static void Main() { - var control = new ScalableControlNoSerializationConfiguration(); + var control = new ScalableControl(); control.ScaleFactor = 1.5f; control.ScaledSize = new SizeF(100, 100); @@ -92,7 +92,7 @@ public static void Main() } } - public class ScalableControlResolved : Control + public class ScalableControl : Control { [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public float ScaleFactor { get; set; } = 1.0f; @@ -117,13 +117,13 @@ public static IEnumerable GetReferenceAssemblies() [Theory] [MemberData(nameof(GetReferenceAssemblies))] - public async Task CS_MissingControlPropertySerializationConfigurationAnalyzer(ReferenceAssemblies referenceAssemblies) + public async Task CS_ControlPropertySerializationConfigurationAnalyzer(ReferenceAssemblies referenceAssemblies) { var context = new CSharpAnalyzerTest { - TestCode = ProblematicCode, + TestCode = CorrectCode, TestState = { OutputKind = OutputKind.WindowsApplication, @@ -132,8 +132,24 @@ public async Task CS_MissingControlPropertySerializationConfigurationAnalyzer(Re }; await context.RunAsync(); + } + + [Theory] + [MemberData(nameof(GetReferenceAssemblies))] + public async Task CS_MissingControlPropertySerializationConfigurationAnalyzer(ReferenceAssemblies referenceAssemblies) + { + var context = new CSharpAnalyzerTest + + { + TestCode = ProblematicCode, + TestState = + { + OutputKind = OutputKind.WindowsApplication, + }, + ReferenceAssemblies = referenceAssemblies + }; - context.TestCode = CorrectCode; await context.RunAsync(); } From f1e3ae6b7d6eda593e3d0528014be4bb0dc1bfd6 Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 18 Jun 2024 18:26:14 -0700 Subject: [PATCH 20/25] Fix issue with iteration numbers in CodeFix with multiple similar diagnostics. --- ...ertySerializationDiagnosticAnalyzerTest.cs | 37 ++++++++++------- ...rSerializationVisibilityCodeFixProvider.cs | 40 +++++++++++++++---- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs index 159cc8a1b35..faea564eb18 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -23,13 +23,16 @@ public static void Main() { var control = new ScalableControl(); - control.ScaleFactor = 1.5f; - control.ScaledSize = new SizeF(100, 100); - control.ScaledLocation = new PointF(10, 10); + // We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5f; + control.ScaledSize = new SizeF(100, 100); + control.ScaledLocation = new PointF(10, 10); } } - public class ScalableControl : Control + // We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + // since this is nothing our code fix touches. + public class ScalableControl : System.Windows.Forms.Control { public float [|ScaleFactor|] { get; set; } = 1.0f; @@ -77,7 +80,7 @@ public class ScalableControl : Control using System.ComponentModel; using System.Drawing; using System.Windows.Forms; - + namespace CSharpControls; public static class Program @@ -85,14 +88,17 @@ public static class Program public static void Main() { var control = new ScalableControl(); - - control.ScaleFactor = 1.5f; - control.ScaledSize = new SizeF(100, 100); - control.ScaledLocation = new PointF(10, 10); + + // We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5f; + control.ScaledSize = new SizeF(100, 100); + control.ScaledLocation = new PointF(10, 10); } } - - public class ScalableControl : Control + + // We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + // since this is nothing our code fix touches. + public class ScalableControl : System.Windows.Forms.Control { [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public float ScaleFactor { get; set; } = 1.0f; @@ -109,9 +115,9 @@ public class ScalableControl : Control // We are testing the analyzer with all versions of the .NET SDK from 6.0 on. public static IEnumerable GetReferenceAssemblies() { - yield return [ReferenceAssemblies.Net.Net60Windows]; - yield return [ReferenceAssemblies.Net.Net70Windows]; - yield return [ReferenceAssemblies.Net.Net80Windows]; + // yield return [ReferenceAssemblies.Net.Net60Windows]; + // yield return [ReferenceAssemblies.Net.Net70Windows]; + // yield return [ReferenceAssemblies.Net.Net80Windows]; yield return [ReferenceAssemblies.Net.Net90Windows]; } @@ -168,7 +174,8 @@ public async Task CS_AddDesignerSerializationVisibilityCodeFix(ReferenceAssembli { OutputKind = OutputKind.WindowsApplication, }, - ReferenceAssemblies = referenceAssemblies + ReferenceAssemblies = referenceAssemblies, + NumberOfFixAllIterations = 2 }; await context.RunAsync(); diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index 2859e77b663..6643c562821 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -11,6 +11,9 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; +using System.Diagnostics; +using Microsoft.CodeAnalysis.Simplification; +using Microsoft.CodeAnalysis.Formatting; namespace System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibility; @@ -18,6 +21,7 @@ namespace System.Windows.Forms.CSharp.CodeFixes.AddDesignerSerializationVisibili internal sealed class AddDesignerSerializationVisibilityCodeFixProvider : CodeFixProvider { private const string SystemComponentModelName = "System.ComponentModel"; + private const string DesignerSerializationVisibilityAttributeName = "DesignerSerializationVisibility"; public sealed override ImmutableArray FixableDiagnosticIds => [DiagnosticIDs.MissingPropertySerializationConfiguration]; @@ -62,9 +66,19 @@ private static async Task AddDesignerSerializationAttribute( return document; } + // Let's make sure, the attribute we want to add is not already there: + if (propertyDeclarationSyntax.AttributeLists + .SelectMany(al => al.Attributes) + .Any(a => a.Name.ToString() == DesignerSerializationVisibilityAttributeName)) + { + Debug.Assert(false, "The attribute should not be there."); + + return document; + } + // Generate the Attribute we need to put on the property AttributeSyntax designerSerializationVisibilityAttribute = SyntaxFactory.Attribute( - SyntaxFactory.ParseName("DesignerSerializationVisibility"), + SyntaxFactory.ParseName(DesignerSerializationVisibilityAttributeName), SyntaxFactory.ParseAttributeArgumentList("(DesignerSerializationVisibility.Hidden)")); // Make sure, we keep the white spaces before and after the property @@ -77,31 +91,41 @@ private static async Task AddDesignerSerializationAttribute( SyntaxFactory.AttributeList( SyntaxFactory.SingletonSeparatedList(designerSerializationVisibilityAttribute))); - // Let's restore the trivia: + // Let's format the property, so the attribute is on top of it: + newProperty = newProperty.NormalizeWhitespace(); + + // Let's restore the original trivia: newProperty = newProperty.WithLeadingTrivia(leadingTrivia); newProperty = newProperty.WithTrailingTrivia(trailingTrivia); - - UsingDirectiveSyntax usingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(SystemComponentModelName)); + newProperty = newProperty.WithAdditionalAnnotations(Formatter.Annotation); // Let's check, if we already have the using directive or if we need to add it: // (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) SyntaxNode root = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false))!; + // Produce a new root, which has the updated property with the attribute. + root = root.ReplaceNode(propertyDeclarationSyntax, newProperty); + // Let's check if we already have the using directive: if (!root.DescendantNodes() .OfType() .Any(u => u?.Name?.ToString() == SystemComponentModelName)) { + UsingDirectiveSyntax usingDirective = SyntaxFactory + .UsingDirective(SyntaxFactory.ParseName(SystemComponentModelName)); + + usingDirective = usingDirective + .WithAdditionalAnnotations(Simplifier.Annotation) + .WithAdditionalAnnotations(Formatter.Annotation); + // We need to add the using directive: SyntaxNode firstNode = root.DescendantNodes().First(); root = root.InsertNodesBefore(firstNode, [usingDirective]); } - // Produce a new root: - SyntaxNode originalRoot = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false))!; - SyntaxNode newRoot = originalRoot.ReplaceNode(propertyDeclarationSyntax, newProperty); + document = document.WithSyntaxRoot(root); // Generate the new document: - return document.WithSyntaxRoot(newRoot); + return document; } } From 992c3678a976a5b8ff7fa6f9b16724730e02403d Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 18 Jun 2024 23:27:30 -0700 Subject: [PATCH 21/25] Eliminate legacy verifiers. --- .../tests/UnitTests/GlobalSuppressions.cs | 9 ++ ...indows.Forms.Analyzers.CSharp.Tests.csproj | 4 - ...ertySerializationDiagnosticAnalyzerTest.cs | 2 +- ...SharpIncrementalSourceGeneratorVerifier.cs | 2 +- .../Verifiers/CSharpSourceGeneratorTest`1.cs | 5 +- .../Verifiers/CSharpVerifierHelper.cs | 2 +- .../ApplicationConfigurationGeneratorTests.cs | 34 +++--- .../src/AnalyzerReleases.Unshipped.md | 4 +- .../Forms/Analyzers/AppManifestAnalyzer.cs | 6 +- .../SharedDiagnosticDescriptors.cs | 4 +- .../Analyzers/AppManifestAnalyzerTests.cs | 101 ++++++++++-------- .../ApplicationConfigTests.FontDescriptor.cs | 26 ++++- .../CSharpAnalyzerVerifier`1+Test.cs | 32 ------ .../Verifiers/CSharpAnalyzerVerifier`1.cs | 38 ------- .../Verifiers/CSharpCodeFixVerifier`2+Test.cs | 34 ------ .../Verifiers/CSharpCodeFixVerifier`2.cs | 61 ----------- .../CSharpCodeRefactoringVerifier`1+Test.cs | 32 ------ .../CSharpCodeRefactoringVerifier`1.cs | 36 ------- .../VisualBasicAnalyzerVerifier`1+Test.cs | 21 ---- .../VisualBasicAnalyzerVerifier`1.cs | 38 ------- .../VisualBasicCodeFixVerifier`2+Test.cs | 18 ---- .../Verifiers/VisualBasicCodeFixVerifier`2.cs | 61 ----------- ...sualBasicCodeRefactoringVerifier`1+Test.cs | 16 --- .../VisualBasicCodeRefactoringVerifier`1.cs | 36 ------- 24 files changed, 118 insertions(+), 504 deletions(-) create mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs rename src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/{MissingControlPropertySerializationConfiguration => MissingPropertySerializationConfiguration}/ControlPropertySerializationDiagnosticAnalyzerTest.cs (98%) rename src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/{ => System/Windows/Forms/Analyzers}/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs (96%) rename src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/{ => System/Windows/Forms/Analyzers}/Verifiers/CSharpSourceGeneratorTest`1.cs (74%) rename src/{System.Windows.Forms.Analyzers/tests/UnitTests => System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers}/Verifiers/CSharpVerifierHelper.cs (96%) delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs delete mode 100644 src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs new file mode 100644 index 00000000000..37aa1514430 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs @@ -0,0 +1,9 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "", Scope = "namespace", Target = "~N:System.Windows.Forms.Analyzers.MissingPropertySerializationConfiguration")] +[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "", Scope = "namespace", Target = "~N:System.Windows.Forms.Generators")] diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj index 67dc85ab087..103ea05e9d6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System.Windows.Forms.Analyzers.CSharp.Tests.csproj @@ -34,8 +34,4 @@ - - - - diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs similarity index 98% rename from src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs rename to src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs index faea564eb18..51adcecb773 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingControlPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Testing; -namespace System.Windows.Forms.Analyzers.MissingControlPropertySerializationConfiguration; +namespace System.Windows.Forms.Analyzers.MissingPropertySerializationConfiguration; public class ControlPropertySerializationDiagnosticAnalyzerTest { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs similarity index 96% rename from src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs rename to src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs index 1a2759f1c8d..6a4bf3f4994 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; -namespace System.Windows.Forms.Analyzers.Tests; +namespace System.Windows.Forms.Analyzers.Verifiers; // Note: this is bleeding edge, eventually this can be removed once it is all baked in to Roslyn SDK. public static partial class CSharpIncrementalSourceGeneratorVerifier diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs similarity index 74% rename from src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs rename to src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs index 7d1fbe564b6..8acec42f1f4 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs @@ -6,9 +6,10 @@ using Microsoft.CodeAnalysis.Testing.Verifiers; using static Microsoft.CodeAnalysis.Testing.ReferenceAssemblies; -namespace System.Windows.Forms.Analyzers.Tests; +namespace System.Windows.Forms.Analyzers.Verifiers; -public class CSharpSourceGeneratorTest : CSharpSourceGeneratorTest +public class CSharpSourceGeneratorTest + : CSharpSourceGeneratorTest where TSourceGenerator : ISourceGenerator, new() { public CSharpSourceGeneratorTest() diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs similarity index 96% rename from src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs rename to src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs index ed83b9308ea..e90d3bf03f2 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using System.Collections.Immutable; -namespace System.Windows.Forms.Analyzers.Tests; +namespace System.Windows.Forms.Analyzers.Verifiers; internal static class CSharpVerifierHelper { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index 90e5e8f3529..4ffa0e01e1d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Text; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators.Tests; +namespace System.Windows.Forms.Generators; public partial class ApplicationConfigurationGeneratorTests { @@ -59,9 +59,9 @@ public static TheoryData UnsupportedProjectTypes_TestData() [Theory] [MemberData(nameof(UnsupportedProjectTypes_TestData))] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_fails_if_project_type_unsupported(OutputKind projectType) + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_fails_if_project_type_unsupported(OutputKind projectType) { - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -80,11 +80,11 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_fails_if_ [Theory] [InlineData(OutputKind.ConsoleApplication)] [InlineData(OutputKind.WindowsApplication)] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_pass_if_supported_project_type(OutputKind projectType) + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_pass_if_supported_project_type(OutputKind projectType) { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -101,11 +101,11 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_pass_if_s } [Fact] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_boilerplate() + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_default_boilerplate() { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -122,11 +122,11 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_b } [Fact] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_settings_boilerplate() + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_user_settings_boilerplate() { SourceText generatedCode = LoadFileContent("GenerateInitialize_user_settings_boilerplate"); - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -155,7 +155,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett } [Fact] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_top_level() + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_default_top_level() { const string source = """ @@ -164,7 +164,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_t SourceText generatedCode = LoadFileContent("GenerateInitialize_default_top_level"); - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -181,7 +181,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_default_t } [Fact] - public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_settings_top_level() + public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_user_settings_top_level() { const string source = """ @@ -190,7 +190,7 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett SourceText generatedCode = LoadFileContent("GenerateInitialize_user_top_level"); - var test = new Analyzers.Tests.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -218,8 +218,8 @@ public async Task ApplicationConfigurationGenerator_GenerateInitialize_user_sett await test.RunAsync(); } - private SourceText LoadFileContent(string testName) - => SourceText.From( - File.ReadAllText($@"System\Windows\Forms\Generators\MockData\{GetType().Name}.{testName}.cs"), - Encoding.UTF8); + private SourceText LoadFileContent(string testName) => + SourceText.From( + File.ReadAllText($@"System\Windows\Forms\Generators\MockData\{GetType().Name}.{testName}.cs"), + Encoding.UTF8); } diff --git a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md index bc04bfcac5a..db72596d24b 100644 --- a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md @@ -5,10 +5,10 @@ Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFAC010 | ApplicationConfiguration | Warning | DiagnosticDescriptors +WFAC010 | Application Configuration | Warning | DiagnosticDescriptors ### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFCA010 | ApplicationConfiguration | Warning | DiagnosticDescriptors +WFCA010 | Application Configuration | Warning | DiagnosticDescriptors diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs index 834d10b091b..33c98037dd2 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/AppManifestAnalyzer.cs @@ -14,7 +14,7 @@ namespace System.Windows.Forms.Analyzers; internal partial class AppManifestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray SupportedDiagnostics - => [SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings, SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings]; + => [SharedDiagnosticDescriptors.s_cSharpMigrateHighDpiSettings, SharedDiagnosticDescriptors.s_visualBasicMigrateHighDpiSettings]; public override void Initialize(AnalysisContext context) { @@ -63,14 +63,14 @@ private static void VerifyAppManifest(AdditionalFileAnalysisContext context, Add switch (context.Compilation.Language) { case LanguageNames.CSharp: - context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings, + context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.s_cSharpMigrateHighDpiSettings, Location.None, appManifest.Path, ApplicationConfig.PropertyNameCSharp.HighDpiMode)); break; case LanguageNames.VisualBasic: - context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings, + context.ReportDiagnostic(Diagnostic.Create(SharedDiagnosticDescriptors.s_visualBasicMigrateHighDpiSettings, Location.None, appManifest.Path, ApplicationConfig.PropertyNameVisualBasic.HighDpiMode)); diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs index 4e2ee28add0..e622d570bfe 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs @@ -8,7 +8,7 @@ namespace System.Windows.Forms.Analyzers.Diagnostics; internal static partial class SharedDiagnosticDescriptors { - internal static DiagnosticDescriptor CSharpMigrateHighDpiSettings { get; } = + internal static readonly DiagnosticDescriptor s_cSharpMigrateHighDpiSettings = new(id: DiagnosticIDs.MigrateHighDpiSettings, title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_CS), SR.ResourceManager, typeof(SR)), @@ -16,7 +16,7 @@ internal static partial class SharedDiagnosticDescriptors defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); - internal static DiagnosticDescriptor VisualBasicMigrateHighDpiSettings { get; } = + internal static readonly DiagnosticDescriptor s_visualBasicMigrateHighDpiSettings = new(id: DiagnosticIDs.MigrateHighDpiSettings, title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_VB), SR.ResourceManager, typeof(SR)), diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index 88533e3972b..46495fd9978 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -2,53 +2,54 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Windows.Forms.Analyzers.Diagnostics; +using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.VisualBasic.Testing; using Xunit; -using VerifyCS = System.Windows.Forms.Analyzers.Tests - .CSharpAnalyzerVerifier; - -using VerifyVB = System.Windows.Forms.Analyzers.Tests - .VisualBasicAnalyzerVerifier; - namespace System.Windows.Forms.Analyzers.Tests; public class AppManifestAnalyzerTests { - private const string CSharCode = @" - namespace ConsoleApplication1 - { - class {|#0:TypeName|} - { + private const string CSharpCode = + """ + namespace ConsoleApplication1 + { + class {|#0:TypeName|} + { + } } - }"; - private const string VbCode = @" -Namespace ConsoleApplication1 - Class {|#0:TypeName|} - End Class -End Namespace"; + """; + + private const string VbCode = + """ + Namespace ConsoleApplication1 + Class {|#0:TypeName|} + End Class + End Namespace + """; [Fact] - public async Task AppManifestAnalyzer_noop_if_no_manifest_file() - { - await new VerifyCS.Test + public async Task AppManifestAnalyzer_no_op_if_no_manifest_file() => + await new CSharpAnalyzerTest() { - TestCode = CSharCode, + TestCode = CSharpCode, TestState = - { - AdditionalFiles = { } - } + { + AdditionalFiles = { } + } }.RunAsync(); - } [Fact] - public async Task AppManifestAnalyzer_noop_if_manifest_file_has_no_dpi_info() + public async Task AppManifestAnalyzer_no_op_if_manifest_file_has_no_dpi_info() { - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\nodpi.manifest")); - await new VerifyCS.Test + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\nodpi.manifest")); + + await new CSharpAnalyzerTest() { - TestCode = CSharCode, + TestCode = CSharpCode, TestState = { AdditionalFiles = { (@"C:\temp\app.manifest", manifestFile) } @@ -59,10 +60,12 @@ public async Task AppManifestAnalyzer_noop_if_manifest_file_has_no_dpi_info() [Fact] public async Task AppManifestAnalyzer_noop_if_manifest_file_corrupt() { - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\invalid.manifest")); - await new VerifyCS.Test + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\invalid.manifest")); + + await new CSharpAnalyzerTest() { - TestCode = CSharCode, + TestCode = CSharpCode, TestState = { AdditionalFiles = { (@"C:\temp\app.manifest", manifestFile) } @@ -74,17 +77,20 @@ public async Task AppManifestAnalyzer_noop_if_manifest_file_corrupt() public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_CSharp() { const string manifestFilePath = @"C:\temp\app.manifest"; - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); - await new VerifyCS.Test + + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + + await new CSharpAnalyzerTest() { - TestCode = CSharCode, + TestCode = CSharpCode, TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) } }, ExpectedDiagnostics = { - new DiagnosticResult(SharedDiagnosticDescriptors.CSharpMigrateHighDpiSettings) + new DiagnosticResult(SharedDiagnosticDescriptors.s_cSharpMigrateHighDpiSettings) .WithArguments(manifestFilePath, ApplicationConfig.PropertyNameCSharp.HighDpiMode) } }.RunAsync(); @@ -94,8 +100,11 @@ public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_CSharp( public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_VB() { const string manifestFilePath = @"C:\temp\app.manifest"; - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); - await new VerifyVB.Test + + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + + await new VisualBasicAnalyzerTest() { TestCode = VbCode, TestState = @@ -104,7 +113,7 @@ public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_VB() }, ExpectedDiagnostics = { - new DiagnosticResult(SharedDiagnosticDescriptors.VisualBasicMigrateHighDpiSettings) + new DiagnosticResult(SharedDiagnosticDescriptors.s_visualBasicMigrateHighDpiSettings) .WithArguments(manifestFilePath, ApplicationConfig.PropertyNameVisualBasic.HighDpiMode) } }.RunAsync(); @@ -114,11 +123,13 @@ public async Task AppManifestAnalyzer_warn_if_manifest_file_has_dpi_info_VB() public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_info_CSharp() { const string manifestFilePath = @"C:\temp\app.manifest"; - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); - await new VerifyCS.Test + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + + await new CSharpAnalyzerTest() { - TestCode = CSharCode, + TestCode = CSharpCode, TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) }, @@ -131,9 +142,11 @@ public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_in public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_info_VB() { const string manifestFilePath = @"C:\temp\app.manifest"; - SourceText manifestFile = SourceText.From(File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); - await new VerifyVB.Test + SourceText manifestFile = SourceText.From( + File.ReadAllText(@"System\Windows\Forms\Analyzers\MockData\dpi.manifest")); + + await new VisualBasicAnalyzerTest() { TestCode = VbCode, TestState = diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs index ffaa924630b..e605c0021e6 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs @@ -22,7 +22,11 @@ public FontDescriptorTests(ITestOutputHelper output) [Fact] public void FontDescriptor_ctor() { - FontDescriptor descriptor = new("fontName", 10f, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); + FontDescriptor descriptor = new( + fontName: "fontName", + emSize: 10f, + style: FontStyle.Bold | FontStyle.Italic, + unit: GraphicsUnit.Point); Assert.Equal("fontName", descriptor.Name); Assert.Equal(10f, descriptor.Size); @@ -41,7 +45,11 @@ public void FontDescriptor_ctor() [InlineData("Name with \r\n lines", "new global::System.Drawing.Font(new global::System.Drawing.FontFamily(\"Name with lines\"), 10f, (global::System.Drawing.FontStyle)3, (global::System.Drawing.GraphicsUnit)3)")] public void FontDescriptor_ToString(string fontName, string expected) { - FontDescriptor descriptor = new(fontName, 10f, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); + FontDescriptor descriptor = new( + fontName: fontName, + emSize: 10f, + style: FontStyle.Bold | FontStyle.Italic, + unit: GraphicsUnit.Point); _output.WriteLine(descriptor.ToString()); Assert.Equal(expected, descriptor.ToString()); @@ -61,10 +69,20 @@ public void FontDescriptor_ToString_culture_agnostic(string cultureName) { Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName); - FontDescriptor descriptor = new("Microsoft Sans Serif", 8.25f, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point); + FontDescriptor descriptor = new( + fontName: "Microsoft Sans Serif", + emSize: 8.25f, + style: FontStyle.Bold | FontStyle.Italic, + unit: GraphicsUnit.Point); _output.WriteLine(descriptor.ToString()); - Assert.Equal("new global::System.Drawing.Font(new global::System.Drawing.FontFamily(\"Microsoft Sans Serif\"), 8.25f, (global::System.Drawing.FontStyle)3, (global::System.Drawing.GraphicsUnit)3)", descriptor.ToString()); + + Assert.Equal( + expected: "new global::System.Drawing.Font(" + + "new global::System.Drawing.FontFamily(\"Microsoft Sans Serif\"), " + + "8.25f, (global::System.Drawing.FontStyle)3, " + + "(global::System.Drawing.GraphicsUnit)3)", + actual: descriptor.ToString()); } } } diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs deleted file mode 100644 index 6905e29ec43..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpAnalyzerVerifier - where TAnalyzer : DiagnosticAnalyzer, new() -{ - public class Test : CSharpAnalyzerTest - { - public Test() - { - ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.WindowsForms; - - SolutionTransforms.Add((solution, projectId) => - { - CompilationOptions compilationOptions = solution.GetProject(projectId)!.CompilationOptions!; - compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); - solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); - - return solution; - }); - } - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs deleted file mode 100644 index c5acd41a904..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpAnalyzerVerifier - where TAnalyzer : DiagnosticAnalyzer, new() -{ - /// - public static DiagnosticResult Diagnostic() - => CSharpAnalyzerVerifier.Diagnostic(); - - /// - public static DiagnosticResult Diagnostic(string diagnosticId) - => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); - - /// - public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => CSharpAnalyzerVerifier.Diagnostic(descriptor); - - /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) - { - Test test = new() - { - TestCode = source, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs deleted file mode 100644 index 99626f17ae5..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpCodeFixVerifier - where TAnalyzer : DiagnosticAnalyzer, new() - where TCodeFix : CodeFixProvider, new() -{ - public class Test : CSharpCodeFixTest - { - public Test() - { - ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.WindowsForms; - - SolutionTransforms.Add((solution, projectId) => - { - CompilationOptions? compilationOptions = solution.GetProject(projectId)!.CompilationOptions!; - compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); - solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); - - return solution; - }); - } - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs deleted file mode 100644 index 5aab6c244b8..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpCodeFixVerifier - where TAnalyzer : DiagnosticAnalyzer, new() - where TCodeFix : CodeFixProvider, new() -{ - /// - public static DiagnosticResult Diagnostic() - => CSharpCodeFixVerifier.Diagnostic(); - - /// - public static DiagnosticResult Diagnostic(string diagnosticId) - => CSharpCodeFixVerifier.Diagnostic(diagnosticId); - - /// - public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => CSharpCodeFixVerifier.Diagnostic(descriptor); - - /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) - { - Test test = new() - { - TestCode = source, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } - - /// - public static async Task VerifyCodeFixAsync(string source, string fixedSource) - => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); - - /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) - => await VerifyCodeFixAsync(source, [expected], fixedSource); - - /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) - { - Test test = new() - { - TestCode = source, - FixedCode = fixedSource, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs deleted file mode 100644 index 0922d3fcc2c..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeRefactorings; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpCodeRefactoringVerifier - where TCodeRefactoring : CodeRefactoringProvider, new() -{ - public class Test : CSharpCodeRefactoringTest - { - public Test() - { - ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.WindowsForms; - - SolutionTransforms.Add((solution, projectId) => - { - CompilationOptions compilationOptions = solution.GetProject(projectId)!.CompilationOptions!; - compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); - solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); - - return solution; - }); - } - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs deleted file mode 100644 index 871082e2705..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis.CodeRefactorings; -using Microsoft.CodeAnalysis.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class CSharpCodeRefactoringVerifier - where TCodeRefactoring : CodeRefactoringProvider, new() -{ - /// - public static async Task VerifyRefactoringAsync(string source, string fixedSource) - { - await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); - } - - /// - public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) - { - await VerifyRefactoringAsync(source, [expected], fixedSource); - } - - /// - public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) - { - Test test = new() - { - TestCode = source, - FixedCode = fixedSource, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs deleted file mode 100644 index d4afd5bc2b7..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; -using Microsoft.CodeAnalysis.VisualBasic.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicAnalyzerVerifier - where TAnalyzer : DiagnosticAnalyzer, new() -{ - public class Test : VisualBasicAnalyzerTest - { - public Test() - { - ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.WindowsForms; - } - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs deleted file mode 100644 index 7b710d40804..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; -using Microsoft.CodeAnalysis.VisualBasic.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicAnalyzerVerifier - where TAnalyzer : DiagnosticAnalyzer, new() -{ - /// - public static DiagnosticResult Diagnostic() - => VisualBasicAnalyzerVerifier.Diagnostic(); - - /// - public static DiagnosticResult Diagnostic(string diagnosticId) - => VisualBasicAnalyzerVerifier.Diagnostic(diagnosticId); - - /// - public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => VisualBasicAnalyzerVerifier.Diagnostic(descriptor); - - /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) - { - Test test = new() - { - TestCode = source, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs deleted file mode 100644 index 9e59d844bc6..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing.Verifiers; -using Microsoft.CodeAnalysis.VisualBasic.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicCodeFixVerifier - where TAnalyzer : DiagnosticAnalyzer, new() - where TCodeFix : CodeFixProvider, new() -{ - public class Test : VisualBasicCodeFixTest - { - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs deleted file mode 100644 index 628fe15570c..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Testing.Verifiers; -using Microsoft.CodeAnalysis.VisualBasic.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicCodeFixVerifier - where TAnalyzer : DiagnosticAnalyzer, new() - where TCodeFix : CodeFixProvider, new() -{ - /// - public static DiagnosticResult Diagnostic() - => VisualBasicCodeFixVerifier.Diagnostic(); - - /// - public static DiagnosticResult Diagnostic(string diagnosticId) - => VisualBasicCodeFixVerifier.Diagnostic(diagnosticId); - - /// - public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => VisualBasicCodeFixVerifier.Diagnostic(descriptor); - - /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) - { - Test test = new() - { - TestCode = source, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } - - /// - public static async Task VerifyCodeFixAsync(string source, string fixedSource) - => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); - - /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) - => await VerifyCodeFixAsync(source, [expected], fixedSource); - - /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) - { - Test test = new() - { - TestCode = source, - FixedCode = fixedSource, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs deleted file mode 100644 index e4927138b71..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis.CodeRefactorings; -using Microsoft.CodeAnalysis.Testing.Verifiers; -using Microsoft.CodeAnalysis.VisualBasic.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicCodeRefactoringVerifier - where TCodeRefactoring : CodeRefactoringProvider, new() -{ - public class Test : VisualBasicCodeRefactoringTest - { - } -} diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs deleted file mode 100644 index 183e5112075..00000000000 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis.CodeRefactorings; -using Microsoft.CodeAnalysis.Testing; - -namespace System.Windows.Forms.Analyzers.Tests; - -public static partial class VisualBasicCodeRefactoringVerifier - where TCodeRefactoring : CodeRefactoringProvider, new() -{ - /// - public static async Task VerifyRefactoringAsync(string source, string fixedSource) - { - await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); - } - - /// - public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) - { - await VerifyRefactoringAsync(source, [expected], fixedSource); - } - - /// - public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) - { - Test test = new() - { - TestCode = source, - FixedCode = fixedSource, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None); - } -} From 9f114822e48bdc967237d43f36853ebbbc64f0ee Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Wed, 19 Jun 2024 18:22:36 -0700 Subject: [PATCH 22/25] Add Visual Basic Analyzer and Code Fix tests; fix up folder structure. --- Winforms.sln | 21 ++- .../Microsoft.Private.Winforms.csproj | 2 +- .../tests/UnitTests/GlobalSuppressions.cs | 9 - ...ertySerializationDiagnosticAnalyzerTest.cs | 2 +- ...SharpIncrementalSourceGeneratorVerifier.cs | 2 +- .../Verifiers/CSharpSourceGeneratorTest`1.cs | 2 +- .../Verifiers/CSharpVerifierHelper.cs | 2 +- .../ApplicationConfigurationGeneratorTests.cs | 17 +- ...tionConfigurationInitializeBuilderTests.cs | 2 +- .../ProjectFileReaderTests.FontConverter.cs | 2 +- .../Generators/ProjectFileReaderTests.cs | 4 +- .../Properties/AssemblyInfo.cs | 1 - .../Properties/AssemblyInfo.vb | 6 + ...rms.Analyzers.CodeFixes.VisualBasic.vbproj | 2 +- ...rSerializationVisibilityCodeFixProvider.vb | 99 ++++++---- .../GlobalSuppressions.vb | 13 -- ...lizationConfigurationDiagnosticAnalyzer.vb | 97 ---------- .../{ => src}/AnalyzerReleases.Shipped.md | 0 .../{ => src}/AnalyzerReleases.Unshipped.md | 0 .../src/GlobalSuppressions.vb | 8 + .../src/Properties/AssemblyInfo.vb | 6 + .../{ => src}/Resources/SR.resx | 0 .../{ => src}/Resources/xlf/SR.cs.xlf | 0 .../{ => src}/Resources/xlf/SR.de.xlf | 0 .../{ => src}/Resources/xlf/SR.es.xlf | 0 .../{ => src}/Resources/xlf/SR.fr.xlf | 0 .../{ => src}/Resources/xlf/SR.it.xlf | 0 .../{ => src}/Resources/xlf/SR.ja.xlf | 0 .../{ => src}/Resources/xlf/SR.ko.xlf | 0 .../{ => src}/Resources/xlf/SR.pl.xlf | 0 .../{ => src}/Resources/xlf/SR.pt-BR.xlf | 0 .../{ => src}/Resources/xlf/SR.ru.xlf | 0 .../{ => src}/Resources/xlf/SR.tr.xlf | 0 .../{ => src}/Resources/xlf/SR.zh-Hans.xlf | 0 .../{ => src}/Resources/xlf/SR.zh-Hant.xlf | 0 ...Windows.Forms.Analyzers.VisualBasic.vbproj | 4 +- ...lizationConfigurationDiagnosticAnalyzer.vb | 83 +++++++++ .../VisualBasicDiagnosticDescriptors.vb | 19 ++ ...s.Forms.Analyzers.VisualBasic.Tests.vbproj | 37 ++++ ...ySerializationConfigurationAnalyzerTest.vb | 171 ++++++++++++++++++ 40 files changed, 428 insertions(+), 183 deletions(-) delete mode 100644 src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs create mode 100644 src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Properties/AssemblyInfo.vb delete mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb delete mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/AnalyzerReleases.Shipped.md (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/AnalyzerReleases.Unshipped.md (100%) create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/src/GlobalSuppressions.vb create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/src/Properties/AssemblyInfo.vb rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/SR.resx (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.cs.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.de.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.es.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.fr.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.it.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.ja.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.ko.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.pl.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.pt-BR.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.ru.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.tr.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.zh-Hans.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/Resources/xlf/SR.zh-Hant.xlf (100%) rename src/System.Windows.Forms.Analyzers.VisualBasic/{ => src}/System.Windows.Forms.Analyzers.VisualBasic.vbproj (88%) create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System.Windows.Forms.Analyzers.VisualBasic.Tests.vbproj create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb diff --git a/Winforms.sln b/Winforms.sln index 4100178de35..9d6bcb221ed 100644 --- a/Winforms.sln +++ b/Winforms.sln @@ -177,12 +177,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimTestBinaryDeserializati EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BinaryFormatTests", "src\System.Private.Windows.Core\tests\BinaryFormatTests\BinaryFormatTests.csproj", "{57EC5288-9513-46CF-8FB7-626199690D90}" EndProject -Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.VisualBasic", "src\System.Windows.Forms.Analyzers.VisualBasic\System.Windows.Forms.Analyzers.VisualBasic.vbproj", "{FF211812-FCCC-4B6B-B536-C4D754195750}" +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.VisualBasic", "src\System.Windows.Forms.Analyzers.VisualBasic\src\System.Windows.Forms.Analyzers.VisualBasic.vbproj", "{FF211812-FCCC-4B6B-B536-C4D754195750}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Analyzers.CodeFixes.CSharp", "src\System.Windows.Forms.Analyzers.CodeFixes.CSharp\System.Windows.Forms.Analyzers.CodeFixes.CSharp.csproj", "{1F836B14-D13D-42E0-BEAF-A821DD75DE49}" EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.CodeFixes.VisualBasic", "src\System.Windows.Forms.Analyzers.CodeFixes.VisualBasic\System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj", "{C4C031D5-F79A-44B6-811E-0797E7D5C1C1}" EndProject +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "System.Windows.Forms.Analyzers.VisualBasic.Tests", "src\System.Windows.Forms.Analyzers.VisualBasic\tests\UnitTests\System.Windows.Forms.Analyzers.VisualBasic.Tests\System.Windows.Forms.Analyzers.VisualBasic.Tests.vbproj", "{0FD53580-3175-4F8F-8372-BE46C9122EE0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1035,6 +1037,22 @@ Global {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x64.Build.0 = Release|Any CPU {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x86.ActiveCfg = Release|Any CPU {C4C031D5-F79A-44B6-811E-0797E7D5C1C1}.Release|x86.Build.0 = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|arm64.ActiveCfg = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|arm64.Build.0 = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|x64.ActiveCfg = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|x64.Build.0 = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|x86.ActiveCfg = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Debug|x86.Build.0 = Debug|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|Any CPU.Build.0 = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|arm64.ActiveCfg = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|arm64.Build.0 = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|x64.ActiveCfg = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|x64.Build.0 = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|x86.ActiveCfg = Release|Any CPU + {0FD53580-3175-4F8F-8372-BE46C9122EE0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1101,6 +1119,7 @@ Global {FF211812-FCCC-4B6B-B536-C4D754195750} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} {1F836B14-D13D-42E0-BEAF-A821DD75DE49} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} {C4C031D5-F79A-44B6-811E-0797E7D5C1C1} = {E4C6C5F5-46E9-4C63-9628-26752B4D9C11} + {0FD53580-3175-4F8F-8372-BE46C9122EE0} = {D3AD0BF9-F5E2-4913-9AE3-9C4998F95EA1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136} diff --git a/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj index 1f828214c82..afbc33ac246 100644 --- a/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj +++ b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj @@ -107,7 +107,7 @@ --> - + diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs deleted file mode 100644 index 37aa1514430..00000000000 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/GlobalSuppressions.cs +++ /dev/null @@ -1,9 +0,0 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "", Scope = "namespace", Target = "~N:System.Windows.Forms.Analyzers.MissingPropertySerializationConfiguration")] -[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "", Scope = "namespace", Target = "~N:System.Windows.Forms.Generators")] diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs index 51adcecb773..af945f0fa65 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Testing; -namespace System.Windows.Forms.Analyzers.MissingPropertySerializationConfiguration; +namespace System.Windows.Forms.Analyzers.Test; public class ControlPropertySerializationDiagnosticAnalyzerTest { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs index 6a4bf3f4994..1ee6dd1fa7b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; -namespace System.Windows.Forms.Analyzers.Verifiers; +namespace System.Windows.Forms.Analyzers.Tests.Verifiers; // Note: this is bleeding edge, eventually this can be removed once it is all baked in to Roslyn SDK. public static partial class CSharpIncrementalSourceGeneratorVerifier diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs index 8acec42f1f4..e7f403a6479 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpSourceGeneratorTest`1.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Testing.Verifiers; using static Microsoft.CodeAnalysis.Testing.ReferenceAssemblies; -namespace System.Windows.Forms.Analyzers.Verifiers; +namespace System.Windows.Forms.Analyzers.Tests.Verifiers; public class CSharpSourceGeneratorTest : CSharpSourceGeneratorTest diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs index e90d3bf03f2..8620970cdab 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/Verifiers/CSharpVerifierHelper.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using System.Collections.Immutable; -namespace System.Windows.Forms.Analyzers.Verifiers; +namespace System.Windows.Forms.Analyzers.Tests.Verifiers; internal static class CSharpVerifierHelper { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index 4ffa0e01e1d..a8e4d3439b2 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -2,14 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text; -using System.Windows.Forms.Analyzers; using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators; +namespace System.Windows.Forms.Analyzers.Tests; public partial class ApplicationConfigurationGeneratorTests { @@ -61,7 +60,7 @@ public static TheoryData UnsupportedProjectTypes_TestData() [MemberData(nameof(UnsupportedProjectTypes_TestData))] public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_fails_if_project_type_unsupported(OutputKind projectType) { - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -84,7 +83,7 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_pass_i { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -105,7 +104,7 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_defaul { SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -126,7 +125,7 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_user_s { SourceText generatedCode = LoadFileContent("GenerateInitialize_user_settings_boilerplate"); - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -163,8 +162,8 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_defaul """; SourceText generatedCode = LoadFileContent("GenerateInitialize_default_top_level"); - - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { @@ -190,7 +189,7 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_user_s SourceText generatedCode = LoadFileContent("GenerateInitialize_user_top_level"); - var test = new Analyzers.Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test + var test = new Verifiers.CSharpIncrementalSourceGeneratorVerifier.Test { TestState = { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs index 4b749add46c..0888a15288d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs @@ -5,7 +5,7 @@ using System.Windows.Forms.Analyzers; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators.Tests; +namespace System.Windows.Forms.Analyzers.Tests; public partial class ApplicationConfigurationInitializeBuilderTests { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs index 2a432895264..f506d5fa375 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs @@ -6,7 +6,7 @@ using static System.Windows.Forms.Analyzers.ApplicationConfig; using static System.Windows.Forms.CSharp.Generators.ApplicationConfiguration.ProjectFileReader; -namespace System.Windows.Forms.Generators.Tests; +namespace System.Windows.Forms.Analyzers.Tests; public partial class ProjectFileReaderTests { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs index 4d1827d28b2..2d56a0fef94 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs @@ -3,8 +3,6 @@ using System.Collections.Immutable; using System.Globalization; -using System.Windows.Forms.Analyzers; -using System.Windows.Forms.Analyzers.Tests; using System.Windows.Forms.CSharp.Analyzers.Diagnostics; using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; @@ -12,7 +10,7 @@ using Xunit.Abstractions; using static System.Windows.Forms.Analyzers.ApplicationConfig; -namespace System.Windows.Forms.Generators.Tests; +namespace System.Windows.Forms.Analyzers.Tests; public partial class ProjectFileReaderTests { diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs index cfb75a1f62a..18c78a00dd6 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/Properties/AssemblyInfo.cs @@ -4,4 +4,3 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.CSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] -// [assembly: InternalsVisibleTo("System.Windows.Forms.Analyzers.VisualBasic.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Properties/AssemblyInfo.vb b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Properties/AssemblyInfo.vb new file mode 100644 index 00000000000..fd74a3a67bb --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/Properties/AssemblyInfo.vb @@ -0,0 +1,6 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.Runtime.CompilerServices + + diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj index 1a8df0102c1..124b0018b67 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic.vbproj @@ -5,7 +5,7 @@ netstandard2.0 true - 15.0 + 15.5 $(NoWarn);CA1812 diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb index d6212350210..6f0d84fde73 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.VisualBasic/System/Windows/Forms/VisualBasic/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.vb @@ -4,25 +4,25 @@ Imports System.Collections.Immutable Imports System.Composition Imports System.Threading -Imports System.Windows.Forms.Analyzers.Diagnostics Imports System.Windows.Forms.Analyzers.CodeFixes.Resources +Imports System.Windows.Forms.Analyzers.Diagnostics Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.CodeActions Imports Microsoft.CodeAnalysis.CodeFixes +Imports Microsoft.CodeAnalysis.Formatting +Imports Microsoft.CodeAnalysis.Simplification Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializationVisibility - - <[Shared]> + Friend NotInheritable Class AddDesignerSerializationVisibilityCodeFixProvider Inherits CodeFixProvider Private Const SystemComponentModelName As String = "System.ComponentModel" + Private Const DesignerSerializationVisibilityAttributeName As String = "DesignerSerializationVisibility" Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String) Get @@ -35,22 +35,21 @@ Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializa End Function Public Overrides Async Function RegisterCodeFixesAsync(context As CodeFixContext) As Task - ' Cannot be null - otherwise we wouldn't have a diagnostic of that ID. - Dim root As SyntaxNode = Await context _ - .Document _ - .GetSyntaxRootAsync(context.CancellationToken) _ - .ConfigureAwait(False) + Dim root As SyntaxNode = Await context. + Document. + GetSyntaxRootAsync(context.CancellationToken). + ConfigureAwait(False) Dim diagnostic As Diagnostic = context.Diagnostics.First() Dim diagnosticSpan As TextSpan = diagnostic.Location.SourceSpan ' Find the type declaration identified by the diagnostic. - Dim propertyDeclaration As PropertyStatementSyntax = root _ - .FindToken(diagnosticSpan.Start) _ - .Parent.AncestorsAndSelf() _ - .OfType(Of PropertyStatementSyntax)() _ - .First() + Dim propertyDeclaration As PropertyStatementSyntax = root. + FindToken(diagnosticSpan.Start). + Parent.AncestorsAndSelf(). + OfType(Of PropertyStatementSyntax)(). + First() ' Register a code action that will invoke the fix. context.RegisterCodeFix( @@ -65,11 +64,24 @@ Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializa End Function - Private Shared Async Function AddDesignerSerializationAttribute(document As Document, propertyDeclarationSyntax As PropertyStatementSyntax, cancellationToken As CancellationToken) As Task(Of Document) + Private Shared Async Function AddDesignerSerializationAttribute( + document As Document, + propertyDeclarationSyntax As PropertyStatementSyntax, + cancellationToken As CancellationToken) As Task(Of Document) + If propertyDeclarationSyntax Is Nothing Then Return document End If + ' Let's make sure, the attribute we want to add is not already there: + If propertyDeclarationSyntax.AttributeLists.SelectMany( + Function(al) al.Attributes).Any( + Function(a) a.Name.ToString() = DesignerSerializationVisibilityAttributeName) Then + + Debug.Assert(False, "The attribute should not be there.") + Return document + End If + ' Generate the Attribute we need to put on the property Dim designerSerializationVisibilityAttribute As AttributeSyntax = SyntaxFactory.Attribute( @@ -82,41 +94,48 @@ Namespace Global.System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializa Dim trailingTrivia As SyntaxTriviaList = propertyDeclarationSyntax.GetTrailingTrivia() ' Add the attribute to the property: - Dim newProperty As PropertyStatementSyntax = propertyDeclarationSyntax.AddAttributeLists(SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(designerSerializationVisibilityAttribute))) - - ' Let's restore the trivia: - newProperty = newProperty.WithLeadingTrivia(leadingTrivia).WithTrailingTrivia(trailingTrivia) + Dim newProperty As PropertyStatementSyntax = propertyDeclarationSyntax.AddAttributeLists( + SyntaxFactory.AttributeList( + SyntaxFactory.SingletonSeparatedList(designerSerializationVisibilityAttribute))) - ' Let's check, if we already have the using directive or if we need to add it: - ' (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) - Dim root As SyntaxNode = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) + ' Let's format the property, so the attribute is on top of it: + newProperty = newProperty.NormalizeWhitespace() - ' Let's check if we already have the using directive: - If Not root.DescendantNodes().OfType(Of ImportsStatementSyntax)() _ - .Any(Function(u) u?.TryGetInferredMemberName() = SystemComponentModelName) Then + ' Let's restore the original trivia: + newProperty = newProperty. + WithLeadingTrivia(leadingTrivia). + WithTrailingTrivia(trailingTrivia). + WithAdditionalAnnotations(Formatter.Annotation) - ' We need to add the using directive: - Dim firstNode As SyntaxNode = root.DescendantNodes().First() + ' Let's check, if we already have the imports statement or if we need to add it: + ' (Remember: We can't throw here, as we are in a code fixer. But this also cannot be null.) + Dim root As SyntaxNode = Await document. + GetSyntaxRootAsync(cancellationToken). + ConfigureAwait(False) - ' Add the imports directive: - Dim systemComponentModelImportsClauseSyntax As ImportsClauseSyntax = - SyntaxFactory.SimpleImportsClause(SyntaxFactory.IdentifierName(SystemComponentModelName)) + ' Produce a new root, which has the updated property with the attribute. + root = root.ReplaceNode(propertyDeclarationSyntax, newProperty) - Dim importsList As SeparatedSyntaxList(Of ImportsClauseSyntax) = - SyntaxFactory.SeparatedList(Of ImportsClauseSyntax)().Add(systemComponentModelImportsClauseSyntax) + ' Let's check if we already have the imports statement: + If Not root.DescendantNodes().OfType(Of ImportsStatementSyntax)(). + Any(Function(u) u.ImportsClauses.OfType(Of SimpleImportsClauseSyntax)(). + Any(Function(i) i.Name.ToString() = SystemComponentModelName)) Then - Dim usingDirective As ImportsStatementSyntax = SyntaxFactory.ImportsStatement(importsList) + Dim importsStatement As ImportsStatementSyntax = SyntaxFactory. + ImportsStatement(SyntaxFactory.SingletonSeparatedList(Of ImportsClauseSyntax)( + SyntaxFactory.SimpleImportsClause( + SyntaxFactory.ParseName(SystemComponentModelName)))). + WithAdditionalAnnotations(Simplifier.Annotation, Formatter.Annotation) - root = root.InsertNodesBefore(firstNode, {usingDirective}) + ' We need to add the imports statement: + Dim firstNode As SyntaxNode = root.DescendantNodes().First() + root = root.InsertNodesBefore(firstNode, {importsStatement}) End If - ' Produce a new root: - Dim originalRoot As SyntaxNode = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) - Dim newRoot As SyntaxNode = originalRoot.ReplaceNode(propertyDeclarationSyntax, newProperty) + document = document.WithSyntaxRoot(root) ' Generate the new document: - Return document.WithSyntaxRoot(newRoot) - + Return document End Function End Class End Namespace diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb deleted file mode 100644 index 2277f412da7..00000000000 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/GlobalSuppressions.vb +++ /dev/null @@ -1,13 +0,0 @@ -' This file is used by Code Analysis to maintain SuppressMessage -' attributes that are applied to this project. -' Project-level suppressions either have no target or are given -' a specific target and scoped to a namespace, type, member, etc. - -Imports System.Diagnostics.CodeAnalysis - - diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb deleted file mode 100644 index 1a8aea2d4d0..00000000000 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb +++ /dev/null @@ -1,97 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. - -Imports System.Collections.Immutable -Imports System.ComponentModel -Imports System.Windows.Forms.Analyzers.Diagnostics -Imports System.Windows.Forms.Analyzers.VisualBasic.Resources -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Diagnostics - -' This is not really a VB-specific diagnostic, since they are not language agnostic. -' We want to stay consistent with the C# version, though, so we rename the class to keep using the variable name. -' (VB is not case-sensitive, so we can't have the same names in a code file, even if the casing is different.) -Imports VBDiagnostic = Microsoft.CodeAnalysis.Diagnostic - -Namespace System.Windows.Forms.VisualBasic.Analyzers.MissingPropertySerializationConfiguration - - - Public Class MissingPropertySerializationConfigurationDiagnosticAnalyzer - Inherits DiagnosticAnalyzer - - Private Shared ReadOnly s_rule As New DiagnosticDescriptor( - id:=DiagnosticIDs.MissingPropertySerializationConfiguration, - title:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerTitle), SR.ResourceManager, GetType(SR)), - messageFormat:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), - category:=DiagnosticCategories.WinFormsSecurity, - defaultSeverity:=DiagnosticSeverity.Error, - isEnabledByDefault:=True, - description:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerDescription), SR.ResourceManager, GetType(SR)) - ) - - Public Overrides ReadOnly Property SupportedDiagnostics As ImmutableArray(Of DiagnosticDescriptor) - Get - Return ImmutableArray.Create(s_rule) - End Get - End Property - - Public Overrides Sub Initialize(context As AnalysisContext) - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None) - context.EnableConcurrentExecution() - context.RegisterSymbolAction(AddressOf AnalyzeSymbol, SymbolKind.Property) - End Sub - - Private Shared Sub AnalyzeSymbol(context As SymbolAnalysisContext) - - ' We analyze only properties. - Dim propertySymbol = DirectCast(context.Symbol, IPropertySymbol) - - ' Does the property belong to a class which derives from Component? - If propertySymbol.ContainingType Is Nothing _ - OrElse Not propertySymbol _ - .ContainingType _ - .AllInterfaces _ - .Any(Function(i) i.Name = NameOf(IComponent)) Then - - Return - End If - - ' Is the read/write and at least internal? - If propertySymbol.SetMethod Is Nothing _ - OrElse propertySymbol.DeclaredAccessibility < Accessibility.Internal Then - - Return - End If - - ' Is the property attributed with DesignerSerializationVisibility or DefaultValue? - If propertySymbol _ - .GetAttributes() _ - .Any(Function(a) a?.AttributeClass?.Name = NameOf(DesignerSerializationVisibilityAttribute) _ - OrElse a?.AttributeClass?.Name = NameOf(DefaultValueAttribute)) Then - - Return - End If - - ' Now, it gets a bit more tedious: - ' If the Serialization is managed via ShouldSerialize and Reset methods, we are also fine, - ' so let's check for that. First, let's get the class of the property: - Dim classSymbol As INamedTypeSymbol = propertySymbol.ContainingType - - ' Now, let's check if the class has a method ShouldSerialize method: - Dim shouldSerializeMethod As IMethodSymbol = classSymbol _ - .GetMembers() _ - .OfType(Of IMethodSymbol)() _ - .FirstOrDefault(Function(m) m.Name = $"ShouldSerialize{propertySymbol.Name}") - - ' Let's make sure the method returns a bool and has no parameters: - If shouldSerializeMethod Is Nothing _ - OrElse shouldSerializeMethod.ReturnType.SpecialType <> SpecialType.System_Boolean _ - OrElse shouldSerializeMethod.Parameters.Length > 0 Then - - ' For ALL such other symbols, produce a diagnostic. - Dim diagnostic = VBDiagnostic.Create(s_rule, propertySymbol.Locations(0), propertySymbol.Name) - context.ReportDiagnostic(diagnostic) - End If - End Sub - End Class -End Namespace diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Shipped.md similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Shipped.md rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Shipped.md diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/AnalyzerReleases.Unshipped.md rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/GlobalSuppressions.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/src/GlobalSuppressions.vb new file mode 100644 index 00000000000..0695e8a0b95 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/GlobalSuppressions.vb @@ -0,0 +1,8 @@ +' This file is used by Code Analysis to maintain SuppressMessage +' attributes that are applied to this project. +' Project-level suppressions either have no target or are given +' a specific target and scoped to a namespace, type, member, etc. + +Imports System.Diagnostics.CodeAnalysis + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Properties/AssemblyInfo.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Properties/AssemblyInfo.vb new file mode 100644 index 00000000000..fd74a3a67bb --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Properties/AssemblyInfo.vb @@ -0,0 +1,6 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.Runtime.CompilerServices + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/SR.resx rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.cs.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.de.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.es.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.fr.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.it.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ja.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ko.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pl.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.pt-BR.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.ru.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.tr.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hans.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf similarity index 100% rename from src/System.Windows.Forms.Analyzers.VisualBasic/Resources/xlf/SR.zh-Hant.xlf rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System.Windows.Forms.Analyzers.VisualBasic.vbproj similarity index 88% rename from src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj rename to src/System.Windows.Forms.Analyzers.VisualBasic/src/System.Windows.Forms.Analyzers.VisualBasic.vbproj index 9f4d9c63714..6aedac3dbcf 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System.Windows.Forms.Analyzers.VisualBasic.vbproj @@ -5,7 +5,7 @@ netstandard2.0 true - 15.0 + 15.5 true @@ -21,7 +21,7 @@ - + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb new file mode 100644 index 00000000000..e452925f644 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationDiagnosticAnalyzer.vb @@ -0,0 +1,83 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.Collections.Immutable +Imports System.ComponentModel +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Diagnostics + +Namespace System.Windows.Forms.VisualBasic.Analyzers.MissingPropertySerializationConfiguration + + + Public Class MissingPropertySerializationConfigurationAnalyzer + Inherits DiagnosticAnalyzer + + Public Overrides ReadOnly Property SupportedDiagnostics As ImmutableArray(Of DiagnosticDescriptor) + Get + Return ImmutableArray.Create(s_missingPropertySerializationConfiguration) + End Get + End Property + + Public Overrides Sub Initialize(context As AnalysisContext) + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None) + context.EnableConcurrentExecution() + context.RegisterSymbolAction(AddressOf AnalyzeSymbol, SymbolKind.Property) + End Sub + + Private Shared Sub AnalyzeSymbol(context As SymbolAnalysisContext) + + ' We analyze only properties. + Dim propertySymbol As IPropertySymbol = TryCast(context.Symbol, IPropertySymbol) + If propertySymbol Is Nothing Then + Return + End If + + ' Does the property belong to a class which derives from Component? + If propertySymbol.ContainingType Is Nothing OrElse + Not propertySymbol.ContainingType.AllInterfaces.Any( + Function(i) i.Name = NameOf(IComponent)) Then + + Return + End If + + ' Is the property read/write and at least internal? + If propertySymbol.SetMethod Is Nothing OrElse + propertySymbol.DeclaredAccessibility < Accessibility.Internal Then + + Return + End If + + ' Is the property attributed with DesignerSerializationVisibility or DefaultValue? + If propertySymbol.GetAttributes().Any( + Function(a) a?.AttributeClass?.Name = NameOf(DesignerSerializationVisibilityAttribute) OrElse + a?.AttributeClass?.Name = NameOf(DefaultValueAttribute)) Then + + Return + End If + + ' Now, it gets a bit more tedious: + ' If the Serialization is managed via ShouldSerialize and Reset methods, we are also fine, + ' so let's check for that. First, let's get the class of the property: + Dim classSymbol As INamedTypeSymbol = propertySymbol.ContainingType + + ' Now, let's check if the class has a method ShouldSerialize method: + Dim shouldSerializeMethod As IMethodSymbol = classSymbol.GetMembers(). + OfType(Of IMethodSymbol)(). + FirstOrDefault(Function(m) m.Name = $"ShouldSerialize{propertySymbol.Name}") + + ' Let's make sure the method returns a bool and has no parameters: + If shouldSerializeMethod Is Nothing OrElse + shouldSerializeMethod.ReturnType.SpecialType <> SpecialType.System_Boolean OrElse + shouldSerializeMethod.Parameters.Length > 0 Then + + ' For ALL such other symbols, produce a diagnostic. + Dim diagnostic As Diagnostic = Diagnostic.Create( + descriptor:=s_missingPropertySerializationConfiguration, + location:=propertySymbol.Locations(0), + propertySymbol.Name) + + context.ReportDiagnostic(diagnostic) + End If + End Sub + End Class +End Namespace diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb new file mode 100644 index 00000000000..b0b67bb27c7 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb @@ -0,0 +1,19 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports Microsoft.CodeAnalysis +Imports System.Windows.Forms.Analyzers.Diagnostics +Imports System.Windows.Forms.Analyzers.VisualBasic.Resources + +Friend Module VisualBasicDiagnosticDescriptors + + Public ReadOnly s_missingPropertySerializationConfiguration As New DiagnosticDescriptor( + id:=DiagnosticIDs.MissingPropertySerializationConfiguration, + title:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerTitle), SR.ResourceManager, GetType(SR)), + messageFormat:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), + category:=DiagnosticCategories.WinFormsSecurity, + defaultSeverity:=DiagnosticSeverity.Error, + isEnabledByDefault:=True, + description:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerDescription), SR.ResourceManager, GetType(SR))) + +End Module diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System.Windows.Forms.Analyzers.VisualBasic.Tests.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System.Windows.Forms.Analyzers.VisualBasic.Tests.vbproj new file mode 100644 index 00000000000..c59dd663ee6 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System.Windows.Forms.Analyzers.VisualBasic.Tests.vbproj @@ -0,0 +1,37 @@ + + + + enable + 15.5 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb new file mode 100644 index 00000000000..59b9929b125 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb @@ -0,0 +1,171 @@ +Imports System.Windows.Forms.VisualBasic.Analyzers.MissingPropertySerializationConfiguration +Imports System.Windows.Forms.VisualBasic.CodeFixes.AddDesignerSerializationVisibility +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Testing +Imports Microsoft.CodeAnalysis.VisualBasic.Testing +Imports Xunit + +Public Class ControlPropertySerializationDiagnosticAnalyzerTest + + Private Const ProblematicCode As String = " + Imports System.Drawing + Imports System.Windows.Forms + + Namespace VBControls + + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() + + ' We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module + + ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + ' since this is nothing our code fix touches. + Public Class ScalableControl + Inherits System.Windows.Forms.Control + + Public Property [|ScaleFactor|] As Single = 1.0F + + Public Property [|ScaledSize|] As SizeF + + Public Property [|ScaledLocation|] As PointF + End Class + + End Namespace + " + + Private Const CorrectCode As String = " + Imports System.ComponentModel + Imports System.Drawing + Imports System.Windows.Forms + + Namespace VBControls + + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() + + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module + + Public Class ScalableControl + Inherits Control + + + Public Property ScaleFactor As Single = 1.0F + + + Public Property ScaledSize As SizeF + + Public Property ScaledLocation As PointF + Private Function ShouldSerializeScaledLocation() As Boolean + Return Me.ScaledLocation <> PointF.Empty + End Function + End Class + + End Namespace + " + + Private Const FixedCode As String = " + Imports System.ComponentModel + Imports System.Drawing + Imports System.Windows.Forms + + Namespace VBControls + + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() + + ' We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module + + ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + ' since this is nothing our code fix touches. + Public Class ScalableControl + Inherits System.Windows.Forms.Control + + + Public Property ScaleFactor As Single = 1.0F + + + Public Property ScaledSize As SizeF + + + Public Property ScaledLocation As PointF + End Class + + End Namespace + " + + ' We are testing the analyzer with all versions of the .NET SDK from 6.0 on. + Public Shared Iterator Function GetReferenceAssemblies() As IEnumerable(Of Object()) + Yield New Object() {ReferenceAssemblies.Net.Net60Windows} + Yield New Object() {ReferenceAssemblies.Net.Net70Windows} + Yield New Object() {ReferenceAssemblies.Net.Net80Windows} + Yield New Object() {ReferenceAssemblies.Net.Net90Windows} + End Function + + + + Public Async Function VB_ControlPropertySerializationConfigurationAnalyzer(referenceAssemblies As ReferenceAssemblies) As Task + Dim context = New VisualBasicAnalyzerTest(Of + MissingPropertySerializationConfigurationAnalyzer, + DefaultVerifier) With + { + .TestCode = CorrectCode, + .ReferenceAssemblies = referenceAssemblies + } + + context.TestState.OutputKind = OutputKind.WindowsApplication + + Await context.RunAsync() + End Function + + + + Public Async Function VB_MissingControlPropertySerializationConfigurationAnalyzer(referenceAssemblies As ReferenceAssemblies) As Task + Dim context = New VisualBasicAnalyzerTest(Of + MissingPropertySerializationConfigurationAnalyzer, + DefaultVerifier) With + { + .TestCode = ProblematicCode, + .ReferenceAssemblies = referenceAssemblies + } + + context.TestState.OutputKind = OutputKind.WindowsApplication + + Await context.RunAsync() + End Function + + + + Public Async Function VB_AddDesignerSerializationVisibilityCodeFix(referenceAssemblies As ReferenceAssemblies) As Task + Dim context = New VisualBasicCodeFixTest(Of + MissingPropertySerializationConfigurationAnalyzer, + AddDesignerSerializationVisibilityCodeFixProvider, + DefaultVerifier) With + { + .TestCode = ProblematicCode, + .FixedCode = FixedCode, + .ReferenceAssemblies = referenceAssemblies, + .NumberOfFixAllIterations = 2 + } + + context.TestState.OutputKind = OutputKind.WindowsApplication + + Await context.RunAsync() + End Function +End Class From 56109648df21b2c4c2c728f344f61691fd6ef8bb Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Thu, 20 Jun 2024 01:37:45 -0700 Subject: [PATCH 23/25] Fix VB CodeFix result file. --- ...ySerializationConfigurationAnalyzerTest.vb | 155 +++++++++--------- 1 file changed, 78 insertions(+), 77 deletions(-) diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb index 59b9929b125..a5531428dc1 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/tests/UnitTests/System.Windows.Forms.Analyzers.VisualBasic.Tests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzerTest.vb @@ -7,108 +7,109 @@ Imports Xunit Public Class ControlPropertySerializationDiagnosticAnalyzerTest - Private Const ProblematicCode As String = " - Imports System.Drawing - Imports System.Windows.Forms + Private Const ProblematicCode As String = +" +Imports System.Drawing +Imports System.Windows.Forms - Namespace VBControls +Namespace VBControls - Public Module Program - Public Sub Main() - Dim control As New ScalableControl() + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() - ' We deliberately format this weirdly, to make sure we only format code our code fix touches. - control.ScaleFactor = 1.5F - control.ScaledSize = New SizeF(100, 100) - control.ScaledLocation = New PointF(10, 10) - End Sub - End Module + ' We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module - ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, - ' since this is nothing our code fix touches. - Public Class ScalableControl - Inherits System.Windows.Forms.Control + ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + ' since this is nothing our code fix touches. + Public Class ScalableControl + Inherits System.Windows.Forms.Control - Public Property [|ScaleFactor|] As Single = 1.0F + Public Property [|ScaleFactor|] As Single = 1.0F - Public Property [|ScaledSize|] As SizeF + Public Property [|ScaledSize|] As SizeF - Public Property [|ScaledLocation|] As PointF - End Class + Public Property [|ScaledLocation|] As PointF + End Class - End Namespace - " +End Namespace +" - Private Const CorrectCode As String = " - Imports System.ComponentModel - Imports System.Drawing - Imports System.Windows.Forms + Private Const CorrectCode As String = +"Imports System.ComponentModel +Imports System.Drawing +Imports System.Windows.Forms - Namespace VBControls +Namespace VBControls - Public Module Program - Public Sub Main() - Dim control As New ScalableControl() + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() - control.ScaleFactor = 1.5F - control.ScaledSize = New SizeF(100, 100) - control.ScaledLocation = New PointF(10, 10) - End Sub - End Module + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module - Public Class ScalableControl - Inherits Control + Public Class ScalableControl + Inherits Control - - Public Property ScaleFactor As Single = 1.0F + + Public Property ScaleFactor As Single = 1.0F - - Public Property ScaledSize As SizeF + + Public Property ScaledSize As SizeF - Public Property ScaledLocation As PointF - Private Function ShouldSerializeScaledLocation() As Boolean - Return Me.ScaledLocation <> PointF.Empty - End Function - End Class + Public Property ScaledLocation As PointF + Private Function ShouldSerializeScaledLocation() As Boolean + Return Me.ScaledLocation <> PointF.Empty + End Function + End Class - End Namespace - " +End Namespace +" - Private Const FixedCode As String = " - Imports System.ComponentModel - Imports System.Drawing - Imports System.Windows.Forms + Private Const FixedCode As String = +"Imports System.ComponentModel +Imports System.Drawing +Imports System.Windows.Forms - Namespace VBControls +Namespace VBControls - Public Module Program - Public Sub Main() - Dim control As New ScalableControl() + Public Module Program + Public Sub Main() + Dim control As New ScalableControl() - ' We deliberately format this weirdly, to make sure we only format code our code fix touches. - control.ScaleFactor = 1.5F - control.ScaledSize = New SizeF(100, 100) - control.ScaledLocation = New PointF(10, 10) - End Sub - End Module + ' We deliberately format this weirdly, to make sure we only format code our code fix touches. + control.ScaleFactor = 1.5F + control.ScaledSize = New SizeF(100, 100) + control.ScaledLocation = New PointF(10, 10) + End Sub + End Module - ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, - ' since this is nothing our code fix touches. - Public Class ScalableControl - Inherits System.Windows.Forms.Control + ' We are writing the fully-qualified name here to make sure, the Simplifier doesn't remove it, + ' since this is nothing our code fix touches. + Public Class ScalableControl + Inherits System.Windows.Forms.Control - - Public Property ScaleFactor As Single = 1.0F + + Public Property ScaleFactor As Single = 1.0F - - Public Property ScaledSize As SizeF + + Public Property ScaledSize As SizeF - - Public Property ScaledLocation As PointF - End Class - - End Namespace - " + + Public Property ScaledLocation As PointF + End Class + +End Namespace +" ' We are testing the analyzer with all versions of the .NET SDK from 6.0 on. Public Shared Iterator Function GetReferenceAssemblies() As IEnumerable(Of Object()) From a94b865507ae1306d045b01e09777c0b867b9dac Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Fri, 21 Jun 2024 17:24:26 -0700 Subject: [PATCH 24/25] Fix merge issues. --- ...tionConfigurationInitializeBuilderTests.cs | 2 +- ...Windows.Forms.Analyzers.VisualBasic.vbproj | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs index 0888a15288d..ff3595863ee 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; -using System.Windows.Forms.Analyzers; +using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using static System.Windows.Forms.Analyzers.ApplicationConfig; namespace System.Windows.Forms.Analyzers.Tests; diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj new file mode 100644 index 00000000000..3f082b28e88 --- /dev/null +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/System.Windows.Forms.Analyzers.VisualBasic.vbproj @@ -0,0 +1,34 @@ + + + + System.Windows.Forms.Analyzers + netstandard2.0 + true + + 15.5 + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + true + System.Windows.Forms.Analyzers.VisualBasic.Resources + + + + From 3cf16307dc5c1ac0bd95ed9150b7321c489b190f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20L=C3=B6ffelmann?= Date: Wed, 24 Jul 2024 17:36:49 -0700 Subject: [PATCH 25/25] Address review feedback. --- eng/packageContent.targets | 4 +- .../src/AnalyzerReleases.Unshipped.md | 15 +++-- .../src/Resources/SR.resx | 18 ++--- .../src/Resources/xlf/SR.cs.xlf | 16 ++--- .../src/Resources/xlf/SR.de.xlf | 16 ++--- .../src/Resources/xlf/SR.es.xlf | 16 ++--- .../src/Resources/xlf/SR.fr.xlf | 16 ++--- .../src/Resources/xlf/SR.it.xlf | 16 ++--- .../src/Resources/xlf/SR.ja.xlf | 16 ++--- .../src/Resources/xlf/SR.ko.xlf | 16 ++--- .../src/Resources/xlf/SR.pl.xlf | 16 ++--- .../src/Resources/xlf/SR.pt-BR.xlf | 16 ++--- .../src/Resources/xlf/SR.ru.xlf | 16 ++--- .../src/Resources/xlf/SR.tr.xlf | 16 ++--- .../src/Resources/xlf/SR.zh-Hans.xlf | 16 ++--- .../src/Resources/xlf/SR.zh-Hant.xlf | 16 ++--- .../CSharpDiagnosticDescriptors.cs | 18 ++--- ...pertySerializationConfigurationAnalyzer.cs | 2 +- .../ApplicationConfigurationGenerator.cs | 24 +++---- ...ertySerializationDiagnosticAnalyzerTest.cs | 6 +- .../ApplicationConfigurationGeneratorTests.cs | 3 +- ...rSerializationVisibilityCodeFixProvider.cs | 2 +- .../src/AnalyzerReleases.Unshipped.md | 2 +- .../src/Resources/SR.resx | 8 +-- .../src/Resources/xlf/SR.cs.xlf | 6 +- .../src/Resources/xlf/SR.de.xlf | 6 +- .../src/Resources/xlf/SR.es.xlf | 6 +- .../src/Resources/xlf/SR.fr.xlf | 6 +- .../src/Resources/xlf/SR.it.xlf | 6 +- .../src/Resources/xlf/SR.ja.xlf | 6 +- .../src/Resources/xlf/SR.ko.xlf | 6 +- .../src/Resources/xlf/SR.pl.xlf | 6 +- .../src/Resources/xlf/SR.pt-BR.xlf | 6 +- .../src/Resources/xlf/SR.ru.xlf | 6 +- .../src/Resources/xlf/SR.tr.xlf | 6 +- .../src/Resources/xlf/SR.zh-Hans.xlf | 6 +- .../src/Resources/xlf/SR.zh-Hant.xlf | 6 +- .../VisualBasicDiagnosticDescriptors.vb | 6 +- .../src/AnalyzerReleases.Unshipped.md | 8 +-- .../src/Resources/SR.resx | 67 +++++++++++++++++-- .../src/Resources/xlf/SR.cs.xlf | 6 +- .../src/Resources/xlf/SR.de.xlf | 6 +- .../src/Resources/xlf/SR.es.xlf | 6 +- .../src/Resources/xlf/SR.fr.xlf | 6 +- .../src/Resources/xlf/SR.it.xlf | 6 +- .../src/Resources/xlf/SR.ja.xlf | 6 +- .../src/Resources/xlf/SR.ko.xlf | 6 +- .../src/Resources/xlf/SR.pl.xlf | 6 +- .../src/Resources/xlf/SR.pt-BR.xlf | 6 +- .../src/Resources/xlf/SR.ru.xlf | 6 +- .../src/Resources/xlf/SR.tr.xlf | 6 +- .../src/Resources/xlf/SR.zh-Hans.xlf | 6 +- .../src/Resources/xlf/SR.zh-Hant.xlf | 6 +- .../Analyzers/Diagnostics/DiagnosticIDs.cs | 20 +++--- .../SharedDiagnosticDescriptors.cs | 8 +-- .../Windows/Forms/Analyzers/IsExternalInit.cs | 7 ++ .../Analyzers/AppManifestAnalyzerTests.cs | 10 +-- 57 files changed, 331 insertions(+), 261 deletions(-) diff --git a/eng/packageContent.targets b/eng/packageContent.targets index e0f76e7a38d..1732e129d44 100644 --- a/eng/packageContent.targets +++ b/eng/packageContent.targets @@ -33,8 +33,8 @@ <_AnalyzerTargetLanguage>$(AssemblyName.Substring($(AssemblyName.LastIndexOf('.')))) - /CSharp - /VisualBasic + /cs + /vb diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md index 344e44977c5..25f28635322 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/AnalyzerReleases.Unshipped.md @@ -1,6 +1,14 @@ ; Unshipped analyzer release ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +WFO0001 | Application Configuration | Error | CSharpDiagnosticDescriptors +WFO0002 | Application Configuration | Error | CSharpDiagnosticDescriptors +WFO1000 | WinForms Security | Error | CSharpDiagnosticDescriptors + ### Removed Rules Rule ID | Category | Severity | Notes @@ -8,10 +16,3 @@ Rule ID | Category | Severity | Notes WFAC001 | Application Configuration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) WFAC002 | Application Configuration | Error | ApplicationConfigurationGenerator, [Documentation](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Analyzers.CSharp/ApplicationConfigurationGenerator.Help.md) -### New Rules - -Rule ID | Category | Severity | Notes ---------|----------|----------|------- -WFCA001 | Application Configuration | Error | CSharpDiagnosticDescriptors -WFCA002 | Application Configuration | Error | CSharpDiagnosticDescriptors -WFCA100 | WinForms Security | Error | ControlPropertySerializationDiagnosticAnalyzer diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx index 60f399c4c10..db337ade04f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/SR.resx @@ -117,19 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Unsupported project type - + Only projects with 'OutputType={0}' supported - + Unsupported property value - + ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. @@ -144,16 +144,16 @@ Only TrueType fonts are supported. '{0}' is not a TrueType font. - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Missing code serialization configuration for property content - + Property '{0}' does not configure the code serialization for its property content Add DesignerSerializationVisibilityAttribute to property - + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf index 249a85ac442..b7da4fa74d4 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.cs.xlf @@ -27,42 +27,42 @@ Analýza textu "{0}" se nezdařila. Byl očekáván text ve formátu {1}. - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf index 3dc8044402e..2fc05fab64e 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.de.xlf @@ -27,42 +27,42 @@ Der Text {0} kann nicht analysiert werden. Textformat {1} erwartet. - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf index 601be66163c..b35d9e057e6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.es.xlf @@ -27,42 +27,42 @@ No se pudo analizar el texto "{0}". Se esperaba el formato de texto "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf index 1b748c4d6f2..24dcdcf1ad0 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.fr.xlf @@ -27,42 +27,42 @@ Impossible d'analyser le texte "{0}". Le format du texte attendu est "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf index 88b20d7f8e4..7d50d6648d8 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.it.xlf @@ -27,42 +27,42 @@ Impossibile analizzare Text "{0}". Testo previsto nel formato "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf index 443872ed467..8a882ad8d6c 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ja.xlf @@ -27,42 +27,42 @@ テキスト "{0}" を解析できません。必要なテキストの形式は "{1}" です。 - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf index 88c220db991..a5565e3958d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ko.xlf @@ -27,42 +27,42 @@ 텍스트 "{0}"을(를) 구문 분석할 수 없습니다. 필요한 텍스트 형식은 "{1}"입니다. - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf index b654d9dd003..6329a26a159 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pl.xlf @@ -27,42 +27,42 @@ Nie można dokonać analizy elementu Text „{0}”. Oczekiwano tekstu w formacie „{1}”. - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf index f31471d5657..0e7c307b8b0 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.pt-BR.xlf @@ -27,42 +27,42 @@ O texto "{0}" não pode ser analisado. O formato de texto esperado é "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf index c97c97d396b..c018b1f9397 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.ru.xlf @@ -27,42 +27,42 @@ Не удается разобрать текст "{0}". Ожидаемый формат текста: "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf index 1207b160ce5..fa738d9bc45 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.tr.xlf @@ -27,42 +27,42 @@ {0} metni ayrıştırılamıyor. Beklenen metin biçimi: "{1}". - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf index 10d8ff7c630..012f5c98de4 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hans.xlf @@ -27,42 +27,42 @@ 无法分析文本“{0}”。文本格式应为“{1}”。 - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf index 9a93d8a6a35..30f6ca73680 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Resources/xlf/SR.zh-Hant.xlf @@ -27,42 +27,42 @@ 文字 "{0}" 無法剖析。預期的文字格式是 "{1}"。 - + Only projects with 'OutputType={0}' supported Only projects with 'OutputType={0}' supported - + Unsupported project type Unsupported project type - + ArgumentException: Project property '{0}' cannot be set to '{1}' ArgumentException: Project property '{0}' cannot be set to '{1}' - + ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. ArgumentException: Project property '{0}' cannot be set to '{1}'. Reason: {2}. - + Unsupported property value Unsupported property value - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs index d8a143d718b..be27d8e6a00 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/Diagnostics/CSharpDiagnosticDescriptors.cs @@ -11,34 +11,34 @@ internal static class CSharpDiagnosticDescriptors { public static readonly DiagnosticDescriptor s_errorUnsupportedProjectType = new(id: DiagnosticIDs.UnsupportedProjectType, - title: new LocalizableResourceString(nameof(SR.WFCA001Title), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA001Message), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO0001Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO0001Message), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.ApplicationConfiguration, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); public static readonly DiagnosticDescriptor s_propertyCantBeSetToValue = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA002Message), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO0002Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO0002Message), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.ApplicationConfiguration, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); public static readonly DiagnosticDescriptor s_propertyCantBeSetToValueWithReason = new(id: DiagnosticIDs.PropertyCantBeSetToValue, - title: new LocalizableResourceString(nameof(SR.WFCA002Title), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA002MessageWithReason), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO0002Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO0002MessageWithReason), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.ApplicationConfiguration, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); public static readonly DiagnosticDescriptor s_missingPropertySerializationConfiguration = new(id: DiagnosticIDs.MissingPropertySerializationConfiguration, - title: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerTitle), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO1000AnalyzerTitle), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO1000AnalyzerMessageFormat), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.WinFormsSecurity, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, - description: new LocalizableResourceString(nameof(SR.WFCA100AnalyzerDescription), SR.ResourceManager, typeof(SR))); + description: new LocalizableResourceString(nameof(SR.WFO1000AnalyzerDescription), SR.ResourceManager, typeof(SR))); } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs index 6fdf207a16a..52a79db8897 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Analyzers/MissingPropertySerializationConfiguration/MissingPropertySerializationConfigurationAnalyzer.cs @@ -37,7 +37,7 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) return; } - // Is the read/write and at least internal? + // Is the property read/write and at least internal? if (propertySymbol.SetMethod is null || propertySymbol.DeclaredAccessibility < Accessibility.Internal) { diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs index 296a564d63b..33607a4b953 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/CSharp/Generators/ApplicationConfiguration/ApplicationConfigurationGenerator.cs @@ -105,27 +105,25 @@ public void Initialize(IncrementalGeneratorInitializationContext context) applicationConfigDiagnostics: source.ApplicationConfigDiagnostics)); } - public static bool IsSupportedSyntaxNode(SyntaxNode syntaxNode) - { - return syntaxNode is InvocationExpressionSyntax + public static bool IsSupportedSyntaxNode(SyntaxNode syntaxNode) => + syntaxNode is InvocationExpressionSyntax { ArgumentList.Arguments.Count: 0, Expression: MemberAccessExpressionSyntax { Name.Identifier.ValueText: "Initialize", Expression: - MemberAccessExpressionSyntax // For: SourceGenerated.ApplicationConfiguration.Initialize() - { - Name.Identifier.ValueText: "ApplicationConfiguration" - } + MemberAccessExpressionSyntax // For: SourceGenerated.ApplicationConfiguration.Initialize() + { + Name.Identifier.ValueText: "ApplicationConfiguration" + } - or + or - IdentifierNameSyntax // For: ApplicationConfiguration.Initialize() with a using statement - { - Identifier.ValueText: "ApplicationConfiguration" - } + IdentifierNameSyntax // For: ApplicationConfiguration.Initialize() with a using statement + { + Identifier.ValueText: "ApplicationConfiguration" + } } }; - } } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs index af945f0fa65..e501bdda55f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Analyzers/MissingPropertySerializationConfiguration/ControlPropertySerializationDiagnosticAnalyzerTest.cs @@ -115,9 +115,9 @@ public class ScalableControl : System.Windows.Forms.Control // We are testing the analyzer with all versions of the .NET SDK from 6.0 on. public static IEnumerable GetReferenceAssemblies() { - // yield return [ReferenceAssemblies.Net.Net60Windows]; - // yield return [ReferenceAssemblies.Net.Net70Windows]; - // yield return [ReferenceAssemblies.Net.Net80Windows]; + yield return [ReferenceAssemblies.Net.Net60Windows]; + yield return [ReferenceAssemblies.Net.Net70Windows]; + yield return [ReferenceAssemblies.Net.Net80Windows]; yield return [ReferenceAssemblies.Net.Net90Windows]; } diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index a8e4d3439b2..064935b03e2 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text; +using System.Windows.Forms.Analyzers.Diagnostics; using System.Windows.Forms.CSharp.Generators.ApplicationConfiguration; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; @@ -68,7 +69,7 @@ public async Task CS_ApplicationConfigurationGenerator_GenerateInitialize_fails_ Sources = { SourceCompilationFailed }, ExpectedDiagnostics = { - DiagnosticResult.CompilerError("WFCA001").WithArguments("WindowsApplication"), + DiagnosticResult.CompilerError(DiagnosticIDs.UnsupportedProjectType).WithArguments("WindowsApplication"), } }, }; diff --git a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs index 6643c562821..62efeee2cd1 100644 --- a/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CodeFixes.CSharp/System/Windows/Forms/CSharp/CodeFixes/AddDesignerSerializationVisibility/AddDesignerSerializationVisibilityCodeFixProvider.cs @@ -71,7 +71,7 @@ private static async Task AddDesignerSerializationAttribute( .SelectMany(al => al.Attributes) .Any(a => a.Name.ToString() == DesignerSerializationVisibilityAttributeName)) { - Debug.Assert(false, "The attribute should not be there."); + Debug.Fail("The attribute should not be there."); return document; } diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md index 801e45de58e..b618d7b263a 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/AnalyzerReleases.Unshipped.md @@ -4,4 +4,4 @@ ### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFCA100 | WinForms Security | Error | ControlPropertySerializationDiagnosticAnalyzer +WFO1000 | WinForms Security | Error | VisualBasicDiagnosticDescriptors diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx index a869f0de5f0..b85c817719b 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/SR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Missing code serialization configuration for property content - + Property '{0}' does not configure the code serialization for its property content - + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf index ce0b8fe394f..524e3bded45 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.cs.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf index 19651251fe8..be4cdfec4ab 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.de.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf index fe8d2689547..dcfd72f230a 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.es.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf index 5149b0efe83..99eac544e11 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.fr.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf index d30cc9a84b1..b64798e47a7 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.it.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf index dec4d447d93..7c5de5cff90 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ja.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf index 9e07b8c8024..71349ef0c2a 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ko.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf index 09c771bf742..dd2eb4d6a38 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pl.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf index 64d7ad28b04..a8ec4b7736a 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.pt-BR.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf index 3d3e6c789ae..e096b18db92 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.ru.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf index 0002b039163..629ce04899e 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.tr.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf index 63ff0091356..5d73d81a966 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf index c8744c8fa57..ebee57c24ac 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,17 +2,17 @@ - + A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method. - + Property '{0}' does not configure the code serialization for its property content Property '{0}' does not configure the code serialization for its property content - + Missing code serialization configuration for property content Missing code serialization configuration for property content diff --git a/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb index b0b67bb27c7..529bf940d6f 100644 --- a/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb +++ b/src/System.Windows.Forms.Analyzers.VisualBasic/src/System/Windows/Forms/VisualBasic/Diagnostic/VisualBasicDiagnosticDescriptors.vb @@ -9,11 +9,11 @@ Friend Module VisualBasicDiagnosticDescriptors Public ReadOnly s_missingPropertySerializationConfiguration As New DiagnosticDescriptor( id:=DiagnosticIDs.MissingPropertySerializationConfiguration, - title:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerTitle), SR.ResourceManager, GetType(SR)), - messageFormat:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), + title:=New LocalizableResourceString(NameOf(SR.WFO1000AnalyzerTitle), SR.ResourceManager, GetType(SR)), + messageFormat:=New LocalizableResourceString(NameOf(SR.WFO1000AnalyzerMessageFormat), SR.ResourceManager, GetType(SR)), category:=DiagnosticCategories.WinFormsSecurity, defaultSeverity:=DiagnosticSeverity.Error, isEnabledByDefault:=True, - description:=New LocalizableResourceString(NameOf(SR.WFCA100AnalyzerDescription), SR.ResourceManager, GetType(SR))) + description:=New LocalizableResourceString(NameOf(SR.WFO1000AnalyzerDescription), SR.ResourceManager, GetType(SR))) End Module diff --git a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md index db72596d24b..5bab43163c0 100644 --- a/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md +++ b/src/System.Windows.Forms.Analyzers/src/AnalyzerReleases.Unshipped.md @@ -1,14 +1,14 @@ ; Unshipped analyzer release ; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md -### Removed Rules +### New Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFAC010 | Application Configuration | Warning | DiagnosticDescriptors +WFO0003 | Application Configuration | Warning | SharedDiagnosticDescriptors -### New Rules +### Removed Rules Rule ID | Category | Severity | Notes --------|----------|----------|------- -WFCA010 | Application Configuration | Warning | DiagnosticDescriptors +WFAC010 | Application Configuration | Warning | DiagnosticDescriptors diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx b/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx index c7ece20377e..8a45c4409c0 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx @@ -1,5 +1,64 @@  + @@ -58,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Unsupported high DPI configuration - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + \ No newline at end of file diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf index 01cce675e9b..53504c96e5a 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.cs.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf index 0fc1da645ce..e00efde08ce 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.de.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf index db4484a933e..6dfdb4380d9 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.es.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf index 5e3b11379ae..1c0851279af 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.fr.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf index 6b0edf46eba..6555d0e84fd 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.it.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf index eed0c5b5854..fc2364f2d5c 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ja.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf index 5e26e25aa77..35064e57ee1 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ko.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf index 7d89062429d..68e4f9ab65f 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pl.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf index bd2b3c2c614..285c0002c2e 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.pt-BR.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf index 50cde8cbf4c..2a1b5f2fd2f 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.ru.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf index 045ee342521..2a8b4a55f7e 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.tr.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf index d703b579395..ae612122627 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf index 9124f1e815c..fd34c52dba4 100644 --- a/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Analyzers/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,17 +2,17 @@ - + Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property Remove high DPI settings from {0} and configure via Application.SetHighDpiMode API or '{1}' project property - + Remove high DPI settings from {0} and configure via '{1}' property in Application Framework Remove high DPI settings from {0} and configure via '{1}' property in Application Framework - + Unsupported high DPI configuration Unsupported high DPI configuration diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs index 4ac22da3f01..10381e1b716 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs @@ -5,14 +5,18 @@ namespace System.Windows.Forms.Analyzers.Diagnostics; internal static class DiagnosticIDs { - // Application Configuration - public const string UnsupportedProjectType = "WFCA001"; - public const string PropertyCantBeSetToValue = "WFCA002"; - public const string MigrateHighDpiSettings = "WFCA010"; + // Application Configuration, number group 0001+ + public const string UnsupportedProjectType = "WFO0001"; + public const string PropertyCantBeSetToValue = "WFO0002"; + public const string MigrateHighDpiSettings = "WFO0003"; - // Security - public const string MissingPropertySerializationConfiguration = "WFCA100"; + // Security, number group 1000+ + public const string MissingPropertySerializationConfiguration = "WFO1000"; - // WinForms Usage - public const string DisposeModalDialog = "WFCA500"; + // WinForms best practize, number group 2000+ + public const string DisposeModalDialog = "WFO2000"; + + // Experimental, number group 9000+ + public const string ExperimentalVisualStyles = "WFO9000"; + public const string ExperimentalDarkMode = "WFO9001"; } diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs index e622d570bfe..27a3e490921 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/SharedDiagnosticDescriptors.cs @@ -10,16 +10,16 @@ internal static partial class SharedDiagnosticDescriptors { internal static readonly DiagnosticDescriptor s_cSharpMigrateHighDpiSettings = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_CS), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO0003Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO0003Message_CS), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.ApplicationConfiguration, defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); internal static readonly DiagnosticDescriptor s_visualBasicMigrateHighDpiSettings = new(id: DiagnosticIDs.MigrateHighDpiSettings, - title: new LocalizableResourceString(nameof(SR.WFCA010Title), SR.ResourceManager, typeof(SR)), - messageFormat: new LocalizableResourceString(nameof(SR.WFCA010Message_VB), SR.ResourceManager, typeof(SR)), + title: new LocalizableResourceString(nameof(SR.WFO0003Title), SR.ResourceManager, typeof(SR)), + messageFormat: new LocalizableResourceString(nameof(SR.WFO0003Message_VB), SR.ResourceManager, typeof(SR)), category: DiagnosticCategories.ApplicationConfiguration, defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs index 4590fd1d388..67ccfa8252f 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/IsExternalInit.cs @@ -1,8 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace System.Runtime.CompilerServices { + /// + /// Reserved to be used by the compiler for tracking metadata. + /// This class should not be used by developers in source code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] internal static class IsExternalInit { } diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index 46495fd9978..2832d5abefd 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -36,9 +36,9 @@ public async Task AppManifestAnalyzer_no_op_if_no_manifest_file() => { TestCode = CSharpCode, TestState = - { - AdditionalFiles = { } - } + { + AdditionalFiles = { } + } }.RunAsync(); [Fact] @@ -133,7 +133,7 @@ public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_in TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) }, - AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFCA010.severity = none") } + AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.{DiagnosticIDs.MigrateHighDpiSettings}.severity = none") } } }.RunAsync(); } @@ -152,7 +152,7 @@ public async Task AppManifestAnalyzer_can_suppressed_if_manifest_file_has_dpi_in TestState = { AdditionalFiles = { (manifestFilePath, manifestFile) }, - AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.WFCA010.severity = none") } + AnalyzerConfigFiles = { ("/.globalconfig", $"is_global = true\r\ndotnet_diagnostic.{DiagnosticIDs.MigrateHighDpiSettings}.severity = none") } } }.RunAsync(); }