Some automatically generated interfaces cannot reference other automatically generated interfaces
Thanks for the amazing package. Saves me so much time.
Some interfaces though I cannot use it on, as it causes other automatically generated interfaces to produce invalid code. Here you can see in a service (which has an autogenerated interface) that I'm trying to reference IProjectDeployment , which is also an autogenerated interface.
If I inspect the interface of the service, you can see it didn't give a full path to the IProjectDeployment interface
If I try to manually specify the global::Path.To.NameSpace etc in front of it, that doesn't change anything. If I change the service method to reference the class ProjectDeployment directly, no issues. And if I manually create the interface in the same file as the class, also no issues.
Is it possible because it's used as a generic argument?
Tried on the latest 5.1.3
Can you show your code structure?
Gesendet von Outlook für Androidhttps://aka.ms/AAb9ysg
From: AustinGrey @.> Sent: Wednesday, March 5, 2025 4:51:39 PM To: codecentric/net_automatic_interface @.> Cc: Subscribed @.***> Subject: [codecentric/net_automatic_interface] Some automatically generated interfaces cannot reference other automatically generated interfaces (Issue #73)
Thanks for the amazing package. Saves me so much time.
Some interfaces though I cannot use it on, as it causes other automatically generated interfaces to produce invalid code. Here you can see in a service (which has an autogenerated interface) that I'm trying to reference IProjectDeployment , which is also an autogenerated interface.
image.png (view on web)https://github.com/user-attachments/assets/2270e565-5b1e-4604-b2f8-403181070c94
If I inspect the interface of the service, you can see it didn't give a full path to the IProjectDeployment interface
image.png (view on web)https://github.com/user-attachments/assets/dc2b825b-7944-4384-8c3e-505f104e1f1a
If I try to manually specify the global::Path.To.NameSpace etc in front of it, that doesn't change anything. If I change the service method to reference the class ProjectDeployment directly, no issues. And if I manually create the interface in the same file as the class, also no issues.
Is it possible because it's used as a generic argument?
Tried on the latest 5.1.3
— Reply to this email directly, view it on GitHubhttps://github.com/codecentric/net_automatic_interface/issues/73, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABXKCSONKMTFEQ6ZP3MAYB32S4MQXAVCNFSM6AAAAABYMOCL3OVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA4TONZRHA3DCNA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
[AustinGrey]AustinGrey created an issue (codecentric/net_automatic_interface#73)https://github.com/codecentric/net_automatic_interface/issues/73
Thanks for the amazing package. Saves me so much time.
Some interfaces though I cannot use it on, as it causes other automatically generated interfaces to produce invalid code. Here you can see in a service (which has an autogenerated interface) that I'm trying to reference IProjectDeployment , which is also an autogenerated interface.
image.png (view on web)https://github.com/user-attachments/assets/2270e565-5b1e-4604-b2f8-403181070c94
If I inspect the interface of the service, you can see it didn't give a full path to the IProjectDeployment interface
image.png (view on web)https://github.com/user-attachments/assets/dc2b825b-7944-4384-8c3e-505f104e1f1a
If I try to manually specify the global::Path.To.NameSpace etc in front of it, that doesn't change anything. If I change the service method to reference the class ProjectDeployment directly, no issues. And if I manually create the interface in the same file as the class, also no issues.
Is it possible because it's used as a generic argument?
Tried on the latest 5.1.3
— Reply to this email directly, view it on GitHubhttps://github.com/codecentric/net_automatic_interface/issues/73, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABXKCSONKMTFEQ6ZP3MAYB32S4MQXAVCNFSM6AAAAABYMOCL3OVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA4TONZRHA3DCNA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
I can't provide the entire project, but here is the structure for the two relevant files?
This is the folder structure on the left, one is in the models folder, and that file contains a this single class with the [GenerateAutomaticInterface] attribute on it.
The service is the DeploymentService, and contains several methods, but only the one referencing the IProjectDeployment is the one that is failing
It might be worth mentioning that the model in question is an EFCore model. So perhaps it's a conflict with EFCore? We do have some other EFCore models being generated from just fine, but this isn't the only model where adding this causes the generated code to be incorrect. There doesn't seem to be a pattern.
I try to take a look tomorrow
Ok, I looked into this and if I see this correctly, you are using multiple Source Generators at the same time?
I think that's the culprit - atm SGs cannot see code from other SGs, so there will be conflicts.
see: https://github.com/dotnet/roslyn/discussions/48358
As a workaround: Put all stuff which uses SG A into a Project, then reference that from a second project which uses SG B.
I have had good luck getting around issues like this with a partial interface.
public partial interface IProjectDeployment;
[GenerateAutomaticInterface]
public sealed class ProjectDeployment : IProjectDeployment
{
public int ProjectId { get; set; }