• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CrefSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BindCref

 internal ImmutableArray<Symbol> BindCref(CrefSyntax syntax, out Symbol ambiguityWinner, DiagnosticBag diagnostics)
 {
     ImmutableArray<Symbol> symbols = BindCrefInternal(syntax, out ambiguityWinner, diagnostics);
     Debug.Assert(!symbols.IsDefault, "Prefer empty to null.");
     Debug.Assert((symbols.Length > 1) == ((object)ambiguityWinner != null), "ambiguityWinner should be set iff more than one symbol is returned.");
     return symbols;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:Binder_Crefs.cs


示例2: BindCrefInternal

 private ImmutableArray<Symbol> BindCrefInternal(CrefSyntax syntax, out Symbol ambiguityWinner, DiagnosticBag diagnostics)
 {
     switch (syntax.Kind())
     {
         case SyntaxKind.TypeCref:
             return BindTypeCref((TypeCrefSyntax)syntax, out ambiguityWinner, diagnostics);
         case SyntaxKind.QualifiedCref:
             return BindQualifiedCref((QualifiedCrefSyntax)syntax, out ambiguityWinner, diagnostics);
         case SyntaxKind.NameMemberCref:
         case SyntaxKind.IndexerMemberCref:
         case SyntaxKind.OperatorMemberCref:
         case SyntaxKind.ConversionOperatorMemberCref:
             return BindMemberCref((MemberCrefSyntax)syntax, containerOpt: null, ambiguityWinner: out ambiguityWinner, diagnostics: diagnostics);
         default:
             throw ExceptionUtilities.UnexpectedValue(syntax.Kind());
     }
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:17,代码来源:Binder_Crefs.cs


示例3: BindCrefInternal

 private ImmutableArray<Symbol> BindCrefInternal(CrefSyntax syntax, out Symbol ambiguityWinner, DiagnosticBag diagnostics)
 {
     switch (syntax.Kind)
     {
         case SyntaxKind.TypeCref:
             return BindTypeCref((TypeCrefSyntax)syntax, out ambiguityWinner, diagnostics);
         case SyntaxKind.QualifiedCref:
             return BindQualifiedCref((QualifiedCrefSyntax)syntax, out ambiguityWinner, diagnostics);
         case SyntaxKind.NameMemberCref:
         case SyntaxKind.IndexerMemberCref:
         case SyntaxKind.OperatorMemberCref:
         case SyntaxKind.ConversionOperatorMemberCref:
             return BindMemberCref((MemberCrefSyntax)syntax, containerOpt: null, ambiguityWinner: out ambiguityWinner, diagnostics: diagnostics);
         default:
             Debug.Assert(false, "Unexpected cref kind " + syntax.Kind);
             ambiguityWinner = null;
             return ImmutableArray<Symbol>.Empty;
     }
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:19,代码来源:Binder_Crefs.cs


示例4: CrefAttribute

 public static XmlCrefAttributeSyntax CrefAttribute(CrefSyntax cref)
 {
     return CrefAttribute(cref, SyntaxKind.DoubleQuoteToken);
 }
开发者ID:nvincent,项目名称:StyleCopAnalyzers,代码行数:4,代码来源:XmlSyntaxFactory.cs


示例5: TryGetSpeculativeSemanticModelCore

        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            Binder binder = GetEnclosingBinder(position);
            if (binder != null &&
                (binder.Flags.Includes(BinderFlags.Cref) || binder.Flags.Includes(BinderFlags.CrefParameterOrReturnType)))
            {
                speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, crefSyntax, binder, position);
                return true;
            }

            speculativeModel = null;
            return false;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:15,代码来源:SyntaxTreeSemanticModel.cs


示例6: TryGetSpeculativeSemanticModelCore

 internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel)
 {
     // crefs can never legally appear within members.
     speculativeModel = null;
     return false;
 }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:6,代码来源:MemberSemanticModel.cs


示例7: ToBadCrefString

 /// <summary>
 /// Given a cref syntax that cannot be resolved, get the string that will be written to
 /// the documentation file in place of a documentation comment ID.
 /// </summary>
 private static string ToBadCrefString(CrefSyntax cref)
 {
     using (StringWriter tmp = new StringWriter(CultureInfo.InvariantCulture))
     {
         cref.WriteTo(tmp);
         return "!:" + tmp.ToString().Replace("{", "&lt;").Replace("}", "&gt;");
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:12,代码来源:DocumentationCommentCompiler.cs


示例8: GetDocumentationCommentId

        /// <summary>
        /// Bind a CrefSyntax and unwrap the result if it's an alias.
        /// </summary>
        /// <remarks>
        /// Does not respect DocumentationMode, so use a temporary bag if diagnostics are not desired.
        /// </remarks>
        private static string GetDocumentationCommentId(CrefSyntax crefSyntax, Binder binder, DiagnosticBag diagnostics)
        {
            if (crefSyntax.ContainsDiagnostics)
            {
                return ToBadCrefString(crefSyntax);
            }

            Symbol ambiguityWinner;
            ImmutableArray<Symbol> symbols = binder.BindCref(crefSyntax, out ambiguityWinner, diagnostics);

            Symbol symbol;
            switch (symbols.Length)
            {
                case 0:
                    return ToBadCrefString(crefSyntax);
                case 1:
                    symbol = symbols[0];
                    break;
                default:
                    symbol = ambiguityWinner;
                    Debug.Assert((object)symbol != null);
                    break;
            }

            if (symbol.Kind == SymbolKind.Alias)
            {
                symbol = ((AliasSymbol)symbol).GetAliasTarget(basesBeingResolved: null);
            }

            return symbol.OriginalDefinition.GetDocumentationCommentId();
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:37,代码来源:DocumentationCommentCompiler.cs


示例9: GetReferencedSymbols

        private static ImmutableArray<Symbol> GetReferencedSymbols(CrefSyntax crefSyntax, CSharpCompilation compilation, out Symbol ambiguityWinner, params DiagnosticDescription[] expectedDiagnostics)
        {
            var binderFactory = compilation.GetBinderFactory(crefSyntax.SyntaxTree);
            var binder = binderFactory.GetBinder(crefSyntax);

            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
            var references = binder.BindCref(crefSyntax, out ambiguityWinner, diagnostics);
            diagnostics.Verify(expectedDiagnostics);
            diagnostics.Free();
            return references;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:11,代码来源:CrefTests.cs


示例10: GetReferencedSymbol

        private static Symbol GetReferencedSymbol(CrefSyntax crefSyntax, CSharpCompilation compilation, params DiagnosticDescription[] expectedDiagnostics)
        {
            Symbol ambiguityWinner;
            var references = GetReferencedSymbols(crefSyntax, compilation, out ambiguityWinner, expectedDiagnostics);
            Assert.Null(ambiguityWinner);
            Assert.InRange(references.Length, 0, 1); //Otherwise, call GetReferencedSymbols

            return references.FirstOrDefault();
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:9,代码来源:CrefTests.cs


示例11: TryReduceOrSimplifyExplicitName

		public static bool TryReduceOrSimplifyExplicitName(
			this CrefSyntax crefSyntax,
			SemanticModel semanticModel,
			out CrefSyntax replacementNode,
			out TextSpan issueSpan,
			OptionSet optionSet,
			CancellationToken cancellationToken)
		{
			replacementNode = null;
			issueSpan = default(TextSpan);

			// Currently Qualified Cref is the only CrefSyntax We are handling separately
			if (crefSyntax.Kind() != SyntaxKind.QualifiedCref)
			{
				return false;
			}

			var qualifiedCrefSyntax = (QualifiedCrefSyntax)crefSyntax;
			var memberCref = qualifiedCrefSyntax.Member;

			// Currently we are dealing with only the NameMemberCrefs
			if (optionSet.GetOption(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, LanguageNames.CSharp) &&
				(memberCref.Kind() == SyntaxKind.NameMemberCref))
			{
				var nameMemberCref = ((NameMemberCrefSyntax)memberCref).Name;
				var symbolInfo = semanticModel.GetSymbolInfo(nameMemberCref, cancellationToken);
				var symbol = symbolInfo.Symbol;

				if (symbol == null)
				{
					return false;
				}

				if (symbol is INamespaceOrTypeSymbol)
				{
					//var namespaceOrTypeSymbol = (INamespaceOrTypeSymbol)symbol;

					// 1. Check for Predefined Types
					if (symbol is INamedTypeSymbol)
					{
						var namedSymbol = (INamedTypeSymbol)symbol;
						var keywordKind = ExpressionSyntaxExtensions.GetPredefinedKeywordKind(namedSymbol.SpecialType);

						if (keywordKind != SyntaxKind.None)
						{
							replacementNode = SyntaxFactory.TypeCref(
								SyntaxFactory.PredefinedType(
									SyntaxFactory.Token(crefSyntax.GetLeadingTrivia(), keywordKind, crefSyntax.GetTrailingTrivia())));
							replacementNode = crefSyntax.CopyAnnotationsTo(replacementNode);

							// we want to show the whole name expression as unnecessary
							issueSpan = crefSyntax.Span;

							return true;
						}
					}
				}
			}

			var oldSymbol = semanticModel.GetSymbolInfo(crefSyntax, cancellationToken).Symbol;
			if (oldSymbol != null)
			{
				var speculativeBindingOption = SpeculativeBindingOption.BindAsExpression;
				if (oldSymbol is INamespaceOrTypeSymbol)
				{
					speculativeBindingOption = SpeculativeBindingOption.BindAsTypeOrNamespace;
				}

				var newSymbol = semanticModel.GetSpeculativeSymbolInfo(crefSyntax.SpanStart, memberCref, speculativeBindingOption).Symbol;

				if (newSymbol == oldSymbol)
				{
					// Copy Trivia and Annotations
					memberCref = memberCref.WithLeadingTrivia(crefSyntax.GetLeadingTrivia());
					memberCref = crefSyntax.CopyAnnotationsTo(memberCref);
					issueSpan = qualifiedCrefSyntax.Container.Span;
					replacementNode = memberCref;
					return true;
				}
			}

			return false;
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:83,代码来源:CrefSyntaxExtensions.cs


示例12: WithCrefTypeParametersBinder

 internal WithCrefTypeParametersBinder(CrefSyntax crefSyntax, Binder next)
     : base(next)
 {
     _crefSyntax = crefSyntax;
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:5,代码来源:WithCrefTypeParametersBinder.cs


示例13: ExceptionElement

 public static XmlElementSyntax ExceptionElement(CrefSyntax cref, params XmlNodeSyntax[] content)
 {
     return ExceptionElement(cref, List(content));
 }
开发者ID:nvincent,项目名称:StyleCopAnalyzers,代码行数:4,代码来源:XmlSyntaxFactory.cs


示例14: CrefAttribute

 public static XmlCrefAttributeSyntax CrefAttribute(CrefSyntax cref, SyntaxKind quoteKind)
 {
     return XmlCrefAttribute(
         XmlName("cref"),
         Token(quoteKind),
         cref,
         Token(quoteKind))
         .WithLeadingTrivia(Whitespace(" "));
 }
开发者ID:pgenfer,项目名称:mixinSharp,代码行数:9,代码来源:XmlSyntaxFactory.cs


示例15: Create

 public static SpeculativeSyntaxTreeSemanticModel Create(CSharpSemanticModel parentSemanticModel, CrefSyntax root, Binder rootBinder, int position)
 {
     return CreateCore(parentSemanticModel, root, rootBinder, position, bindingOption: SpeculativeBindingOption.BindAsTypeOrNamespace);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:4,代码来源:SpeculativeSyntaxTreeSemanticModel.cs


示例16: TryGetSpeculativeSemanticModelCore

        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            Binder binder = GetEnclosingBinder(position);
            if (binder?.InCref == true)
            {
                speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, crefSyntax, binder, position);
                return true;
            }

            speculativeModel = null;
            return false;
        }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:14,代码来源:SyntaxTreeSemanticModel.cs


示例17: SeeAlsoElement

 public static XmlEmptyElementSyntax SeeAlsoElement(CrefSyntax cref)
 {
     return EmptyElement("seealso").AddAttributes(CrefAttribute(cref));
 }
开发者ID:nvincent,项目名称:StyleCopAnalyzers,代码行数:4,代码来源:XmlSyntaxFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Criteria类代码示例发布时间:2022-05-24
下一篇:
C# CreditCard类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap