diff --git a/GitHubReleaseNotes.txt b/GitHubReleaseNotes.txt
index 1d44dfc..58c3354 100644
--- a/GitHubReleaseNotes.txt
+++ b/GitHubReleaseNotes.txt
@@ -1,3 +1,3 @@
https://github.com/StefH/GitHubReleaseNotes
-GitHubReleaseNotes --output ReleaseNotes.md --skip-empty-releases --exclude-labels question invalid doc --version 0.0.8
\ No newline at end of file
+GitHubReleaseNotes --output ReleaseNotes.md --skip-empty-releases --exclude-labels question invalid doc --version 0.0.9
\ No newline at end of file
diff --git a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj
index bff8280..7e92732 100644
--- a/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj
+++ b/src-examples/ProxyInterfaceConsumerViaNuGet/ProxyInterfaceConsumerViaNuGet.csproj
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs
index b63802a..512c19a 100644
--- a/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs
+++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs
@@ -30,7 +30,7 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
var interfaceName = targetClassSymbol.ResolveInterfaceNameWithOptionalTypeConstraints(pd.InterfaceName);
var file = new FileData(
- $"{pd.FileName}.cs",
+ $"{pd.FileName}.g.cs",
CreatePartialInterfaceCode(pd.Namespace, targetClassSymbol, interfaceName, pd.ProxyAll)
);
@@ -39,7 +39,17 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
return file;
}
- private string CreatePartialInterfaceCode(string ns, INamedTypeSymbol targetClassSymbol, string interfaceName, bool proxyAll) => $@"using System;
+ private string CreatePartialInterfaceCode(string ns, INamedTypeSymbol targetClassSymbol, string interfaceName, bool proxyAll) => $@"//----------------------------------------------------------------------------------------
+//
+// 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 {ns}
{{
@@ -51,7 +61,8 @@ namespace {ns}
{GenerateEvents(targetClassSymbol)}
}}
-}}";
+}}
+#nullable disable";
private string GenerateProperties(INamedTypeSymbol targetClassSymbol, bool proxyAll)
{
diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs
index aa8b85b..21aea38 100644
--- a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs
+++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyAttributeGenerator.cs
@@ -1,4 +1,4 @@
-namespace ProxyInterfaceSourceGenerator.FileGenerators
+namespace ProxyInterfaceSourceGenerator.FileGenerators
{
internal class ProxyAttributeGenerator : IFileGenerator
{
@@ -6,7 +6,16 @@
public FileData GenerateFile()
{
- return new FileData($"{ClassName}.cs", $@"using System;
+ return new FileData($"{ClassName}.g.cs", $@"//----------------------------------------------------------------------------------------
+//
+// 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.
+//
+//----------------------------------------------------------------------------------------
+
+using System;
namespace ProxyInterfaceGenerator
{{
diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs
index 6e16004..8113240 100644
--- a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs
+++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs
@@ -32,7 +32,7 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
var constructorName = $"{targetClassSymbol.Name}Proxy";
var file = new FileData(
- $"{pd.FileName}Proxy.cs",
+ $"{pd.FileName}Proxy.g.cs",
CreateProxyClassCode(pd.Namespace, targetClassSymbol, interfaceName, className, constructorName)
);
@@ -41,7 +41,17 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
return file;
}
- private string CreateProxyClassCode(string ns, INamedTypeSymbol targetClassSymbol, string interfaceName, string className, string constructorName) => $@"using System;
+ private string CreateProxyClassCode(string ns, INamedTypeSymbol targetClassSymbol, string interfaceName, string className, string constructorName) => $@"//----------------------------------------------------------------------------------------
+//
+// 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;
using AutoMapper;
namespace {ns}
@@ -65,7 +75,8 @@ namespace {ns}
{GeneratePrivateAutoMapper()}
}}
-}}";
+}}
+#nullable disable";
private string GeneratePrivateAutoMapper()
{
return _context.ReplacedTypes.Count == 0 ? string.Empty : " private readonly IMapper _mapper;";
diff --git a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs
index 60ad2ce..23deaf4 100644
--- a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs
+++ b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceCodeGenerator.cs
@@ -7,7 +7,7 @@ using ProxyInterfaceSourceGenerator.SyntaxReceiver;
namespace ProxyInterfaceSourceGenerator
{
[Generator]
- public class ProxyInterfaceCodeGenerator : ISourceGenerator
+ internal class ProxyInterfaceCodeGenerator : ISourceGenerator
{
private readonly ProxyAttributeGenerator _proxyAttributeGenerator = new ProxyAttributeGenerator();
diff --git a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj
index c8035bb..9056e5c 100644
--- a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj
+++ b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj
@@ -1,53 +1,52 @@
-
- 0.0.8
- netstandard2.0
- 9
- enable
- Stef Heyenrath
-
- ProxyInterfaceGenerator
- ProxyInterfaceGenerator
- This project uses Source Generation to generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI.
- class;interface;proxy;SourceGenerator;Analyzer;Generation;Generate;wrap
+
+ 0.0.9
+ netstandard2.0
+ 9
+ enable
+ Stef Heyenrath
+
+ ProxyInterfaceGenerator
+ ProxyInterfaceGenerator
+ This project uses Source Generation to generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI.
+ class;interface;proxy;SourceGenerator;Analyzer;Generation;Generate;wrap
- MIT
- See ReleaseNotes.md
- https://github.com/StefH/ProxyInterfaceGenerator
- git
- https://github.com/StefH/ProxyInterfaceGenerator
+ MIT
+ See ReleaseNotes.md
+ https://github.com/StefH/ProxyInterfaceGenerator
+ git
+ https://github.com/StefH/ProxyInterfaceGenerator
- netstandard2.0
- {12344228-91F4-4502-9595-39584E5ABB34}
+ netstandard2.0
+ {12344228-91F4-4502-9595-39584E5ABB34}
- false
- true
- $(BaseIntermediateOutputPath)Generated
-
+ false
+ true
+ $(BaseIntermediateOutputPath)Generated
+
-
- true
-
+
+ true
+
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
\ No newline at end of file