I have a .Net framework project that contains two different concerns:
( This is a cut down illustration of the real problem space )
CompanyName.ProjectName
/consumers
/DTOs
I want to split out the /DTOs
into a different project:
CompanyName.ProjectName
/consumers
CompanyName.ProjectName.Dtos
/DTOs
So that I can easily convert the DTOs to use .NET Standard 2.0, so they can be consumed elsewhere by .Net8 projects.
The Consumers part relies on Framework, so converting the whole project is not at this time an option.
I can move over the DTOs to a different project and the build works.
However we have historical data serialized with the type information in the JSON such as:
{
"$type": "CompanyName.Project.Namespace.Item, CompanyName.ProjectName",
...
If I try to move out the DTOs to a different project, then even if I maintain the namespace, the deserialisation breaks, because it can’t find NameSpace.Item
in assembly CompanyName.ProjectName
.
Question:
Is there a way to compile a dependency such that the types are found in the parent project assembly?
Alternatively, is there something I do to alter the behaviour of NewtonSoft.Json type handling to also look in the new assembly for the type?