Add <auto-generated> (#24)

This commit is contained in:
Stef Heyenrath
2021-08-05 21:34:50 +02:00
committed by GitHub
parent 2a56acea6e
commit 8d43c73816
7 changed files with 83 additions and 53 deletions
@@ -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) => $@"//----------------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//----------------------------------------------------------------------------------------
#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;";