ProxyAll for interface part 1...

This commit is contained in:
Stef Heyenrath
2021-07-24 10:05:54 +02:00
parent afe1710816
commit 97fddc2f3f
9 changed files with 127 additions and 56 deletions
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using ProxyInterfaceSourceGenerator.SyntaxReceiver;
namespace ProxyInterfaceSourceGenerator.FileGenerators
{
internal abstract class BaseGenerator
{
protected readonly Context _context;
protected readonly IDictionary<InterfaceDeclarationSyntax, ProxyData> _candidateInterfaces;
public BaseGenerator(Context context, IDictionary<InterfaceDeclarationSyntax, ProxyData> candidateInterfaces)
{
_context = context;
_candidateInterfaces = candidateInterfaces;
}
protected INamedTypeSymbol GetType(string name)
{
var symbol = _context.GeneratorExecutionContext.Compilation.GetTypeByMetadataName(name);
if (symbol is null)
{
throw new Exception($"The type '{name}' is not found.");
}
return symbol;
}
}
}