From 2e3a2b3f96f67c7dfc72963e5135662d3230b5fe Mon Sep 17 00:00:00 2001 From: CleanCodeDeveloper <16760760+CleanCodeDeveloper@users.noreply.github.com> Date: Fri, 18 Mar 2022 17:47:18 +0100 Subject: [PATCH] [meta]common csproj/vcxproj settings to Directory.Build.props (#17067) * Add common csproj/vcxproj settings to Directory.Build.props * Set TreatWarningsAsErrors to true for all c# projects * Minor fixes in unit test projects where Analyzers where not enabled before * Clean up Directory.Build.props * Remove properties from ImageResizer csprojs files --- Directory.Build.props | 20 +++++++++++++++++-- PowerToys.sln | 1 + .../tests/ImageResizerUITest.csproj | 17 ---------------- .../imageresizer/ui/ImageResizerUI.csproj | 13 ------------ .../DriveOrSharedFolderTests.cs | 4 ++-- .../GcodePreviewHandlerTest.cs | 1 + .../PdfPreviewHandlerTest.cs | 1 + .../SvgPreviewControlTests.cs | 1 + 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b487d980ac..910bf222a5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,24 @@ - - + + + + Copyright (C) 2022 Microsoft Corporation + Microsoft Corp. + Copyright (C) 2022 Microsoft Corporation + PowerToys + Microsoft Corporation + en-US + x64 + true + Recommended + + + + true + <_PropertySheetDisplayName>PowerToys.Root.Props $(MsbuildThisFileDirectory)\Cpp.Build.props + \ No newline at end of file diff --git a/PowerToys.sln b/PowerToys.sln index f56d438622..0e665755df 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -177,6 +177,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject src\.editorconfig = src\.editorconfig .vsconfig = .vsconfig + Directory.Build.props = Directory.Build.props Solution.props = Solution.props EndProjectSection EndProject diff --git a/src/modules/imageresizer/tests/ImageResizerUITest.csproj b/src/modules/imageresizer/tests/ImageResizerUITest.csproj index 809b5f7230..d87199465f 100644 --- a/src/modules/imageresizer/tests/ImageResizerUITest.csproj +++ b/src/modules/imageresizer/tests/ImageResizerUITest.csproj @@ -8,28 +8,11 @@ Properties ImageResizer ImageResizer.Test - Microsoft Corp. - Copyright (C) 2022 Microsoft Corp. $(Version).0 $(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer\$(AssemblyName)\ - ..\..\..\codeAnalysis\Rules.ruleset - x64 - - - - x64 - true $(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\ - true - Recommended - - x64 - - - x64 - diff --git a/src/modules/imageresizer/ui/ImageResizerUI.csproj b/src/modules/imageresizer/ui/ImageResizerUI.csproj index c37f536ecd..3d4a3fa602 100644 --- a/src/modules/imageresizer/ui/ImageResizerUI.csproj +++ b/src/modules/imageresizer/ui/ImageResizerUI.csproj @@ -3,44 +3,31 @@ PowerToys.ImageResizer - Microsoft Corp. - Copyright (C) 2022 Microsoft Corp. - ..\..\..\codeAnalysis\Rules.ruleset $(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer false false true - x64 - x64 {2BE46397-4DFA-414C-9BD4-41E4BBF8CB34} WinExe ImageResizer PowerToys.ImageResizer net6.0-windows10.0.18362.0 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - true $(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\ - true - Recommended Resources\ImageResizer.ico - en-US - true true - x64 - true false - x64 diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs index 1c6ea106f6..e521246768 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/DriveOrSharedFolderTests.cs @@ -93,11 +93,11 @@ namespace Microsoft.Plugin.Folder.UnitTests // Assert if (hasValues) { - Assert.IsTrue(results.Count() > 0); + Assert.IsTrue(results.Any()); } else { - Assert.IsTrue(results.Count() == 0); + Assert.IsFalse(results.Any()); } } } diff --git a/src/modules/previewpane/UnitTests-GcodePreviewHandler/GcodePreviewHandlerTest.cs b/src/modules/previewpane/UnitTests-GcodePreviewHandler/GcodePreviewHandlerTest.cs index ad01086586..e1b7a24554 100644 --- a/src/modules/previewpane/UnitTests-GcodePreviewHandler/GcodePreviewHandlerTest.cs +++ b/src/modules/previewpane/UnitTests-GcodePreviewHandler/GcodePreviewHandlerTest.cs @@ -16,6 +16,7 @@ using Moq; namespace GcodePreviewHandlerUnitTests { [STATestClass] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2201:Do not raise reserved exception types", Justification = "new Exception() is fine in test projects.")] public class GcodePreviewHandlerTest { [TestMethod] diff --git a/src/modules/previewpane/UnitTests-PdfPreviewHandler/PdfPreviewHandlerTest.cs b/src/modules/previewpane/UnitTests-PdfPreviewHandler/PdfPreviewHandlerTest.cs index 68545a012c..e7952a13e5 100644 --- a/src/modules/previewpane/UnitTests-PdfPreviewHandler/PdfPreviewHandlerTest.cs +++ b/src/modules/previewpane/UnitTests-PdfPreviewHandler/PdfPreviewHandlerTest.cs @@ -16,6 +16,7 @@ using Moq; namespace PdfPreviewHandlerUnitTests { [STATestClass] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2201:Do not raise reserved exception types", Justification = "new Exception() is fine in test projects.")] public class PdfPreviewHandlerTest { [TestMethod] diff --git a/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs b/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs index 5ad0f1db88..21611d06a9 100644 --- a/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs +++ b/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs @@ -17,6 +17,7 @@ using PreviewHandlerCommon; namespace SvgPreviewHandlerUnitTests { [STATestClass] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2201:Do not raise reserved exception types", Justification = "new Exception() is fine in test projects.")] public class SvgPreviewControlTests { [TestMethod]