Reputation: 401
I'm creating na analyzer for Visual Studio, and I need the Solution property required by SymbolFinder.FindSourceDefinitionAsync(ISymbol, Solution) to ensure that I'm really operating over the type I want.
public static async Task<ITypeSymbol> GetBaseScenario(ITypeSymbol type)
{
if (type == null)
return null;
var origType = await SymbolFinder.FindSourceDefinitionAsync(type, _solution);
if (BaseScnSymbols.Contains(origType) || BaseVersionScnSymbols.Contains(origType))
return origType as ITypeSymbol;
return null;
}
I can get the Semantic Model, the compilation, but I can't get the solution. How can I get the solution? Is there a better approach for this problem?
Upvotes: 0
Views: 300
Reputation: 18976
You cannot and generally should not try to access the Solution during an analyzer. This is for performance and correctness. This answer still applies. If you describe your actual scenario there's generally a way to not get the Solution.
Upvotes: 2
Reputation: 1418
As far as I know the only way to get a solution symbol is to load it via its physical path with MSBuildWorkspace.OpenSolutionAsync.
Upvotes: 0