json-api-dotnet / JsonApiDotNetCore

A framework for building JSON:API compliant REST APIs using ASP.NET and Entity Framework Core.

Home Page:https://www.jsonapi.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source generation when models are in a separate project

wayne-o opened this issue · comments

We have the following structure:

  • CompanyName.Models (only has reference to JADNC.Annotations)
    • Model.cs
    • DbContext.cs
    • Migrations
    • etc etc
  • CompanyName.Web (has reference to full JADNC package)
    • Program.cs

I was hoping that the source gen would happen in CompanyName.Web since it has a reference to CompanyName.Models but that doesn't seem to be the case?

We don't want to have to add a reference to the full package in the Models project and we would prefer to not pulute that project with controllers. Is there any way around this?

Understandable. This is a limitation of using source generators. They operate at the project level. I'm not aware of a way to fix that.

In your case, it requires to turn it off and define controllers manually.