aboutsummaryrefslogtreecommitdiffstats
path: root/src/EndpointFinder.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-11-19 07:52:13 +0100
committerivarlovlie <git@ivarlovlie.no>2022-11-19 07:52:13 +0100
commitf48f101eb0dd6bbdca91d5f50b4ce4194d7369ab (patch)
treed7e659690d0936bd3d08e25d4e5229d76d517a08 /src/EndpointFinder.cs
downloaddotnet-endpoints-f48f101eb0dd6bbdca91d5f50b4ce4194d7369ab.tar.xz
dotnet-endpoints-f48f101eb0dd6bbdca91d5f50b4ce4194d7369ab.zip
feat: Initial commit
Diffstat (limited to 'src/EndpointFinder.cs')
-rw-r--r--src/EndpointFinder.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/EndpointFinder.cs b/src/EndpointFinder.cs
new file mode 100644
index 0000000..ce1b321
--- /dev/null
+++ b/src/EndpointFinder.cs
@@ -0,0 +1,19 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace I2R.Endpoints;
+
+public class EndpointFinder : ISyntaxReceiver
+{
+ public HashSet<ClassDeclarationSyntax> AsyncEndpoints { get; } = new();
+ public HashSet<ClassDeclarationSyntax> SyncEndpoints { get; } = new();
+
+ public void OnVisitSyntaxNode(SyntaxNode syntaxNode) {
+ if (syntaxNode is not ClassDeclarationSyntax endpoint) return;
+ if (endpoint.BaseList?.Types.Any(c => c.ToString().StartsWith("AsyncEndpoint")) ?? false) {
+ AsyncEndpoints.Add(endpoint);
+ } else if (endpoint.BaseList?.Types.Any(c => c.ToString().StartsWith("SyncEndpoint")) ?? false) {
+ SyncEndpoints.Add(endpoint);
+ }
+ }
+} \ No newline at end of file