Update filename for generated interface files + set DevelopmentDependency to true for the project (#26)

* Update filename for generated interface files

* .

* .

* <DevelopmentDependency>true</DevelopmentDependency>
This commit is contained in:
Stef Heyenrath
2021-08-10 20:33:34 +02:00
committed by GitHub
parent cec093775c
commit 00cd67f355
11 changed files with 383 additions and 7 deletions
@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using ProxyInterfaceSourceGenerator.Enums;
using ProxyInterfaceSourceGenerator.Extensions;
using ProxyInterfaceSourceGenerator.SyntaxReceiver;
@@ -20,17 +21,18 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
{
foreach (var ci in _context.CandidateInterfaces)
{
yield return GenerateFile(ci.Value);
yield return GenerateFile(ci.Key, ci.Value);
}
}
private FileData GenerateFile(ProxyData pd)
private FileData GenerateFile(InterfaceDeclarationSyntax ci, ProxyData pd)
{
var sourceInterfaceSymbol = GetNamedTypeSymbolByFullName(ci.Identifier.ToString(), pd.Usings);
var targetClassSymbol = GetNamedTypeSymbolByFullName(pd.TypeName, pd.Usings);
var interfaceName = targetClassSymbol.ResolveInterfaceNameWithOptionalTypeConstraints(pd.InterfaceName);
var file = new FileData(
$"{targetClassSymbol.GetFileName()}.g.cs",
$"{sourceInterfaceSymbol.GetFileName()}.g.cs",
CreatePartialInterfaceCode(pd.Namespace, targetClassSymbol, interfaceName, pd.ProxyAll)
);
@@ -6,7 +6,7 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
public FileData GenerateFile()
{
return new FileData($"{ClassName}.g.cs", $@"//----------------------------------------------------------------------------------------
return new FileData($"ProxyInterfaceGenerator.{ClassName}.g.cs", $@"//----------------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator.
//