Refactored
- Added Benchmarks - Added Nuke build - Refactored directory structure - Generated GitHub Actions config from Nuke - Added tool to handle benchmarking from Nuke
This commit is contained in:
parent
e291f691f1
commit
d8d307545f
42 changed files with 752 additions and 159 deletions
18
.config/dotnet-tools.json
Normal file
18
.config/dotnet-tools.json
Normal file
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
28
.github/workflows/dotnet.yml
vendored
Normal file
28
.github/workflows/dotnet.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# <auto-generated>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# </auto-generated>
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
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
|
26
.github/workflows/publish.yml
vendored
26
.github/workflows/publish.yml
vendored
|
@ -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/
|
26
.github/workflows/validate.yml
vendored
26
.github/workflows/validate.yml
vendored
|
@ -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/
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,8 +3,11 @@
|
|||
###############
|
||||
/**/DROP/
|
||||
/**/TEMP/
|
||||
**/.tmp/
|
||||
/**/packages/
|
||||
/**/bin/
|
||||
/**/obj/
|
||||
_site
|
||||
.idea/
|
||||
*.Artifacts/
|
||||
**/artifacts/
|
||||
|
|
1
.nuke
Normal file
1
.nuke
Normal file
|
@ -0,0 +1 @@
|
|||
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
|
11
build/.editorconfig
Normal file
11
build/.editorconfig
Normal file
|
@ -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
|
106
build/Build.cs
Normal file
106
build/Build.cs
Normal file
|
@ -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<Build>(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)))
|
||||
);
|
||||
}
|
22
build/_build.csproj
Normal file
22
build/_build.csproj
Normal file
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<NoWarn>CS0649;CS0169</NoWarn>
|
||||
<NukeRootDirectory>..</NukeRootDirectory>
|
||||
<NukeScriptDirectory>..\test</NukeScriptDirectory>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nuke.Common" Version="0.24.4" />
|
||||
<PackageDownload Include="GitVersion.Tool" Version="[5.1.1]" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="..\.github\workflows\validate.yml" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
25
build/_build.csproj.DotSettings
Normal file
25
build/_build.csproj.DotSettings
Normal file
|
@ -0,0 +1,25 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=HeapView_002EDelegateAllocation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableHidesOuterVariable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">0</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">False</s:Boolean>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ATTRIBUTE_LENGTH_FOR_SAME_LINE/@EntryValue">120</s:Int64>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">IF_OWNER_IS_SINGLE_LINE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
47
build/benchmarks/BenchmarkToolSettings.cs
Normal file
47
build/benchmarks/BenchmarkToolSettings.cs
Normal file
|
@ -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<string, string> _arguments;
|
||||
|
||||
public BenchmarkToolSettings()
|
||||
{
|
||||
_arguments = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
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<OutputType, string> 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);
|
||||
}
|
||||
}
|
||||
}
|
21
build/benchmarks/DotnetBenchmarkExtensions.cs
Normal file
21
build/benchmarks/DotnetBenchmarkExtensions.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Generic;
|
||||
using Nuke.Common.Tooling;
|
||||
|
||||
namespace _build.benchmarks
|
||||
{
|
||||
public static class DotNetBenchmarkExtensions
|
||||
{
|
||||
public static IReadOnlyCollection<Output> DotNetBenchmark(Configure<BenchmarkToolSettings> configurator)
|
||||
{
|
||||
return DotNetBenchmark(configurator(new BenchmarkToolSettings()));
|
||||
}
|
||||
|
||||
public static IReadOnlyCollection<Output> DotNetBenchmark(BenchmarkToolSettings toolSettings = null)
|
||||
{
|
||||
toolSettings ??= new BenchmarkToolSettings();
|
||||
var process = ProcessTasks.StartProcess(toolSettings);
|
||||
process.AssertZeroExitCode();
|
||||
return process.Output;
|
||||
}
|
||||
}
|
||||
}
|
9
src/Tand.Core/Api/IDependencyResolver.cs
Normal file
9
src/Tand.Core/Api/IDependencyResolver.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Tand.Core.Api
|
||||
{
|
||||
public interface IDependencyResolver
|
||||
{
|
||||
ITandTarget<T>? TargetOfType<T>(Type type);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using Tand.Core.Models;
|
||||
|
||||
namespace Tand.Core
|
||||
namespace Tand.Core.Api
|
||||
{
|
||||
public interface ITandTarget<T>
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace Tand.Core
|
||||
namespace Tand.Core.Api
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class TandAttribute : Attribute
|
|
@ -7,6 +7,7 @@
|
|||
<Version>0.0.1</Version>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reflection;
|
||||
using Tand.Core.Api;
|
||||
|
||||
namespace Tand.Core
|
||||
{
|
|
@ -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<int, Type[]>();
|
||||
}
|
||||
|
||||
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<T>(Decorated, mappedMethodArgs));
|
||||
|
||||
|
||||
var result = targetMethod.Invoke(Decorated, args);
|
||||
|
||||
ProcessOnLeaving(targets, new CallLeaveContext<T>(Decorated, mappedMethodArgs, result));
|
||||
|
@ -104,7 +106,8 @@ namespace Tand.Core
|
|||
|
||||
return _targetCache[hash]
|
||||
.Select(type => DependencyResolver.TargetOfType<T>(type))
|
||||
.ToList();
|
||||
.Where(target => target != null)
|
||||
.ToList()!;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Tand.Core;
|
||||
using Tand.Core.Api;
|
||||
using Tand.Core.Models;
|
||||
|
||||
namespace Tand.Extensions.DependencyInjection
|
|
@ -1,9 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Tand.Core
|
||||
{
|
||||
public interface IDependencyResolver
|
||||
{
|
||||
ITandTarget<T> TargetOfType<T>(Type type);
|
||||
}
|
||||
}
|
35
test/Tand.Core.Benchmarks/ExecutionTimeTand.cs
Normal file
35
test/Tand.Core.Benchmarks/ExecutionTimeTand.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Tand.Core.Api;
|
||||
using Tand.Core.Models;
|
||||
|
||||
namespace Tand.Core.Benchmarks
|
||||
{
|
||||
public class ExecutionTimeTand<T> : ITandTarget<T>
|
||||
{
|
||||
private readonly Stopwatch _stopwatch;
|
||||
private readonly Action<string>? _resultHandler;
|
||||
|
||||
public ExecutionTimeTand() : this(null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ExecutionTimeTand(Action<string>? resultHandler)
|
||||
{
|
||||
_stopwatch = new Stopwatch();
|
||||
_resultHandler = resultHandler;
|
||||
}
|
||||
|
||||
public void OnEnterMethod(CallEnterContext<T> enterContext)
|
||||
{
|
||||
_stopwatch.Start();
|
||||
}
|
||||
|
||||
public void OnLeaveMethod(CallLeaveContext<T> leaveContext)
|
||||
{
|
||||
_stopwatch.Stop();
|
||||
_resultHandler?.Invoke($"Total execution time: {_stopwatch.Elapsed}");
|
||||
}
|
||||
}
|
||||
}
|
12
test/Tand.Core.Benchmarks/Program.cs
Normal file
12
test/Tand.Core.Benchmarks/Program.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using BenchmarkDotNet.Running;
|
||||
|
||||
namespace Tand.Core.Benchmarks
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var summary = BenchmarkRunner.Run<RationalTandBenchmerk>();
|
||||
}
|
||||
}
|
||||
}
|
33
test/Tand.Core.Benchmarks/Rational.cs
Normal file
33
test/Tand.Core.Benchmarks/Rational.cs
Normal file
|
@ -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)
|
||||
};
|
||||
}
|
||||
}
|
71
test/Tand.Core.Benchmarks/RationalTandBenchmerk.cs
Normal file
71
test/Tand.Core.Benchmarks/RationalTandBenchmerk.cs
Normal file
|
@ -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<ExecutionTimeTand<IRationalsProvider>, IRationalsProvider>(() => new ExecutionTimeTand<IRationalsProvider>());
|
||||
}
|
||||
|
||||
[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<IRationalsProvider, RationalsProvider>(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<Type, Func<object>> _registeredProducers;
|
||||
|
||||
public SimpleDependencyResolver()
|
||||
{
|
||||
_registeredProducers = new Dictionary<Type, Func<object>>();
|
||||
}
|
||||
|
||||
internal void Register<T, TS>(Func<T> producer) where T : class, ITandTarget<TS>
|
||||
{
|
||||
_registeredProducers[producer.Method.ReturnType] = producer;
|
||||
}
|
||||
|
||||
public ITandTarget<T>? TargetOfType<T>(Type type)
|
||||
{
|
||||
if (_registeredProducers.ContainsKey(type))
|
||||
{
|
||||
return _registeredProducers[type]() as ITandTarget<T>;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
17
test/Tand.Core.Benchmarks/RationalsProvider.cs
Normal file
17
test/Tand.Core.Benchmarks/RationalsProvider.cs
Normal file
|
@ -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<IRationalsProvider>))]
|
||||
ICollection<Rational> Generate(IEnumerable<(int n, int d)> input);
|
||||
}
|
||||
|
||||
public class RationalsProvider : IRationalsProvider
|
||||
{
|
||||
public ICollection<Rational> Generate(IEnumerable<(int n, int d)> input) => input.Select(tuple => new Rational(tuple.n, tuple.d)).ToList();
|
||||
}
|
||||
}
|
18
test/Tand.Core.Benchmarks/Tand.Core.Benchmarks.csproj
Normal file
18
test/Tand.Core.Benchmarks/Tand.Core.Benchmarks.csproj
Normal file
|
@ -0,0 +1,18 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Optimize>true</Optimize>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Tand.Core\Tand.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Tand.Core.Api;
|
||||
using Tand.Core.Models;
|
||||
|
||||
namespace Tand.Core.Tests
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Tand.Core.Api;
|
||||
|
||||
namespace Tand.Core.Tests
|
||||
{
|
|
@ -15,7 +15,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tand.Core\Tand.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\Tand.Core\Tand.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -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;
|
|
@ -15,7 +15,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tand.Extensions.DependencyInjection\Tand.Extensions.DependencyInjection.csproj" />
|
||||
<ProjectReference Include="..\..\src\Tand.Extensions.DependencyInjection\Tand.Extensions.DependencyInjection.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Tand.Core;
|
||||
using Tand.Core.Api;
|
||||
using Tand.Core.Models;
|
||||
using Xunit;
|
||||
|
6
test/build.cmd
Executable file
6
test/build.cmd
Executable file
|
@ -0,0 +1,6 @@
|
|||
:; set -eo pipefail
|
||||
:; ./build.sh "$@"
|
||||
:; exit $?
|
||||
|
||||
@ECHO OFF
|
||||
powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %*
|
68
test/build.ps1
Normal file
68
test/build.ps1
Normal file
|
@ -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 }
|
62
test/build.sh
Executable file
62
test/build.sh
Executable file
|
@ -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 -- "$@"
|
Loading…
Reference in a new issue