LenFon / StronglyTypedId

A base implementation of strongly typed ids.
MIT License
1 stars 1 forks source link

Bug: EfCoreCodeGenerator and SwaggerCodeGenerator only apply to StronglyTypedIds within same assembly #4

Closed SigtryggurO closed 8 months ago

SigtryggurO commented 10 months ago

Issue Report

Description

The created record or a record struct must be within the same project where the StronglyTypedIds.ApplyTo(..) is called else it won't be mapped/converted.

Steps to Reproduce

  1. Create a WebUI project, Infrastructure Project and Domain Project
  2. Add a StronglyTypedId to the domain project
  3. Call StronglyTypedIds.ApplyTo(configurationBuilder) within your Infrastructure project context.
  4. Call StronglyTypedIds.ApplyTo(options) within your swaggerGen options.

Expected Behavior

The StronglyTypedId has Conversion within the EFCore ModelConfigurationBuilder ApplyTo method The StronglyTypedId is mapped to the correct format within the SwaggerGen SwaggerGenOptions ApplyTo method

Actual Behavior

The StronglyTypedId has no conversion and ain't mapped

Screenshots

In this example I have 3 ProjectId types: ProjectId is in the domain project, ProjectId2 is in the EFCore project, ProjectId3 is within the WebUI project. image image

SigtryggurO commented 10 months ago

After going through the code to figure out what was wrong I found out that the mapping/conversion are added but only if you close and open VS2022 again. When debugging the project it's apparent that the generator doesn't run on changes in the a child project, nether when adding or removing StronglyTypedId attribute.

I'm not sure if this is an issue with VS2022 or in Roslyn, either way it needs to be fixed if possible, or the at least add a information box/warning of the issue in the readme.