From dfb5b08f26573799a7254b64e022759ed4acf102 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 21 Dec 2022 19:14:48 +0100 Subject: feat: latest, not working --- code/source-generator/EndpointFinder.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 code/source-generator/EndpointFinder.cs (limited to 'code/source-generator/EndpointFinder.cs') diff --git a/code/source-generator/EndpointFinder.cs b/code/source-generator/EndpointFinder.cs new file mode 100644 index 0000000..b30451e --- /dev/null +++ b/code/source-generator/EndpointFinder.cs @@ -0,0 +1,17 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace I2R.Endpoints.Generator; + +public class EndpointFinder : ISyntaxReceiver +{ + public HashSet Endpoints { get; } = new(); + + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { + if (syntaxNode is not ClassDeclarationSyntax endpoint) return; + if ((endpoint.BaseList?.Types.Any(c => EndpointGenerator.IsSyncEndpoint(c.ToString())) ?? false) + || (endpoint.BaseList?.Types.Any(c => EndpointGenerator.IsAyncEndpoint(c.ToString())) ?? false)) { + Endpoints.Add(endpoint); + } + } +} -- cgit v1.3