Modifiers
This commit is contained in:
@@ -71,6 +71,7 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
|
||||
|
||||
protected INamedTypeSymbol GetType(string name)
|
||||
{
|
||||
// The GetTypeByMetadataName method returns null if no type matches the full name or if 2 or more types (in different assemblies) match the full name.
|
||||
var symbol = _context.GeneratorExecutionContext.Compilation.GetTypeByMetadataName(name);
|
||||
if (symbol is null)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace ProxyInterfaceSourceGenerator.SyntaxReceiver
|
||||
{
|
||||
internal class ProxySyntaxReceiver : ISyntaxReceiver
|
||||
{
|
||||
private static readonly string[] Modifiers = new[] { "public", "partial" };
|
||||
|
||||
public IDictionary<InterfaceDeclarationSyntax, ProxyData> CandidateInterfaces { get; } = new Dictionary<InterfaceDeclarationSyntax, ProxyData>();
|
||||
|
||||
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
|
||||
@@ -20,9 +22,14 @@ namespace ProxyInterfaceSourceGenerator.SyntaxReceiver
|
||||
|
||||
private static bool TryGet(InterfaceDeclarationSyntax interfaceDeclarationSyntax, out ProxyData data)
|
||||
{
|
||||
data = new(string.Empty, string.Empty, string.Empty, false);
|
||||
|
||||
// TODO : how to check if the InterfaceDeclarationSyntax has 'partial' ?
|
||||
data = new(string.Empty, string.Empty, string.Empty, false);
|
||||
|
||||
if (interfaceDeclarationSyntax.Modifiers.Select(m => m.ToString()).Except(Modifiers).Count() != 0)
|
||||
{
|
||||
// InterfaceDeclarationSyntax should be "public" and "partial"
|
||||
return false;
|
||||
}
|
||||
|
||||
var attributeLists = interfaceDeclarationSyntax.AttributeLists.FirstOrDefault(x => x.Attributes.Any(a => a.Name.ToString().Equals("ProxyInterfaceGenerator.Proxy")));
|
||||
if (attributeLists is null)
|
||||
{
|
||||
@@ -45,7 +52,7 @@ namespace ProxyInterfaceSourceGenerator.SyntaxReceiver
|
||||
(
|
||||
ns,
|
||||
interfaceDeclarationSyntax.Identifier.ToString(),
|
||||
argumentList.Arguments[0].Expression.ChildNodes().First().GetText().ToString(),
|
||||
((TypeOfExpressionSyntax)argumentList.Arguments[0].Expression).Type.ToString(),
|
||||
false //bool.Parse(argumentList.Arguments[1].Expression.GetText().ToString())
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user