Add support for Events (#23)

* event wip...

* Add support for 'event'

* event example
This commit is contained in:
Stef Heyenrath
2021-08-03 21:03:45 +02:00
committed by GitHub
parent 7b158adadc
commit c536e194e7
8 changed files with 228 additions and 159 deletions
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using ProxyInterfaceSourceGenerator.Enums;
using ProxyInterfaceSourceGenerator.Extensions;
using ProxyInterfaceSourceGenerator.SyntaxReceiver;
using ProxyInterfaceSourceGenerator.Utils;
using System.Collections.Generic;
using System.Text;
namespace ProxyInterfaceSourceGenerator.FileGenerators
{
@@ -47,6 +48,8 @@ namespace {ns}
{GenerateProperties(targetClassSymbol, proxyAll)}
{GenerateMethods(targetClassSymbol)}
{GenerateEvents(targetClassSymbol)}
}}
}}";
@@ -89,5 +92,19 @@ namespace {ns}
return str.ToString();
}
private string GenerateEvents(INamedTypeSymbol targetClassSymbol)
{
var str = new StringBuilder();
foreach (var @event in MemberHelper.GetPublicEvents(targetClassSymbol))
{
var ps = @event.First().Parameters.First();
var type = ps.GetTypeEnum() == TypeEnum.Complex ? GetParameterType(ps, out _) : ps.Type.ToString();
str.AppendLine($" event {type} {@event.Key.GetSanitizedName()};");
str.AppendLine();
}
return str.ToString();
}
}
}