Esempio n. 1
0
 internal override BoundNode Bind(Binder binder, CSharpSyntaxNode node, DiagnosticBag diagnostics)
 {
     if (node.Kind() == SyntaxKind.Attribute)
     {
         var attribute = (AttributeSyntax)node;
         return(binder.BindAttribute(attribute, AttributeType, diagnostics));
     }
     else if (SyntaxFacts.IsAttributeName(node))
     {
         return(new BoundTypeExpression((NameSyntax)node, _aliasOpt, type: AttributeType));
     }
     else
     {
         return(base.Bind(binder, node, diagnostics));
     }
 }
Esempio n. 2
0
 internal override BoundNode Bind(Binder binder, CSharpSyntaxNode node, DiagnosticBag diagnostics)
 {
     if (node.Kind == SyntaxKind.Attribute)
     {
         var attribute = (AttributeSyntax)node;
         return binder.BindAttribute(attribute, AttributeType, diagnostics);
     }
     else if (SyntaxFacts.IsAttributeName(node))
     {
         return new BoundTypeExpression((NameSyntax)node, aliasOpt, inferredType: false, type: AttributeType);
     }
     else
     {
         return base.Bind(binder, node, diagnostics);
     }
 }
 internal override BoundNode Bind(Binder binder, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics)
 {
     if (node.Kind() == SyntaxKind.Attribute)
     {
         var attribute = (AttributeSyntax)node;
         // note: we should find the attributed member before binding the attribute as part of https://github.com/dotnet/roslyn/issues/53618
         return(binder.BindAttribute(attribute, AttributeType, attributedMember: null, diagnostics));
     }
     else if (SyntaxFacts.IsAttributeName(node))
     {
         return(new BoundTypeExpression((NameSyntax)node, _aliasOpt, type: AttributeType));
     }
     else
     {
         return(base.Bind(binder, node, diagnostics));
     }
 }
        /// <summary>
        /// Bind the given attribute speculatively at the given position, and return back
        /// the resulting bound node. May return null in some error cases.
        /// </summary>
        private BoundAttribute GetSpeculativelyBoundAttribute(int position, AttributeSyntax attribute, out Binder binder)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            binder = this.GetSpeculativeBinderForAttribute(position);
            if (binder == null)
            {
                return null;
            }

            var diagnostics = DiagnosticBag.GetInstance();
            AliasSymbol aliasOpt; // not needed.
            NamedTypeSymbol attributeType = (NamedTypeSymbol)binder.BindType(attribute.Name, diagnostics, out aliasOpt);
            var boundNode = binder.BindAttribute(attribute, attributeType, diagnostics);
            diagnostics.Free();

            return boundNode;
        }