diff --git a/.editorconfig b/.editorconfig index 0b172c41ab..a0e1655de2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -233,6 +233,9 @@ dotnet_diagnostic.CA1816.severity = warning # not default, increased severity to # CA1018: Mark attributes with AttributeUsageAttribute dotnet_diagnostic.CA1018.severity = warning # not default, increased severity to ensure it is applied +# CA1051: Do not declare visible instance fields +dotnet_diagnostic.CA1051.severity = warning # not default, increased severity to ensure it is applied + #### C# Coding Conventions #### # var preferences diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs index 88227019f1..522881f531 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs @@ -44,9 +44,11 @@ public class DesignModeClient : IDesignModeClient private readonly IEnvironment _platformEnvironment; private readonly TestSessionMessageLogger _testSessionMessageLogger; private readonly object _lockObject = new(); - [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + [SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Part of the public API")] protected Action? onCustomTestHostLaunchAckReceived; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + [SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Part of the public API")] protected Action? onAttachDebuggerAckRecieved; /// diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs index 12f841ed5f..12af69e5b2 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; @@ -10,6 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; /// It stores the all relevant information of the test run. /// [DataContract] +[SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Part of the public API")] public sealed class TestRunDetails { /// diff --git a/test/.editorconfig b/test/.editorconfig index 2be7bb24d6..0197e0b09d 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -15,6 +15,9 @@ dotnet_diagnostic.IDE0060.severity = warning # CA1018: Mark attributes with AttributeUsageAttribute dotnet_diagnostic.CA1018.severity = warning +# CA1051: Do not declare visible instance fields +dotnet_diagnostic.CA1051.severity = silent # Disabled on tests as it does not matter + #### C# Coding Conventions #### #### .NET Formatting Rules #### diff --git a/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs b/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs index e8855920d4..98097a2972 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs @@ -11,7 +11,7 @@ namespace Microsoft.TestPlatform.TestUtilities; public class TestableTestPluginCache : TestPluginCache { - public Action? Action; + public Action? Action { get; set; } public TestableTestPluginCache(List extensionsPath) {