From 94846bfe53e9f83d8a254e40aa5331d71e9b1f40 Mon Sep 17 00:00:00 2001 From: Val Date: Sun, 26 May 2024 21:31:18 +0300 Subject: [PATCH 01/11] buildtest and publish workflows --- .github/workflows/dotnet-lib.yml | 44 ++++++++++++++++ .github/workflows/publish-nuget.yml | 81 +++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/dotnet-lib.yml create mode 100644 .github/workflows/publish-nuget.yml diff --git a/.github/workflows/dotnet-lib.yml b/.github/workflows/dotnet-lib.yml new file mode 100644 index 0000000..a142a0b --- /dev/null +++ b/.github/workflows/dotnet-lib.yml @@ -0,0 +1,44 @@ +name: buildtest +run-name: build and test +on: [push] + +jobs: + + build: + + strategy: + matrix: + configuration: [Debug, Release] + + runs-on: windows-latest # For a list of available runner types, refer to + # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on + + env: + Solution_Name: ValueInjecter.sln + Test_Project_Path: Tests\Tests.csproj + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Install the .NET Core workload + - name: Install .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v2 + + # Execute all unit tests in the solution + - name: Execute unit tests + run: dotnet test $env:Solution_Name + + # Restore the application to populate the obj folder with RuntimeIdentifiers + - name: Restore the application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 0000000..948662f --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,81 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: publish +on: + workflow_dispatch: # Allow running the workflow manually from the GitHub UI + push: + branches: + - '*' # Run the workflow when pushing to all branches + pull_request: + branches: + - '*' # Run the workflow for all pull requests + release: + types: + - published # Run the workflow when a new GitHub release is published + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace}}/nuget + +defaults: + run: + shell: pwsh + +jobs: + create_nuget: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + # Create the NuGet package in the folder from the environment variable NuGetDirectory + - run: dotnet pack HelloWorldLib --configuration Release --output ${{ env.NuGetDirectory }} + + # Publish the NuGet package as an artifact, so they can be used in the following jobs + - uses: actions/upload-artifact@v4 + with: + name: nuget + if-no-files-found: error + path: ${{ env.NuGetDirectory }}/*.nupkg + + run_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + - name: Run tests + run: dotnet test HelloWorldLib --configuration Release + + deploy: + # Publish only when creating a GitHub Release + # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository + # You can update this logic if you want to manage releases differently + if: github.event_name == 'release' + runs-on: ubuntu-latest + needs: [ run_test ] + steps: + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + + # Publish all NuGet packages to NuGet.org + # Use --skip-duplicate to prevent errors if a package with the same version already exists. + # If you retry a failed workflow, already published packages will be skipped without error. + - name: Publish NuGet package + run: | + foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { + dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } \ No newline at end of file From b284dd2dc04cec9e2a99b8984c2d2df35b7f84a7 Mon Sep 17 00:00:00 2001 From: Val Date: Sun, 26 May 2024 21:47:12 +0300 Subject: [PATCH 02/11] Update publish-nuget.yml --- .github/workflows/publish-nuget.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 948662f..5e23515 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -35,7 +35,7 @@ jobs: uses: actions/setup-dotnet@v4 # Create the NuGet package in the folder from the environment variable NuGetDirectory - - run: dotnet pack HelloWorldLib --configuration Release --output ${{ env.NuGetDirectory }} + - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} # Publish the NuGet package as an artifact, so they can be used in the following jobs - uses: actions/upload-artifact@v4 @@ -51,7 +51,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 - name: Run tests - run: dotnet test HelloWorldLib --configuration Release + run: dotnet test --configuration Release deploy: # Publish only when creating a GitHub Release From f3eab54166cee4469e0b3a06a5f534ea84aa3354 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 11:34:10 +0300 Subject: [PATCH 03/11] buildtest workflow --- .../{dotnet-lib.yml => buildtest.yml} | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) rename .github/workflows/{dotnet-lib.yml => buildtest.yml} (69%) diff --git a/.github/workflows/dotnet-lib.yml b/.github/workflows/buildtest.yml similarity index 69% rename from .github/workflows/dotnet-lib.yml rename to .github/workflows/buildtest.yml index a142a0b..2b51bf6 100644 --- a/.github/workflows/dotnet-lib.yml +++ b/.github/workflows/buildtest.yml @@ -1,11 +1,14 @@ name: buildtest run-name: build and test -on: [push] -jobs: +on: + workflow_dispatch: # Allow running the workflow manually from the GitHub UI + push: + branches: + - '*' # Run the workflow when pushing to all branches +jobs: build: - strategy: matrix: configuration: [Debug, Release] @@ -14,7 +17,7 @@ jobs: # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on env: - Solution_Name: ValueInjecter.sln + Project_Path: ValueInjecter\ValueInjecter.csproj Test_Project_Path: Tests\Tests.csproj steps: @@ -33,12 +36,16 @@ jobs: - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v2 + #dotnet build .\ValueInjecter\ValueInjecter.csproj + - name: build + run: dotnet build $env.Project_Path + # Execute all unit tests in the solution - name: Execute unit tests - run: dotnet test $env:Solution_Name + run: dotnet test $env:Test_Project_Path # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + run: msbuild $env:Project_Path /t:Restore /p:Configuration=$env:Configuration env: Configuration: ${{ matrix.configuration }} From 97e5326c72b8723dc55fb7df2f507b25bd175812 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 11:37:46 +0300 Subject: [PATCH 04/11] Update buildtest.yml --- .github/workflows/buildtest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buildtest.yml b/.github/workflows/buildtest.yml index 2b51bf6..f1cb384 100644 --- a/.github/workflows/buildtest.yml +++ b/.github/workflows/buildtest.yml @@ -38,14 +38,14 @@ jobs: #dotnet build .\ValueInjecter\ValueInjecter.csproj - name: build - run: dotnet build $env.Project_Path + run: dotnet build ${{ env.Project_Path }} # Execute all unit tests in the solution - name: Execute unit tests - run: dotnet test $env:Test_Project_Path + run: dotnet test ${{ env.Test_Project_Path }} # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application - run: msbuild $env:Project_Path /t:Restore /p:Configuration=$env:Configuration + run: msbuild ${{ env.Project_Path }} /t:Restore /p:Configuration=${{ env.Configuration }} env: Configuration: ${{ matrix.configuration }} From a91525db8072e565166db8a7da8c4e9d387ab694 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 12:00:35 +0300 Subject: [PATCH 05/11] Update buildtest.yml --- .github/workflows/buildtest.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildtest.yml b/.github/workflows/buildtest.yml index f1cb384..243d13c 100644 --- a/.github/workflows/buildtest.yml +++ b/.github/workflows/buildtest.yml @@ -38,7 +38,9 @@ jobs: #dotnet build .\ValueInjecter\ValueInjecter.csproj - name: build - run: dotnet build ${{ env.Project_Path }} + run: dotnet build ${{ env.Project_Path }} /p:Configuration=${{ env.Configuration }} + env: + Configuration: ${{ matrix.configuration }} # Execute all unit tests in the solution - name: Execute unit tests @@ -48,4 +50,4 @@ jobs: - name: Restore the application run: msbuild ${{ env.Project_Path }} /t:Restore /p:Configuration=${{ env.Configuration }} env: - Configuration: ${{ matrix.configuration }} + Configuration: ${{ matrix.configuration }} \ No newline at end of file From adcde74a378564d66eefd695dde96368133ca0c3 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 12:43:26 +0300 Subject: [PATCH 06/11] Update publish-nuget.yml --- .github/workflows/publish-nuget.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 5e23515..77592dd 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -24,7 +24,7 @@ defaults: jobs: create_nuget: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 with: @@ -35,8 +35,8 @@ jobs: uses: actions/setup-dotnet@v4 # Create the NuGet package in the folder from the environment variable NuGetDirectory - - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} - + - run: dotnet pack .\ValueInjecter\ValueInjecter.csproj --configuration Release --output ${{ env.NuGetDirectory }} + # Publish the NuGet package as an artifact, so they can be used in the following jobs - uses: actions/upload-artifact@v4 with: @@ -45,7 +45,7 @@ jobs: path: ${{ env.NuGetDirectory }}/*.nupkg run_test: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -58,7 +58,7 @@ jobs: # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository # You can update this logic if you want to manage releases differently if: github.event_name == 'release' - runs-on: ubuntu-latest + runs-on: windows-latest needs: [ run_test ] steps: # Download the NuGet package created in the previous job From bbfc5842237223f5f1ab88d6ae06938298c51886 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 12:49:37 +0300 Subject: [PATCH 07/11] v. 3.2.1 --- ValueInjecter/Injections/IValueInjection.cs | 6 ++++++ ValueInjecter/Injections/KnownSourceInjection.cs | 11 ++++++++++- ValueInjecter/Injections/ValueInjection.cs | 7 ++++++- ValueInjecter/ValueInjecter.csproj | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ValueInjecter/Injections/IValueInjection.cs b/ValueInjecter/Injections/IValueInjection.cs index 65fe6a2..620ac20 100644 --- a/ValueInjecter/Injections/IValueInjection.cs +++ b/ValueInjecter/Injections/IValueInjection.cs @@ -1,7 +1,13 @@ namespace Omu.ValueInjecter.Injections { + /// + /// value injection + /// public interface IValueInjection { + /// + /// map source object properties to target object properties + /// object Map(object source, object target); } } \ No newline at end of file diff --git a/ValueInjecter/Injections/KnownSourceInjection.cs b/ValueInjecter/Injections/KnownSourceInjection.cs index 39dc810..64660b0 100644 --- a/ValueInjecter/Injections/KnownSourceInjection.cs +++ b/ValueInjecter/Injections/KnownSourceInjection.cs @@ -1,13 +1,22 @@ namespace Omu.ValueInjecter.Injections { + /// + /// + /// public abstract class KnownSourceInjection : IValueInjection { + /// + /// + /// public object Map(object source, object target) { Inject((TSource) source, target); return target; } - + + /// + /// map TSource object to object target + /// protected abstract void Inject(TSource source, object target); } } \ No newline at end of file diff --git a/ValueInjecter/Injections/ValueInjection.cs b/ValueInjecter/Injections/ValueInjection.cs index 53d8303..d195806 100644 --- a/ValueInjecter/Injections/ValueInjection.cs +++ b/ValueInjecter/Injections/ValueInjection.cs @@ -1,13 +1,18 @@ namespace Omu.ValueInjecter.Injections -{ +{ + /// public abstract class ValueInjection : IValueInjection { + /// public object Map(object source, object target) { Inject(source, target); return target; } + /// + /// Map source object to target object + /// protected abstract void Inject(object source, object target); } } \ No newline at end of file diff --git a/ValueInjecter/ValueInjecter.csproj b/ValueInjecter/ValueInjecter.csproj index 0bf59b6..e323429 100644 --- a/ValueInjecter/ValueInjecter.csproj +++ b/ValueInjecter/ValueInjecter.csproj @@ -18,7 +18,7 @@ true 3.2.0.0 3.2.0.0 - 3.2 + 3.2.1 https://github.com/omuleanu/ValueInjecter/blob/master/LICENSE https://github.com/omuleanu/ValueInjecter From d4282f33fd060070d2f73b7c61d153b41edd2050 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 12:56:32 +0300 Subject: [PATCH 08/11] Update publish-nuget.yml --- .github/workflows/publish-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 77592dd..71a2ab4 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -51,7 +51,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 - name: Run tests - run: dotnet test --configuration Release + run: dotnet test .\Tests\Tests.csproj --configuration Release deploy: # Publish only when creating a GitHub Release From f35e8eb1c5c2f1e9b7f0eff2b1c919501934a0d3 Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 13:26:21 +0300 Subject: [PATCH 09/11] Update publish-nuget.yml --- .github/workflows/publish-nuget.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 71a2ab4..30c4418 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -33,6 +33,15 @@ jobs: # Install the .NET SDK indicated in the global.json file - name: Setup .NET uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v2 + + - name: Build libs + run: msbuild .\ValueInjecter\ValueInjecter.csproj /p:Configuration=Release # Create the NuGet package in the folder from the environment variable NuGetDirectory - run: dotnet pack .\ValueInjecter\ValueInjecter.csproj --configuration Release --output ${{ env.NuGetDirectory }} From c4acc65ba73ea81ece8be90181f2ec11dd1681ca Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 27 May 2024 13:47:34 +0300 Subject: [PATCH 10/11] Update publish-nuget.yml --- .github/workflows/publish-nuget.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 30c4418..031f980 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -35,7 +35,10 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - + + - name: Restore NuGet packages + run: dotnet restore ./ValueInjecter/ValueInjecter.csproj + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v2 From b98c56e1aed5a67efc3d6386fffea38af950e817 Mon Sep 17 00:00:00 2001 From: Valentin Plamadeala Date: Mon, 27 May 2024 14:06:52 +0300 Subject: [PATCH 11/11] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b56f09..2440222 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![buildtest](https://github.com/omuleanu/ValueInjecter/actions/workflows/buildtest.yml/badge.svg)](https://github.com/omuleanu/ValueInjecter/actions/workflows/buildtest.yml) ![NuGet Downloads](https://img.shields.io/nuget/dt/ValueInjecter) + + get via nuget **[ValueInjecter](https://www.nuget.org/packages/ValueInjecter/)** #### usage ``` ruby @@ -127,8 +130,6 @@ there's samples in the source code for winforms, ASP.net web-forms, DAL, and wpf deep cloning sample [here](https://github.com/omuleanu/ValueInjecter/blob/dae7956439cac8516979fe254a520a1942c5cdeb/Tests/Cloning.cs), and the [CloneInjection](https://github.com/omuleanu/ValueInjecter/blob/master/Tests/Injections/CloneInjection.cs) -for ASP.net MVC see http://prodinner.codeplex.com - **questions:** http://stackoverflow.com/questions/tagged/valueinjecter **chat:** https://gitter.im/omuleanu/ValueInjecter