diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 5ffb68c..c035a8d 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -1,4 +1,4 @@ -name: Slim CD Pipeline +name: Slim CD Pipeline on: push: @@ -6,7 +6,6 @@ on: - master jobs: - build: environment: Default strategy: @@ -21,30 +20,32 @@ jobs: Test_Project_Path: Slim.Tests\Slim.Tests.csproj Source_Project_Path: Slim\Slim.csproj Integration_Project_Path: Slim.Integration\Slim.Integration.csproj - Actions_Allow_Unsecure_Commands: true steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: '9.x' + - name: Restore dependencies + run: dotnet restore $env:Solution_Path + - name: Build Slim project - run: dotnet build Slim -c $env:Configuration + run: dotnet build Slim -c $env:Configuration --no-restore - name: Build Slim.Integration project - run: dotnet build $env:Integration_Project_Path -c $env:Configuration + run: dotnet build $env:Integration_Project_Path -c $env:Configuration --no-restore - name: Package Slim - run: dotnet pack -c Release -o . $env:Source_Project_Path + run: dotnet pack -c Release -o . $env:Source_Project_Path --no-build - name: Package Slim.Integration - run: dotnet pack -c Release -o . $env:Integration_Project_Path + run: dotnet pack -c Release -o . $env:Integration_Project_Path --no-build - name: Publish run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4fa8915..f2bc6e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Slim CI Pipeline +name: Slim CI Pipeline on: push: @@ -9,9 +9,7 @@ on: - master jobs: - build: - strategy: matrix: targetplatform: [x64] @@ -23,27 +21,26 @@ jobs: Test_Project_Path: Slim.Tests\Slim.Tests.csproj Integration_Test_Project_Path: Slim.Integration.Tests\Slim.Integration.Tests.csproj Source_Project_Path: Slim\Slim.csproj - Actions_Allow_Unsecure_Commands: true steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: '9.x' + - name: Restore dependencies + run: dotnet restore $env:Solution_Path + + - name: Build solution + run: dotnet build $env:Solution_Path --no-restore --configuration Release + - name: Execute Slim Unit Tests - run: dotnet test $env:Test_Project_Path + run: dotnet test $env:Test_Project_Path --no-build --configuration Release --verbosity normal - name: Execute Slim.Integration Unit Tests - run: dotnet test $env:Integration_Test_Project_Path - - - name: Restore Project - run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier - env: - Configuration: Debug - RuntimeIdentifier: win-${{ matrix.targetplatform }} \ No newline at end of file + run: dotnet test $env:Integration_Test_Project_Path --no-build --configuration Release --verbosity normal \ No newline at end of file diff --git a/Slim.Tests/ServiceManagerTests.cs b/Slim.Tests/ServiceManagerTests.cs index 376b354..a0d1854 100644 --- a/Slim.Tests/ServiceManagerTests.cs +++ b/Slim.Tests/ServiceManagerTests.cs @@ -27,18 +27,15 @@ public class ServiceManagerTests } [TestMethod] - public void DependencyOnPrivateConstructorServiceThrows() + public void DependencyOnPrivateConstructorServiceImplements() { var di = new ServiceManager(); di.RegisterSingleton(); di.RegisterSingleton(); - var action = new Action(() => - { - di.GetService(); - }); + var service = di.GetService(); - action.Should().Throw(); + service.Should().NotBeNull(); } [TestMethod] diff --git a/Slim.Tests/Slim.Tests.csproj b/Slim.Tests/Slim.Tests.csproj index 27c4463..5d242fd 100644 --- a/Slim.Tests/Slim.Tests.csproj +++ b/Slim.Tests/Slim.Tests.csproj @@ -2,16 +2,16 @@ net6.0 - latest + latest false - - - - - + + + + + diff --git a/Slim/ServiceManager.cs b/Slim/ServiceManager.cs index 3f577d2..7a6f134 100644 --- a/Slim/ServiceManager.cs +++ b/Slim/ServiceManager.cs @@ -807,7 +807,7 @@ public sealed class ServiceManager : IServiceManager /* * Order constructors to give priority to constructors that have PrefferedConstructorAttribute decorator */ - var constructors = implementType.GetConstructors() + var constructors = implementType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(c => c.GetCustomAttribute() is null) .OrderBy(c => c.GetCustomAttribute() is PreferredConstructorAttribute preferredConstructorAttribute ? diff --git a/Slim/Slim.csproj b/Slim/Slim.csproj index 7e5dee7..f1e74fa 100644 --- a/Slim/Slim.csproj +++ b/Slim/Slim.csproj @@ -8,10 +8,10 @@ Service lifetime management and dependency injection framework. - 1.10.1 - 1.10.1 + 1.10.2 + 1.10.2 https://github.com/AlexMacocian/Slim - 1.10.1 + 1.10.2 true true LICENSE