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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Core.ElasticSearch/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Core.ElasticSearch;

public class ElasticSearchConfig
{
public string Url { get; set; } = default!;
public string DefaultIndex { get; set; } = default!;
public string Url { get; set; } = null!;
public string DefaultIndex { get; set; } = null!;
}

public static class ElasticSearchConfigExtensions
Expand Down
14 changes: 7 additions & 7 deletions Core.EntityFramework.Tests/EntityFrameworkProjectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public async Task Applies_Works_Separately()
{
var projection = new ShoppingCartProjection { DbContext = context };

var cartId = Guid.NewGuid();
var clientId = Guid.NewGuid();
var cartId = Guid.CreateVersion7();
var clientId = Guid.CreateVersion7();

await projection.Handle([EventEnvelope.From(new Opened(cartId, clientId))], CancellationToken.None);
await context.SaveChangesAsync();
Expand Down Expand Up @@ -75,8 +75,8 @@ public async Task Applies_Works_In_Batch()
{
var projection = new ShoppingCartProjection { DbContext = context };

var cartId = Guid.NewGuid();
var clientId = Guid.NewGuid();
var cartId = Guid.CreateVersion7();
var clientId = Guid.CreateVersion7();

await projection.Handle([
EventEnvelope.From(new Opened(cartId, clientId)),
Expand All @@ -96,8 +96,8 @@ public async Task Applies_Works_In_Batch_With_AddAndDeleteOnTheSameRecord()
{
var projection = new ShoppingCartProjection { DbContext = context };

var cartId = Guid.NewGuid();
var clientId = Guid.NewGuid();
var cartId = Guid.CreateVersion7();
var clientId = Guid.CreateVersion7();

await projection.Handle([
EventEnvelope.From(new Opened(cartId, clientId)),
Expand All @@ -112,7 +112,7 @@ await projection.Handle([
[Fact]
public async Task SmokeTest()
{
var entity = new ShoppingCart { Id = Guid.NewGuid(), ProductCount = 2, ClientId = Guid.NewGuid() };
var entity = new ShoppingCart { Id = Guid.CreateVersion7(), ProductCount = 2, ClientId = Guid.CreateVersion7() };
context.ShoppingCarts.Add(entity);
await context.SaveChangesAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class EfCorePostgresContainerFixture<TContext>: IAsyncLifetime where TCon
{
private readonly PostgresContainerFixture postgresContainerFixture = new();

public TContext DbContext { get; private set; } = default!;
public TContext DbContext { get; private set; } = null!;

public async Task InitializeAsync()
{
Expand Down
2 changes: 1 addition & 1 deletion Core.EntityFramework.Tests/TestDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ShoppingCart

public class TestDbContext(DbContextOptions<TestDbContext> options): DbContext(options)
{
public DbSet<ShoppingCart> ShoppingCarts { get; set; } = default!;
public DbSet<ShoppingCart> ShoppingCarts { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder modelBuilder) =>
modelBuilder.Entity<ShoppingCart>();
Expand Down
6 changes: 3 additions & 3 deletions Core.EntityFramework/Projections/EntityFrameworkProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Core.EntityFramework.Projections;
public class EntityFrameworkProjection<TDbContext>: IEventBatchHandler
where TDbContext : DbContext
{
public TDbContext DbContext { protected get; set; } = default!;
public TDbContext DbContext { protected get; set; } = null!;
public IAsyncPolicy RetryPolicy { protected get; set; } = Policy.NoOpAsync();

private readonly HashSet<Type> handledEventTypes = [];
Expand Down Expand Up @@ -47,8 +47,8 @@ private record ProjectEvent(
);

private readonly Dictionary<Type, ProjectEvent> projectors = new();
private Expression<Func<TView, TId>> viewIdExpression = default!;
private Func<TView, TId> viewId = default!;
private Expression<Func<TView, TId>> viewIdExpression = null!;
private Func<TView, TId> viewId = null!;

public void ViewId(Expression<Func<TView, TId>> id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public EventStoreDBAsyncCommandBusTests()
public async Task CommandIsStoredInEventStoreDBAndForwardedToCommandHandler()
{
// Given
var userId = Guid.NewGuid();
var userId = Guid.CreateVersion7();
var command = new AddUser(userId);

// When
Expand All @@ -91,7 +91,7 @@ public async Task CommandIsStoredInEventStoreDBAndForwardedToCommandHandler()
}
}

public record AddUser(Guid UserId, string? Sth = default);
public record AddUser(Guid UserId, string? Sth = null);

internal class AddUserCommandHandler(List<Guid> userIds): ICommandHandler<AddUser>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Core.EventStoreDB.Tests.Subscriptions.Checkpoints;
public class PostgresSubscriptionCheckpointRepositoryTests(PostgresContainerFixture fixture)
: IClassFixture<PostgresContainerFixture>
{
private readonly string subscriptionId = Guid.NewGuid().ToString("N");
private readonly string subscriptionId = Guid.CreateVersion7().ToString("N");

[Fact]
public async Task Store_InitialInsert_Success()
Expand Down
2 changes: 1 addition & 1 deletion Core.EventStoreDB/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Core.EventStoreDB;

public class EventStoreDBConfig
{
public string ConnectionString { get; set; } = default!;
public string ConnectionString { get; set; } = null!;
}

public record EventStoreDBOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private static IEnumerable<string> ExtractTraceContextFromEventMetadata(Dictiona
try
{
return headers.TryGetValue(key, out var value) && value != null
? new[] { value }
: Enumerable.Empty<string>();
? [value]
: [];
}
catch (Exception ex)
{
Expand Down
12 changes: 6 additions & 6 deletions Core.EventStoreDB/Events/EventStoreDBExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static async Task<TEntity> Find<TEntity>(
throw AggregateNotFoundException.For<TEntity>(id);

var result = getDefault();
await foreach (var @event in readResult)
result = when(result, @event);
await foreach (var resolvedEvent in readResult)
result = when(result, resolvedEvent.Deserialize()!);
return result;
}

Expand All @@ -71,7 +71,7 @@ public static async Task<List<object>> ReadStream(

var result = new List<object>();
await foreach (var @event in readResult)
result.Add(@event);
result.Add(@event.Deserialize()!);
return result;
}

Expand All @@ -85,8 +85,8 @@ CancellationToken cancellationToken
{
var result = await eventStore.AppendToStreamAsync(
id,
StreamState.NoStream,
new[] { @event.ToJsonEventData(TelemetryPropagator.GetPropagationContext()) },
StreamState.Any,
[@event.ToJsonEventData(TelemetryPropagator.GetPropagationContext())],
cancellationToken: cancellationToken
).ConfigureAwait(false);
return result.NextExpectedStreamRevision;
Expand All @@ -104,7 +104,7 @@ CancellationToken cancellationToken
var result = await eventStore.AppendToStreamAsync(
id,
expectedRevision,
new[] { @event.ToJsonEventData(TelemetryPropagator.GetPropagationContext()) },
[@event.ToJsonEventData(TelemetryPropagator.GetPropagationContext())],
cancellationToken: cancellationToken
).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public enum ProcessingStatus

public record EventBatch(string SubscriptionId, ResolvedEvent[] Events);

public EventStoreDBSubscriptionToAllOptions Options { get; set; } = default!;
public EventStoreDBSubscriptionToAllOptions Options { get; set; } = null!;

public Func<IServiceProvider, IEventBatchHandler[]> GetHandlers { get; set; } = default!;
public Func<IServiceProvider, IEventBatchHandler[]> GetHandlers { get; set; } = null!;

public ProcessingStatus Status = ProcessingStatus.NotStarted;

Expand Down
4 changes: 2 additions & 2 deletions Core.Kafka/Consumers/KafkaConsumerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Core.Kafka.Consumers;

public class KafkaConsumerConfig
{
public ConsumerConfig ConsumerConfig { get; set; } = default!;
public string[] Topics { get; set; } = default!;
public ConsumerConfig ConsumerConfig { get; set; } = null!;
public string[] Topics { get; set; } = null!;

public bool IgnoreDeserializationErrors { get; set; } = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Core.Kafka/Producers/KafkaProducerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Core.Kafka.Producers;
public class KafkaProducerConfig
{
public ProducerConfig? ProducerConfig { get; set; }
public string Topic { get; set; } = default!;
public string Topic { get; set; } = null!;
public int? ProducerTimeoutInMs { get; set; }
}

Expand Down
2 changes: 1 addition & 1 deletion Core.Marten/Commands/MartenAsyncCommandBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Core.Marten.Commands;
/// </summary>
public class MartenAsyncCommandBus(IDocumentSession documentSession): IAsyncCommandBus
{
public static readonly Guid CommandsStreamId = new("11111111-1111-1111-1111-111111111111");
public const string CommandsStreamId = "__commands";

public Task Schedule<TCommand>(TCommand command, CancellationToken ct = default) where TCommand: notnull
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Handle(EventEnvelope<TEvent> eventEnvelope, CancellationToken

public class MartenCheckpoint
{
public string Id { get; set; } = default!;
public string Id { get; set; } = null!;

public ulong? Position { get; set; }

Expand Down
10 changes: 6 additions & 4 deletions Core.Marten/MartenConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Core.Marten.Ids;
using Core.Marten.Subscriptions;
using JasperFx;
using JasperFx.Events;
using JasperFx.Events.Daemon;
using Marten;
using Marten.Services;
Expand All @@ -18,7 +19,7 @@ public class MartenConfig
{
private const string DefaultSchema = "public";

public string ConnectionString { get; set; } = default!;
public string ConnectionString { get; set; } = null!;

public string WriteModelSchema { get; set; } = DefaultSchema;
public string ReadModelSchema { get; set; } = DefaultSchema;
Expand Down Expand Up @@ -100,11 +101,12 @@ private static StoreOptions SetStoreOptions(
options.Events.DatabaseSchemaName = schemaName ?? martenConfig.WriteModelSchema;
options.DatabaseSchemaName = schemaName ?? martenConfig.ReadModelSchema;

options.UseNewtonsoftForSerialization(
EnumStorage.AsString,
nonPublicMembersStorage: NonPublicMembersStorage.All
options.UseSystemTextJsonForSerialization(
EnumStorage.AsString
);

options.Events.StreamIdentity = StreamIdentity.AsString;

options.Projections.Errors.SkipApplyErrors = false;
options.Projections.Errors.SkipSerializationErrors = false;
options.Projections.Errors.SkipUnknownEvents = false;
Expand Down
4 changes: 2 additions & 2 deletions Core.Marten/Subscriptions/MartenEventPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private IEnumerable<string> ExtractTraceContextFromEventMetadata(Dictionary<stri
var stringValue = value.ToString();

return stringValue != null
? new[] { stringValue }
: Enumerable.Empty<string>();
? [stringValue]
: [];
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion Core.Testing/Fixtures/PostgresContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class PostgresContainerFixture: IAsyncLifetime
.WithReuse(true)
.Build();

public NpgsqlDataSource DataSource { get; private set; } = default!;
public NpgsqlDataSource DataSource { get; private set; } = null!;

public async Task InitializeAsync()
{
Expand Down
7 changes: 4 additions & 3 deletions Core.Testing/TestWebApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Core.Requests;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Open.ChannelExtensions;
Expand All @@ -16,7 +17,7 @@ public class TestWebApplicationFactory<TProject>: WebApplicationFactory<TProject
private readonly DummyExternalCommandBus externalCommandBus = new();
private readonly EventListener eventListener = new();

private readonly string schemaName = $"test{Guid.NewGuid().ToString("N").ToLower()}";
private readonly string schemaName = $"test{Guid.CreateVersion7().ToString("N").ToLower()}";

protected override IHost CreateHost(IHostBuilder builder)
{
Expand All @@ -36,7 +37,7 @@ protected override IHost CreateHost(IHostBuilder builder)
.AddSingleton<IExternalEventConsumer, DummyExternalEventConsumer>();
});


Environment.SetEnvironmentVariable("ConnectionStrings__kafka", "localhost:9092");
Environment.SetEnvironmentVariable("SchemaName", schemaName);

return Policy.Handle<Exception>()
Expand All @@ -49,7 +50,7 @@ public void PublishedExternalEventsOfType<TEvent>() where TEvent : IExternalEven

public Task PublishInternalEvent<TEvent>(TEvent @event, CancellationToken ct = default) where TEvent : notnull =>
PublishInternalEvent(
new EventEnvelope<TEvent>(@event, new EventMetadata(Guid.NewGuid().ToString(), 0, 0, null)), ct);
new EventEnvelope<TEvent>(@event, new EventMetadata(Guid.CreateVersion7().ToString(), 0, 0, null)), ct);

public async Task PublishInternalEvent<TEvent>(EventEnvelope<TEvent> eventEnvelope, CancellationToken ct = default)
where TEvent : notnull
Expand Down
4 changes: 2 additions & 2 deletions Core.Tests/AggregateWithWhenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public enum InvoiceStatus
public class Invoice: Aggregate<object, string>
{
public double Amount { get; private set; }
public string Number { get; private set; } = default!;
public string Number { get; private set; } = null!;

public InvoiceStatus Status { get; private set; }

public Person IssuedTo { get; private set; } = default!;
public Person IssuedTo { get; private set; } = null!;
public DateTime InitiatedAt { get; private set; }

public string? IssuedBy { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion Core/Events/EventEnvelope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public static IEventEnvelope From(object data, EventMetadata metadata)
}

public static EventEnvelope<T> From<T>(T data) where T : notnull =>
new(data, new EventMetadata(Guid.NewGuid().ToString(), 0, 0, null));
new(data, new EventMetadata(Guid.CreateVersion7().ToString(), 0, 0, null));
}
4 changes: 2 additions & 2 deletions Core/Ids/NulloIdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class NulloIdGenerator : IIdGenerator
{
public Guid New() => Guid.NewGuid();
}
public Guid New() => Guid.CreateVersion7();
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis

private static IEnumerable<string> ExtractTraceContextFromEventMetadata(Dictionary<string, string?> headers, string key) =>
headers.TryGetValue(key, out var value) && value != null
? new[] { value }
: Enumerable.Empty<string>();
? [value]
: [];
}
5 changes: 2 additions & 3 deletions Core/OpenTelemetry/TelemetryPropagator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ public static class TelemetryPropagator
public static void UseDefaultCompositeTextMapPropagator()
{
propagator =
new CompositeTextMapPropagator(new TextMapPropagator[]
{
new CompositeTextMapPropagator([
new TraceContextPropagator(), new BaggagePropagator()
});
]);
}

public static void Inject<T>(
Expand Down
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
<PackageVersion Include="Marten.AspNetCore" Version="8.22.0" />
<PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR" Version="1.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.3" />
Expand All @@ -43,9 +43,9 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.3.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.3.0" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="9.2.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.2" />
Expand Down
Loading
Loading