1
0

Merge branch 'main' into packing

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
2023-04-03 09:43:31 +02:00
7 changed files with 198 additions and 23 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -0,0 +1,91 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Storage;
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Extensions for the <see cref="DbContext"/>.
/// </summary>
public static class DbContextExensions
{
/// <summary>
/// Starts a new transaction.
/// </summary>
/// <remarks>
/// See <see href="https://aka.ms/efcore-docs-transactions">Transactions in EF Core</see> for more information.
/// </remarks>
/// <param name="dbContext">The current <see cref="DbContext"/>.</param>
/// <returns>
/// A <see cref="IDbContextTransaction" /> that represents the started transaction.
/// </returns>
public static IDbContextTransaction BeginTransaction(this DbContext dbContext)
{
if (dbContext.Database.GetProviderType() == DatabaseFacadeExtensions.DatabaseProvider.InMemory)
return new DbContextTransactionStub();
return dbContext.Database.BeginTransaction();
}
/// <summary>
/// Asynchronously starts a new transaction.
/// </summary>
/// <remarks>
/// <para>
/// 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 <see href="https://aka.ms/efcore-docs-threading">Avoiding DbContext threading issues</see>
/// for more information.
/// </para>
/// <para>
/// See <see href="https://aka.ms/efcore-docs-transactions">Transactions in EF Core</see> for more information.
/// </para>
/// </remarks>
/// <param name="dbContext">The current <see cref="DbContext"/>.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>
/// A task that represents the asynchronous transaction initialization. The task result contains a <see cref="IDbContextTransaction" /> that represents the started transaction.
/// </returns>
/// <exception cref="OperationCanceledException">If the <see cref="CancellationToken" /> is canceled.</exception>
public static Task<IDbContextTransaction> BeginTransactionAsync(this DbContext dbContext, CancellationToken cancellationToken)
{
if (dbContext.Database.GetProviderType() == DatabaseFacadeExtensions.DatabaseProvider.InMemory)
return Task.FromResult<IDbContextTransaction>(new DbContextTransactionStub());
return dbContext.Database.BeginTransactionAsync(cancellationToken);
}
/// <inheritdoc cref="IDbContextTransaction" />
private class DbContextTransactionStub : IDbContextTransaction
{
/// <inheritdoc />
public Guid TransactionId { get; private set; } = Guid.NewGuid();
/// <inheritdoc />
public void Commit()
{ }
/// <inheritdoc />
public Task CommitAsync(CancellationToken cancellationToken = default)
=> Task.CompletedTask;
/// <inheritdoc />
public void Dispose()
{ }
/// <inheritdoc />
public ValueTask DisposeAsync()
=> new(Task.CompletedTask);
/// <inheritdoc />
public void Rollback()
{ }
/// <inheritdoc />
public Task RollbackAsync(CancellationToken cancellationToken = default)
=> Task.CompletedTask;
}
}
}

View File

@@ -14,9 +14,9 @@ namespace AMWD.Common.Logging
/// Implements a file logging based on the <see cref="ILogger"/> interface.
/// </summary>
/// <remarks>
/// This implementation is also implementing the <see cref="IDisposable"/> interface!
/// This implementation is also using the <see cref="IDisposable"/> interface!
/// <br/>
/// Inspired by <a href="https://github.com/aspnet/Logging/blob/2d2f31968229eddb57b6ba3d34696ef366a6c71b/src/Microsoft.Extensions.Logging.Console/ConsoleLogger.cs" />
/// Inspired by <see href="https://github.com/aspnet/Logging/blob/2d2f31968229eddb57b6ba3d34696ef366a6c71b/src/Microsoft.Extensions.Logging.Console/ConsoleLogger.cs">ConsoleLogger.cs</see>
/// </remarks>
/// <seealso cref="ILogger" />
/// <seealso cref="IDisposable" />

View File

@@ -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

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<NrtRevisionFormat>{semvertag:main}{!:-mod}</NrtRevisionFormat>
<NrtRevisionFormat>{semvertag:main}{!:-dev}</NrtRevisionFormat>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>