From ae409e92c4bf8650d08dd3398d090cac872f6240 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Wed, 12 Jan 2022 18:34:37 +1000 Subject: [PATCH 1/2] SA1509 Opening braces should not be preceded by blank line --- eng/Common.globalconfig | 2 +- src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs | 1 - src/Build/Utilities/EngineFileUtilities.cs | 1 - src/MSBuild/CommandLineSwitchException.cs | 1 - src/MSBuild/InitializationException.cs | 1 - src/StringTools/StringTools.cs | 1 - src/Tasks.UnitTests/XslTransformation_Tests.cs | 2 -- 7 files changed, 1 insertion(+), 8 deletions(-) diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index ba417e063f2..d4104d11ecd 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -996,7 +996,7 @@ dotnet_diagnostic.SA1507.severity = suggestion dotnet_diagnostic.SA1508.severity = suggestion # Opening braces should not be preceded by blank line -dotnet_diagnostic.SA1509.severity = suggestion +dotnet_diagnostic.SA1509.severity = warning # 'else' statement should not be preceded by a blank line dotnet_diagnostic.SA1510.severity = suggestion diff --git a/src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs b/src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs index 1bd2d2e55de..e6ce265d280 100644 --- a/src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs +++ b/src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs @@ -3338,7 +3338,6 @@ public void UpdateAndRemoveShouldUseCaseInsensitiveMatching() public static IEnumerable UpdateAndRemoveShouldWorkWithEscapedCharactersTestData { get - { var expectedMetadata = new[] { diff --git a/src/Build/Utilities/EngineFileUtilities.cs b/src/Build/Utilities/EngineFileUtilities.cs index 5ee535bc9b7..52ce8f00319 100644 --- a/src/Build/Utilities/EngineFileUtilities.cs +++ b/src/Build/Utilities/EngineFileUtilities.cs @@ -53,7 +53,6 @@ internal static string[] GetFileListUnescaped string directoryEscaped, string filespecEscaped ) - { return GetFileList(directoryEscaped, filespecEscaped, returnEscaped: false, forceEvaluateWildCards: false, excludeSpecsEscaped: null, fileMatcher: FileMatcher.Default); } diff --git a/src/MSBuild/CommandLineSwitchException.cs b/src/MSBuild/CommandLineSwitchException.cs index b1ee673c8ee..d5a4b8bb7a6 100644 --- a/src/MSBuild/CommandLineSwitchException.cs +++ b/src/MSBuild/CommandLineSwitchException.cs @@ -56,7 +56,6 @@ private CommandLineSwitchException StreamingContext context ) : base(info, context) - { ErrorUtilities.VerifyThrowArgumentNull(info, nameof(info)); diff --git a/src/MSBuild/InitializationException.cs b/src/MSBuild/InitializationException.cs index 0461ba155f2..deb2a93f11c 100644 --- a/src/MSBuild/InitializationException.cs +++ b/src/MSBuild/InitializationException.cs @@ -61,7 +61,6 @@ private InitializationException StreamingContext context ) : base(info, context) - { ErrorUtilities.VerifyThrowArgumentNull(info, nameof(info)); diff --git a/src/StringTools/StringTools.cs b/src/StringTools/StringTools.cs index fbe794342b9..664057961b5 100644 --- a/src/StringTools/StringTools.cs +++ b/src/StringTools/StringTools.cs @@ -6,7 +6,6 @@ namespace Microsoft.NET.StringTools { public static class Strings - { #region Fields diff --git a/src/Tasks.UnitTests/XslTransformation_Tests.cs b/src/Tasks.UnitTests/XslTransformation_Tests.cs index 59223662e76..cf2cab02dfc 100644 --- a/src/Tasks.UnitTests/XslTransformation_Tests.cs +++ b/src/Tasks.UnitTests/XslTransformation_Tests.cs @@ -864,7 +864,6 @@ public void CompiledDllWithTwoTypes() string doubleTypePath = Path.Combine(dir, "double.dll"); CompileDoubleType(doubleTypePath); - { XslTransformation t = new XslTransformation(); t.BuildEngine = engine; @@ -912,7 +911,6 @@ public void MultipleXmlInputs_Matching() // outputPaths have one output path, lets duplicate it TaskItem[] outputMultiPaths = new TaskItem[] { new TaskItem(outputPaths[0].ItemSpec + ".1.xml"), new TaskItem(outputPaths[0].ItemSpec + ".2.xml"), new TaskItem(outputPaths[0].ItemSpec + ".3.xml"), new TaskItem(outputPaths[0].ItemSpec + ".4.xml") }; - { XslTransformation t = new XslTransformation(); t.BuildEngine = engine; From 694db9585b7a92df5aca96a93e0fe2dad1ad1e7b Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Wed, 19 Jan 2022 08:24:05 +1000 Subject: [PATCH 2/2] Remove braces and additional refactor --- .../XslTransformation_Tests.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Tasks.UnitTests/XslTransformation_Tests.cs b/src/Tasks.UnitTests/XslTransformation_Tests.cs index cf2cab02dfc..467ebc482cb 100644 --- a/src/Tasks.UnitTests/XslTransformation_Tests.cs +++ b/src/Tasks.UnitTests/XslTransformation_Tests.cs @@ -864,25 +864,26 @@ public void CompiledDllWithTwoTypes() string doubleTypePath = Path.Combine(dir, "double.dll"); CompileDoubleType(doubleTypePath); - { - XslTransformation t = new XslTransformation(); - t.BuildEngine = engine; - t.OutputPaths = outputPaths; - t.XmlContent = _xmlDocument; - t.XslCompiledDllPath = new TaskItem(doubleTypePath); - try - { - t.Execute(); - Console.WriteLine(engine.Log); - } - catch (Exception e) - { - Assert.Contains("error?", e.Message); - } - System.Diagnostics.Debug.WriteLine(engine.Log); + XslTransformation t = new() + { + BuildEngine = engine, + OutputPaths = outputPaths, + XmlContent = _xmlDocument, + XslCompiledDllPath = new TaskItem(doubleTypePath), + }; + try + { + t.Execute(); + Console.WriteLine(engine.Log); + } + catch (Exception e) + { + Assert.Contains("error?", e.Message); } + System.Diagnostics.Debug.WriteLine(engine.Log); + CleanUp(dir); } #endif