From 3c0c7dae0fe407097af6455adbfb4d6e8b8ba600 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 22:36:49 -0600 Subject: [PATCH] Use top-level test folder --- .editorconfig | 8 ++ Directory.Build.props | 43 ++++++++++ Directory.Build.targets | 8 ++ Expand-Template.ps1 | 22 +++--- Library.sln | 28 +++++-- azure-pipelines/artifacts/testResults.ps1 | 4 +- src/.editorconfig | 0 src/Directory.Build.props | 44 +---------- src/Directory.Build.targets | 8 +- src/Library.Tests/Library.Tests.csproj | 23 ------ src/Library/Library.csproj | 5 -- src/shipping.ruleset | 74 ------------------ src/tests.ruleset | 18 ----- src/strongname.snk => strongname.snk | Bin src/stylecop.json => stylecop.json | 0 test/.editorconfig | 28 +++++++ test/Directory.Build.props | 11 +++ test/Directory.Build.targets | 3 + .../Library.Tests/CalculatorTests.cs | 0 test/Library.Tests/Library.Tests.csproj | 14 ++++ {src => test}/Library.Tests/app.config | 0 tools/Install-DotNetSdk.ps1 | 2 +- 22 files changed, 157 insertions(+), 186 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Build.targets create mode 100644 src/.editorconfig delete mode 100644 src/Library.Tests/Library.Tests.csproj delete mode 100644 src/shipping.ruleset delete mode 100644 src/tests.ruleset rename src/strongname.snk => strongname.snk (100%) rename src/stylecop.json => stylecop.json (100%) create mode 100644 test/.editorconfig create mode 100644 test/Directory.Build.props create mode 100644 test/Directory.Build.targets rename {src => test}/Library.Tests/CalculatorTests.cs (100%) create mode 100644 test/Library.Tests/Library.Tests.csproj rename {src => test}/Library.Tests/app.config (100%) diff --git a/.editorconfig b/.editorconfig index 3a833bd..979d170 100644 --- a/.editorconfig +++ b/.editorconfig @@ -155,3 +155,11 @@ csharp_new_line_before_members_in_anonymous_types = true # Blocks are allowed csharp_prefer_braces = true:silent + +[*.cs] + +# SA1130: Use lambda syntax +dotnet_diagnostic.SA1130.severity = silent + +[*.sln] +indent_style = tab diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..7a97368 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,43 @@ + + + Debug + $(MSBuildThisFileDirectory) + $(RepoRootPath)obj\$(MSBuildProjectName)\ + $(RepoRootPath)bin\$(MSBuildProjectName)\ + $(RepoRootPath)bin\Packages\$(Configuration)\ + 8.0 + enable + true + + true + $(MSBuildThisFileDirectory)\strongname.snk + + COMPANY-PLACEHOLDER + COMPANY-PLACEHOLDER + © COMPANY-PLACEHOLDER. All rights reserved. + MIT + true + true + true + snupkg + + + + + + + + + + + + + + + + + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..1ddcba6 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,8 @@ + + + cobertura + [xunit.*]* + + $(OutputPath)/ + + diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 6a030fc..9a05ece 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -83,20 +83,20 @@ try { git mv Library.sln "$LibraryName.sln" git mv src/Library/Library.csproj "src/Library/$LibraryName.csproj" git mv src/Library "src/$LibraryName" - git mv src/Library.Tests/Library.Tests.csproj "src/Library.Tests/$LibraryName.Tests.csproj" - git mv src/Library.Tests "src/$LibraryName.Tests" + git mv test/Library.Tests/Library.Tests.csproj "test/Library.Tests/$LibraryName.Tests.csproj" + git mv test/Library.Tests "test/$LibraryName.Tests" # Refresh solution file both to update paths and give the projects unique GUIDs dotnet sln remove src/Library/Library.csproj - dotnet sln remove src/Library.Tests/Library.Tests.csproj + dotnet sln remove test/Library.Tests/Library.Tests.csproj dotnet sln add "src/$LibraryName" - dotnet sln add "src/$LibraryName.Tests" + dotnet sln add "test/$LibraryName.Tests" git add "$LibraryName.sln" # Update project reference in test project. Add before removal to keep the same ItemGroup in place. - dotnet add "src/$LibraryName.Tests" reference "src/$LibraryName" - dotnet remove "src/$LibraryName.Tests" reference src/Library/Library.csproj - git add "src/$LibraryName.Tests/$LibraryName.Tests.csproj" + dotnet add "test/$LibraryName.Tests" reference "src/$LibraryName" + dotnet remove "test/$LibraryName.Tests" reference src/Library/Library.csproj + git add "test/$LibraryName.Tests/$LibraryName.Tests.csproj" # Establish a new strong-name key & $sn.Path -k 2048 src/strongname.snk @@ -107,17 +107,17 @@ try { 'Library'=$LibraryName 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/$LibraryName.Tests/CalculatorTests.cs" -Replacements @{ + Replace-Placeholders -Path "test/$LibraryName.Tests/CalculatorTests.cs" -Replacements @{ 'Library'=$LibraryName 'COMPANY-PLACEHOLDER'=$Author } Replace-Placeholders -Path "LICENSE" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/stylecop.json" -Replacements @{ + Replace-Placeholders -Path "stylecop.json" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/Directory.Build.props" -Replacements @{ + Replace-Placeholders -Path "Directory.Build.props" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } Replace-Placeholders -Path "README.md" -Replacements @{ @@ -174,4 +174,4 @@ try { } # When testing this script, all the changes can be quickly reverted with this command: -# git reset HEAD :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git co -- :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git clean -fd :/src +# git reset HEAD :/README.md :/LICENSE :/azure-pipelines.yml :/src :/test :/azure-pipelines; git co -- :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git clean -fd :/src :/test diff --git a/Library.sln b/Library.sln index d034f5b..85b8939 100644 --- a/Library.sln +++ b/Library.sln @@ -5,21 +5,33 @@ VisualStudioVersion = 16.0.29322.22 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "src\Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "src\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "test\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - src\Directory.Build.props = src\Directory.Build.props - src\Directory.Build.targets = src\Directory.Build.targets + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets global.json = global.json nuget.config = nuget.config - src\shipping.ruleset = src\shipping.ruleset - src\stylecop.json = src\stylecop.json - src\tests.ruleset = src\tests.ruleset + stylecop.json = stylecop.json version.json = version.json EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E154A29-1796-4B85-BD81-B6A385D8FF71}" + ProjectSection(SolutionItems) = preProject + src\.editorconfig = src\.editorconfig + src\Directory.Build.props = src\Directory.Build.props + src\Directory.Build.targets = src\Directory.Build.targets + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}" + ProjectSection(SolutionItems) = preProject + test\.editorconfig = test\.editorconfig + test\Directory.Build.props = test\Directory.Build.props + test\Directory.Build.targets = test\Directory.Build.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +50,10 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9E154A29-1796-4B85-BD81-B6A385D8FF71} = {1CE9670B-D5FF-46A7-9D00-24E70E6ED48B} + {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A} = {1CE9670B-D5FF-46A7-9D00-24E70E6ED48B} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E3944F6A-384B-4B0F-B93F-3BD513DC57BD} EndGlobalSection diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index bc9e046..1e4c4c4 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -5,8 +5,8 @@ if ($env:AGENT_TEMPDIRECTORY) { $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); } } else { - $srcRoot = Resolve-Path "$PSScriptRoot\..\..\src" + $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" @{ - $srcRoot = (Get-ChildItem "$srcRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); + $testRoot = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); } } diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 0000000..e69de29 diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ce9c319..50b6409 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,43 +1,7 @@ - + + + - Debug - $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\')) - $(RepoRootPath)obj\$(MSBuildProjectName)\ - $(RepoRootPath)bin\$(MSBuildProjectName)\ - $(RepoRootPath)bin\Packages\$(Configuration)\ - 8.0 - enable - true - - true - $(MSBuildThisFileDirectory)\strongname.snk - - COMPANY-PLACEHOLDER - COMPANY-PLACEHOLDER - © COMPANY-PLACEHOLDER. All rights reserved. - MIT - true - true - true - snupkg + netstandard2.0 - - - - - - - - - - - - - - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 8f529fa..ada7665 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -3,10 +3,6 @@ false - - cobertura - [xunit.*]* - - $(OutputPath)/ - + + diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj deleted file mode 100644 index 8018f97..0000000 --- a/src/Library.Tests/Library.Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net472;netcoreapp2.1;netcoreapp3.1 - false - $(NoWarn);CS1591 - true - ..\tests.ruleset - - - - - - - - - - - - - - - diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index ae6eca9..61718a1 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,8 +1,3 @@ - - netstandard2.0 - ..\shipping.ruleset - - diff --git a/src/shipping.ruleset b/src/shipping.ruleset deleted file mode 100644 index 7290354..0000000 --- a/src/shipping.ruleset +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/tests.ruleset b/src/tests.ruleset deleted file mode 100644 index a136597..0000000 --- a/src/tests.ruleset +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/strongname.snk b/strongname.snk similarity index 100% rename from src/strongname.snk rename to strongname.snk diff --git a/src/stylecop.json b/stylecop.json similarity index 100% rename from src/stylecop.json rename to stylecop.json diff --git a/test/.editorconfig b/test/.editorconfig new file mode 100644 index 0000000..eac6d8a --- /dev/null +++ b/test/.editorconfig @@ -0,0 +1,28 @@ +[*.cs] + +# SA1600: Elements should be documented +dotnet_diagnostic.SA1600.severity = silent + +# SA1601: Partial elements should be documented +dotnet_diagnostic.SA1601.severity = silent + +# SA1602: Enumeration items should be documented +dotnet_diagnostic.SA1602.severity = silent + +# SA1615: Element return value should be documented +dotnet_diagnostic.SA1615.severity = silent + +# VSTHRD103: Call async methods when in an async method +dotnet_diagnostic.VSTHRD103.severity = silent + +# VSTHRD111: Use .ConfigureAwait(bool) +dotnet_diagnostic.VSTHRD111.severity = none + +# VSTHRD200: Use Async suffix for async methods +dotnet_diagnostic.VSTHRD200.severity = silent + +# CA1303: Do not pass literals as localized parameters +dotnet_diagnostic.CA1303.severity = none + +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = silent diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000..66b41d5 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,11 @@ + + + + + net472;netcoreapp2.1;netcoreapp3.1 + false + true + + + + diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets new file mode 100644 index 0000000..6a5a72c --- /dev/null +++ b/test/Directory.Build.targets @@ -0,0 +1,3 @@ + + + diff --git a/src/Library.Tests/CalculatorTests.cs b/test/Library.Tests/CalculatorTests.cs similarity index 100% rename from src/Library.Tests/CalculatorTests.cs rename to test/Library.Tests/CalculatorTests.cs diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj new file mode 100644 index 0000000..6113925 --- /dev/null +++ b/test/Library.Tests/Library.Tests.csproj @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Library.Tests/app.config b/test/Library.Tests/app.config similarity index 100% rename from src/Library.Tests/app.config rename to test/Library.Tests/app.config diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 8d77a9f..7f9bf6c 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -31,7 +31,7 @@ $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1 # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() -Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { +Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { $projXml = [xml](Get-Content -Path $_) $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework if (!$targetFrameworks) {