Esempio n. 1
0
            public void GetUniqueSymbolOrArities(out IArityEnumerable?arities, out TSymbol?uniqueSymbol)
            {
                if (this.HasUniqueSymbol)
                {
                    arities = null;
#nullable disable // Can '_uniqueSymbolOrArities' be null? https://github.com/dotnet/roslyn/issues/39166
                    uniqueSymbol = (TSymbol)_uniqueSymbolOrArities;
#nullable enable
                }
Esempio n. 2
0
        internal static ResultProperties GetResultProperties <TSymbol>(
            this TSymbol?symbol,
            DkmClrCompilationResultFlags flags,
            bool isConstant
            ) where TSymbol : class, ISymbolInternal
        {
            var category =
                (symbol != null)
                    ? GetResultCategory(symbol.Kind)
                    : DkmEvaluationResultCategory.Data;

            var accessType =
                (symbol != null)
                    ? GetResultAccessType(symbol.DeclaredAccessibility)
                    : DkmEvaluationResultAccessType.None;

            var storageType =
                (symbol != null) && symbol.IsStatic
                    ? DkmEvaluationResultStorageType.Static
                    : DkmEvaluationResultStorageType.None;

            var modifierFlags = DkmEvaluationResultTypeModifierFlags.None;

            if (isConstant)
            {
                modifierFlags = DkmEvaluationResultTypeModifierFlags.Constant;
            }
            else if (symbol is null)
            {
                // No change.
            }
            else if (symbol.IsVirtual || symbol.IsAbstract || symbol.IsOverride)
            {
                modifierFlags = DkmEvaluationResultTypeModifierFlags.Virtual;
            }
            else if (symbol.Kind == SymbolKind.Field && ((IFieldSymbolInternal)symbol).IsVolatile)
            {
                modifierFlags = DkmEvaluationResultTypeModifierFlags.Volatile;
            }

            // CONSIDER: for completeness, we could check for [MethodImpl(MethodImplOptions.Synchronized)]
            // and set DkmEvaluationResultTypeModifierFlags.Synchronized, but it doesn't seem to have any
            // impact on the UI.  It is exposed through the DTE, but cscompee didn't set the flag either.

            return(new ResultProperties(flags, category, accessType, storageType, modifierFlags));
        }
Esempio n. 3
0
 static TSymbol?TryGetSingleSymbol <TSymbol> (ImmutableArray <ISymbol> members) where TSymbol: class, ISymbol
 {
     TSymbol?candidate = null;
     foreach (var m in members)
     {
         if (m is TSymbol tsym)
         {
             if (candidate is null)
             {
                 candidate = tsym;
             }
             else
             {
                 return(null);
             }
         }
     }
     return(candidate);
 }
Esempio n. 4
0
 static void AddIfNotNull <TSymbol> (ImmutableArray <TSymbol> .Builder properties, TSymbol? p) where TSymbol: class, ISymbol
 {
     if (p != null)
     {
         properties.Add(p);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Try getting the <see cref="ISymbol"/> for the node.
        /// Gets the semantic model for the tree if the node is not in the tree corresponding to <paramref name="semanticModel"/>.
        /// </summary>
        /// <typeparam name="TSymbol">The symbol.</typeparam>
        /// <param name="semanticModel">The <see cref="SemanticModel"/>.</param>
        /// <param name="node">The <see cref="SyntaxNode"/>.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
        /// <param name="symbol">The symbol if found.</param>
        /// <returns>True if a symbol was found.</returns>
        public static bool TryGetSymbol <TSymbol>(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken, [NotNullWhen(true)] out TSymbol?symbol)
            where TSymbol : class, ISymbol
        {
            if (semanticModel is null)
            {
                throw new System.ArgumentNullException(nameof(semanticModel));
            }

            if (node is null)
            {
                throw new System.ArgumentNullException(nameof(node));
            }

            symbol = GetSymbolSafe(semanticModel, node, cancellationToken) as TSymbol ??
                     GetDeclaredSymbolSafe(semanticModel, node, cancellationToken) as TSymbol;
            return(symbol != null);
        }
Esempio n. 6
0
 protected abstract SymbolKeyResolution Resolve(SymbolKeyReader reader, TSymbol?contextualSymbol, out string?failureReason);