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


C# ISymbol.ToDisplayString方法代码示例

本文整理汇总了C#中ISymbol.ToDisplayString方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.ToDisplayString方法的具体用法?C# ISymbol.ToDisplayString怎么用?C# ISymbol.ToDisplayString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISymbol的用法示例。


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

示例1: CallHierarchyItem

 public CallHierarchyItem(ISymbol symbol, ProjectId projectId, IEnumerable<AbstractCallFinder> finders, Func<ImageSource> glyphCreator, CallHierarchyProvider provider, IEnumerable<Location> callsites, Workspace workspace)
 {
     _symbolId = symbol.GetSymbolKey();
     _projectId = projectId;
     _finders = finders;
     _containingTypeName = symbol.ContainingType.ToDisplayString(ContainingTypeFormat);
     _containingNamespaceName = symbol.ContainingNamespace.ToDisplayString(ContainingNamespaceFormat);
     _glyphCreator = glyphCreator;
     _name = symbol.ToDisplayString(MemberNameFormat);
     _provider = provider;
     _callsites = callsites.Select(l => new CallHierarchyDetail(l, workspace));
     _sortText = symbol.ToDisplayString();
     _workspace = workspace;
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:14,代码来源:CallHierarchyItem.cs

示例2: SourceDefinitionTreeItem

        public SourceDefinitionTreeItem(Document document, TextSpan sourceSpan, ISymbol symbol, ushort glyphIndex)
            : base(document, sourceSpan, glyphIndex)
        {
            _symbolDisplay = symbol.ToDisplayString(definitionDisplayFormat);

            this.DisplayText = $"[{document.Project.Name}] {_symbolDisplay}";
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:7,代码来源:SourceDefinitionTreeItem.cs

示例3: TryOnAfterGlobalSymbolRenamed

        public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable<DocumentId> changedDocumentIDs, ISymbol symbol, string newName, bool throwOnFailure)
        {
            var visualStudioWorkspace = workspace as VisualStudioWorkspaceImpl;
            if (visualStudioWorkspace != null)
            {
                foreach (var documentId in changedDocumentIDs)
                {
                    var containedDocument = visualStudioWorkspace.GetHostDocument(documentId) as ContainedDocument;
                    if (containedDocument != null)
                    {
                        var containedLanguageHost = containedDocument.ContainedLanguage.ContainedLanguageHost;
                        if (containedLanguageHost != null)
                        {
                            var hresult = containedLanguageHost.OnRenamed(
                                GetRenameType(symbol), symbol.ToDisplayString(s_qualifiedDisplayFormat), newName);
                            if (hresult < 0)
                            {
                                if (throwOnFailure)
                                {
                                    Marshal.ThrowExceptionForHR(hresult);
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }
                    }
                }
            }

            return true;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:33,代码来源:ContainedLanguageRefactorNotifyService.cs

示例4: ConvertSymbol

        private QuickFix ConvertSymbol(ISymbol symbol, Location location)
        {
            var lineSpan = location.GetLineSpan();
            var path = lineSpan.Path;
            var documents = _workspace.GetDocuments(path);

            var format = SymbolDisplayFormat.MinimallyQualifiedFormat;
            format = format.WithMemberOptions(format.MemberOptions
                                              ^ SymbolDisplayMemberOptions.IncludeContainingType
                                              ^ SymbolDisplayMemberOptions.IncludeType);

            format = format.WithKindOptions(SymbolDisplayKindOptions.None);

            return new SymbolLocation
            {
                Text = symbol.ToDisplayString(format),
                Kind = symbol.GetKind(),
                FileName = path,
                Line = lineSpan.StartLinePosition.Line + 1,
                Column = lineSpan.StartLinePosition.Character + 1,
                EndLine = lineSpan.EndLinePosition.Line + 1,
                EndColumn = lineSpan.EndLinePosition.Character + 1,
                Projects = documents.Select(document => document.Project.Name).ToArray()
            };
        }
开发者ID:tugberkugurlu,项目名称:omnisharp-roslyn,代码行数:25,代码来源:OmnisharpController.FindSymbols.cs

示例5: SourceDefinitionTreeItem

        public SourceDefinitionTreeItem(Document document, TextSpan sourceSpan, ISymbol symbol, ushort glyphIndex)
            : base(document, sourceSpan, glyphIndex)
        {
            _symbolDisplay = symbol.ToDisplayString(definitionDisplayFormat);
            this.DisplayText = $"{GetProjectNameString()}{_symbolDisplay}";

            _canGoToDefinition = symbol.Kind != SymbolKind.Namespace;
        }
开发者ID:xyh413,项目名称:roslyn,代码行数:8,代码来源:SourceDefinitionTreeItem.cs

示例6: CreateBreakpoint

        private BreakpointResolutionResult CreateBreakpoint(ISymbol methodSymbol)
        {
            var location = methodSymbol.Locations.First(loc => loc.IsInSource);

            var document = _solution.GetDocument(location.SourceTree);
            var textSpan = new TextSpan(location.SourceSpan.Start, 0);
            var vsDebugName = methodSymbol.ToDisplayString(s_vsDebugNameFormat);

            return BreakpointResolutionResult.CreateSpanResult(document, textSpan, vsDebugName);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:10,代码来源:AbstractBreakpointResolver.cs

示例7: MetadataDefinitionTreeItem

 public MetadataDefinitionTreeItem(Workspace workspace, ISymbol definition, ProjectId referencingProjectId, ushort glyphIndex)
     : base(glyphIndex)
 {
     _workspace = workspace;
     _referencingProjectId = referencingProjectId;
     _symbolKey = definition.GetSymbolKey();
     _assemblyName = definition.ContainingAssembly.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
     _symbolDefinition = definition.ToDisplayString(definitionDisplayFormat);
     this.DisplayText = $"[{_assemblyName}] {_symbolDefinition}";
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:10,代码来源:MetadataDefinitionTreeItem.cs

示例8: AddItem

        private void AddItem(ISymbol symbol)
        {
            var item = new ListBoxItem()
                           {
                               Tag = symbol,
                               Visibility = Visibility.Visible,
                               IsEnabled = true,
                               Foreground = Brushes.Blue,
                               Background = Brushes.White,
                               Content = symbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat)
                           };

            // TODO: hook up selection event handler to render/update associated events, handlers, etc

            listBox.Items.Add(item);
        }
开发者ID:jjrdk,项目名称:CqrsMessagingTools,代码行数:16,代码来源:CommandVisualizerControl.xaml.cs

示例9: UpdateLabelsForNode

        private static void UpdateLabelsForNode(ISymbol symbol, Solution solution, GraphNode node)
        {
            var progressionLanguageService = solution.Workspace.Services.GetLanguageServices(symbol.Language).GetService<IProgressionLanguageService>();

            // A call from unittest may not have a proper language service.
            if (progressionLanguageService != null)
            {
                node[RoslynGraphProperties.Description] = progressionLanguageService.GetDescriptionForSymbol(symbol, includeContainingSymbol: false);
                node[RoslynGraphProperties.DescriptionWithContainingSymbol] = progressionLanguageService.GetDescriptionForSymbol(symbol, includeContainingSymbol: true);

                node[RoslynGraphProperties.FormattedLabelWithoutContainingSymbol] = progressionLanguageService.GetLabelForSymbol(symbol, includeContainingSymbol: false);
                node[RoslynGraphProperties.FormattedLabelWithContainingSymbol] = progressionLanguageService.GetLabelForSymbol(symbol, includeContainingSymbol: true);
            }

            switch (symbol.Kind)
            {
                case SymbolKind.NamedType:
                    var typeSymbol = (INamedTypeSymbol)symbol;
                    if (typeSymbol != null && typeSymbol.IsGenericType)
                    {
                        // Symbol.name does not contain type params for generic types, so we populate them here for some requiring cases like VS properties panel.
                        node.Label = (string)node[RoslynGraphProperties.FormattedLabelWithoutContainingSymbol];

                        // Some consumers like CodeMap want to show types in an unified way for both C# and VB.
                        // Therefore, populate a common label property using only name and its type parameters.
                        // For example, VB's "Foo(Of T)" or C#'s "Foo<T>(): T" will be shown as "Foo<T>".
                        // This property will be used for drag-and-drop case.
                        var commonLabel = new System.Text.StringBuilder();
                        commonLabel.Append(typeSymbol.Name);
                        commonLabel.Append("<");
                        commonLabel.Append(string.Join(", ", typeSymbol.TypeParameters.Select(t => t.Name)));
                        commonLabel.Append(">");
                        node[Microsoft.VisualStudio.ArchitectureTools.ProgressiveReveal.ProgressiveRevealSchema.CommonLabel] = commonLabel.ToString();

                        return;
                    }
                    else
                    {
                        node.Label = symbol.Name;
                    }

                    break;

                case SymbolKind.Method:
                    var methodSymbol = (IMethodSymbol)symbol;
                    if (methodSymbol.MethodKind == MethodKind.Constructor)
                    {
                        node.Label = CodeQualifiedIdentifierBuilder.SpecialNames.GetConstructorLabel(methodSymbol.ContainingSymbol.Name);
                    }
                    else if (methodSymbol.MethodKind == MethodKind.StaticConstructor)
                    {
                        node.Label = CodeQualifiedIdentifierBuilder.SpecialNames.GetStaticConstructorLabel(methodSymbol.ContainingSymbol.Name);
                    }
                    else if (methodSymbol.MethodKind == MethodKind.Destructor)
                    {
                        node.Label = CodeQualifiedIdentifierBuilder.SpecialNames.GetFinalizerLabel(methodSymbol.ContainingSymbol.Name);
                    }
                    else
                    {
                        node.Label = methodSymbol.Name;
                    }

                    break;

                case SymbolKind.Property:
                    node.Label = symbol.MetadataName;

                    var propertySymbol = symbol as IPropertySymbol;
                    if (propertySymbol != null && propertySymbol.IsIndexer && LanguageNames.CSharp == propertySymbol.Language)
                    {
                        // For C# indexer, we will strip off the "[]"
                        node.Label = symbol.Name.Replace("[]", string.Empty);
                    }

                    break;

                case SymbolKind.Namespace:
                    // Use a name with its parents (e.g., A.B.C)
                    node.Label = symbol.ToDisplayString();
                    break;

                default:
                    node.Label = symbol.Name;
                    break;
            }

            // When a node is dragged and dropped from SE to CodeMap, its label could be reset during copying to clipboard.
            // So, we try to keep its label that we computed above in a common label property, which CodeMap can access later.
            node[Microsoft.VisualStudio.ArchitectureTools.ProgressiveReveal.ProgressiveRevealSchema.CommonLabel] = node.Label;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:90,代码来源:GraphBuilder.cs

示例10: Format

        private string Format(ISymbol symbol)
        {
            if (symbol is ITypeSymbol || symbol is INamespaceSymbol)
            {
                return FormatTypeOrNamespace((INamespaceOrTypeSymbol)symbol);
            }

            if (symbol.MatchesKind(SymbolKind.Alias, SymbolKind.Local, SymbolKind.Parameter))
            {
                return Format(symbol.GetSymbolType());
            }

            var containingType = FormatTypeOrNamespace(symbol.ContainingType);
            var name = symbol.ToDisplayString(NameFormat);

            if (symbol.IsConstructor())
            {
                return string.Format("{0}.#ctor", containingType);
            }

            if (symbol.GetTypeArguments().Any())
            {
                return string.Format("{0}.{1}``{2}", containingType, name, symbol.GetTypeArguments().Length);
            }

            return string.Format("{0}.{1}", containingType, name);
        }
开发者ID:hemaltandel,项目名称:roslyn,代码行数:27,代码来源:CSharpHelpContextService.cs

示例11: CreateItemForMember

        private NavigationBarItem CreateItemForMember(ISymbol member, int symbolIndex, SyntaxTree tree, CancellationToken cancellationToken)
        {
            var spans = GetSpansInDocument(member, tree, cancellationToken);

            return new NavigationBarSymbolItem(
                member.ToDisplayString(s_memberFormat),
                member.GetGlyph(),
                spans,
                member.GetSymbolKey(),
                symbolIndex,
                grayed: spans.Count == 0);
        }
开发者ID:vslsnap,项目名称:roslyn,代码行数:12,代码来源:CSharpNavigationBarItemService.cs

示例12: GetQualifiedName

 private static string GetQualifiedName(ISymbol symbol)
 {
     return symbol.ToDisplayString(new SymbolDisplayFormat(
         typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
         genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters));
 }
开发者ID:martinvobr,项目名称:Wyam,代码行数:6,代码来源:AnalyzeSymbolVisitor.cs

示例13: CheckMember

		/// <summary>
		///   Checks whether the <paramref name="symbol" />'s implementing member for <paramref name="interfaceMember" /> has the
		///   correct port kind.
		/// </summary>
		/// <param name="context">The context in which the analysis should be performed.</param>
		/// <param name="symbol">The symbol that should be analyzed.</param>
		/// <param name="compilation">The compilation the symbol is declared in.</param>
		/// <param name="interfaceMember">The interface member that should be checked.</param>
		private static void CheckMember(SymbolAnalysisContext context, ITypeSymbol symbol, Compilation compilation, ISymbol interfaceMember)
		{
			var implementingMember = symbol.FindImplementationForInterfaceMember(interfaceMember);

			var interfaceIsRequired = interfaceMember.HasAttribute<RequiredAttribute>(compilation);
			var interfaceIsProvided = interfaceMember.HasAttribute<ProvidedAttribute>(compilation);

			var implementationIsRequired = implementingMember.HasAttribute<RequiredAttribute>(compilation) || implementingMember.IsExtern;
			var implementationIsProvided = implementingMember.HasAttribute<ProvidedAttribute>(compilation) || !implementingMember.IsExtern;

			// If we can't uniquely classify the port kind of either the interface member or the implementation, 
			// there is another problem that another analyzer deals with. So let's just ignore it here.
			if ((interfaceIsRequired && interfaceIsProvided) || (implementationIsProvided && implementationIsRequired))
				return;

			var location = implementingMember.ContainingType.Equals(symbol) ? implementingMember : symbol;
			if (interfaceIsRequired && !implementationIsRequired)
			{
				_requiredPortImplementedAsProvidedPort.Emit(context, location,
					implementingMember.ToDisplayString(), interfaceMember.ToDisplayString());
			}

			if (interfaceIsProvided && !implementationIsProvided)
			{
				_providedPortImplementedAsRequiredPort.Emit(context, location,
					implementingMember.ToDisplayString(), interfaceMember.ToDisplayString());
			}
		}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:36,代码来源:PortImplementationAnalyzer.cs

示例14: RoslynCompletionCategory

		public RoslynCompletionCategory (ISymbol symbol)
		{
			this.symbol = symbol;
			this.DisplayText = Ambience.EscapeText (symbol.ToDisplayString (MonoDevelop.Ide.TypeSystem.Ambience.NameFormat));
			this.Icon = MonoDevelop.Ide.TypeSystem.Stock.GetStockIcon (symbol);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:6,代码来源:RoslynCompletionCategory.cs

示例15: AddDocument

        private void AddDocument(ISymbol symbol, bool xmlDocumentation, MetadataItems items)
        {
            // Get universal metadata
            items.AddRange(new []
            {
                // In general, cache the values that need calculation and don't cache the ones that are just properties of ISymbol
                new MetadataItem(CodeAnalysisKeys.IsResult, !_finished),
                new MetadataItem(CodeAnalysisKeys.SymbolId, (k, m) => GetId(symbol), true),
                new MetadataItem(CodeAnalysisKeys.Symbol, symbol),
                new MetadataItem(CodeAnalysisKeys.Name, (k, m) => symbol.Name),
                new MetadataItem(CodeAnalysisKeys.FullName, (k, m) => GetFullName(symbol), true),
                new MetadataItem(CodeAnalysisKeys.DisplayName, (k, m) => GetDisplayName(symbol), true),
                new MetadataItem(CodeAnalysisKeys.QualifiedName, (k, m) => GetQualifiedName(symbol), true),
                new MetadataItem(CodeAnalysisKeys.Kind, (k, m) => symbol.Kind.ToString()),
                new MetadataItem(CodeAnalysisKeys.ContainingNamespace, DocumentFor(symbol.ContainingNamespace)),
                new MetadataItem(CodeAnalysisKeys.Syntax, (k, m) => GetSyntax(symbol), true)
            });

            // Add metadata that's specific to initially-processed symbols
            if (!_finished)
            {
                items.AddRange(new[]
                {
                    new MetadataItem(Keys.WritePath, (k, m) => _writePath(m), true),
                    new MetadataItem(Keys.RelativeFilePath, 
                        (k, m) => m.String(Keys.WritePath)),
                    new MetadataItem(Keys.RelativeFilePathBase, 
                        (k, m) => PathHelper.RemoveExtension(m.String(Keys.WritePath))),
                    new MetadataItem(Keys.RelativeFileDir, 
                        (k, m) => Path.GetDirectoryName(m.String(Keys.WritePath)))
                });
            }

            // XML Documentation
            if (xmlDocumentation && (!_finished || _docsForImplicitSymbols))
            {
                AddXmlDocumentation(symbol, items);
            }

            // Create the document and add it to the cache
            IDocument document = _context.GetNewDocument(symbol.ToDisplayString(), null, items);
            _symbolToDocument.GetOrAdd(symbol, _ => document);

            // Map the comment ID to the document
            if (!_finished)
            {
                string documentationCommentId = symbol.GetDocumentationCommentId();
                if (documentationCommentId != null)
                {
                    _commentIdToDocument.GetOrAdd(documentationCommentId, _ => document);
                }
            }
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:53,代码来源:AnalyzeSymbolVisitor.cs


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