blob: ce1b321a8f44cffe7480e235f55d46c4341d82da (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
}
}
}
|