net_automatic_interface icon indicating copy to clipboard operation
net_automatic_interface copied to clipboard

Fully qualify references to generated interfaces

Open simonmckenzie opened this issue 4 months ago • 6 comments

This addresses an issue where, when a class references a generated interface, those references are not fully qualified, resulting in an interface that doesn't compile. See #87.

The change is to precalculate the list of interface names that will be generated, and, during symbol string generation, replace unrecognised symbols with generated names where a single unambiguous match can be made between the symbol and the list of interfaces being generated.

For the example provided in #87, the code will now generate this output:

//--------------------------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//--------------------------------------------------------------------------------------------------

namespace Test
{
    [global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")]
    public partial interface ITest1
    {
        /// <inheritdoc cref="Test.Test1.Get(ITest2)" />
        void Get(global::Test.Tests.ITest2 test);
        
    }
}


//--------------------------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//--------------------------------------------------------------------------------------------------

namespace Test.Tests
{
    [global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")]
    public partial interface ITest2
    {
    }
}

simonmckenzie avatar Sep 03 '25 04:09 simonmckenzie

This is ready for review again - I just had a last minute refactoring idea :)

simonmckenzie avatar Oct 22 '25 08:10 simonmckenzie

Could you be so kind and merge master into this? Than I will merge it as 6.x I think because it's potentially breaking

ChristianSauer avatar Nov 04 '25 12:11 ChristianSauer

Not a problem @ChristianSauer. I hope to get this done next week.

simonmckenzie avatar Nov 05 '25 03:11 simonmckenzie

Hi @ChristianSauer,

I've rebased the branch on master, but happy to get the other PR merged first, then I can rebase and refactor again, as I think I should probably move the other PR's changes into the RoslynExtensions class. Whatever suits you, of course :)

simonmckenzie avatar Nov 12 '25 01:11 simonmckenzie

@simonmckenzie I merged the other PR first :)

ChristianSauer avatar Nov 13 '25 10:11 ChristianSauer

Hi @ChristianSauer,

I've rebased again and refactored the changes from #85 into the RoslynExtensions (9148e56675769c355fba27c65c6afca83419745e).

simonmckenzie avatar Nov 18 '25 23:11 simonmckenzie