Skip to content

Commit

Permalink
Merge pull request #721 from Cysharp/feature/RestoreMethodCollectorTests
Browse files Browse the repository at this point in the history
Restore MethodCollector tests
  • Loading branch information
mayuki authored Dec 12, 2023
2 parents e72757a + dbbfa96 commit 25d0759
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 521 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis;
/// <summary>
/// Provides logic to collect MagicOnion Services and StreamingHubs from a compilation.
/// </summary>
public class MethodCollector
public static class MethodCollector
{
public static (MagicOnionServiceCollection ServiceCollection, IReadOnlyList<Diagnostic> Diagnostics) Collect(ImmutableArray<INamedTypeSymbol> interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.CodeAnalysis;

namespace MagicOnion.Client.SourceGenerator.Tests.Collector;

public static class MethodCollectorTestHelper
{
public static IEnumerable<INamedTypeSymbol> Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol)
{
foreach (var namespaceOrTypeSymbol in rootNamespaceOrTypeSymbol.GetMembers())
{
if (namespaceOrTypeSymbol is INamedTypeSymbol { TypeKind: TypeKind.Interface } typeSymbol)
{
yield return typeSymbol;
}
else if (namespaceOrTypeSymbol is INamespaceSymbol namespaceSymbol)
{
foreach (var t in Traverse(namespaceSymbol))
{
yield return t;
}
}
}
}
}
Loading

0 comments on commit 25d0759

Please sign in to comment.