roslyn
roslyn copied to clipboard
Semantic search should check project's type
Using Roslyn.sln, and copy this code to the semantic search window
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
static IEnumerable<ISymbol> Find(CSharpCompilation compilation)
{
var asyncMethods = new List<ISymbol>();
foreach (var syntaxTree in compilation.SyntaxTrees)
{
var semanticModel = compilation.GetSemanticModel(syntaxTree);
var root = syntaxTree.GetRoot();
var methodDeclarations = root.DescendantNodes().OfType<MethodDeclarationSyntax>();
foreach (var methodDeclaration in methodDeclarations)
{
if (methodDeclaration.Modifiers.Any(SyntaxKind.AsyncKeyword))
{
var methodSymbol = semanticModel.GetDeclaredSymbol(methodDeclaration);
asyncMethods.Add(methodSymbol);
}
}
}
return asyncMethods;
}
VS shows: