IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Duplicate DomainEvents property and IHasDomainEvent interface on Aggregate Root entities #1

Closed stephanjohnson closed 1 year ago

stephanjohnson commented 1 year ago

I updated to Intent Architect 4.0.0-beta.4 and created a new Clean Architecture project. I added a couple of test entities, and the resulting code has duplicated the DomainEvents properties and IHasDomainEvent interfaces on the Aggregate Root entity classes.

image

The resulting code:

using System;
using System.Collections.Generic;
using CleanArchitecture.Domain.Common;
using Intent.RoslynWeaver.Attributes;

[assembly: DefaultIntentManaged(Mode.Fully)]
[assembly: IntentTemplate("Intent.Entities.DomainEntity", Version = "1.0")]

namespace CleanArchitecture.Domain.Entities
{
    [IntentManaged(Mode.Merge, Signature = Mode.Fully)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Properties)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Methods, Body = Mode.Ignore, AccessModifiers = AccessModifiers.Public)]
    public class Expense : IHasDomainEvent, IHasDomainEvent
    {
        public Guid Id { get; private set; }

        public string Description { get; private set; }

        public decimal Amount { get; private set; }

        public DateTimeOffset Date { get; private set; }

        public virtual ICollection<ExpenseCategory> ExpenseCategories { get; private set; } = new List<ExpenseCategory>();

        public List<DomainEvent> DomainEvents { get; set; } = new List<DomainEvent>();

        public List<DomainEvent> DomainEvents { get; set; } = new List<DomainEvent>();
    }
}

The persistance configuration is also affected by this issue:

public class ExpenseConfiguration : IEntityTypeConfiguration<Expense>
{
    public void Configure(EntityTypeBuilder<Expense> builder)
    {
        builder.HasKey(x => x.Id);

        builder.Property(x => x.Description)
            .IsRequired();

        builder.Property(x => x.Amount)
            .IsRequired();

        builder.Property(x => x.Date)
            .IsRequired();

        builder.OwnsMany(x => x.ExpenseCategories, ConfigureExpenseCategories);

        builder.Ignore(e => e.DomainEvents);

        builder.Ignore(e => e.DomainEvents);
    }
}

Here is the modules.config:

<?xml version="1.0" encoding="utf-8"?>
<modules>
  <module moduleId="Intent.Application.AutoMapper" version="4.0.0" />
  <module moduleId="Intent.Application.DependencyInjection" version="4.0.0" />
  <module moduleId="Intent.Application.DependencyInjection.AutoMapper" version="3.4.0" />
  <module moduleId="Intent.Application.DependencyInjection.FluentValidation" version="3.4.0" />
  <module moduleId="Intent.Application.DependencyInjection.MediatR" version="3.4.0" />
  <module moduleId="Intent.Application.Dtos" version="4.0.0" />
  <module moduleId="Intent.Application.Dtos.AutoMapper" version="4.0.2" />
  <module moduleId="Intent.Application.Dtos.Pagination" version="4.0.1" />
  <module moduleId="Intent.Application.FluentValidation" version="3.4.1" />
  <module moduleId="Intent.Application.Identity" version="3.4.0" />
  <module moduleId="Intent.Application.MediatR" version="4.0.3" />
  <module moduleId="Intent.Application.MediatR.Behaviours" version="4.1.1" />
  <module moduleId="Intent.Application.MediatR.CRUD" version="5.0.0" />
  <module moduleId="Intent.Application.MediatR.CRUD.Eventing" version="4.0.1" />
  <module moduleId="Intent.Application.MediatR.FluentValidation" version="4.0.3" />
  <module moduleId="Intent.AspNetCore" version="4.0.0" />
  <module moduleId="Intent.AspNetCore.Controllers" version="5.0.0" />
  <module moduleId="Intent.AspNetCore.Controllers.Dispatch.MediatR" version="5.0.0" />
  <module moduleId="Intent.AspNetCore.Docker" version="3.3.6" />
  <module moduleId="Intent.AspNetCore.Swashbuckle" version="4.0.0" />
  <module moduleId="Intent.AspNetCore.Swashbuckle.Security" version="4.0.0" />
  <module moduleId="Intent.Common" version="3.3.19" />
  <module moduleId="Intent.Common.CSharp" version="3.3.30" />
  <module moduleId="Intent.Common.Types" version="3.3.7" />
  <module moduleId="Intent.DomainEvents" version="4.0.1" />
  <module moduleId="Intent.DomainServices" version="1.0.0" />
  <module moduleId="Intent.Entities" version="4.1.0" />
  <module moduleId="Intent.Entities.Repositories.Api" version="4.0.2" />
  <module moduleId="Intent.EntityFrameworkCore" version="4.2.2" />
  <module moduleId="Intent.EntityFrameworkCore.Interop.DomainEvents" version="4.0.0" />
  <module moduleId="Intent.EntityFrameworkCore.Repositories" version="4.1.0" />
  <module moduleId="Intent.Eventing.Contracts" version="4.0.1" />
  <module moduleId="Intent.Eventing.Contracts.DomainMapping" version="4.0.0" />
  <module moduleId="Intent.Eventing.MassTransit" version="4.0.4" />
  <module moduleId="Intent.Eventing.MassTransit.EntityFrameworkCore" version="4.0.1" />
  <module moduleId="Intent.Infrastructure.DependencyInjection" version="4.0.2" />
  <module moduleId="Intent.MediatR.DomainEvents" version="4.1.0" />
  <module moduleId="Intent.Metadata.RDBMS" version="3.4.2" />
  <module moduleId="Intent.Metadata.WebApi" version="3.4.0" />
  <module moduleId="Intent.Modelers.Domain" version="3.4.0" />
  <module moduleId="Intent.Modelers.Domain.Events" version="3.3.4" />
  <module moduleId="Intent.Modelers.Domain.Services" version="1.0.0" />
  <module moduleId="Intent.Modelers.Domain.ValueObjects" version="3.3.3" />
  <module moduleId="Intent.Modelers.Eventing" version="4.0.2" />
  <module moduleId="Intent.Modelers.Services" version="3.3.9" />
  <module moduleId="Intent.Modelers.Services.CQRS" version="4.0.0" />
  <module moduleId="Intent.Modules.AspNetCore.Logging.Serilog" version="3.3.7" />
  <module moduleId="Intent.OutputManager.RoslynWeaver" version="3.3.9" />
  <module moduleId="Intent.Security.JWT" version="4.1.0" />
  <module moduleId="Intent.ValueObjects" version="4.0.0" />
  <module moduleId="Intent.VisualStudio.Projects" version="3.3.23" />
</modules>
stephanjohnson commented 1 year ago

This problem is resolved by updating the Intent.EntityFrameworkCore.Interop.DomainEvents module to version 4.0.1.

stephanjohnson commented 1 year ago

I am unable to reproduce this behavior in Intent Architect v3.4.2, using the same module versions.

JonathanLydall commented 1 year ago

Thanks @stephanjohnson, we updated the Application Template and supportedClientVersions on Friday as appropriate so that this issue should not occur.