Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs (C#)

Code before:
                    : SpecialMember.System_Runtime_CompilerServices_AsyncHelpers__HandleAsyncEntryPoint_Task;

                if (Binder.TryGetSpecialTypeMember(compilation, specialMember, _userMainReturnTypeSyntax, BindingDiagnosticBag.Discarded, out MethodSymbol handleAsyncEntryPointMethod, isOptional: true)
                    && handleAsyncEntryPointMethod.Parameters[0].Type.Equals(userMain.ReturnType, TypeCompareKind.AllIgnoreOptions))
                {
                    // Use the new HandleAsyncEntryPoint API
                    _userEntryPointInvocation = new BoundCall(
                            syntax: _userMainReturnTypeSyntax,
                            receiverOpt: null,
                            initialBindingReceiverIsSubjectToCloning: ThreeState.Unknown,
                            method: handleAsyncEntryPointMethod,
                            arguments: ImmutableArray.Create<BoundExpression>(userMainInvocation),
                            argumentNamesOpt: default(ImmutableArray<string>),
                            argumentRefKindsOpt: default(ImmutableArray<RefKind>),
                            isDelegateCall: false,
                            expanded: false,
                            invokedAsExtensionMethod: false,
                            argsToParamsOpt: default(ImmutableArray<int>),
                            defaultArguments: default(BitVector),
                            resultKind: LookupResultKind.Viable,
                            type: handleAsyncEntryPointMethod.ReturnType)
                    { WasCompilerGenerated = true };
                }
                else
                {
                    // Fall back to the old GetAwaiter/GetResult pattern
                    // The diagnostics that would be produced here will already have been captured and returned.
                    var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _userEntryPointInvocation!, runtimeAsyncAwaitCall: out _, _userMainReturnTypeSyntax, BindingDiagnosticBag.Discarded);
                }

                Debug.Assert(
                    ReturnType.IsVoidType() ||
                    ReturnType.SpecialType == SpecialType.System_Int32);
                Debug.Assert(!compilation.IsRuntimeAsyncEnabledIn(this));
            }

            internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<CSharpAttributeData> attributes)
            {
                base.AddSynthesizedAttributes(moduleBuilder, ref attributes);

                AddSynthesizedAttribute(ref attributes, this.DeclaringCompilation.SynthesizeDebuggerStepThroughAttribute());
            }

            public override string Name => MainName;

            public override ImmutableArray<ParameterSymbol> Parameters => _parameters;

            public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_userEntryPointInvocation.Type);

            internal override BoundBlock CreateBody(BindingDiagnosticBag diagnostics)
            {

Review comment (suggestion):

```suggestion
                    // Fall back to the old GetAwaiter().GetResult() pattern
``` #Resolved

Code after:
                    : SpecialMember.System_Runtime_CompilerServices_AsyncHelpers__HandleAsyncEntryPoint_Task;

                if (Binder.TryGetSpecialTypeMember(compilation, specialMember, _userMainReturnTypeSyntax, BindingDiagnosticBag.Discarded, out MethodSymbol handleAsyncEntryPointMethod, isOptional: true)
                    && handleAsyncEntryPointMethod.Parameters[0].Type.Equals(userMain.ReturnType, TypeCompareKind.AllIgnoreOptions))
                {
                    // Use the new HandleAsyncEntryPoint API
                    _userEntryPointInvocation = new BoundCall(
                            syntax: _userMainReturnTypeSyntax,
                            receiverOpt: null,
                            initialBindingReceiverIsSubjectToCloning: ThreeState.Unknown,
                            method: handleAsyncEntryPointMethod,
                            arguments: [userMainInvocation],
                            argumentNamesOpt: default(ImmutableArray<string>),
                            argumentRefKindsOpt: default(ImmutableArray<RefKind>),
                            isDelegateCall: false,
                            expanded: false,
                            invokedAsExtensionMethod: false,
                            argsToParamsOpt: default(ImmutableArray<int>),
                            defaultArguments: default(BitVector),
                            resultKind: LookupResultKind.Viable,
                            type: handleAsyncEntryPointMethod.ReturnType)
                    { WasCompilerGenerated = true };
                }
                else
                {
                    // Fall back to the old GetAwaiter().GetResult() pattern
                    // The diagnostics that would be produced here will already have been captured and returned.
                    var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _userEntryPointInvocation!, runtimeAsyncAwaitCall: out _, _userMainReturnTypeSyntax, BindingDiagnosticBag.Discarded);
                }

                Debug.Assert(
                    ReturnType.IsVoidType() ||
                    ReturnType.SpecialType == SpecialType.System_Int32);
                Debug.Assert(!compilation.IsRuntimeAsyncEnabledIn(this));
            }

            internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<CSharpAttributeData> attributes)
            {
                base.AddSynthesizedAttributes(moduleBuilder, ref attributes);

                AddSynthesizedAttribute(ref attributes, this.DeclaringCompilation.SynthesizeDebuggerStepThroughAttribute());
            }

            public override string Name => MainName;

            public override ImmutableArray<ParameterSymbol> Parameters => _parameters;

            public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_userEntryPointInvocation.Type);

            internal override BoundBlock CreateBody(BindingDiagnosticBag diagnostics)
            {