当前位置: 首页>>代码示例>>C#>>正文


C# INamespaceOrTypeSymbol类代码示例

本文整理汇总了C#中INamespaceOrTypeSymbol的典型用法代码示例。如果您正苦于以下问题:C# INamespaceOrTypeSymbol类的具体用法?C# INamespaceOrTypeSymbol怎么用?C# INamespaceOrTypeSymbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


INamespaceOrTypeSymbol类属于命名空间,在下文中一共展示了INamespaceOrTypeSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Visit

		private void Visit(INamespaceOrTypeSymbol type)
		{
			foreach (var method in type.GetMembers().OfType<IMethodSymbol>())
			{
				Visit(method);
			}
		}
开发者ID:tumtumtum,项目名称:Shaolinq,代码行数:7,代码来源:CompilationLookup.cs

示例2: SuppressDefaultTupleElements

        /// <summary>
        /// If container is a tuple type, any of its tuple element which has a friendly name will cause
        /// the suppression of the corresponding default name (ItemN).
        /// In that case, Rest is also removed.
        /// </summary>
        protected static ImmutableArray<ISymbol> SuppressDefaultTupleElements(
            INamespaceOrTypeSymbol container, ImmutableArray<ISymbol> symbols)
        {
            if (container?.IsType != true)
            {
                return symbols;
            }

            var type = (ITypeSymbol)container;
            if (!type.IsTupleType)
            {
                return symbols;
            }

            var tuple = (INamedTypeSymbol)type;
            var elementNames = tuple.TupleElementNames;
            if (elementNames.IsDefault)
            {
                return symbols;
            }

            // TODO This should be revised once we have a good public API for tuple fields
            // See https://github.com/dotnet/roslyn/issues/13229
            var fieldsToRemove = elementNames.Select((n, i) => IsFriendlyName(i, n) ? "Item" + (i + 1) : null)
                .Where(n => n != null).Concat("Rest").ToSet();

            return symbols.WhereAsArray(
                s => s.Kind != SymbolKind.Field ||
                     elementNames.Contains(s.Name) || 
                     !fieldsToRemove.Contains(s.Name));
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:36,代码来源:AbstractRecommendationService.cs

示例3: CompareTo

        public static int CompareTo(this INamespaceOrTypeSymbol n1, INamespaceOrTypeSymbol n2)
        {
            var names1 = s_namespaceOrTypeToNameMap.GetValue(n1, s_getNamePartsCallBack);
            var names2 = s_namespaceOrTypeToNameMap.GetValue(n2, s_getNamePartsCallBack);

            return CompareNameParts(names1, names2);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:INamespaceOrTypeSymbolExtensions.cs

示例4: CompareTo

 public static TypeDiff CompareTo(this INamespaceOrTypeSymbol symbol, INamespaceOrTypeSymbol comparedTo)
 {
     var result = new TypeDiff();
     result.Original = symbol;
     result.ComparedTo = comparedTo;
     result.MethodDifferences = symbol.GetAllContractMembers().FullOuterJoin(comparedTo.GetAllContractMembers(), SymbolComparer.Instance, (a, b) => a.CompareTo(b));
     return result;
 }
开发者ID:run00,项目名称:Roslyn,代码行数:8,代码来源:NamespaceOrTypeSymbolExtensions.cs

示例5: AddNamespaceOrTypeDeclarationAsync

		public static Task<Document> AddNamespaceOrTypeDeclarationAsync(Solution solution, INamespaceSymbol destination, INamespaceOrTypeSymbol namespaceOrType, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
		{
			try {
				return (Task<Document>)addNamespaceOrTypeDeclarationAsyncMethod.Invoke (null, new object[] { solution, destination, namespaceOrType, options != null ? options.Instance : null, cancellationToken });
			} catch (TargetInvocationException ex) {
				ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
				return null;
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:9,代码来源:CodeGenerator.cs

示例6: GetNameParts

        private static void GetNameParts(INamespaceOrTypeSymbol namespaceOrTypeSymbol, List<string> result)
        {
            if (namespaceOrTypeSymbol == null || (namespaceOrTypeSymbol.IsNamespace && ((INamespaceSymbol)namespaceOrTypeSymbol).IsGlobalNamespace))
            {
                return;
            }

            GetNameParts(namespaceOrTypeSymbol.ContainingNamespace, result);
            result.Add(namespaceOrTypeSymbol.Name);
        }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:10,代码来源:INamespaceOrTypeSymbolExtensions.cs

示例7: dfs_through_members

 private void dfs_through_members(TreeNodeCollection treenode, INamespaceOrTypeSymbol symbol)
 {
     if (symbol != null && symbol.GetMembers() != null)
     foreach (var el in symbol.GetMembers()) {
         var cur = el as INamespaceOrTypeSymbol;
         if (cur != null) {
             treenode.Add(cur.Name.ToString());
             dfs_through_members(treenode[treenode.Count - 1].Nodes, cur);
         }
     }
 }
开发者ID:Emettant,项目名称:Metr2,代码行数:11,代码来源:VotesForm.cs

示例8: SuppressDefaultTupleElements

        /// <summary>
        /// If container is a tuple type, any of its tuple element which has a friendly name will cause
        /// the suppression of the corresponding default name (ItemN).
        /// In that case, Rest is also removed.
        /// </summary>
        protected static ImmutableArray<ISymbol> SuppressDefaultTupleElements(
            INamespaceOrTypeSymbol container, ImmutableArray<ISymbol> symbols)
        {
            var namedType = container as INamedTypeSymbol;
            if (namedType?.IsTupleType != true)
            {
                // container is not a tuple
                return symbols;
            }

            //return tuple elements followed by other members that are not fields
            return ImmutableArray<ISymbol>.CastUp(namedType.TupleElements).
                Concat(symbols.WhereAsArray(s => s.Kind != SymbolKind.Field));
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:19,代码来源:AbstractRecommendationService.cs

示例9: TryGetAliasSymbol

        public static bool TryGetAliasSymbol(SemanticModel semanticModel, int namespaceId, INamespaceOrTypeSymbol targetSymbol, out IAliasSymbol aliasSymbol)
        {
            // TODO: given semantic model must be not speculative semantic model for now. 
            // currently it can't be checked since it is not exposed to common layer yet.
            // once exposed, this method itself will make sure it use original semantic model
            aliasSymbol = null;
            if (!s_treeAliasMap.TryGetValue(semanticModel.Compilation, out var treeMap) ||
                !treeMap.TryGetValue((semanticModel.SyntaxTree, namespaceId), out var symbolMap))
            {
                return false;
            }

            symbolMap.TryGetValue(targetSymbol, out aliasSymbol);
            return true;
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:15,代码来源:AliasSymbolCache.cs

示例10: CompareTo

        public static int CompareTo(this INamespaceOrTypeSymbol n1, INamespaceOrTypeSymbol n2)
        {
            var names1 = s_namespaceOrTypeToNameMap.GetValue(n1, GetNameParts);
            var names2 = s_namespaceOrTypeToNameMap.GetValue(n2, GetNameParts);

            for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
            {
                var comp = names1[i].CompareTo(names2[i]);
                if (comp != 0)
                {
                    return comp;
                }
            }

            return names1.Count - names2.Count;
        }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:16,代码来源:INamespaceOrTypeSymbolExtensions.cs

示例11: Resolve

            private static IEnumerable<INamedTypeSymbol> Resolve(
                SymbolKeyReader reader,
                INamespaceOrTypeSymbol container,
                string metadataName,
                int arity,
                TypeKind typeKind,
                bool isUnboundGenericType,
                ImmutableArray<SymbolKeyResolution> typeArguments)
            {
                var types = container.GetTypeMembers(GetName(metadataName), arity);
                var result = InstantiateTypes(
                    reader.Compilation, reader.IgnoreAssemblyKey, types, arity, typeArguments);

                return isUnboundGenericType
                    ? result.Select(t => t.ConstructUnboundGenericType())
                    : result;
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:SymbolKey.NamedTypeSymbolKey.cs

示例12: FindTypeCompilations

 public void FindTypeCompilations(INamespaceOrTypeSymbol symbol)
 {
     if (symbol.IsNamespace)
     {
         foreach (var member in (symbol as INamespaceSymbol).GetMembers())
         {
             FindTypeCompilations(member);
         }
     }
     else
     {
         var typeSymbol = symbol as ITypeSymbol;
         foreach (var attribute in typeSymbol.GetAttributes())
         {
             if (attribute.AttributeClass.Name == "AssemblyNeutralAttribute")
             {
                 _typeCompilationContexts.Add(new TypeCompilationContext(this, typeSymbol));
             }
         }
     }
 }
开发者ID:jack4it,项目名称:KRuntime,代码行数:21,代码来源:AssemblyNeutralWorker.cs

示例13: GetFullMetadataName

        public static string GetFullMetadataName(INamespaceOrTypeSymbol symbol)
        {
            ISymbol s = symbol;
            var sb = new StringBuilder(s.MetadataName);

            var last = s;
            s = s.ContainingSymbol;
            while (!IsRootNamespace(s))
            {
                if (s is ITypeSymbol && last is ITypeSymbol)
                {
                    sb.Insert(0, '+');
                }
                else
                {
                    sb.Insert(0, '.');
                }
                sb.Insert(0, s.MetadataName);
                s = s.ContainingSymbol;
            }

            return sb.ToString();
        }
开发者ID:yumapos,项目名称:Yumapos-WCF-Generator,代码行数:23,代码来源:GeneratorHelper.cs

示例14: GetDescription

 protected abstract string GetDescription(INamespaceOrTypeSymbol symbol, SemanticModel semanticModel, SyntaxNode root);
开发者ID:GloryChou,项目名称:roslyn,代码行数:1,代码来源:AbstractAddImportCodeFixProvider.cs

示例15: GetAliasForSymbol

        public static IAliasSymbol GetAliasForSymbol(INamespaceOrTypeSymbol symbol, SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
        {
            var originalSemanticModel = semanticModel.GetOriginalSemanticModel();
            if (!originalSemanticModel.SyntaxTree.HasCompilationUnitRoot)
            {
                return null;
            }

            IAliasSymbol aliasSymbol;
            var namespaceId = GetNamespaceIdForAliasSearch(semanticModel, token, cancellationToken);
            if (namespaceId < 0)
            {
                return null;
            }

            if (!AliasSymbolCache.TryGetAliasSymbol(originalSemanticModel, namespaceId, symbol, out aliasSymbol))
            {
                // add cache
                AliasSymbolCache.AddAliasSymbols(originalSemanticModel, namespaceId, semanticModel.LookupNamespacesAndTypes(token.SpanStart).OfType<IAliasSymbol>());

                // retry
                AliasSymbolCache.TryGetAliasSymbol(originalSemanticModel, namespaceId, symbol, out aliasSymbol);
            }

            return aliasSymbol;
        }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:26,代码来源:ExpressionSyntaxExtensions.cs


注:本文中的INamespaceOrTypeSymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。