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


C# ISymbol.GetDocumentationComment方法代码示例

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


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

示例1: AddExceptions

            private void AddExceptions(ISymbol symbol)
            {
                var exceptionTypes = symbol.GetDocumentationComment().ExceptionTypes;
                if (exceptionTypes.Any())
                {
                    var parts = new List<SymbolDisplayPart>();
                    parts.Add(new SymbolDisplayPart(kind: SymbolDisplayPartKind.Text, symbol: null, text: $"\r\n{WorkspacesResources.Exceptions_colon}"));
                    foreach (var exceptionString in exceptionTypes)
                    {
                        parts.AddRange(LineBreak());
                        parts.AddRange(Space(count: 2));
                        parts.AddRange(AbstractDocumentationCommentFormattingService.CrefToSymbolDisplayParts(exceptionString, _position, _semanticModel));
                    }

                    AddToGroup(SymbolDescriptionGroups.Exceptions, parts);
                }
            }
开发者ID:jkotas,项目名称:roslyn,代码行数:17,代码来源:AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs

示例2: GetAutoCompleteItem

		private static IEnumerable<AutoCompleteItem> GetAutoCompleteItem(ISymbol symbol, bool showClassesAsStatic)
		{
			var result = new List<AutoCompleteItem>();

			var item = new AutoCompleteItem {Name = symbol.Name};

			var itemDoc = symbol.GetDocumentationComment(CultureInfo.GetCultureInfo("en-US"));
				
			if (itemDoc != null)
				item.Description = itemDoc.SummaryTextOpt;

			switch (symbol.Kind)
			{
				case CommonSymbolKind.Method:
					item.ItemType = AutoCompleteItemType.Method;
					var methodSymbol = (IMethodSymbol) symbol;
					item.IsExtension = methodSymbol.IsExtensionMethod;
					item.IsStatic = methodSymbol.IsStatic;
					item.Type = methodSymbol.ReturnsVoid ? "void" : methodSymbol.ReturnType.Name;
					//args
					item.Params = GetSymbolParameters(methodSymbol.Parameters, itemDoc);
					item.IsGeneric = methodSymbol.IsGenericMethod;
					break;
				case CommonSymbolKind.Local:
					item.ItemType = AutoCompleteItemType.Variable;
					var localSymbol = (ILocalSymbol) symbol;
					item.Type = localSymbol.Type.Name;
					break;
				case CommonSymbolKind.Field:
					item.ItemType = AutoCompleteItemType.Variable;
					var fieldSymbol = (IFieldSymbol) symbol;
					item.Type = fieldSymbol.Type.Name;
					break;
				case CommonSymbolKind.Property:
					item.ItemType = AutoCompleteItemType.Property;
					var propertySymbol = (IPropertySymbol) symbol;
					item.Type = propertySymbol.Type.Name;
					break;
				case CommonSymbolKind.Namespace:
					item.ItemType = AutoCompleteItemType.Namespace;
					var namespaceSymbol = (INamespaceSymbol) symbol;
					item.Name = namespaceSymbol.Name;
					break;
				case CommonSymbolKind.NamedType:
					item.ItemType = AutoCompleteItemType.Class;
					var classSymbol = (INamedTypeSymbol) symbol;
					item.Name = classSymbol.Name;
					item.IsStatic = showClassesAsStatic || classSymbol.IsStatic;
					item.IsGeneric = classSymbol.IsGenericType;
					
					if (!showClassesAsStatic)
					{
						var constructors = classSymbol.GetConstructors();
						foreach (var constructor in constructors)
						{
							itemDoc = constructor.GetDocumentationComment(CultureInfo.GetCultureInfo("en-US"));

							var consItem = (AutoCompleteItem) item.Clone();
							if (itemDoc != null)
								consItem.Description = itemDoc.SummaryTextOpt;
							consItem.Params = GetSymbolParameters(constructor.Parameters, itemDoc);
							result.Add(consItem);
						}
					}
					break;
			}

			if (result.Count == 0)
				result.Add(item);

			return result;
		}
开发者ID:modulexcite,项目名称:.NET-Fiddle-NancyFX-Integration,代码行数:72,代码来源:RoslynCodeHelper.cs

示例3: GetDocumentation

 private static string GetDocumentation(ISymbol symbol, CancellationToken cancellationToken)
 {
     switch (symbol)
     {
         case IParameterSymbol parameter: return parameter.ContainingSymbol.OriginalDefinition.GetDocumentationComment(cancellationToken: cancellationToken).GetParameterText(symbol.Name);
         case ITypeParameterSymbol typeParam: return typeParam.ContainingSymbol.GetDocumentationComment(cancellationToken: cancellationToken).GetTypeParameterText(symbol.Name);
         case IMethodSymbol method: return GetMethodDocumentation(method);
         case IAliasSymbol alias: return alias.Target.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText;
         default: return symbol.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText;
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:ISymbolExtensions_2.cs

示例4: BuildXmlDocumentation

        private void BuildXmlDocumentation(ISymbol symbol, Compilation compilation, _VSOBJDESCOPTIONS options)
        {
            var documentationComment = symbol.GetDocumentationComment(expandIncludes: true, cancellationToken: CancellationToken.None);
            if (documentationComment == null)
            {
                return;
            }

            var formattingService = _project.LanguageServices.GetService<IDocumentationCommentFormattingService>();
            if (formattingService == null)
            {
                return;
            }

            var emittedDocs = false;

            if (documentationComment.SummaryText != null)
            {
                AddLineBreak();
                AddName(ServicesVSResources.Library_Summary);
                AddLineBreak();

                AddText(formattingService.Format(documentationComment.SummaryText, compilation));
                emittedDocs = true;
            }

            if (documentationComment.TypeParameterNames.Length > 0)
            {
                if (emittedDocs)
                {
                    AddLineBreak();
                }

                AddLineBreak();
                AddName(ServicesVSResources.Library_TypeParameters);

                foreach (var typeParameterName in documentationComment.TypeParameterNames)
                {
                    AddLineBreak();

                    var typeParameterText = documentationComment.GetTypeParameterText(typeParameterName);
                    if (typeParameterText != null)
                    {
                        AddParam(typeParameterName);
                        AddText(": ");

                        AddText(formattingService.Format(typeParameterText, compilation));
                        emittedDocs = true;
                    }
                }
            }

            if (documentationComment.ParameterNames.Length > 0)
            {
                if (emittedDocs)
                {
                    AddLineBreak();
                }

                AddLineBreak();
                AddName(ServicesVSResources.Library_Parameters);

                foreach (var parameterName in documentationComment.ParameterNames)
                {
                    AddLineBreak();

                    var parameterText = documentationComment.GetParameterText(parameterName);
                    if (parameterText != null)
                    {
                        AddParam(parameterName);
                        AddText(": ");

                        AddText(formattingService.Format(parameterText, compilation));
                        emittedDocs = true;
                    }
                }
            }

            if (ShowReturnsDocumentation(symbol) && documentationComment.ReturnsText != null)
            {
                if (emittedDocs)
                {
                    AddLineBreak();
                }

                AddLineBreak();
                AddName(ServicesVSResources.Library_Returns);
                AddLineBreak();

                AddText(formattingService.Format(documentationComment.ReturnsText, compilation));
                emittedDocs = true;
            }

            if (documentationComment.RemarksText != null)
            {
                if (emittedDocs)
                {
                    AddLineBreak();
                }

//.........这里部分代码省略.........
开发者ID:GloryChou,项目名称:roslyn,代码行数:101,代码来源:AbstractDescriptionBuilder.cs


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