Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ name: Build and Test

on:
push:
branches: [ "main" ]
branches: [main, dev]
paths: ['Code/**', 'build-and-test.yml']
pull_request:
branches: [ "main" ]
branches: [main, dev]
paths: ['Code/**', 'build-and-test.yml']

jobs:
build-and-test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./Code/Light.SharedCore.sln
- name: Build
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/release-on-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release to NuGet

on:
release:
types: [published]
workflow_dispatch:
inputs:
dotnetVersion:
description: "The version of .NET to use"
required: false
default: "8.0.x"

jobs:
release-to-nuget:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ github.event.inputs.dotnetVersion || '8.0.x' }}
- name: Prepare SNK file
env:
LIGHT_SHAREDCORE_SNK: ${{ secrets.LIGHT_SHAREDCORE_SNK }}
run: |
echo $LIGHT_SHAREDCORE_SNK | base64 --decode > ./Code/Light.SharedCore/Light.SharedCore.snk
- name: Create NuGet packages
run: dotnet pack ./Code/Light.SharedCore/Light.SharedCore.csproj -c Release /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=Light.SharedCore.snk /p:ContinuousIntegrationBuild=true
- name: Delete SNK file
run: rm ./Code/Light.SharedCore/Light.SharedCore.snk
- name: Push nupkg package
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push "./Code/Light.SharedCore/bin/Release/Light.SharedCore.*.nupkg" --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json

This file was deleted.

10 changes: 5 additions & 5 deletions Code/Light.SharedCore.Tests/Light.SharedCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<Import Project="Light.SharedCore.Tests.Local.props" Condition="Exists('Light.SharedCore.Tests.Local.props')" />

<PropertyGroup>
<TargetFramework Condition="'$(TargetFramework)' == '' AND '$(TargetFrameworks)' == ''">net7.0</TargetFramework>
<TargetFramework Condition="'$(TargetFramework)' == '' AND '$(TargetFrameworks)' == ''">net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Light.SharedCore\Light.SharedCore.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" PrivateAssets="all" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Light.Xunit" Version="1.0.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Code/Light.SharedCore.Tests/Parsing/DecimalParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static void CheckNumberAsSpan(ReadOnlySpan<char> text, decimal expectedV

[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumber(string text)
public static void InvalidNumber(string? text)
{
var result = DecimalParser.TryParse(text, out var actualValue);

Expand All @@ -102,7 +102,7 @@ public static void InvalidNumber(string text)
#if !NETFRAMEWORK
[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumberAsSpan(string text)
public static void InvalidNumberAsSpan(string? text)
{
var result = DecimalParser.TryParse(text.AsSpan(), out var actualValue);

Expand Down
4 changes: 2 additions & 2 deletions Code/Light.SharedCore.Tests/Parsing/DoubleParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static void CheckNumberAsSpan(ReadOnlySpan<char> text, double expectedVa

[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumber(string text)
public static void InvalidNumber(string? text)
{
var result = DoubleParser.TryParse(text, out var actualValue);

Expand All @@ -107,7 +107,7 @@ public static void InvalidNumber(string text)
#if !NETFRAMEWORK
[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumberAsSpan(string text)
public static void InvalidNumberAsSpan(string? text)
{
var result = DoubleParser.TryParse(text.AsSpan(), out var actualValue);

Expand Down
4 changes: 2 additions & 2 deletions Code/Light.SharedCore.Tests/Parsing/FloatParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static void CheckNumberAsSpan(ReadOnlySpan<char> text, float expectedVal

[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumber(string text)
public static void InvalidNumber(string? text)
{
var result = FloatParser.TryParse(text, out var actualValue);

Expand All @@ -104,7 +104,7 @@ public static void InvalidNumber(string text)
#if !NETFRAMEWORK
[Theory]
[MemberData(nameof(InvalidNumbers))]
public static void InvalidNumberAsSpan(string text)
public static void InvalidNumberAsSpan(string? text)
{
var result = FloatParser.TryParse(text.AsSpan(), out var actualValue);

Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions Code/Light.SharedCore/DataAccessAbstractions/IAsyncSession.cs

This file was deleted.

24 changes: 0 additions & 24 deletions Code/Light.SharedCore/DataAccessAbstractions/ISession.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;

namespace Light.SharedCore.DatabaseAccessAbstractions;

/// <summary>
/// Represents an asynchronous session to the database that
/// is only used to read data. This usually means that no explicit
/// transaction is needed for this session, although implementations can support
/// it to allow using READ UNCOMMITED isolation levels for queries, for example.
/// The connection to the database can be terminated by calling
/// <see cref="IAsyncDisposable.DisposeAsync" /> (or <see cref="IDisposable.Dispose" />).
/// If you want to manipulate data, use <see cref="IAsyncSession" />.
/// </summary>
/// <remarks>
/// Conceptually, a session is identical to a "Unit of Work" as defined in "Patterns of
/// Enterprise Application Architecture" by Martin Fowler et al. It manages the connection
/// to the database and represents a transaction. Strictly speaking, a Unit of Work also needs
/// to do Change Tracking which plain ADO.NET and all Micro-ORMs do not support. For this reason,
/// we chose the term "session" instead of "Unit of Work", also because it is simpler to use in daily life.
/// </remarks>
public interface IAsyncReadOnlySession : IDisposable, IAsyncDisposable;
31 changes: 31 additions & 0 deletions Code/Light.SharedCore/DatabaseAccessAbstractions/IAsyncSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Light.SharedCore.DatabaseAccessAbstractions;

/// <summary>
/// Represents an asynchronous session to a database that manipulates data. This means that
/// the implementation will either use a single dedicated transaction in the case of ADO.NET or Micro-ORMs
/// to ensure ACID properties, or the Change Tracking capabilities of a full ORM like Entity Framework Core.
/// The connection to the database can be terminated by calling
/// <see cref="IAsyncDisposable.DisposeAsync" /> (or <see cref="IDisposable.Dispose" />), the underlying transaction
/// will be automatically rolled back if <see cref="SaveChangesAsync"/> was not called beforehand.
/// Changes can be saved or committed to the database by calling <see cref="SaveChangesAsync" />.
/// If your session does not manipulate data, consider using the <see cref="IAsyncReadOnlySession" /> interface instead.
/// </summary>
/// <remarks>
/// Conceptually, a session is identical to a "Unit of Work" as defined in "Patterns of
/// Enterprise Application Architecture" by Martin Fowler et al. It manages the connection
/// to the database and represents a transaction. Strictly speaking, a Unit of Work also needs
/// to do Change Tracking which plain ADO.NET and all Micro-ORMs do not support. For this reason,
/// we chose the term "session" instead of "Unit of Work", also because it is simpler to use in daily life.
/// </remarks>
public interface IAsyncSession : IAsyncReadOnlySession
{
/// <summary>
/// Commits all changes to the database.
/// </summary>
/// <param name="cancellationToken">The token to cancel this asynchronous operation (optional).</param>
Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using System.Threading;
using System.Threading.Tasks;

namespace Light.SharedCore.DataAccessAbstractions;
namespace Light.SharedCore.DatabaseAccessAbstractions;

/// <summary>
/// Represents an asynchronous transaction that can be committed. The transaction should always be disposed.
/// A rollback is performed automatically on <see cref="IAsyncDisposable.DisposeAsync" /> when commit was not
/// A rollback is performed automatically on <see cref="IAsyncDisposable.DisposeAsync" /> when <see cref="CommitAsync"/> was not
/// called beforehand.
/// </summary>
public interface IAsyncTransaction : IAsyncDisposable, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace Light.SharedCore.DataAccessAbstractions;
namespace Light.SharedCore.DatabaseAccessAbstractions;

/// <summary>
/// Represents an asynchronous session to a database that is able to create individual transactions.
Expand All @@ -20,5 +20,5 @@ public interface IAsyncTransactionalSession : IAsyncReadOnlySession
/// is still active in your current scope (to avoid nesting transactions).
/// </summary>
/// <param name="cancellationToken">The token to cancel this asynchronous operation (optional).</param>
Task<IAsyncTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
ValueTask<IAsyncTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
}
Loading