0
私はクラスのプライベートメンバーのすべてのリファレンスを探したい。 私はこれを行うにしようとしました:Roslynのプライベートメンバーのリファレンスを探す
MemberInfo member = ...//the private member for which I want to find its references
Type type = member.DeclaringType;
string assemblyName = type.Assembly.GetName().Name;
Solution solution = workspace.CurrentSolution;
Project project = solution.Projects.First(x => x.AssemblyName == assemblyName);
Compilation compilation = project.GetCompilation();
ClassDeclarationSyntax classDeclaration = compilation.GetClassDeclaration(type);
MemberDeclarationSyntax memberDeclaration = classDeclaration.GetMemberDeclaration(member.Name);
SemanticModel semanticModel = compilation.GetSemanticModel(classDeclaration.SyntaxTree);
ISymbol memberSymbol = semanticModel.GetSymbolInfo(memberDeclaration).Symbol; ==> this is null since GetSymbolInfo does not expect a MemberDeclaationSyntax
IEnumerable<ReferencedSymbol> references = SymbolFinder.FindReferencesAsync(memberSymbol, solution).Result;
どのように私はプライベートメンバのすべての参照を見つけることができますか?