aboutsummaryrefslogtreecommitdiffstats
path: root/code/source-generator/EndpointFinder.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-12-21 19:14:48 +0100
committerivarlovlie <git@ivarlovlie.no>2022-12-21 19:14:48 +0100
commitdfb5b08f26573799a7254b64e022759ed4acf102 (patch)
tree0829ea32cbaa82921f75c4bbb09f19925a1078ca /code/source-generator/EndpointFinder.cs
parent09250198cdd7a7c13bc50664ef3c8b51bdc1ea8b (diff)
downloaddotnet-endpoints-dfb5b08f26573799a7254b64e022759ed4acf102.tar.xz
dotnet-endpoints-dfb5b08f26573799a7254b64e022759ed4acf102.zip
feat: latest, not working
Diffstat (limited to 'code/source-generator/EndpointFinder.cs')
-rw-r--r--code/source-generator/EndpointFinder.cs17
1 files changed, 17 insertions, 0 deletions
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<ClassDeclarationSyntax> 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);
+ }
+ }
+}