private static void ReportErrorOnWellKnownMember(Symbol symbol, WellKnownMember member, DiagnosticBag diagnostics, ref bool hasError)
 {
     if ((object)symbol == null)
     {
         MemberDescriptor memberDescriptor = WellKnownMembers.GetDescriptor(member);
         diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, NoLocation.Singleton,
             ((WellKnownType)memberDescriptor.DeclaringTypeId).GetMetadataName(), memberDescriptor.Name);
         hasError = true;
     }
     else
     {
         ReportErrorOnSymbol(symbol, diagnostics, ref hasError);
         ReportErrorOnSymbol(symbol.ContainingType, diagnostics, ref hasError);
     }
 }
        /// <summary>
        /// Lookup member declaration in well known type used by this Compilation.
        /// </summary>
        /// <remarks>
        /// If a well-known member of a generic type instantiation is needed use this method to get the corresponding generic definition and
        /// <see cref="MethodSymbol.AsMember"/> to construct an instantiation.
        /// </remarks>
        internal Symbol GetWellKnownTypeMember(WellKnownMember member)
        {
            Debug.Assert(member >= 0 && member < WellKnownMember.Count);

            // Test hook: if a member is marked missing, then return null.
            if (IsMemberMissing(member))
            {
                return(null);
            }

            if (_lazyWellKnownTypeMembers == null || ReferenceEquals(_lazyWellKnownTypeMembers[(int)member], ErrorTypeSymbol.UnknownResultType))
            {
                if (_lazyWellKnownTypeMembers == null)
                {
                    var wellKnownTypeMembers = new Symbol[(int)WellKnownMember.Count];

                    for (int i = 0; i < wellKnownTypeMembers.Length; i++)
                    {
                        wellKnownTypeMembers[i] = ErrorTypeSymbol.UnknownResultType;
                    }

                    Interlocked.CompareExchange(ref _lazyWellKnownTypeMembers, wellKnownTypeMembers, null);
                }

                MemberDescriptor descriptor = WellKnownMembers.GetDescriptor(member);
                NamedTypeSymbol  type       = descriptor.DeclaringTypeId <= (int)SpecialType.Count
                                            ? this.GetSpecialType((SpecialType)descriptor.DeclaringTypeId)
                                            : this.GetWellKnownType((WellKnownType)descriptor.DeclaringTypeId);
                Symbol result = null;

                if (!type.IsErrorType())
                {
                    result = GetRuntimeMember(type, ref descriptor, _wellKnownMemberSignatureComparer, accessWithinOpt: this.Assembly);
                }

                Interlocked.CompareExchange(ref _lazyWellKnownTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType);
            }

            return(_lazyWellKnownTypeMembers[(int)member]);
        }
Example #3
0
        internal override SynthesizedAttributeData SynthesizeNativeIntegerAttribute(
            WellKnownMember member,
            ImmutableArray <TypedConstant> arguments
            )
        {
            if ((object)_lazyNativeIntegerAttribute != null)
            {
                var constructorIndex =
                    (
                        member
                        == WellKnownMember.System_Runtime_CompilerServices_NativeIntegerAttribute__ctorTransformFlags
                    )
                        ? 1
                        : 0;
                return(new SynthesizedAttributeData(
                           _lazyNativeIntegerAttribute.Constructors[constructorIndex],
                           arguments,
                           ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty
                           ));
            }

            return(base.SynthesizeNativeIntegerAttribute(member, arguments));
        }
Example #4
0
 private static void ReportErrorOnWellKnownMember(
     Symbol symbol,
     WellKnownMember member,
     BindingDiagnosticBag diagnostics,
     ref bool hasError
     )
 {
     if ((object)symbol == null)
     {
         MemberDescriptor memberDescriptor = WellKnownMembers.GetDescriptor(member);
         diagnostics.Add(
             ErrorCode.ERR_MissingPredefinedMember,
             NoLocation.Singleton,
             memberDescriptor.DeclaringTypeMetadataName,
             memberDescriptor.Name
             );
         hasError = true;
     }
     else
     {
         ReportErrorOnSymbol(symbol, diagnostics, ref hasError);
         ReportErrorOnSymbol(symbol.ContainingType, diagnostics, ref hasError);
     }
 }
 private BoundExpression ExprFactory(WellKnownMember method, ImmutableArray<TypeSymbol> typeArgs, params BoundExpression[] arguments)
 {
     var m0 = _bound.WellKnownMethod(method);
     Debug.Assert((object)m0 != null);
     Debug.Assert(m0.ParameterCount == arguments.Length);
     var m1 = m0.Construct(typeArgs);
     return _bound.Call(null, m1, arguments);
 }
Example #6
0
 private Symbol EnsureWellKnownMember(WellKnownMember member, DiagnosticBag bag)
 {
     return Binder.GetWellKnownTypeMember(F.Compilation, member, bag, body.Syntax.Location);
 }
Example #7
0
        /// <summary>
        /// Report diagnostics that should be reported when using a synthesized attribute. 
        /// </summary>
        internal static void ReportUseSiteDiagnosticForSynthesizedAttribute(
            CSharpCompilation compilation,
            WellKnownMember attributeMember,
            DiagnosticBag diagnostics,
            Location location = null,
            CSharpSyntaxNode syntax = null)
        {
            Debug.Assert((location != null) ^ (syntax != null));

            // Dev11 reports use-site diagnostics when an optional attribute is found but is bad for some other reason 
            // (comes from an unified assembly). When the symbol is not found no error is reported. See test VersionUnification_UseSiteDiagnostics_OptionalAttributes.
            bool isOptional = WellKnownMembers.IsSynthesizedAttributeOptional(attributeMember);

            GetWellKnownTypeMember(compilation, attributeMember, diagnostics, location, syntax, isOptional);
        }
 public BoundExpression MethodInfo(WellKnownMember method)
 {
     return MethodInfo(WellKnownMethod(method));
 }
        /// <summary>
        /// Get the symbol for a well-known member. The use of this method to get a well-known member
        /// that does not exist will result in an exception of type MissingPredefinedMember being thrown
        /// containing an appropriate diagnostic for the caller to report.
        /// </summary>
        /// <param name="wm">The desired well-known member</param>
        /// <param name="isOptional">If true, the method may return null for a missing member without an exception</param>
        /// <returns>A symbol for the well-known member, or null if it is missing and isOptions == true</returns>
        public Symbol WellKnownMember(WellKnownMember wm, bool isOptional = false)
        {
            Symbol wellKnownMember = Binder.GetWellKnownTypeMember(Compilation, wm, Diagnostics, syntax: Syntax, isOptional: true);
            if (wellKnownMember == null && !isOptional)
            {
                RuntimeMembers.MemberDescriptor memberDescriptor = WellKnownMembers.GetDescriptor(wm);
                WellKnownType containingType = (WellKnownType)memberDescriptor.DeclaringTypeId;
                var diagnostic = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, containingType.GetMetadataName(), memberDescriptor.Name), Syntax.Location);
                throw new MissingPredefinedMember(diagnostic);
            }

            return wellKnownMember;
        }
 public BoundExpression Property(WellKnownMember member)
 {
     var propertySym = WellKnownMember(member) as PropertySymbol;
     //if (propertySym == null) return BoundBadExpression
     Binder.ReportUseSiteDiagnostics(propertySym, Diagnostics, Syntax);
     Debug.Assert(propertySym.IsStatic);
     return Call(null, propertySym.GetMethod);
 }
        private bool CheckIfAttributeShouldBeEmbedded(DiagnosticBag diagnosticsOpt, Location locationOpt, WellKnownType attributeType, WellKnownMember attributeCtor)
        {
            var userDefinedAttribute = GetWellKnownType(attributeType);

            if (userDefinedAttribute is MissingMetadataTypeSymbol)
            {
                if (Options.OutputKind == OutputKind.NetModule)
                {
                    if (diagnosticsOpt != null)
                    {
                        var errorReported = Binder.ReportUseSiteDiagnostics(userDefinedAttribute, diagnosticsOpt, locationOpt);
                        Debug.Assert(errorReported);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else if (diagnosticsOpt != null)
            {
                // This should produce diagnostics if the member is missing or bad
                Binder.GetWellKnownTypeMember(this, attributeCtor, diagnosticsOpt, locationOpt);
            }

            return(false);
        }
Example #12
0
 private bool TryGetWellKnownTypeMember <TSymbol>(SyntaxNode syntax, WellKnownMember member, out TSymbol symbol, bool isOptional = false) where TSymbol : Symbol
 {
     symbol = (TSymbol)Binder.GetWellKnownTypeMember(_compilation, member, _diagnostics, syntax: syntax, isOptional: isOptional);
     return((object)symbol != null);
 }
 internal override ISymbol CommonGetWellKnownTypeMember(WellKnownMember member)
 {
     throw new NotImplementedException();
 }
 public BoundExpression MethodInfo(WellKnownMember method)
 {
     return(MethodInfo(WellKnownMethod(method)));
 }
Example #15
0
        private static bool TryGetWellKnownPropertyAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownProperty, NamedTypeSymbol containingType, out PropertySymbol propertySymbol)
        {
            propertySymbol = F.WellKnownMember(wellKnownProperty) as PropertySymbol;
            if ((object)propertySymbol == null)
            {
                return(false);
            }

            propertySymbol = propertySymbol.AsMember(containingType);
            return(true);
        }
Example #16
0
        private static bool TryGetWellKnownMethodAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownMethod, NamedTypeSymbol containingType, out MethodSymbol methodSymbol)
        {
            methodSymbol = F.WellKnownMember(wellKnownMethod) as MethodSymbol;
            if ((object)methodSymbol == null)
            {
                return(false);
            }

            methodSymbol = methodSymbol.AsMember(containingType);
            return(true);
        }
Example #17
0
 internal override ISymbol CommonGetWellKnownTypeMember(WellKnownMember member)
 {
     return GetWellKnownTypeMember(member);
 }
 internal void MakeMemberMissing(WellKnownMember member)
 {
     MakeMemberMissing((int)member);
 }
        /// <summary>
        /// This function defines whether an attribute is optional or not.
        /// </summary>
        /// <param name="attributeMember">The attribute member.</param>
        internal static bool IsSynthesizedAttributeOptional(WellKnownMember attributeMember)
        {
            switch (attributeMember)
            {
                case WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor:
                case WellKnownMember.System_Diagnostics_DebuggableAttribute__ctorDebuggingModes:
                case WellKnownMember.System_Diagnostics_DebuggerBrowsableAttribute__ctor:
                case WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor:
                case WellKnownMember.System_Diagnostics_DebuggerDisplayAttribute__ctor:
                case WellKnownMember.System_Diagnostics_DebuggerStepThroughAttribute__ctor:
                case WellKnownMember.System_Diagnostics_DebuggerNonUserCodeAttribute__ctor:
                case WellKnownMember.System_STAThreadAttribute__ctor:
                case WellKnownMember.System_Runtime_CompilerServices_AsyncStateMachineAttribute__ctor:
                case WellKnownMember.System_Runtime_CompilerServices_IteratorStateMachineAttribute__ctor:
                    return true;

                default:
                    return false;
            }
        }
Example #20
0
        /// <summary>
        /// Converts access to a tuple instance into access into the underlying ValueTuple(s).
        ///
        /// For instance, tuple.Item8
        /// produces fieldAccess(field=Item1, receiver=fieldAccess(field=Rest, receiver=ValueTuple for tuple))
        /// </summary>
        private BoundExpression MakeTupleFieldAccess(
            SyntaxNode syntax,
            FieldSymbol tupleField,
            BoundExpression?rewrittenReceiver
            )
        {
            var tupleType = tupleField.ContainingType;

            NamedTypeSymbol currentLinkType = tupleType;
            FieldSymbol     underlyingField = tupleField.TupleUnderlyingField;

            if ((object)underlyingField == null)
            {
                // Use-site error must have been reported elsewhere.
                return(_factory.BadExpression(tupleField.Type));
            }

            if (rewrittenReceiver?.Kind == BoundKind.DefaultExpression)
            {
                // Optimization: `default((int, string)).Item2` is simply `default(string)`
                return(new BoundDefaultExpression(syntax, tupleField.Type));
            }

            if (
                !TypeSymbol.Equals(
                    underlyingField.ContainingType,
                    currentLinkType,
                    TypeCompareKind.ConsiderEverything2
                    )
                )
            {
                WellKnownMember wellKnownTupleRest = NamedTypeSymbol.GetTupleTypeMember(
                    NamedTypeSymbol.ValueTupleRestPosition,
                    NamedTypeSymbol.ValueTupleRestPosition
                    );
                var tupleRestField = (FieldSymbol?)NamedTypeSymbol.GetWellKnownMemberInType(
                    currentLinkType.OriginalDefinition,
                    wellKnownTupleRest,
                    _diagnostics,
                    syntax
                    );

                if (tupleRestField is null)
                {
                    // error tolerance for cases when Rest is missing
                    return(_factory.BadExpression(tupleField.Type));
                }

                // make nested field accesses to Rest
                do
                {
                    FieldSymbol nestedFieldSymbol = tupleRestField.AsMember(currentLinkType);
                    rewrittenReceiver = _factory.Field(rewrittenReceiver, nestedFieldSymbol);

                    currentLinkType =
                        (NamedTypeSymbol)currentLinkType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[
                            NamedTypeSymbol.ValueTupleRestPosition - 1
                        ].Type;
                } while (
                    !TypeSymbol.Equals(
                        underlyingField.ContainingType,
                        currentLinkType,
                        TypeCompareKind.ConsiderEverything2
                        )
                    );
            }

            // make a field access for the most local access
            return(_factory.Field(rewrittenReceiver, underlyingField));
        }
 public MethodSymbol WellKnownMethod(WellKnownMember wm, bool isOptional = false)
 {
     return((MethodSymbol)WellKnownMember(wm, isOptional));
 }
Example #22
0
 private Symbol EnsureWellKnownMember(WellKnownMember member, BindingDiagnosticBag bag)
 {
     return(Binder.GetWellKnownTypeMember(F.Compilation, member, bag, body.Syntax.Location));
 }
Example #23
0
 public abstract ICustomAttribute SynthesizeAttribute(WellKnownMember attributeConstructor);
 public static MemberDescriptor GetDescriptor(WellKnownMember member)
 {
     return s_descriptors[(int)member];
 }
        private static bool TryCreate(
            SyntheticBoundNodeFactory F,
            NamedTypeSymbol builderType,
            TypeSymbol resultType,
            WellKnownMember setException,
            WellKnownMember setResult,
            WellKnownMember awaitOnCompleted,
            WellKnownMember awaitUnsafeOnCompleted,
            WellKnownMember start,
            WellKnownMember setStateMachine,
            PropertySymbol task,
            out AsyncMethodBuilderMemberCollection collection)
        {
            MethodSymbol setExceptionMethod;
            MethodSymbol setResultMethod;
            MethodSymbol awaitOnCompletedMethod;
            MethodSymbol awaitUnsafeOnCompletedMethod;
            MethodSymbol startMethod;
            MethodSymbol setStateMachineMethod;

            if (TryGetWellKnownMethodAsMember(F, setException, builderType, out setExceptionMethod) &&
                TryGetWellKnownMethodAsMember(F, setResult, builderType, out setResultMethod) &&
                TryGetWellKnownMethodAsMember(F, awaitOnCompleted, builderType, out awaitOnCompletedMethod) &&
                TryGetWellKnownMethodAsMember(F, awaitUnsafeOnCompleted, builderType, out awaitUnsafeOnCompletedMethod) &&
                TryGetWellKnownMethodAsMember(F, start, builderType, out startMethod) &&
                TryGetWellKnownMethodAsMember(F, setStateMachine, builderType, out setStateMachineMethod))
            {
                collection = new AsyncMethodBuilderMemberCollection(
                    builderType,
                    resultType,
                    setExceptionMethod,
                    setResultMethod,
                    awaitOnCompletedMethod,
                    awaitUnsafeOnCompletedMethod,
                    startMethod,
                    setStateMachineMethod,
                    task);

                return true;
            }

            collection = default(AsyncMethodBuilderMemberCollection);
            return false;
        }
Example #26
0
 private static MethodSymbol GetCreatePayloadOverload(CSharpCompilation compilation, WellKnownMember overload, SyntaxNode syntax, DiagnosticBag diagnostics)
 {
     return((MethodSymbol)Binder.GetWellKnownTypeMember(compilation, overload, diagnostics, syntax: syntax));
 }
        private static bool TryGetWellKnownMethodAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownMethod, NamedTypeSymbol containingType, out MethodSymbol methodSymbol)
        {
            methodSymbol = F.WellKnownMember(wellKnownMethod) as MethodSymbol;
            if ((object)methodSymbol == null) return false;

            methodSymbol = methodSymbol.AsMember(containingType);
            return true;
        }
 public BoundExpression Property(BoundExpression receiver, WellKnownMember member)
 {
     var propertySym = WellKnownMember(member) as PropertySymbol;
     Debug.Assert(!propertySym.IsStatic);
     Debug.Assert(receiver.Type.GetMembers(propertySym.Name).OfType<PropertySymbol>().Single() == propertySym);
     //if (propertySym == null) return BoundBadExpression
     Binder.ReportUseSiteDiagnostics(propertySym, Diagnostics, Syntax);
     Debug.Assert(!propertySym.IsStatic);
     return Call(receiver, propertySym.GetMethod);
 }
        private static bool TryGetWellKnownPropertyAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownProperty, NamedTypeSymbol containingType, out PropertySymbol propertySymbol)
        {
            propertySymbol = F.WellKnownMember(wellKnownProperty) as PropertySymbol;
            if ((object)propertySymbol == null) return false;

            propertySymbol = propertySymbol.AsMember(containingType);
            return true;
        }
 public MethodSymbol WellKnownMethod(WellKnownMember wm, bool isOptional = false)
 {
     return (MethodSymbol)WellKnownMember(wm, isOptional);
 }
Example #31
0
        internal override SynthesizedAttributeData SynthesizeLifetimeAnnotationAttribute(WellKnownMember member, ImmutableArray <TypedConstant> arguments)
        {
            if ((object)_lazyLifetimeAnnotationAttribute != null)
            {
                return(new SynthesizedAttributeData(
                           _lazyLifetimeAnnotationAttribute.Constructors[0],
                           arguments,
                           ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty));
            }

            return(base.SynthesizeLifetimeAnnotationAttribute(member, arguments));
        }
Example #32
0
 internal override ISymbol CommonGetWellKnownTypeMember(WellKnownMember member)
 {
     return(GetWellKnownTypeMember(member));
 }
 public SynthesizedImplementationMethod OpenMethodImplementation(WellKnownMember interfaceMethod, string methodName = null, bool debuggerHidden = false, MethodSymbol asyncKickoffMethod = null)
 {
     var methodToImplement = (MethodSymbol)this.WellKnownMember(interfaceMethod);
     return OpenMethodImplementation(methodToImplement, methodName, debuggerHidden, asyncKickoffMethod: asyncKickoffMethod);
 }
Example #34
0
 internal abstract Cci.ICustomAttribute SynthesizeAttribute(WellKnownMember attributeConstructor);
 public BoundExpression MethodInfo(WellKnownMember meth)
 {
     var method = (MethodSymbol)WellKnownMember(meth);
     return MethodInfo(method);
 }
Example #36
0
 internal abstract TAttributeData CreateSynthesizedAttribute(WellKnownMember constructor, TAttributeData attrData, TSyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics);
Example #37
0
 public BoundExpression StaticCall(WellKnownMember method, params BoundExpression[] args)
 {
     MethodSymbol methodSymbol = WellKnownMethod(method);
     Binder.ReportUseSiteDiagnostics(methodSymbol, Diagnostics, Syntax);
     Debug.Assert(methodSymbol.IsStatic);
     return Call(null, methodSymbol, args);
 }
Example #38
0
        /// <summary>
        /// Generate a thread-safe accessor for a WinRT field-like event.
        ///
        /// Add:
        ///   return EventRegistrationTokenTable&lt;Event&gt;.GetOrCreateEventRegistrationTokenTable(ref _tokenTable).AddEventHandler(value);
        ///
        /// Remove:
        ///   EventRegistrationTokenTable&lt;Event&gt;.GetOrCreateEventRegistrationTokenTable(ref _tokenTable).RemoveEventHandler(value);
        /// </summary>
        internal static BoundBlock ConstructFieldLikeEventAccessorBody_WinRT(SourceEventSymbol eventSymbol, bool isAddMethod, CSharpCompilation compilation, DiagnosticBag diagnostics)
        {
            CSharpSyntaxNode syntax = eventSymbol.CSharpSyntaxNode;

            MethodSymbol accessor = isAddMethod ? eventSymbol.AddMethod : eventSymbol.RemoveMethod;

            Debug.Assert((object)accessor != null);

            FieldSymbol field = eventSymbol.AssociatedField;

            Debug.Assert((object)field != null);

            NamedTypeSymbol fieldType = (NamedTypeSymbol)field.Type;

            Debug.Assert(fieldType.Name == "EventRegistrationTokenTable");

            MethodSymbol getOrCreateMethod = (MethodSymbol)Binder.GetWellKnownTypeMember(
                compilation,
                WellKnownMember.System_Runtime_InteropServices_WindowsRuntime_EventRegistrationTokenTable_T__GetOrCreateEventRegistrationTokenTable,
                diagnostics,
                syntax: syntax);

            if ((object)getOrCreateMethod == null)
            {
                Debug.Assert(diagnostics.HasAnyErrors());
                return(null);
            }

            getOrCreateMethod = getOrCreateMethod.AsMember(fieldType);

            WellKnownMember processHandlerMember = isAddMethod
                ? WellKnownMember.System_Runtime_InteropServices_WindowsRuntime_EventRegistrationTokenTable_T__AddEventHandler
                : WellKnownMember.System_Runtime_InteropServices_WindowsRuntime_EventRegistrationTokenTable_T__RemoveEventHandler;

            MethodSymbol processHandlerMethod = (MethodSymbol)Binder.GetWellKnownTypeMember(
                compilation,
                processHandlerMember,
                diagnostics,
                syntax: syntax);

            if ((object)processHandlerMethod == null)
            {
                Debug.Assert(diagnostics.HasAnyErrors());
                return(null);
            }

            processHandlerMethod = processHandlerMethod.AsMember(fieldType);

            // _tokenTable
            BoundFieldAccess fieldAccess = new BoundFieldAccess(
                syntax,
                field.IsStatic ? null : new BoundThisReference(syntax, accessor.ThisParameter.Type),
                field,
                constantValueOpt: null)
            {
                WasCompilerGenerated = true
            };

            // EventRegistrationTokenTable<Event>.GetOrCreateEventRegistrationTokenTable(ref _tokenTable)
            BoundCall getOrCreateCall = BoundCall.Synthesized(
                syntax,
                receiverOpt: null,
                method: getOrCreateMethod,
                arg0: fieldAccess);

            // value
            BoundParameter parameterAccess = new BoundParameter(
                syntax,
                accessor.Parameters.Single());

            // EventRegistrationTokenTable<Event>.GetOrCreateEventRegistrationTokenTable(ref _tokenTable).AddHandler(value) // or RemoveHandler
            BoundCall processHandlerCall = BoundCall.Synthesized(
                syntax,
                receiverOpt: getOrCreateCall,
                method: processHandlerMethod,
                arg0: parameterAccess);

            if (isAddMethod)
            {
                // {
                //     return EventRegistrationTokenTable<Event>.GetOrCreateEventRegistrationTokenTable(ref _tokenTable).AddHandler(value);
                // }
                BoundStatement returnStatement = BoundReturnStatement.Synthesized(syntax, processHandlerCall);
                return(BoundBlock.SynthesizedNoLocals(syntax, returnStatement));
            }
            else
            {
                // {
                //     EventRegistrationTokenTable<Event>.GetOrCreateEventRegistrationTokenTable(ref _tokenTable).RemoveHandler(value);
                //     return;
                // }
                BoundStatement callStatement   = new BoundExpressionStatement(syntax, processHandlerCall);
                BoundStatement returnStatement = new BoundReturnStatement(syntax, expressionOpt: null);
                return(BoundBlock.SynthesizedNoLocals(syntax, callStatement, returnStatement));
            }
        }
        private BoundExpression MakeBinderConstruction(WellKnownMember factoryMethod, BoundExpression[] args)
        {
            var binderFactory = _factory.WellKnownMember(factoryMethod);
            if ((object)binderFactory == null)
            {
                return null;
            }

            return _factory.Call(null, (MethodSymbol)binderFactory, args.AsImmutableOrNull());
        }
 internal bool IsMemberMissing(WellKnownMember member)
 {
     return IsMemberMissing((int)member);
 }
        private static bool TryCreate(
            SyntheticBoundNodeFactory F,
            bool customBuilder,
            NamedTypeSymbol builderType,
            TypeSymbol resultType,
            MethodSymbol createBuilderMethod,
            PropertySymbol taskProperty,
            WellKnownMember?setException,
            WellKnownMember setResult,
            WellKnownMember awaitOnCompleted,
            WellKnownMember awaitUnsafeOnCompleted,
            WellKnownMember start,
            WellKnownMember?setStateMachine,
            out AsyncMethodBuilderMemberCollection collection
            )
        {
            MethodSymbol setExceptionMethod;
            MethodSymbol setResultMethod;
            MethodSymbol awaitOnCompletedMethod;
            MethodSymbol awaitUnsafeOnCompletedMethod;
            MethodSymbol startMethod;
            MethodSymbol setStateMachineMethod;

            if (
                TryGetBuilderMember(
                    F,
                    setException,
                    builderType,
                    customBuilder,
                    out setExceptionMethod
                    ) &&
                TryGetBuilderMember(
                    F,
                    setResult,
                    builderType,
                    customBuilder,
                    out setResultMethod
                    ) &&
                TryGetBuilderMember(
                    F,
                    awaitOnCompleted,
                    builderType,
                    customBuilder,
                    out awaitOnCompletedMethod
                    ) &&
                TryGetBuilderMember(
                    F,
                    awaitUnsafeOnCompleted,
                    builderType,
                    customBuilder,
                    out awaitUnsafeOnCompletedMethod
                    ) &&
                TryGetBuilderMember(F, start, builderType, customBuilder, out startMethod) &&
                TryGetBuilderMember(
                    F,
                    setStateMachine,
                    builderType,
                    customBuilder,
                    out setStateMachineMethod
                    )
                )
            {
                collection = new AsyncMethodBuilderMemberCollection(
                    builderType,
                    resultType,
                    createBuilderMethod,
                    setExceptionMethod,
                    setResultMethod,
                    awaitOnCompletedMethod,
                    awaitUnsafeOnCompletedMethod,
                    startMethod,
                    setStateMachineMethod,
                    taskProperty,
                    checkGenericMethodConstraints: customBuilder
                    );

                return(true);
            }

            collection = default(AsyncMethodBuilderMemberCollection);
            return(false);
        }