diff --git a/src/ConsoleTest/ConsoleTest.csproj b/src/ConsoleTest/ConsoleTest.csproj
index 083aad4..f5d58dd 100644
--- a/src/ConsoleTest/ConsoleTest.csproj
+++ b/src/ConsoleTest/ConsoleTest.csproj
@@ -4,6 +4,7 @@
Exe
net7.0
+ 11
enable
diff --git a/src/ConsoleTest/FileScopedClass.cs b/src/ConsoleTest/FileScopedClass.cs
new file mode 100644
index 0000000..51fa3f7
--- /dev/null
+++ b/src/ConsoleTest/FileScopedClass.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SpeedyGenerators;
+
+namespace ConsoleTest;
+
+internal partial class FileScopedClass
+{
+ [MakeProperty("MyProperty")]
+ private int _myField;
+}
diff --git a/src/LibraryTest/FileScopedClass.cs b/src/LibraryTest/FileScopedClass.cs
new file mode 100644
index 0000000..0a291c1
--- /dev/null
+++ b/src/LibraryTest/FileScopedClass.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SpeedyGenerators;
+
+namespace LibraryTest;
+
+internal partial class ClassOutsideNamespace
+{
+ [MakeProperty("MyProperty")]
+ private int _myField1;
+}
+
+file partial class FileScopedClass
+{
+ // Cannot use source generators with file scoped classes because
+ // - source generators must create a separate source file
+ // - file scoped classes must reside in the same file
+ //[MakeProperty("YourProperty")]
+ //protected int _yourField1;
+}
+
+// file scoped partial classes can be defined only in the same file
+file partial class FileSCopedClass
+{
+}
\ No newline at end of file
diff --git a/src/LibraryTest/ShortDemo.cs b/src/LibraryTest/ShortDemo.cs
index 42cedd6..143a42e 100644
--- a/src/LibraryTest/ShortDemo.cs
+++ b/src/LibraryTest/ShortDemo.cs
@@ -10,7 +10,7 @@ namespace LibraryTest
{
internal partial class ShortDemo
{
- [MakeProperty("Name")]
- private string? _name;
+ //[MakeProperty("Name")]
+ //private string? _name;
}
}
diff --git a/src/SpeedyGenerators/PropertyChangedGenerator.cs b/src/SpeedyGenerators/PropertyChangedGenerator.cs
index d5a276d..3f52041 100644
--- a/src/SpeedyGenerators/PropertyChangedGenerator.cs
+++ b/src/SpeedyGenerators/PropertyChangedGenerator.cs
@@ -155,6 +155,13 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
.FirstOrDefault()
?.Name
?.ToString();
+
+ namespaceName ??= editedClass.Ancestors()
+ .OfType()
+ .FirstOrDefault()
+ ?.Name
+ ?.ToString();
+
namespaceName ??= String.Empty;
var className = editedClass.Identifier.ToString();
var fullName = $"{namespaceName}.{className}";