diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..7828719 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "benchmarkdotnet.tool": { + "version": "0.12.0", + "commands": [ + "dotnet-benchmark" + ] + }, + "nuke.globaltool": { + "version": "0.24.4", + "commands": [ + "nuke" + ] + } + } +} \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..0fa0fe2 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,28 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [GitHubActions (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_dotnet --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: dotnet + +on: [push, pull_request] + +jobs: + ubuntu-latest: + name: ubuntu-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run './test/build.cmd ' + run: ./test/build.cmd diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 70b0c85..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Publish -on: - push: - tags: - - '**' -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1.4.0 - with: - dotnet-version: 3.1.101 - source-url: https://nuget.pkg.github.com/baez90/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: Pack for deploying package - run: dotnet pack --configuration Release - working-directory: ./src/tand/ - - name: Publish Core package - run: dotnet nuget push "Tand.Core/bin/Release/Tand.Core.0.0.1.nupkg" - working-directory: ./src/tand/ - - name: Publish DI extensions package - run: dotnet nuget push "Tand.Extensions.DependencyInjection/bin/Release/Tand.Extensions.DependencyInjection.0.0.1.nupkg" - working-directory: ./src/tand/ \ No newline at end of file diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index 7d69b7a..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Validate - -on: - push: - branches: [ '**' ] - pull_request: - branches: [ '**' ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1.4.0 - with: - dotnet-version: 3.1.101 - source-url: https://nuget.pkg.github.com/baez90/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: Build with dotnet - run: dotnet build --configuration Release - working-directory: ./src/tand/ - - name: Run tests - run: dotnet test --configuration Release --no-build - working-directory: ./src/tand/ diff --git a/.gitignore b/.gitignore index 710698c..9cc6249 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,11 @@ ############### /**/DROP/ /**/TEMP/ +**/.tmp/ /**/packages/ /**/bin/ /**/obj/ _site .idea/ +*.Artifacts/ +**/artifacts/ diff --git a/.nuke b/.nuke new file mode 100644 index 0000000..8c26cb1 --- /dev/null +++ b/.nuke @@ -0,0 +1 @@ +Tand.sln \ No newline at end of file diff --git a/src/tand/Tand.sln b/Tand.sln similarity index 67% rename from src/tand/Tand.sln rename to Tand.sln index ee3a12c..b150fff 100644 --- a/src/tand/Tand.sln +++ b/Tand.sln @@ -1,86 +1,118 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Core", "Tand.Core\Tand.Core.csproj", "{994166B2-862B-451B-B3E5-B2797EFF7022}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4A0DFFF5-7BB2-481A-BB0F-152D89823F48}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C51CA370-A0C7-4229-90FA-ADF7B51DE021}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Core.Tests", "Tand.Core.Tests\Tand.Core.Tests.csproj", "{7CFEE412-6D6A-407B-9FAE-1640F74D98E7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Extensions.DependencyInjection", "Tand.Extensions.DependencyInjection\Tand.Extensions.DependencyInjection.csproj", "{C535C043-7A0E-4F17-89E4-493E7805CFAC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Extensions.DependencyInjection.Tests", "Tand.Extensions.DependencyInjection.Tests\Tand.Extensions.DependencyInjection.Tests.csproj", "{D1287B4D-319A-4D7A-BB5B-93C4E8320480}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|Any CPU.Build.0 = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x64.ActiveCfg = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x64.Build.0 = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x86.ActiveCfg = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x86.Build.0 = Debug|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|Any CPU.ActiveCfg = Release|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|Any CPU.Build.0 = Release|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x64.ActiveCfg = Release|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x64.Build.0 = Release|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x86.ActiveCfg = Release|Any CPU - {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x86.Build.0 = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x64.ActiveCfg = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x64.Build.0 = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x86.ActiveCfg = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x86.Build.0 = Debug|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|Any CPU.Build.0 = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x64.ActiveCfg = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x64.Build.0 = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x86.ActiveCfg = Release|Any CPU - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x86.Build.0 = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x64.ActiveCfg = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x64.Build.0 = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x86.ActiveCfg = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x86.Build.0 = Debug|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|Any CPU.Build.0 = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x64.ActiveCfg = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x64.Build.0 = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x86.ActiveCfg = Release|Any CPU - {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x86.Build.0 = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x64.ActiveCfg = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x64.Build.0 = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x86.ActiveCfg = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x86.Build.0 = Debug|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|Any CPU.Build.0 = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x64.ActiveCfg = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x64.Build.0 = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x86.ActiveCfg = Release|Any CPU - {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {994166B2-862B-451B-B3E5-B2797EFF7022} = {4A0DFFF5-7BB2-481A-BB0F-152D89823F48} - {7CFEE412-6D6A-407B-9FAE-1640F74D98E7} = {C51CA370-A0C7-4229-90FA-ADF7B51DE021} - {C535C043-7A0E-4F17-89E4-493E7805CFAC} = {4A0DFFF5-7BB2-481A-BB0F-152D89823F48} - {D1287B4D-319A-4D7A-BB5B-93C4E8320480} = {C51CA370-A0C7-4229-90FA-ADF7B51DE021} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4A0DFFF5-7BB2-481A-BB0F-152D89823F48}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C51CA370-A0C7-4229-90FA-ADF7B51DE021}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Core", "src\Tand.Core\Tand.Core.csproj", "{994166B2-862B-451B-B3E5-B2797EFF7022}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Core.Tests", "test\Tand.Core.Tests\Tand.Core.Tests.csproj", "{7CFEE412-6D6A-407B-9FAE-1640F74D98E7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Extensions.DependencyInjection", "src\Tand.Extensions.DependencyInjection\Tand.Extensions.DependencyInjection.csproj", "{C535C043-7A0E-4F17-89E4-493E7805CFAC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Extensions.DependencyInjection.Tests", "test\Tand.Extensions.DependencyInjection.Tests\Tand.Extensions.DependencyInjection.Tests.csproj", "{D1287B4D-319A-4D7A-BB5B-93C4E8320480}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tand.Core.Benchmarks", "test\Tand.Core.Benchmarks\Tand.Core.Benchmarks.csproj", "{9D1DB302-21BA-4C4C-893C-BD390325186A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{7657E6DA-0025-43EE-A26D-5FEA9B3994A7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3D5041A2-DEFB-4DB8-AD09-74D4B8737F82}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vcs", "vcs", "{803F6FE6-CBC3-44E7-9F45-5722B5832D4B}" +ProjectSection(SolutionItems) = preProject + docfx.json = docfx.json + index.md = index.md + README.md = README.md + toc.yml = toc.yml + .gitignore = .gitignore + .nuke = .nuke +EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7657E6DA-0025-43EE-A26D-5FEA9B3994A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7657E6DA-0025-43EE-A26D-5FEA9B3994A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|Any CPU.Build.0 = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x64.ActiveCfg = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x64.Build.0 = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x86.ActiveCfg = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Debug|x86.Build.0 = Debug|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|Any CPU.ActiveCfg = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|Any CPU.Build.0 = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x64.ActiveCfg = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x64.Build.0 = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x86.ActiveCfg = Release|Any CPU + {994166B2-862B-451B-B3E5-B2797EFF7022}.Release|x86.Build.0 = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x64.ActiveCfg = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x64.Build.0 = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Debug|x86.Build.0 = Debug|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|Any CPU.Build.0 = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x64.ActiveCfg = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x64.Build.0 = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x86.ActiveCfg = Release|Any CPU + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7}.Release|x86.Build.0 = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x64.ActiveCfg = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x64.Build.0 = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x86.ActiveCfg = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Debug|x86.Build.0 = Debug|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|Any CPU.Build.0 = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x64.ActiveCfg = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x64.Build.0 = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x86.ActiveCfg = Release|Any CPU + {C535C043-7A0E-4F17-89E4-493E7805CFAC}.Release|x86.Build.0 = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x64.ActiveCfg = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x64.Build.0 = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x86.ActiveCfg = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Debug|x86.Build.0 = Debug|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|Any CPU.Build.0 = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x64.ActiveCfg = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x64.Build.0 = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x86.ActiveCfg = Release|Any CPU + {D1287B4D-319A-4D7A-BB5B-93C4E8320480}.Release|x86.Build.0 = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|x64.ActiveCfg = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|x64.Build.0 = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|x86.ActiveCfg = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Debug|x86.Build.0 = Debug|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|Any CPU.Build.0 = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|x64.ActiveCfg = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|x64.Build.0 = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|x86.ActiveCfg = Release|Any CPU + {9D1DB302-21BA-4C4C-893C-BD390325186A}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {994166B2-862B-451B-B3E5-B2797EFF7022} = {4A0DFFF5-7BB2-481A-BB0F-152D89823F48} + {7CFEE412-6D6A-407B-9FAE-1640F74D98E7} = {C51CA370-A0C7-4229-90FA-ADF7B51DE021} + {C535C043-7A0E-4F17-89E4-493E7805CFAC} = {4A0DFFF5-7BB2-481A-BB0F-152D89823F48} + {D1287B4D-319A-4D7A-BB5B-93C4E8320480} = {C51CA370-A0C7-4229-90FA-ADF7B51DE021} + {9D1DB302-21BA-4C4C-893C-BD390325186A} = {C51CA370-A0C7-4229-90FA-ADF7B51DE021} + {7657E6DA-0025-43EE-A26D-5FEA9B3994A7} = {3D5041A2-DEFB-4DB8-AD09-74D4B8737F82} + EndGlobalSection +EndGlobal diff --git a/build/.editorconfig b/build/.editorconfig new file mode 100644 index 0000000..31e43dc --- /dev/null +++ b/build/.editorconfig @@ -0,0 +1,11 @@ +[*.cs] +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning +dotnet_style_require_accessibility_modifiers = never:warning + +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_properties = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_accessors = true:warning diff --git a/build/Build.cs b/build/Build.cs new file mode 100644 index 0000000..036aa7b --- /dev/null +++ b/build/Build.cs @@ -0,0 +1,106 @@ +using Nuke.Common; +using Nuke.Common.CI.GitHubActions; +using Nuke.Common.Execution; +using Nuke.Common.Git; +using Nuke.Common.IO; +using Nuke.Common.ProjectModel; +using Nuke.Common.Tooling; +using Nuke.Common.Tools.DotNet; +using Nuke.Common.Tools.GitVersion; +using Nuke.Common.Utilities.Collections; +using static Nuke.Common.IO.FileSystemTasks; +using static Nuke.Common.Tools.DotNet.DotNetTasks; +using static _build.benchmarks.DotNetBenchmarkExtensions; + +[GitHubActions( + "dotnet", + GitHubActionsImage.UbuntuLatest, + AutoGenerate = true, + On = new []{GitHubActionsTrigger.Push, GitHubActionsTrigger.PullRequest} + ) +] +[CheckBuildProjectConfigurations] +[UnsetVisualStudioEnvironmentVariables] +class Build : NukeBuild +{ + /// Support plugins are available for: + /// - JetBrains ReSharper https://nuke.build/resharper + /// - JetBrains Rider https://nuke.build/rider + /// - Microsoft VisualStudio https://nuke.build/visualstudio + /// - Microsoft VSCode https://nuke.build/vscode + public static int Main() => Execute(x => x.Pack); + + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + + [Solution] readonly Solution Solution; + [GitRepository] readonly GitRepository GitRepository; + [GitVersion] readonly GitVersion GitVersion; + + AbsolutePath SourceDirectory => RootDirectory / "src"; + AbsolutePath TestsDirectory => RootDirectory / "test"; + AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; + + Target Clean => _ => _ + .Before(Restore) + .Executes(() => + { + SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + EnsureCleanDirectory(ArtifactsDirectory); + }); + + Target Restore => _ => _ + .Executes(() => + DotNetRestore(s => s + .SetProjectFile(Solution)) + ); + + Target Compile => _ => _ + .DependsOn(Restore) + .DependsOn(Clean) + .Executes(() => DotNetBuild(s => s + .SetProjectFile(Solution) + .SetConfiguration(Configuration) + .SetAssemblyVersion(GitVersion.AssemblySemVer) + .SetFileVersion(GitVersion.AssemblySemFileVer) + .SetInformationalVersion(GitVersion.InformationalVersion) + .EnableNoRestore())); + + Target Test => _ => _ + .DependsOn(Compile) + .Executes(() => DotNetTest(s => s + .SetProjectFile(Solution) + .SetConfiguration(Configuration) + .EnableNoRestore() + .EnableNoBuild() + .EnableLogOutput())); + + Target Pack => _ => _ + .DependsOn(Test) + .OnlyWhenStatic(() => GitRepository.IsOnMasterBranch()) + .Executes(() => SourceDirectory + .GlobFiles("**/*.csproj") + .ForEach(csproj => DotNetPack(s => s + .SetProject(csproj) + .SetConfiguration(Configuration) + .SetOutputDirectory(ArtifactsDirectory) + .SetVersion(GitVersion.FullSemVer) + .EnableIncludeSource() + .EnableIncludeSymbols() + .EnableNoRestore() + .EnableNoBuild() + .EnableLogOutput() + ))); + + Target Benchmark => _ => _ + .DependsOn(Compile) + .Requires(() => Configuration.Equals(Configuration.Release)) + .Executes(() => TestsDirectory + .GlobFiles($"**/bin/{Configuration}/**/*Benchmark*.dll") + .ForEach(benchmarkFile => DotNetBenchmark( + s => s + .WithFilter("*") + .WithDllPath(benchmarkFile))) + ); +} \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj new file mode 100644 index 0000000..300de38 --- /dev/null +++ b/build/_build.csproj @@ -0,0 +1,22 @@ + + + + Exe + netcoreapp3.1 + CS0649;CS0169 + .. + ..\test + 8 + enable + + + + + + + + + + + + diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings new file mode 100644 index 0000000..fbc421a --- /dev/null +++ b/build/_build.csproj.DotSettings @@ -0,0 +1,25 @@ + + DO_NOT_SHOW + DO_NOT_SHOW + Implicit + Implicit + ExpressionBody + 0 + NEXT_LINE + True + False + 120 + IF_OWNER_IS_SINGLE_LINE + WRAP_IF_LONG + False + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + True + True + True + True + True + True + True + True + True diff --git a/build/benchmarks/BenchmarkToolSettings.cs b/build/benchmarks/BenchmarkToolSettings.cs new file mode 100644 index 0000000..ecb4655 --- /dev/null +++ b/build/benchmarks/BenchmarkToolSettings.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using Nuke.Common.Tooling; +using Nuke.Common.Tools.DotNet; + +namespace _build.benchmarks +{ + public class BenchmarkToolSettings : ToolSettings + { + readonly IDictionary _arguments; + + public BenchmarkToolSettings() + { + _arguments = new Dictionary(); + } + + public override string ToolPath => base.ToolPath ?? DotNetTasks.DotNetPath; + + public string DllPath { get; private set; } + + public BenchmarkToolSettings WithDllPath(string path) + { + DllPath = path; + return this; + } + + public BenchmarkToolSettings WithFilter(string filter) + { + _arguments["filter"] = filter; + return this; + } + + public override Action CustomLogger => DotNetTasks.DotNetLogger; + + protected override Arguments ConfigureArguments(Arguments arguments) + { + arguments.Add("benchmark"); + arguments.Add(DllPath); + foreach (var (k, v) in _arguments) + { + arguments.Add($"--{k} {{value}}", v); + } + + return base.ConfigureArguments(arguments); + } + } +} \ No newline at end of file diff --git a/build/benchmarks/DotnetBenchmarkExtensions.cs b/build/benchmarks/DotnetBenchmarkExtensions.cs new file mode 100644 index 0000000..686c8a3 --- /dev/null +++ b/build/benchmarks/DotnetBenchmarkExtensions.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Nuke.Common.Tooling; + +namespace _build.benchmarks +{ + public static class DotNetBenchmarkExtensions + { + public static IReadOnlyCollection DotNetBenchmark(Configure configurator) + { + return DotNetBenchmark(configurator(new BenchmarkToolSettings())); + } + + public static IReadOnlyCollection DotNetBenchmark(BenchmarkToolSettings toolSettings = null) + { + toolSettings ??= new BenchmarkToolSettings(); + var process = ProcessTasks.StartProcess(toolSettings); + process.AssertZeroExitCode(); + return process.Output; + } + } +} \ No newline at end of file diff --git a/src/Tand.Core/Api/IDependencyResolver.cs b/src/Tand.Core/Api/IDependencyResolver.cs new file mode 100644 index 0000000..1ac9d01 --- /dev/null +++ b/src/Tand.Core/Api/IDependencyResolver.cs @@ -0,0 +1,9 @@ +using System; + +namespace Tand.Core.Api +{ + public interface IDependencyResolver + { + ITandTarget? TargetOfType(Type type); + } +} \ No newline at end of file diff --git a/src/tand/Tand.Core/ITandTarget.cs b/src/Tand.Core/Api/ITandTarget.cs similarity index 89% rename from src/tand/Tand.Core/ITandTarget.cs rename to src/Tand.Core/Api/ITandTarget.cs index 3afca63..6c937f0 100644 --- a/src/tand/Tand.Core/ITandTarget.cs +++ b/src/Tand.Core/Api/ITandTarget.cs @@ -1,6 +1,6 @@ using Tand.Core.Models; -namespace Tand.Core +namespace Tand.Core.Api { public interface ITandTarget { diff --git a/src/tand/Tand.Core/TandAttribute.cs b/src/Tand.Core/Api/TandAttribute.cs similarity index 92% rename from src/tand/Tand.Core/TandAttribute.cs rename to src/Tand.Core/Api/TandAttribute.cs index 6b04ff9..7cf5bad 100644 --- a/src/tand/Tand.Core/TandAttribute.cs +++ b/src/Tand.Core/Api/TandAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Tand.Core +namespace Tand.Core.Api { [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class TandAttribute : Attribute diff --git a/src/tand/Tand.Core/Models/CallEnterContext.cs b/src/Tand.Core/Models/CallEnterContext.cs similarity index 100% rename from src/tand/Tand.Core/Models/CallEnterContext.cs rename to src/Tand.Core/Models/CallEnterContext.cs diff --git a/src/tand/Tand.Core/Models/CallLeaveContext.cs b/src/Tand.Core/Models/CallLeaveContext.cs similarity index 100% rename from src/tand/Tand.Core/Models/CallLeaveContext.cs rename to src/Tand.Core/Models/CallLeaveContext.cs diff --git a/src/tand/Tand.Core/Models/MethodArgument.cs b/src/Tand.Core/Models/MethodArgument.cs similarity index 100% rename from src/tand/Tand.Core/Models/MethodArgument.cs rename to src/Tand.Core/Models/MethodArgument.cs diff --git a/src/tand/Tand.Core/Tand.Core.csproj b/src/Tand.Core/Tand.Core.csproj similarity index 88% rename from src/tand/Tand.Core/Tand.Core.csproj rename to src/Tand.Core/Tand.Core.csproj index f63a73e..7a53e42 100644 --- a/src/tand/Tand.Core/Tand.Core.csproj +++ b/src/Tand.Core/Tand.Core.csproj @@ -7,6 +7,7 @@ 0.0.1 8 enable + true diff --git a/src/tand/Tand.Core/Tand.cs b/src/Tand.Core/Tand.cs similarity index 98% rename from src/tand/Tand.Core/Tand.cs rename to src/Tand.Core/Tand.cs index e4086d7..2082da8 100644 --- a/src/tand/Tand.Core/Tand.cs +++ b/src/Tand.Core/Tand.cs @@ -1,4 +1,5 @@ using System.Reflection; +using Tand.Core.Api; namespace Tand.Core { diff --git a/src/tand/Tand.Core/TandProxy.cs b/src/Tand.Core/TandProxy.cs similarity index 92% rename from src/tand/Tand.Core/TandProxy.cs rename to src/Tand.Core/TandProxy.cs index 46499b8..8c026a3 100644 --- a/src/tand/Tand.Core/TandProxy.cs +++ b/src/Tand.Core/TandProxy.cs @@ -2,7 +2,9 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Reflection; +using Tand.Core.Api; using Tand.Core.Models; namespace Tand.Core @@ -22,10 +24,10 @@ namespace Tand.Core _targetCache = new ConcurrentDictionary(); } - public Type ImplementationType { get; set; } - public T Decorated { private get; set; } + public Type ImplementationType { get; set; } = default!; + public T Decorated { private get; set; } = default!; - public IDependencyResolver DependencyResolver { get; set; } + public IDependencyResolver DependencyResolver { get; set; } = default!; protected override object Invoke(MethodInfo targetMethod, object[] args) { @@ -33,7 +35,7 @@ namespace Tand.Core var targets = TargetTypesForMethod(targetMethod); ProcessOnEntering(targets, new CallEnterContext(Decorated, mappedMethodArgs)); - + var result = targetMethod.Invoke(Decorated, args); ProcessOnLeaving(targets, new CallLeaveContext(Decorated, mappedMethodArgs, result)); @@ -104,7 +106,8 @@ namespace Tand.Core return _targetCache[hash] .Select(type => DependencyResolver.TargetOfType(type)) - .ToList(); + .Where(target => target != null) + .ToList()!; } } } \ No newline at end of file diff --git a/src/tand/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs b/src/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs similarity index 96% rename from src/tand/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs rename to src/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs index a1c02c0..a51b300 100644 --- a/src/tand/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs +++ b/src/Tand.Extensions.DependencyInjection/DependencyResolverProxy.cs @@ -1,5 +1,6 @@ using System; using Tand.Core; +using Tand.Core.Api; using Tand.Core.Models; namespace Tand.Extensions.DependencyInjection diff --git a/src/tand/Tand.Extensions.DependencyInjection/Tand.Extensions.DependencyInjection.csproj b/src/Tand.Extensions.DependencyInjection/Tand.Extensions.DependencyInjection.csproj similarity index 100% rename from src/tand/Tand.Extensions.DependencyInjection/Tand.Extensions.DependencyInjection.csproj rename to src/Tand.Extensions.DependencyInjection/Tand.Extensions.DependencyInjection.csproj diff --git a/src/tand/Tand.Extensions.DependencyInjection/TandServiceExtensions.cs b/src/Tand.Extensions.DependencyInjection/TandServiceExtensions.cs similarity index 100% rename from src/tand/Tand.Extensions.DependencyInjection/TandServiceExtensions.cs rename to src/Tand.Extensions.DependencyInjection/TandServiceExtensions.cs diff --git a/src/tand/Tand.Core/IDependencyResolver.cs b/src/tand/Tand.Core/IDependencyResolver.cs deleted file mode 100644 index 8f7610a..0000000 --- a/src/tand/Tand.Core/IDependencyResolver.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Tand.Core -{ - public interface IDependencyResolver - { - ITandTarget TargetOfType(Type type); - } -} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/ExecutionTimeTand.cs b/test/Tand.Core.Benchmarks/ExecutionTimeTand.cs new file mode 100644 index 0000000..09fc956 --- /dev/null +++ b/test/Tand.Core.Benchmarks/ExecutionTimeTand.cs @@ -0,0 +1,35 @@ +using System; +using System.Diagnostics; +using Tand.Core.Api; +using Tand.Core.Models; + +namespace Tand.Core.Benchmarks +{ + public class ExecutionTimeTand : ITandTarget + { + private readonly Stopwatch _stopwatch; + private readonly Action? _resultHandler; + + public ExecutionTimeTand() : this(null) + { + + } + + public ExecutionTimeTand(Action? resultHandler) + { + _stopwatch = new Stopwatch(); + _resultHandler = resultHandler; + } + + public void OnEnterMethod(CallEnterContext enterContext) + { + _stopwatch.Start(); + } + + public void OnLeaveMethod(CallLeaveContext leaveContext) + { + _stopwatch.Stop(); + _resultHandler?.Invoke($"Total execution time: {_stopwatch.Elapsed}"); + } + } +} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/Program.cs b/test/Tand.Core.Benchmarks/Program.cs new file mode 100644 index 0000000..77221f5 --- /dev/null +++ b/test/Tand.Core.Benchmarks/Program.cs @@ -0,0 +1,12 @@ +using BenchmarkDotNet.Running; + +namespace Tand.Core.Benchmarks +{ + public class Program + { + public static void Main(string[] args) + { + var summary = BenchmarkRunner.Run(); + } + } +} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/Rational.cs b/test/Tand.Core.Benchmarks/Rational.cs new file mode 100644 index 0000000..05edaae --- /dev/null +++ b/test/Tand.Core.Benchmarks/Rational.cs @@ -0,0 +1,33 @@ +using System; + +namespace Tand.Core.Benchmarks +{ + public readonly struct Rational + { + public Rational(int numerator, int denominator) + { + var gcd = GCD(numerator, denominator); + numerator /= gcd; + denominator /= gcd; + if (denominator < 0) + { + Numerator = -numerator; + Denominator = -denominator; + } + else + { + Numerator = numerator; + Denominator = denominator; + } + } + + public int Numerator { get; } + public int Denominator { get; } + + private static int GCD(int a, int b) => (Math.Abs(a), Math.Abs(b)) switch + { + (_, 0) => a, + _ => GCD(b, a % b) + }; + } +} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/RationalTandBenchmerk.cs b/test/Tand.Core.Benchmarks/RationalTandBenchmerk.cs new file mode 100644 index 0000000..4764b09 --- /dev/null +++ b/test/Tand.Core.Benchmarks/RationalTandBenchmerk.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using BenchmarkDotNet.Attributes; +using Tand.Core.Api; + +namespace Tand.Core.Benchmarks +{ + public class RationalTandBenchmerk + { + + private readonly SimpleDependencyResolver _dependencyResolver; + + public RationalTandBenchmerk() + { + _dependencyResolver = new SimpleDependencyResolver(); + _dependencyResolver.Register, IRationalsProvider>(() => new ExecutionTimeTand()); + } + + [Benchmark] + public void GenerateWithoutTand() + { + var rationalProvider = new RationalsProvider(); + // just to mimic behavior + var stopWatch = new Stopwatch(); + stopWatch.Start(); + var result = rationalProvider.Generate(Numbers()); + stopWatch.Stop(); + } + + [Benchmark] + public void GenerateWithTand() + { + + var tand = new Tand(_dependencyResolver); + var rationalProvider = tand.DecorateWithTand(new RationalsProvider()); + var result = rationalProvider.Generate(Numbers()); + } + + private static IEnumerable<(int, int)> Numbers() => Enumerable + .Range(1, 50_000) + .Zip(Enumerable.Range(25_000, 50_000), (x, y) => (x, y)) + .ToList(); + } + + internal class SimpleDependencyResolver : IDependencyResolver + { + private readonly IDictionary> _registeredProducers; + + public SimpleDependencyResolver() + { + _registeredProducers = new Dictionary>(); + } + + internal void Register(Func producer) where T : class, ITandTarget + { + _registeredProducers[producer.Method.ReturnType] = producer; + } + + public ITandTarget? TargetOfType(Type type) + { + if (_registeredProducers.ContainsKey(type)) + { + return _registeredProducers[type]() as ITandTarget; + } + + return null; + } + } +} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/RationalsProvider.cs b/test/Tand.Core.Benchmarks/RationalsProvider.cs new file mode 100644 index 0000000..0085e3c --- /dev/null +++ b/test/Tand.Core.Benchmarks/RationalsProvider.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Linq; +using Tand.Core.Api; + +namespace Tand.Core.Benchmarks +{ + public interface IRationalsProvider + { + [Tand(typeof(ExecutionTimeTand))] + ICollection Generate(IEnumerable<(int n, int d)> input); + } + + public class RationalsProvider : IRationalsProvider + { + public ICollection Generate(IEnumerable<(int n, int d)> input) => input.Select(tuple => new Rational(tuple.n, tuple.d)).ToList(); + } +} \ No newline at end of file diff --git a/test/Tand.Core.Benchmarks/Tand.Core.Benchmarks.csproj b/test/Tand.Core.Benchmarks/Tand.Core.Benchmarks.csproj new file mode 100644 index 0000000..f362315 --- /dev/null +++ b/test/Tand.Core.Benchmarks/Tand.Core.Benchmarks.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.1 + true + 8 + enable + + + + + + + + + + + diff --git a/src/tand/Tand.Core.Tests/LogTarget.cs b/test/Tand.Core.Tests/LogTarget.cs similarity index 96% rename from src/tand/Tand.Core.Tests/LogTarget.cs rename to test/Tand.Core.Tests/LogTarget.cs index e58ca8f..a7d656e 100644 --- a/src/tand/Tand.Core.Tests/LogTarget.cs +++ b/test/Tand.Core.Tests/LogTarget.cs @@ -1,4 +1,5 @@ using System; +using Tand.Core.Api; using Tand.Core.Models; namespace Tand.Core.Tests diff --git a/src/tand/Tand.Core.Tests/ResolverMock.cs b/test/Tand.Core.Tests/ResolverMock.cs similarity index 96% rename from src/tand/Tand.Core.Tests/ResolverMock.cs rename to test/Tand.Core.Tests/ResolverMock.cs index 907a86c..516ec8f 100644 --- a/src/tand/Tand.Core.Tests/ResolverMock.cs +++ b/test/Tand.Core.Tests/ResolverMock.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Tand.Core.Api; namespace Tand.Core.Tests { diff --git a/src/tand/Tand.Core.Tests/Tand.Core.Tests.csproj b/test/Tand.Core.Tests/Tand.Core.Tests.csproj similarity index 89% rename from src/tand/Tand.Core.Tests/Tand.Core.Tests.csproj rename to test/Tand.Core.Tests/Tand.Core.Tests.csproj index fb93ae4..8cc13a4 100644 --- a/src/tand/Tand.Core.Tests/Tand.Core.Tests.csproj +++ b/test/Tand.Core.Tests/Tand.Core.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/tand/Tand.Core.Tests/TandSample.cs b/test/Tand.Core.Tests/TandSample.cs similarity index 83% rename from src/tand/Tand.Core.Tests/TandSample.cs rename to test/Tand.Core.Tests/TandSample.cs index 9300be4..992b1cf 100644 --- a/src/tand/Tand.Core.Tests/TandSample.cs +++ b/test/Tand.Core.Tests/TandSample.cs @@ -1,3 +1,5 @@ +using Tand.Core.Api; + namespace Tand.Core.Tests { @@ -11,9 +13,7 @@ namespace Tand.Core.Tests { private int _counter; - - public string ContextSample { get; set; } - + public int LogMyParams(string s, int i) { return ++_counter; diff --git a/src/tand/Tand.Core.Tests/TandTests.cs b/test/Tand.Core.Tests/TandTests.cs similarity index 100% rename from src/tand/Tand.Core.Tests/TandTests.cs rename to test/Tand.Core.Tests/TandTests.cs diff --git a/src/tand/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj b/test/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj similarity index 83% rename from src/tand/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj rename to test/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj index a4bd305..67c4386 100644 --- a/src/tand/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj +++ b/test/Tand.Extensions.DependencyInjection.Tests/Tand.Extensions.DependencyInjection.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/tand/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs b/test/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs similarity index 99% rename from src/tand/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs rename to test/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs index b4de5d5..2cf4b4c 100644 --- a/src/tand/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs +++ b/test/Tand.Extensions.DependencyInjection.Tests/TandServiceExtensionsTests.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Extensions.DependencyInjection; using Tand.Core; +using Tand.Core.Api; using Tand.Core.Models; using Xunit; diff --git a/test/build.cmd b/test/build.cmd new file mode 100755 index 0000000..f9683e7 --- /dev/null +++ b/test/build.cmd @@ -0,0 +1,6 @@ +:; set -eo pipefail +:; ./build.sh "$@" +:; exit $? + +@ECHO OFF +powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %* diff --git a/test/build.ps1 b/test/build.ps1 new file mode 100644 index 0000000..98d26de --- /dev/null +++ b/test/build.ps1 @@ -0,0 +1,68 @@ +[CmdletBinding()] +Param( + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$BuildArguments +) + +Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" + +Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 } +$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent + +########################################################################### +# CONFIGURATION +########################################################################### + +$BuildProjectFile = "$PSScriptRoot\..\build\_build.csproj" +$TempDirectory = "$PSScriptRoot\..\.tmp" + +$DotNetGlobalFile = "$PSScriptRoot\..\global.json" +$DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" +$DotNetChannel = "Current" + +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 +$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 + +########################################################################### +# EXECUTION +########################################################################### + +function ExecSafe([scriptblock] $cmd) { + & $cmd + if ($LASTEXITCODE) { exit $LASTEXITCODE } +} + +# If global.json exists, load expected version +if (Test-Path $DotNetGlobalFile) { + $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) + if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { + $DotNetVersion = $DotNetGlobal.sdk.version + } +} + +# If dotnet is installed locally, and expected version is not set or installation matches the expected version +if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` + (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { + $env:DOTNET_EXE = (Get-Command "dotnet").Path +} +else { + $DotNetDirectory = "$TempDirectory\dotnet-win" + $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" + + # Download install script + $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" + New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null + (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) + + # Install by channel or version + if (!(Test-Path variable:DotNetVersion)) { + ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } + } else { + ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } + } +} + +Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" + +ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet } +ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 0000000..0289f2e --- /dev/null +++ b/test/build.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +echo $(bash --version 2>&1 | head -n 1) + +set -eo pipefail +SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) + +########################################################################### +# CONFIGURATION +########################################################################### + +BUILD_PROJECT_FILE="$SCRIPT_DIR/../build/_build.csproj" +TEMP_DIRECTORY="$SCRIPT_DIR/../.tmp" + +DOTNET_GLOBAL_FILE="$SCRIPT_DIR/../global.json" +DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" +DOTNET_CHANNEL="Current" + +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + +########################################################################### +# EXECUTION +########################################################################### + +function FirstJsonValue { + perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2} +} + +# If global.json exists, load expected version +if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then + DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) + if [[ "$DOTNET_VERSION" == "" ]]; then + unset DOTNET_VERSION + fi +fi + +# If dotnet is installed locally, and expected version is not set or installation matches the expected version +if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then + export DOTNET_EXE="$(command -v dotnet)" +else + DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" + export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" + + # Download install script + DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" + mkdir -p "$TEMP_DIRECTORY" + curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" + chmod +x "$DOTNET_INSTALL_FILE" + + # Install by channel or version + if [[ -z ${DOTNET_VERSION+x} ]]; then + "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path + else + "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path + fi +fi + +echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" + +"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet +"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"