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


C# CrefSyntax类代码示例

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


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


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