From fb4e57ad2e1627b28f17e5f18f776f2a8e926037 Mon Sep 17 00:00:00 2001 From: beakona Date: Wed, 28 Jul 2021 13:39:26 +0200 Subject: [PATCH] Types does not have to be in same compile unit.. --- AutoInterface.sln | 6 +++++ .../AutoInterfaceSample.csproj | 4 ++++ AutoInterfaceSample/Program.cs | 22 +++---------------- .../CSharpCodeTextWriter.cs | 5 +++++ TestInterfaces/Interfaces.cs | 22 +++++++++++++++++++ TestInterfaces/TestInterfaces.csproj | 7 ++++++ 6 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 TestInterfaces/Interfaces.cs create mode 100644 TestInterfaces/TestInterfaces.csproj diff --git a/AutoInterface.sln b/AutoInterface.sln index 6029cc7..ccdbfb2 100644 --- a/AutoInterface.sln +++ b/AutoInterface.sln @@ -12,6 +12,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoInterfaceSample", "Auto {FF7DF2CF-FA1C-4655-B451-B6FD1E374E3A} = {FF7DF2CF-FA1C-4655-B451-B6FD1E374E3A} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestInterfaces", "TestInterfaces\TestInterfaces.csproj", "{E271DF85-2B8E-48C4-8EB0-37FBF60A2E15}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -28,6 +30,10 @@ Global {D80AD027-6463-4CBB-91B5-4952AE0204B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D80AD027-6463-4CBB-91B5-4952AE0204B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {D80AD027-6463-4CBB-91B5-4952AE0204B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E271DF85-2B8E-48C4-8EB0-37FBF60A2E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E271DF85-2B8E-48C4-8EB0-37FBF60A2E15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E271DF85-2B8E-48C4-8EB0-37FBF60A2E15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E271DF85-2B8E-48C4-8EB0-37FBF60A2E15}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AutoInterfaceSample/AutoInterfaceSample.csproj b/AutoInterfaceSample/AutoInterfaceSample.csproj index 47f008b..d869359 100644 --- a/AutoInterfaceSample/AutoInterfaceSample.csproj +++ b/AutoInterfaceSample/AutoInterfaceSample.csproj @@ -18,4 +18,8 @@ + + + + diff --git a/AutoInterfaceSample/Program.cs b/AutoInterfaceSample/Program.cs index 7c88721..d59d252 100644 --- a/AutoInterfaceSample/Program.cs +++ b/AutoInterfaceSample/Program.cs @@ -1,4 +1,6 @@ -namespace AutoInterfaceSample +using TestInterfaces; + +namespace AutoInterfaceSample { public class Program { @@ -10,24 +12,6 @@ public static void Main() } } - public interface ITestable - { - void PrintTest(); - } - - public interface IPrintable : ITestable - { - int Length { get; } - int Count { get; } - void Print1(); - void Print2(); - } - - public interface IPrintable2 - { - void Print3(); - } - public class PrinterV1 : IPrintable, IPrintable2 { public int Length => 100; diff --git a/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs b/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs index 138d632..5af3577 100644 --- a/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs +++ b/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs @@ -949,6 +949,11 @@ private string GetSourceIdentifier(ISymbol symbol) } } + if (symbol.DeclaringSyntaxReferences.Length == 0) + { + return symbol.Name; + } + throw new NotSupportedException(); } } diff --git a/TestInterfaces/Interfaces.cs b/TestInterfaces/Interfaces.cs new file mode 100644 index 0000000..2c6be96 --- /dev/null +++ b/TestInterfaces/Interfaces.cs @@ -0,0 +1,22 @@ +using System; + +namespace TestInterfaces +{ + public interface ITestable + { + void PrintTest(); + } + + public interface IPrintable : ITestable + { + int Length { get; } + int Count { get; } + void Print1(); + void Print2(); + } + + public interface IPrintable2 + { + void Print3(); + } +} diff --git a/TestInterfaces/TestInterfaces.csproj b/TestInterfaces/TestInterfaces.csproj new file mode 100644 index 0000000..f208d30 --- /dev/null +++ b/TestInterfaces/TestInterfaces.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + +