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
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Threading.Tasks;
using Marten.Events;
using Marten.Events.Projections;
using Marten.Testing.Harness;
using Shouldly;
using Xunit;

namespace EventSourcingTests.Bugs;

public class Bug_3665_compiling_with_private_members : BugIntegrationContext
{
[Fact]
public async Task try_to_compile_self_aggregate()
{
StoreOptions(opts =>
{
opts.Projections.Snapshot<Product>(SnapshotLifecycle.Inline);
opts.Events.StreamIdentity = StreamIdentity.AsString;
});

var id = Guid.NewGuid().ToString();
theSession.Events.StartStream<Product>(id, new ProductCreated(id, "Shoes"));
await theSession.SaveChangesAsync();

var product = await theSession.LoadAsync<Product>(id);
product.Name.ShouldBe("Shoes");
}
}

public record ProductCreated(string Id, string Name);

public record ProductNameChanged(string NewName);

public record ProductRemoved;


public class Product
{
public string Id { get; set; }
public string Name { get; set; }

public Product() { }

public Product(ProductCreated cr)
{
Id = cr.Id;
Name = cr.Name;
}

private void Apply(ProductNameChanged ev) => Name = ev.NewName;

private bool ShouldDelete(ProductRemoved ev) => true;
}


2 changes: 1 addition & 1 deletion src/Marten/Events/CodeGeneration/MethodCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected MethodCollection(string methodName, Type projectionType, Type aggregat

protected MethodCollection(string[] methodNames, Type projectionType, Type aggregateType)
{
LambdaName = methodNames.First();
_validArgumentTypes.Add(typeof(CancellationToken));

MethodNames.AddRange(methodNames);
Expand All @@ -78,7 +79,6 @@ protected MethodCollection(string[] methodNames, Type projectionType, Type aggre


IsAsync = Methods.Select(x => x.Method).OfType<MethodInfo>().Any(x => x.IsAsync());
LambdaName = methodNames.First();
}

public Type ProjectionType { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/ValueTypeTests/ValueTypeTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="FSharp.SystemTextJson" Version="1.3.13" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Vogen" Version="4.0.17" />
<PackageReference Include="Vogen" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading