diff --git a/.editorconfig b/.editorconfig
index 5426f75..108919f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -143,6 +143,6 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
-[*.{xml,csproj,targets,props,json}]
+[*.{xml,csproj,targets,props,json,yml}]
indent_size = 2
indent_style = space
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 37ec665..2e23646 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,33 +6,110 @@ variables:
LANG: "de"
-debug-job:
+
+stages:
+ - build
+ - test
+ - deploy
+
+
+
+debug-build:
+ stage: build
tags:
- docker
+ - lnx
except:
- tags
- # branch-coverage
- #coverage: '/Total[^|]*\|[^|]*\|\s*([0-9.%]+)/'
- # line-coverage
- coverage: '/Total[^|]*\|\s*([0-9.%]+)/'
script:
- dotnet restore --no-cache --force
- dotnet build -c Debug --nologo --no-restore --no-incremental
- - dotnet test -c Debug --nologo --no-restore --no-build
- - dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate **/*.nupkg
+ - mkdir ./artifacts
+ - mv ./AMWD.Common/bin/Debug/*.nupkg ./artifacts/
+ - mv ./AMWD.Common/bin/Debug/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.AspNetCore/bin/Debug/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.AspNetCore/bin/Debug/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.EntityFrameworkCore/bin/Debug/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.EntityFrameworkCore/bin/Debug/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.Moq/bin/Debug/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.Moq/bin/Debug/*.snupkg ./artifacts/
+ artifacts:
+ paths:
+ - artifacts/*.nupkg
+ - artifacts/*.snupkg
+ expire_in: 7 days
-
-release-job:
+debug-test:
+ stage: test
+ dependencies:
+ - debug-build
tags:
- docker
- only:
+ - lnx
+ except:
- tags
# branch-coverage
- #coverage: '/Total[^|]*\|[^|]*\|\s*([0-9.%]+)/'
+ coverage: '/Total[^|]*\|[^|]*\|\s*([0-9.%]+)/'
+ script:
+ - dotnet restore --no-cache --force
+ - dotnet test -c Debug --nologo --no-restore
+
+
+
+
+release-build:
+ stage: build
+ tags:
+ - docker
+ - lnx
+ - amd64
+ only:
+ - tags
+ script:
+ - dotnet restore --no-cache --force
+ - dotnet build -c Release --nologo --no-restore --no-incremental
+ - mkdir ./artifacts
+ - mv ./AMWD.Common/bin/Release/*.nupkg ./artifacts/
+ - mv ./AMWD.Common/bin/Release/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.AspNetCore/bin/Release/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.AspNetCore/bin/Release/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.EntityFrameworkCore/bin/Release/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.EntityFrameworkCore/bin/Release/*.snupkg ./artifacts/
+ - mv ./AMWD.Common.Moq/bin/Release/*.nupkg ./artifacts/
+ - mv ./AMWD.Common.Moq/bin/Release/*.snupkg ./artifacts/
+ artifacts:
+ paths:
+ - artifacts/*.nupkg
+ - artifacts/*.snupkg
+ expire_in: 1 day
+
+release-test:
+ stage: test
+ dependencies:
+ - release-build
+ tags:
+ - docker
+ - lnx
+ - amd64
+ only:
+ - tags
# line-coverage
coverage: '/Total[^|]*\|\s*([0-9.%]+)/'
script:
- dotnet restore --no-cache --force
- - dotnet build -c Release --nologo --no-restore --no-incremental
- - dotnet test -c Release --nologo --no-restore --no-build
- - dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate **/*.nupkg
+ - dotnet test -c Release --nologo --no-restore
+
+
+release-deploy:
+ stage: deploy
+ dependencies:
+ - release-build
+ - release-test
+ tags:
+ - docker
+ - lnx
+ - amd64
+ only:
+ - tags
+ script:
+ - dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate artifacts/*.nupkg
diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs b/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs
index 184c247..c41c2fa 100644
--- a/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs
+++ b/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs
@@ -114,7 +114,7 @@ namespace Microsoft.EntityFrameworkCore
}
}
- private static DatabaseProvider GetProviderType(this DatabaseFacade database)
+ internal static DatabaseProvider GetProviderType(this DatabaseFacade database)
=> GetProviderType(database.ProviderName);
private static DatabaseProvider GetProviderType(this DbConnection connection)
@@ -342,7 +342,7 @@ END;"
}
}
- private enum DatabaseProvider
+ internal enum DatabaseProvider
{
MySQL = 1,
Oracle = 2,
diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs b/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs
new file mode 100644
index 0000000..d24fd71
--- /dev/null
+++ b/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Storage;
+
+namespace Microsoft.EntityFrameworkCore
+{
+ ///
+ /// Extensions for the .
+ ///
+ public static class DbContextExensions
+ {
+ ///
+ /// Starts a new transaction.
+ ///
+ ///
+ /// See Transactions in EF Core for more information.
+ ///
+ /// The current .
+ ///
+ /// A that represents the started transaction.
+ ///
+ public static IDbContextTransaction BeginTransaction(this DbContext dbContext)
+ {
+ if (dbContext.Database.GetProviderType() == DatabaseFacadeExtensions.DatabaseProvider.InMemory)
+ return new DbContextTransactionStub();
+
+ return dbContext.Database.BeginTransaction();
+ }
+
+ ///
+ /// Asynchronously starts a new transaction.
+ ///
+ ///
+ ///
+ /// Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This
+ /// includes both parallel execution of async queries and any explicit concurrent use from multiple threads.
+ /// Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute
+ /// in parallel. See Avoiding DbContext threading issues
+ /// for more information.
+ ///
+ ///
+ /// See Transactions in EF Core for more information.
+ ///
+ ///
+ /// The current .
+ /// A to observe while waiting for the task to complete.
+ ///
+ /// A task that represents the asynchronous transaction initialization. The task result contains a that represents the started transaction.
+ ///
+ /// If the is canceled.
+ public static Task BeginTransactionAsync(this DbContext dbContext, CancellationToken cancellationToken)
+ {
+ if (dbContext.Database.GetProviderType() == DatabaseFacadeExtensions.DatabaseProvider.InMemory)
+ return Task.FromResult(new DbContextTransactionStub());
+
+ return dbContext.Database.BeginTransactionAsync(cancellationToken);
+ }
+
+ ///
+ private class DbContextTransactionStub : IDbContextTransaction
+ {
+ ///
+ public Guid TransactionId { get; private set; } = Guid.NewGuid();
+
+ ///
+ public void Commit()
+ { }
+
+ ///
+ public Task CommitAsync(CancellationToken cancellationToken = default)
+ => Task.CompletedTask;
+
+ ///
+ public void Dispose()
+ { }
+
+ ///
+ public ValueTask DisposeAsync()
+ => new(Task.CompletedTask);
+
+ ///
+ public void Rollback()
+ { }
+
+ ///
+ public Task RollbackAsync(CancellationToken cancellationToken = default)
+ => Task.CompletedTask;
+ }
+ }
+}
diff --git a/AMWD.Common/Logging/FileLogger.cs b/AMWD.Common/Logging/FileLogger.cs
index 73d233a..834c34f 100644
--- a/AMWD.Common/Logging/FileLogger.cs
+++ b/AMWD.Common/Logging/FileLogger.cs
@@ -14,9 +14,9 @@ namespace AMWD.Common.Logging
/// Implements a file logging based on the interface.
///
///
- /// This implementation is also implementing the interface!
+ /// This implementation is also using the interface!
///
- /// Inspired by
+ /// Inspired by ConsoleLogger.cs
///
///
///
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0d6bbb..be06e8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,15 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [Upcoming](https://git.am-wd.de/AM.WD/common/compare/v1.10.0...main) - 0000-00-00
+## [Upcoming](https://git.am-wd.de/AM.WD/common/compare/v1.11.0...main) - 0000-00-00
+
+### Added
+
+- `ArReader` and `ArWriter` for Unix archives
+- `TarReader` and `TarWriter` for TAR archives
+
+
+## [v1.11.0](https://git.am-wd.de/AM.WD/common/compare/v1.10.0...v1.11.0) - 2023-03-29
### Added
- `directory.build.props` and `directory.build.targets`
- `GetDisplayName()` extension for enums (`DisplayAttribute(Name = "")`)
- `FileLogger` as additional `ILogger` implementation (from `Microsoft.Extensions.Logging`)
-- `ArReader` and `ArWriter` for Unix archives
-- `TarReader` and `TarWriter` for TAR archives
+- `StartTransaction(Async)` as `DbContext` extensions; prevents exceptions on `InMemory` database
## [v1.10.0](https://git.am-wd.de/AM.WD/common/compare/v1.9.0...v1.10.0) - 2022-09-18
diff --git a/Directory.Build.props b/Directory.Build.props
index e32b6ca..e903063 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,6 +1,6 @@
- {semvertag:main}{!:-mod}
+ {semvertag:main}{!:-dev}
true
false