From f977a420cb55a0cc624d4a7d2bcffc5eb91e6a27 Mon Sep 17 00:00:00 2001 From: Christian Prochnow Date: Tue, 24 Jun 2025 16:13:44 +0200 Subject: [PATCH 1/2] Use Directory.Packages.props, updated dependencies and target frameworks. --- .editorconfig | 2 +- .github/workflows/build-test.yaml | 8 ++-- AppCoreNet.EventStore.sln | 2 + Directory.Build.props | 15 +++---- Directory.Packages.props | 42 +++++++++++++++++++ GitVersion.yml | 11 ++--- NuGet.config | 16 +++++++ global.json | 2 +- .../AppCoreNet.EventStore.Abstractions.csproj | 15 ++----- .../StreamId.cs | 8 ++-- .../StreamPosition.cs | 6 +-- .../StreamState.cs | 6 +-- .../EventHandlerSubscriptionOptions.cs | 2 +- .../Subscriptions/SubscriptionId.cs | 8 ++-- .../Subscriptions/SubscriptionOptions.cs | 6 +-- .../AppCoreNet.EventStore.SqlServer.csproj | 19 ++------- .../DeleteStreamCommand.cs | 2 +- .../Migrations/MigrationBuilderExtensions.cs | 4 +- .../Model/Event.cs | 4 +- .../Model/EventStream.cs | 2 +- .../Model/EventSubscription.cs | 4 +- .../Model/EventTableType.cs | 6 +-- .../ReadEventsCommand.cs | 8 ++-- .../SqlServerEventStore.cs | 4 +- .../CreateSubscriptionCommand.cs | 4 +- .../DeleteSubscriptionCommand.cs | 2 +- .../UpdateSubscriptionCommand.cs | 4 +- .../WatchSubscriptionsStoredProcedure.cs | 6 +-- .../WatchEventsStoredProcedure.cs | 8 ++-- .../WriteEventsStoredProcedure.cs | 29 +++++++------ .../AppCoreNet.EventStore.csproj | 17 +++----- .../Subscriptions/SubscriptionManager.cs | 4 +- src/Directory.Build.props | 6 +-- ...reNet.EventStore.SpecificationTests.csproj | 15 +++---- .../EventStoreTests.cs | 6 +-- .../Subscriptions/SubscriptionStoreTests.cs | 3 ++ ...pCoreNet.EventStore.SqlServer.Tests.csproj | 20 ++------- ...rverFixture.cs => SqlServerTestFixture.cs} | 0 .../AppCoreNet.EventStore.Tests.csproj | 15 +++---- test/Directory.Build.props | 16 +++---- 40 files changed, 187 insertions(+), 170 deletions(-) create mode 100644 Directory.Packages.props create mode 100644 NuGet.config rename test/AppCoreNet.EventStore.SqlServer.Tests/{SqlServerFixture.cs => SqlServerTestFixture.cs} (100%) diff --git a/.editorconfig b/.editorconfig index a6ab73d..98f3666 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,7 +20,7 @@ charset=utf-8 # Microsoft .NET properties csharp_new_line_before_members_in_object_initializers=false -csharp_preferred_modifier_order=required, public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion csharp_style_var_elsewhere=false:none csharp_style_var_for_built_in_types=false:error dotnet_naming_rule.constants_rule.severity=warning diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 79d59cd..9d6314f 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -29,14 +29,14 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.x 8.0.x + 9.0.x - name: Restore run: dotnet restore - name: Build run: dotnet build --configuration ${{env.BUILD_CONFIGURATION}} --no-restore - name: Test - run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --filter "Category!=Integration" --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory test-results --no-build + run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory test-results --no-build - name: Build packages run: dotnet pack --configuration ${{env.BUILD_CONFIGURATION}} --output ./artifacts --no-build # - name: Upload coverage to Codecov @@ -69,8 +69,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.x 8.0.x + 9.0.x - name: Download artifacts uses: actions/download-artifact@v4 with: @@ -92,8 +92,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.x 8.0.x + 9.0.x - name: Download artifacts uses: actions/download-artifact@v4 with: diff --git a/AppCoreNet.EventStore.sln b/AppCoreNet.EventStore.sln index b491e67..877d92b 100644 --- a/AppCoreNet.EventStore.sln +++ b/AppCoreNet.EventStore.sln @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution LICENSE = LICENSE README.md = README.md stylecop.json = stylecop.json + Directory.Packages.props = Directory.Packages.props + NuGet.config = NuGet.config EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E85A2A1-38E1-4B4F-B32B-06E7856B5C52}" diff --git a/Directory.Build.props b/Directory.Build.props index 3506f4a..6b06777 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -38,7 +38,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -47,6 +47,7 @@ true + true $(MSBuildThisFileDirectory)AppCoreNet.ruleset @@ -55,19 +56,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..62fd83d --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,42 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml index 54ab19b..7a5d928 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,12 +1,13 @@ +workflow: GitFlow/v1 +mode: ContinuousDelivery assembly-versioning-scheme: Major assembly-file-versioning-scheme: MajorMinorPatchTag assembly-informational-format: '{SemVer}+{ShortSha}' -continuous-delivery-fallback-tag: 'alpha' -mode: 'ContinuousDeployment' branches: main: + label: alpha increment: Minor + support: + label: alpha pull-request: - tag: 'pr' -ignore: - sha: [] + label: pr diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..603adb2 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/global.json b/global.json index da113e4..a148135 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "9.0.301", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/src/AppCoreNet.EventStore.Abstractions/AppCoreNet.EventStore.Abstractions.csproj b/src/AppCoreNet.EventStore.Abstractions/AppCoreNet.EventStore.Abstractions.csproj index f5dde27..34280f3 100644 --- a/src/AppCoreNet.EventStore.Abstractions/AppCoreNet.EventStore.Abstractions.csproj +++ b/src/AppCoreNet.EventStore.Abstractions/AppCoreNet.EventStore.Abstractions.csproj @@ -1,25 +1,18 @@  - netstandard2.0;net462 + net8.0;netstandard2.0;net462 AppCoreNet.EventStore Provides public API for the AppCore .NET event store. - + - - - - - - - - - + + diff --git a/src/AppCoreNet.EventStore.Abstractions/StreamId.cs b/src/AppCoreNet.EventStore.Abstractions/StreamId.cs index 437478f..fb9b898 100644 --- a/src/AppCoreNet.EventStore.Abstractions/StreamId.cs +++ b/src/AppCoreNet.EventStore.Abstractions/StreamId.cs @@ -18,7 +18,7 @@ public sealed class StreamId : IEquatable /// /// Gets the special ID which refers to all existing streams. /// - public static readonly StreamId All = new ("*"); + public static readonly StreamId All = new("*"); /// /// Gets the ID value. @@ -68,7 +68,7 @@ public StreamId(string id) public static StreamId Prefix(string prefix) { Ensure.Arg.NotEmpty(prefix); - return new ($"{prefix}*"); + return new($"{prefix}*"); } /// @@ -79,7 +79,7 @@ public static StreamId Prefix(string prefix) public static StreamId Suffix(string suffix) { Ensure.Arg.NotEmpty(suffix); - return new ($"*{suffix}"); + return new($"*{suffix}"); } /// @@ -146,5 +146,5 @@ public override int GetHashCode() /// /// The value. /// The . - public static implicit operator StreamId(string id) => new (id); + public static implicit operator StreamId(string id) => new(id); } \ No newline at end of file diff --git a/src/AppCoreNet.EventStore.Abstractions/StreamPosition.cs b/src/AppCoreNet.EventStore.Abstractions/StreamPosition.cs index da3f4e0..411e0d0 100644 --- a/src/AppCoreNet.EventStore.Abstractions/StreamPosition.cs +++ b/src/AppCoreNet.EventStore.Abstractions/StreamPosition.cs @@ -18,12 +18,12 @@ namespace AppCoreNet.EventStore; /// /// Specifies to read from the start of the stream. /// - public static readonly StreamPosition Start = new (StartValue); + public static readonly StreamPosition Start = new(StartValue); /// /// Specifies to read from the end of the stream. /// - public static readonly StreamPosition End = new (EndValue); + public static readonly StreamPosition End = new(EndValue); /// /// Gets the value. @@ -71,7 +71,7 @@ public override string ToString() } /// - public string ToString(string? format, IFormatProvider formatProvider) + public string ToString(string? format, IFormatProvider? formatProvider) { switch (Value) { diff --git a/src/AppCoreNet.EventStore.Abstractions/StreamState.cs b/src/AppCoreNet.EventStore.Abstractions/StreamState.cs index f50bb72..9250fa7 100644 --- a/src/AppCoreNet.EventStore.Abstractions/StreamState.cs +++ b/src/AppCoreNet.EventStore.Abstractions/StreamState.cs @@ -20,12 +20,12 @@ namespace AppCoreNet.EventStore; /// /// Specifies that the stream can be at any position. /// - public static readonly StreamState Any = new (AnyValue); + public static readonly StreamState Any = new(AnyValue); /// /// Specifies that the stream should not exist. /// - public static readonly StreamState None = new (NoneValue); + public static readonly StreamState None = new(NoneValue); /// /// Gets the value. @@ -76,7 +76,7 @@ public override string ToString() } /// - public string ToString(string? format, IFormatProvider formatProvider) + public string ToString(string? format, IFormatProvider? formatProvider) { switch (Value) { diff --git a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/EventHandlerSubscriptionOptions.cs b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/EventHandlerSubscriptionOptions.cs index 9e3e3d7..7014a38 100644 --- a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/EventHandlerSubscriptionOptions.cs +++ b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/EventHandlerSubscriptionOptions.cs @@ -15,7 +15,7 @@ namespace AppCoreNet.EventStore.Subscriptions; /// public sealed class EventHandlerSubscriptionOptions { - internal List> EventHandlerFactories { get; } = new (); + internal List> EventHandlerFactories { get; } = new(); /// /// Adds the specified factory to create an . diff --git a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionId.cs b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionId.cs index 143a171..981249c 100644 --- a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionId.cs +++ b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionId.cs @@ -18,7 +18,7 @@ public sealed class SubscriptionId : IEquatable /// /// Gets the special ID which refers to all existing subscriptions. /// - public static readonly SubscriptionId All = new ("*"); + public static readonly SubscriptionId All = new("*"); /// /// Gets the ID value. @@ -68,7 +68,7 @@ public SubscriptionId(string id) public static SubscriptionId Prefix(string prefix) { Ensure.Arg.NotEmpty(prefix); - return new ($"{prefix}*"); + return new($"{prefix}*"); } /// @@ -79,7 +79,7 @@ public static SubscriptionId Prefix(string prefix) public static SubscriptionId Suffix(string suffix) { Ensure.Arg.NotEmpty(suffix); - return new ($"*{suffix}"); + return new($"*{suffix}"); } /// @@ -155,5 +155,5 @@ public override int GetHashCode() /// /// The value. /// The . - public static implicit operator SubscriptionId(string id) => new (id); + public static implicit operator SubscriptionId(string id) => new(id); } \ No newline at end of file diff --git a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionOptions.cs b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionOptions.cs index 25025fc..713c3d8 100644 --- a/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionOptions.cs +++ b/src/AppCoreNet.EventStore.Abstractions/Subscriptions/SubscriptionOptions.cs @@ -13,9 +13,9 @@ namespace AppCoreNet.EventStore.Subscriptions; /// public sealed class SubscriptionOptions { - private readonly Dictionary _subscribers = new (); + private readonly Dictionary _subscribers = new(); - internal Dictionary EventHandlerOptions { get; } = new (); + internal Dictionary EventHandlerOptions { get; } = new(); /// /// Gets or sets the batch size when processing event subscriptions. @@ -105,7 +105,7 @@ public SubscriptionOptions AddEventHandlers( Ensure.Arg.NotNull(subscriptionId); Ensure.Arg.NotNull(configure); - if (_subscribers.TryGetValue(subscriptionId, out Subscriber subscriber)) + if (_subscribers.TryGetValue(subscriptionId, out Subscriber? subscriber)) { if (subscriber.StreamId != streamId) throw new InvalidOperationException(); diff --git a/src/AppCoreNet.EventStore.SqlServer/AppCoreNet.EventStore.SqlServer.csproj b/src/AppCoreNet.EventStore.SqlServer/AppCoreNet.EventStore.SqlServer.csproj index e7defe2..32cf3d3 100644 --- a/src/AppCoreNet.EventStore.SqlServer/AppCoreNet.EventStore.SqlServer.csproj +++ b/src/AppCoreNet.EventStore.SqlServer/AppCoreNet.EventStore.SqlServer.csproj @@ -1,24 +1,13 @@  - net8.0;net6.0;netstandard2.0;net462 + net8.0 Provides public API for the AppCore .NET event store. - - - - - - - - - - - - - - + + + diff --git a/src/AppCoreNet.EventStore.SqlServer/DeleteStreamCommand.cs b/src/AppCoreNet.EventStore.SqlServer/DeleteStreamCommand.cs index 6d11ab8..5efcc20 100644 --- a/src/AppCoreNet.EventStore.SqlServer/DeleteStreamCommand.cs +++ b/src/AppCoreNet.EventStore.SqlServer/DeleteStreamCommand.cs @@ -11,7 +11,7 @@ internal sealed class DeleteStreamCommand : SqlTextCommand { private readonly string _schema; - required public StreamId StreamId { get; init; } + public required StreamId StreamId { get; init; } public DeleteStreamCommand(DbContext dbContext, string? schema) : base(dbContext) diff --git a/src/AppCoreNet.EventStore.SqlServer/Migrations/MigrationBuilderExtensions.cs b/src/AppCoreNet.EventStore.SqlServer/Migrations/MigrationBuilderExtensions.cs index 3e09913..118744b 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Migrations/MigrationBuilderExtensions.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Migrations/MigrationBuilderExtensions.cs @@ -26,7 +26,7 @@ public static void CreateEventStore(this MigrationBuilder builder, string? schem { Ensure.Arg.NotNull(builder); - foreach (string script in WriteEventsSqlStoredProcedure.GetCreateScripts(schema)) + foreach (string script in WriteEventsStoredProcedure.GetCreateScripts(schema)) { builder.ExecuteSql(script); } @@ -44,7 +44,7 @@ public static void DropEventStore(this MigrationBuilder builder, string? schema { Ensure.Arg.NotNull(builder); - foreach (string script in WriteEventsSqlStoredProcedure.GetDropScripts(schema)) + foreach (string script in WriteEventsStoredProcedure.GetDropScripts(schema)) { builder.ExecuteSql(script); } diff --git a/src/AppCoreNet.EventStore.SqlServer/Model/Event.cs b/src/AppCoreNet.EventStore.SqlServer/Model/Event.cs index 7710e96..425afd8 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Model/Event.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Model/Event.cs @@ -13,13 +13,13 @@ internal sealed class Event public EventStream? EventStream { get; init; } - required public string EventType { get; init; } + public required string EventType { get; init; } public DateTimeOffset? CreatedAt { get; init; } public long Index { get; init; } - required public string Data { get; init; } + public required string Data { get; init; } public string? Metadata { get; init; } } \ No newline at end of file diff --git a/src/AppCoreNet.EventStore.SqlServer/Model/EventStream.cs b/src/AppCoreNet.EventStore.SqlServer/Model/EventStream.cs index f734628..4ef8839 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Model/EventStream.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Model/EventStream.cs @@ -13,7 +13,7 @@ internal sealed class EventStream /// /// Gets the ID of the stream. /// - required public string StreamId { get; init; } + public required string StreamId { get; init; } /// /// Gets the last sequence number used by the stream. diff --git a/src/AppCoreNet.EventStore.SqlServer/Model/EventSubscription.cs b/src/AppCoreNet.EventStore.SqlServer/Model/EventSubscription.cs index 1b69700..67328ab 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Model/EventSubscription.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Model/EventSubscription.cs @@ -15,12 +15,12 @@ internal sealed class EventSubscription /// /// Gets the ID of the subscription. /// - required public string SubscriptionId { get; init; } + public required string SubscriptionId { get; init; } /// /// Gets the ID of the stream. /// - required public string StreamId { get; init; } + public required string StreamId { get; init; } /// /// Gets the date and time when the subscription was created. diff --git a/src/AppCoreNet.EventStore.SqlServer/Model/EventTableType.cs b/src/AppCoreNet.EventStore.SqlServer/Model/EventTableType.cs index bf8c279..a8012ce 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Model/EventTableType.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Model/EventTableType.cs @@ -6,18 +6,18 @@ namespace AppCoreNet.EventStore.SqlServer.Model; /// -/// Used to pass events to the . This class +/// Used to pass events to the . This class /// does not represent a database table. /// internal sealed class EventTableType { - required public string EventType { get; init; } + public required string EventType { get; init; } public DateTimeOffset CreatedAt { get; init; } public int Offset { get; init; } - required public string Data { get; init; } + public required string Data { get; init; } public string? Metadata { get; set; } } \ No newline at end of file diff --git a/src/AppCoreNet.EventStore.SqlServer/ReadEventsCommand.cs b/src/AppCoreNet.EventStore.SqlServer/ReadEventsCommand.cs index c9115a5..39407a6 100644 --- a/src/AppCoreNet.EventStore.SqlServer/ReadEventsCommand.cs +++ b/src/AppCoreNet.EventStore.SqlServer/ReadEventsCommand.cs @@ -12,13 +12,13 @@ namespace AppCoreNet.EventStore.SqlServer; internal sealed class ReadEventsCommand : SqlCommand> { - required public StreamId StreamId { get; init; } + public required StreamId StreamId { get; init; } - required public StreamPosition Position { get; init; } + public required StreamPosition Position { get; init; } - required public StreamReadDirection Direction { get; init; } + public required StreamReadDirection Direction { get; init; } - required public int MaxCount { get; init; } + public required int MaxCount { get; init; } public ReadEventsCommand(DbContext dbContext) : base(dbContext) diff --git a/src/AppCoreNet.EventStore.SqlServer/SqlServerEventStore.cs b/src/AppCoreNet.EventStore.SqlServer/SqlServerEventStore.cs index 03535f7..9777847 100644 --- a/src/AppCoreNet.EventStore.SqlServer/SqlServerEventStore.cs +++ b/src/AppCoreNet.EventStore.SqlServer/SqlServerEventStore.cs @@ -57,7 +57,7 @@ public async Task WriteAsync( Ensure.Arg.NotWildcard(streamId); Ensure.Arg.NotNull(events); - var procedure = new WriteEventsSqlStoredProcedure(_dbContext, _options.SchemaName, _serializer) + var procedure = new WriteEventsStoredProcedure(_dbContext, _options.SchemaName, _serializer) { StreamId = streamId, ExpectedPosition = state.Value, @@ -113,7 +113,7 @@ public async Task> ReadAsync( result.Add( new EventEnvelope( e.EventType, - _serializer.Deserialize(e.EventType, e.Data) !, + _serializer.Deserialize(e.EventType, e.Data)!, new EventMetadata { Index = e.Index, diff --git a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/CreateSubscriptionCommand.cs b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/CreateSubscriptionCommand.cs index 533dfd5..f2eeddf 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/CreateSubscriptionCommand.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/CreateSubscriptionCommand.cs @@ -11,9 +11,9 @@ internal sealed class CreateSubscriptionCommand : SqlTextCommand { private readonly string _schema; - required public SubscriptionId SubscriptionId { get; init; } + public required SubscriptionId SubscriptionId { get; init; } - required public StreamId StreamId { get; init; } + public required StreamId StreamId { get; init; } public bool FailIfExists { get; init; } diff --git a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/DeleteSubscriptionCommand.cs b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/DeleteSubscriptionCommand.cs index 2c71098..28e7dba 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/DeleteSubscriptionCommand.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/DeleteSubscriptionCommand.cs @@ -12,7 +12,7 @@ internal sealed class DeleteSubscriptionCommand : SqlTextCommand { private readonly string _schema; - required public SubscriptionId SubscriptionId { get; init; } + public required SubscriptionId SubscriptionId { get; init; } public DeleteSubscriptionCommand(DbContext dbContext, string? schema) : base(dbContext) diff --git a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/UpdateSubscriptionCommand.cs b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/UpdateSubscriptionCommand.cs index 1725a81..308d017 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/UpdateSubscriptionCommand.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/UpdateSubscriptionCommand.cs @@ -11,9 +11,9 @@ internal sealed class UpdateSubscriptionCommand : SqlTextCommand { private readonly string _schema; - required public SubscriptionId SubscriptionId { get; init; } + public required SubscriptionId SubscriptionId { get; init; } - required public long Position { get; init; } + public required long Position { get; init; } public UpdateSubscriptionCommand(DbContext dbContext, string? schema) : base(dbContext) diff --git a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/WatchSubscriptionsStoredProcedure.cs b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/WatchSubscriptionsStoredProcedure.cs index 04acb5d..a31947d 100644 --- a/src/AppCoreNet.EventStore.SqlServer/Subscriptions/WatchSubscriptionsStoredProcedure.cs +++ b/src/AppCoreNet.EventStore.SqlServer/Subscriptions/WatchSubscriptionsStoredProcedure.cs @@ -13,11 +13,11 @@ internal sealed class WatchSubscriptionsStoredProcedure : SqlStoredProcedure +internal sealed class WriteEventsStoredProcedure : SqlStoredProcedure { private const string ProcedureName = "WriteEvents"; private readonly string? _schema; private readonly IEventStoreSerializer _serializer; - required public StreamId StreamId { get; init; } + public required StreamId StreamId { get; init; } - required public long ExpectedPosition { get; init; } + public required long ExpectedPosition { get; init; } - required public IEnumerable Events { get; init; } + public required IEnumerable Events { get; init; } - required public string LockResource { get; init; } + public required string LockResource { get; init; } - public WriteEventsSqlStoredProcedure(DbContext dbContext, string? schema, IEventStoreSerializer serializer) + public WriteEventsStoredProcedure(DbContext dbContext, string? schema, IEventStoreSerializer serializer) : base(dbContext, $"[{SchemaUtils.GetEventStoreSchema(schema)}].{ProcedureName}") { _schema = schema; @@ -171,18 +171,21 @@ private DataTable CreateEventDataTable() dataTable.Columns.Add(new DataColumn(nameof(Model.EventTableType.Data), typeof(string))); dataTable.Columns.Add(new DataColumn(nameof(Model.EventTableType.Metadata), typeof(string))); - IEnumerable<(EventEnvelope, int index)> eventEnvelopes = Events.Select( - (e, index) => (e as EventEnvelope ?? new EventEnvelope(e), index)); + IEnumerable<(EventEnvelope Envelope, int Index)> eventEnvelopes = Events.Select( + (e, index) => (e as EventEnvelope ?? new EventEnvelope(e), Index: index)); - foreach ((EventEnvelope @event, int index) in eventEnvelopes) + foreach ((EventEnvelope Envelope, int Index) eventEnvelopeWithIndex in eventEnvelopes) { + EventEnvelope envelope = eventEnvelopeWithIndex.Envelope; + int index = eventEnvelopeWithIndex.Index; + dataTable.Rows.Add( [ - @event.EventTypeName, - @event.Metadata.CreatedAt, + envelope.EventTypeName, + envelope.Metadata.CreatedAt, index, - _serializer.Serialize(@event.Data), - _serializer.Serialize(@event.Metadata.Data), + _serializer.Serialize(envelope.Data), + _serializer.Serialize(envelope.Metadata.Data), ]); } diff --git a/src/AppCoreNet.EventStore/AppCoreNet.EventStore.csproj b/src/AppCoreNet.EventStore/AppCoreNet.EventStore.csproj index 2aee218..1e1726c 100644 --- a/src/AppCoreNet.EventStore/AppCoreNet.EventStore.csproj +++ b/src/AppCoreNet.EventStore/AppCoreNet.EventStore.csproj @@ -10,18 +10,11 @@ - - - - - - - - - - - - + + + + + diff --git a/src/AppCoreNet.EventStore/Subscriptions/SubscriptionManager.cs b/src/AppCoreNet.EventStore/Subscriptions/SubscriptionManager.cs index f6f740f..77e3c0f 100644 --- a/src/AppCoreNet.EventStore/Subscriptions/SubscriptionManager.cs +++ b/src/AppCoreNet.EventStore/Subscriptions/SubscriptionManager.cs @@ -18,11 +18,11 @@ public sealed class SubscriptionManager : ISubscriptionManager { private readonly IServiceScopeFactory _serviceScopeFactory; private readonly SubscriptionOptions _options; - private readonly ConcurrentDictionary _subscriptions = new (); + private readonly ConcurrentDictionary _subscriptions = new(); private sealed class NoOpListener : ISubscriptionListener { - public static readonly NoOpListener Instance = new (); + public static readonly NoOpListener Instance = new(); public Task HandleAsync( SubscriptionId subscriptionId, diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 3efd5ba..8e5ec29 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,13 +6,13 @@ - + all - + all - + all diff --git a/test/AppCoreNet.EventStore.SpecificationTests/AppCoreNet.EventStore.SpecificationTests.csproj b/test/AppCoreNet.EventStore.SpecificationTests/AppCoreNet.EventStore.SpecificationTests.csproj index fb5e102..e5405cc 100644 --- a/test/AppCoreNet.EventStore.SpecificationTests/AppCoreNet.EventStore.SpecificationTests.csproj +++ b/test/AppCoreNet.EventStore.SpecificationTests/AppCoreNet.EventStore.SpecificationTests.csproj @@ -1,20 +1,15 @@ - net8.0;net6.0 - $(TargetFrameworks);net462 + net9.0;net8.0 + $(TargetFrameworks);net472 false AppCoreNet.EventStore - - - - - - - - + + + diff --git a/test/AppCoreNet.EventStore.SpecificationTests/EventStoreTests.cs b/test/AppCoreNet.EventStore.SpecificationTests/EventStoreTests.cs index db2e5bb..51a7ab7 100644 --- a/test/AppCoreNet.EventStore.SpecificationTests/EventStoreTests.cs +++ b/test/AppCoreNet.EventStore.SpecificationTests/EventStoreTests.cs @@ -36,14 +36,14 @@ protected virtual void ConfigureServices(IServiceCollection services) { -2 => StreamState.Any, -1 => StreamState.None, - _ => StreamState.Index(value) + _ => StreamState.Index(value), }; private static StreamPosition CreateStreamPosition(long value) => value switch { -2 => StreamPosition.End, -1 => StreamPosition.Start, - _ => StreamPosition.FromValue(value) + _ => StreamPosition.FromValue(value), }; async Task IAsyncLifetime.InitializeAsync() @@ -422,7 +422,7 @@ public async Task WatchWithoutEventsReturnsNull() var eventStore = scope.ServiceProvider.GetRequiredService(); TimeSpan timeout = TimeSpan.FromSeconds(1); - Stopwatch watch = new (); + Stopwatch watch = new(); watch.Start(); WatchEventResult? result = await eventStore.WatchAsync("$all", StreamPosition.Start, timeout); diff --git a/test/AppCoreNet.EventStore.SpecificationTests/Subscriptions/SubscriptionStoreTests.cs b/test/AppCoreNet.EventStore.SpecificationTests/Subscriptions/SubscriptionStoreTests.cs index d7c2d9e..3ba86aa 100644 --- a/test/AppCoreNet.EventStore.SpecificationTests/Subscriptions/SubscriptionStoreTests.cs +++ b/test/AppCoreNet.EventStore.SpecificationTests/Subscriptions/SubscriptionStoreTests.cs @@ -209,7 +209,10 @@ public async Task WatchAndUpdateSucceedsOnceWithoutNewEvents() await subscriptionStore.UpdateAsync(subscriptionId, events.Last().Metadata.Sequence); if (transaction != null) + { await transaction.CommitAsync(); + await transaction.DisposeAsync(); + } await using ITransaction? transaction2 = subscriptionStore is ITransactionalStore transactionalStore2 ? await transactionalStore2.BeginTransactionAsync() diff --git a/test/AppCoreNet.EventStore.SqlServer.Tests/AppCoreNet.EventStore.SqlServer.Tests.csproj b/test/AppCoreNet.EventStore.SqlServer.Tests/AppCoreNet.EventStore.SqlServer.Tests.csproj index d653141..9a9d69d 100644 --- a/test/AppCoreNet.EventStore.SqlServer.Tests/AppCoreNet.EventStore.SqlServer.Tests.csproj +++ b/test/AppCoreNet.EventStore.SqlServer.Tests/AppCoreNet.EventStore.SqlServer.Tests.csproj @@ -1,27 +1,15 @@  - net8.0;net6.0 - + net9.0;net8.0 AppCoreNet.EventStore.SqlServer - - - - - - - - - - - - - + + - + diff --git a/test/AppCoreNet.EventStore.SqlServer.Tests/SqlServerFixture.cs b/test/AppCoreNet.EventStore.SqlServer.Tests/SqlServerTestFixture.cs similarity index 100% rename from test/AppCoreNet.EventStore.SqlServer.Tests/SqlServerFixture.cs rename to test/AppCoreNet.EventStore.SqlServer.Tests/SqlServerTestFixture.cs diff --git a/test/AppCoreNet.EventStore.Tests/AppCoreNet.EventStore.Tests.csproj b/test/AppCoreNet.EventStore.Tests/AppCoreNet.EventStore.Tests.csproj index d20a1ac..80c2a32 100644 --- a/test/AppCoreNet.EventStore.Tests/AppCoreNet.EventStore.Tests.csproj +++ b/test/AppCoreNet.EventStore.Tests/AppCoreNet.EventStore.Tests.csproj @@ -1,19 +1,14 @@ - net8.0;net6.0 - $(TargetFrameworks);net462 + net9.0;net8.0 + $(TargetFrameworks);net472 AppCoreNet.EventStore - - - - - - - - + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 27a8cd8..6e1c272 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,23 +7,23 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 9428e3f3e2ee48c71a94ea8c378ff024b81fa4ef Mon Sep 17 00:00:00 2001 From: Christian Prochnow Date: Tue, 24 Jun 2025 16:21:12 +0200 Subject: [PATCH 2/2] Fixed Github workflow. --- .github/workflows/build-test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 9d6314f..c2207a7 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -31,12 +31,15 @@ jobs: dotnet-version: | 8.0.x 9.0.x + - name: Set BUILD_CONFIGURATION + if: startsWith(github.ref, 'refs/tags/') + run: echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV - name: Restore run: dotnet restore - name: Build run: dotnet build --configuration ${{env.BUILD_CONFIGURATION}} --no-restore - name: Test - run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory test-results --no-build + run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --filter "Category!=Integration" --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory test-results --no-build - name: Build packages run: dotnet pack --configuration ${{env.BUILD_CONFIGURATION}} --output ./artifacts --no-build # - name: Upload coverage to Codecov