Esempio n. 1
0
        private static async Task <ISymbol> TryResolveAsync(
            Document document, DeclaredSymbolInfo info, ConcurrentSet <SemanticModel> cachedModels,
            CancellationToken cancellationToken)
        {
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            cachedModels.Add(semanticModel);
            return(info.TryResolve(semanticModel, cancellationToken));
        }
            private ISymbol TryFindSymbol()
            {
                // Here, we will use partial semantics. We are going to use this symbol to get a glyph, display string,
                // and potentially documentation comments. The first two should work fine even if we don't have full
                // references, and the latter will probably be fine. (It wouldn't be if you have a partial type
                // and we didn't get all the trees parsed yet to know that. In other words, an edge case we don't care about.)

                // Cancellation isn't supported when computing the various properties that depend on the symbol, hence
                // CancellationToken.None.
                var semanticModel = Document.GetPartialSemanticModelAsync(CancellationToken.None).GetAwaiter().GetResult();

                return(_declaredSymbolInfo.TryResolve(semanticModel, CancellationToken.None));
            }