diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs
new file mode 100644
index 0000000..8d015f6
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespaceProxy.g.cs
@@ -0,0 +1,29 @@
+//----------------------------------------------------------------------------------------
+//
+// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//----------------------------------------------------------------------------------------
+
+#nullable enable
+using System;
+
+namespace ProxyInterfaceSourceGeneratorTests.Namespace1
+{
+ public partial class ClassInNamespaceProxy : global::ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace
+ {
+ public global::ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespace _Instance { get; }
+
+
+ public ClassInNamespaceProxy(global::ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespace instance)
+ {
+ _Instance = instance;
+
+
+
+ }
+ }
+}
+#nullable restore
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs
new file mode 100644
index 0000000..09a85ca
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace1.IClassInNamespace.g.cs
@@ -0,0 +1,22 @@
+//----------------------------------------------------------------------------------------
+//
+// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//----------------------------------------------------------------------------------------
+
+#nullable enable
+using System;
+
+namespace ProxyInterfaceSourceGeneratorTests.Namespace1
+{
+ public partial interface IClassInNamespace
+ {
+ global::ProxyInterfaceSourceGeneratorTests.Namespace1.ClassInNamespace _Instance { get; }
+
+
+ }
+}
+#nullable restore
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs
new file mode 100644
index 0000000..0480f4b
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespaceProxy.g.cs
@@ -0,0 +1,29 @@
+//----------------------------------------------------------------------------------------
+//
+// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//----------------------------------------------------------------------------------------
+
+#nullable enable
+using System;
+
+namespace ProxyInterfaceSourceGeneratorTests.Namespace2
+{
+ public partial class ClassInNamespaceProxy : global::ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace
+ {
+ public global::ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespace _Instance { get; }
+
+
+ public ClassInNamespaceProxy(global::ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespace instance)
+ {
+ _Instance = instance;
+
+
+
+ }
+ }
+}
+#nullable restore
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs
new file mode 100644
index 0000000..ddad4d3
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Namespace2.IClassInNamespace.g.cs
@@ -0,0 +1,22 @@
+//----------------------------------------------------------------------------------------
+//
+// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//----------------------------------------------------------------------------------------
+
+#nullable enable
+using System;
+
+namespace ProxyInterfaceSourceGeneratorTests.Namespace2
+{
+ public partial interface IClassInNamespace
+ {
+ global::ProxyInterfaceSourceGeneratorTests.Namespace2.ClassInNamespace _Instance { get; }
+
+
+ }
+}
+#nullable restore
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs
index 27ea67e..1a1f749 100644
--- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs
+++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs
@@ -572,4 +572,58 @@ public class ProxyInterfaceSourceGeneratorTest
if (Write) File.WriteAllText($"../../../Destination/{proxyClassIHttpMessageInvokerFilename}", proxyIMessageInvoker);
proxyIMessageInvoker.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassIHttpMessageInvokerFilename}"));
}
+
+ [Fact]
+ public void GenerateFiles_ForClassWithSameName_But_DifferentNamespace_Should_GenerateCorrectFiles()
+ {
+ // Arrange
+ const string @class = "ClassInNamespace";
+ foreach (var x in new[] { 1, 2 })
+ {
+ var attributeFilename = "ProxyInterfaceGenerator.Extra.g.cs";
+ var interfaceFilename = $"ProxyInterfaceSourceGeneratorTests.Namespace{x}.I{@class}.g.cs";
+ var proxyClassFilename = $"ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class}Proxy.g.cs";
+
+ var path = $"./Source/I{@class}{x}.cs";
+ var sourceFile = new SourceFile
+ {
+ Path = path,
+ Text = File.ReadAllText(path),
+ AttributeToAddToInterface = new ExtraAttribute
+ {
+ Name = "ProxyInterfaceGenerator.Proxy",
+ ArgumentList = new[] { $"typeof(ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class})", "true" }
+ }
+ };
+
+ // Act
+ var result = _sut.Execute(new[] { sourceFile });
+
+ // Assert
+ result.Valid.Should().BeTrue();
+ result.Files.Should().HaveCount(3);
+
+ // Assert attribute
+ var attribute = result.Files[0].SyntaxTree;
+ attribute.FilePath.Should().EndWith(attributeFilename);
+
+ // Assert interface
+ var @interface = result.Files[1].SyntaxTree;
+ @interface.FilePath.Should().EndWith(interfaceFilename);
+
+ var interfaceCode = @interface.ToString();
+ if (Write) File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
+ interfaceCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
+
+ // Assert Proxy
+ var proxyClass = result.Files[2].SyntaxTree;
+ proxyClass.FilePath.Should().EndWith(proxyClassFilename);
+
+ var proxyCode = proxyClass.ToString();
+ if (Write) File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
+ proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
+ }
+
+
+ }
}
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj
index c9156d3..5acaa96 100644
--- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj
+++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj
@@ -3,7 +3,7 @@
net8.0
false
- 12.0
+ latest
enable
Debug;Release;DebugAttach
enable
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace1.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace1.cs
new file mode 100644
index 0000000..c5a1490
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace1.cs
@@ -0,0 +1,7 @@
+// ReSharper disable once CheckNamespace
+namespace ProxyInterfaceSourceGeneratorTests.Namespace1
+{
+ public class ClassInNamespace
+ {
+ }
+}
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace2.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace2.cs
new file mode 100644
index 0000000..a485120
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/ClassInNamespace2.cs
@@ -0,0 +1,7 @@
+// ReSharper disable once CheckNamespace
+namespace ProxyInterfaceSourceGeneratorTests.Namespace2
+{
+ public class ClassInNamespace
+ {
+ }
+}
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace1.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace1.cs
new file mode 100644
index 0000000..ea5f7bd
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace1.cs
@@ -0,0 +1,7 @@
+// ReSharper disable once CheckNamespace
+namespace ProxyInterfaceSourceGeneratorTests.Namespace1
+{
+ public partial interface IClassInNamespace
+ {
+ }
+}
\ No newline at end of file
diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace2.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace2.cs
new file mode 100644
index 0000000..25dcc6b
--- /dev/null
+++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/IClassInNamespace2.cs
@@ -0,0 +1,7 @@
+// ReSharper disable once CheckNamespace
+namespace ProxyInterfaceSourceGeneratorTests.Namespace2
+{
+ public partial interface IClassInNamespace
+ {
+ }
+}
\ No newline at end of file