Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda Generated Main Fails To Compile With Ambiguous Call Error #1907

Open
1 task
grochoge opened this issue Dec 16, 2024 · 1 comment
Open
1 task

Lambda Generated Main Fails To Compile With Ambiguous Call Error #1907

grochoge opened this issue Dec 16, 2024 · 1 comment
Labels
annotations bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue

Comments

@grochoge
Copy link

Describe the bug

Trying to upgrade a .NET Lambda from Core 3.1 to 8.0 AOT. It takes no input and produces no output (it's just being used as a scheduled task).

I added a [assembly: LambdaGlobalProperties( GenerateMain = true )] attribute and added a [LambdaFunction] attribute to my function handler method, but compiling now gives error CS0121.

Note that the generated Program.g.cs is immediately deleted so I'm not able to examine it.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Lambda generated main compiles

Current Behavior

Error (active) CS0121 The call is ambiguous between the following methods or properties: 'LambdaBootstrapBuilder.Create<TInput>(Func<TInput, Task>, ILambdaSerializer)' and 'LambdaBootstrapBuilder.Create<TOutput>(Func<Stream, TOutput>, ILambdaSerializer)' PROJECT PROJECTPATH\obj\Release\net8.0\Amazon.Lambda.Annotations.SourceGenerator\Amazon.Lambda.Annotations.SourceGenerator.Generator\Program.g.cs 25

Reproduction Steps

using System.Linq;
using System.Threading.Tasks;

using Amazon.EC2;
using Amazon.EC2.Model;
using Amazon.Lambda.Annotations;
using Amazon.Lambda.Core;

// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer( typeof( Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer ) )]
[assembly: LambdaGlobalProperties( GenerateMain = true )]

namespace  NAMESPACE
{
    public class Function : IDisposable
    {
        /// <summary>
        /// AWS EC2 API client
        /// </summary>
        private IAmazonEC2 EC2 { get; }

        /// <summary>
        /// Default contructor
        /// </summary>
        public Function()
        {
            EC2 = new AmazonEC2Client(  );
        }

        /// <summary>
        /// Dispose this object
        /// </summary>
        public void Dispose()
        {
            EC2.Dispose();
            return;
        }

        [LambdaFunction]
        public async Task FunctionHandler()
        {
            try
            {
                Logger.LogInfo( $"Function handler invoked at {DateTime.UtcNow.ToString("o")}" );
                await Task.Delay( 50 );
                Logger.LogInfo( $"Function handler finished at {DateTime.UtcNow.ToString("o")}" );
            }
            catch(Exception lEx)
            {
                Logger.LogError( $"Caught exception {lEx.Message}, stack trace : {lEx.StackTrace}" );
            }
        }
}

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

    <PackageReference Include="Amazon.Lambda.Annotations" Version="1.6.2" />
    <PackageReference Include="Amazon.Lambda.Core" Version="2.5.0" />
    <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.12.2" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
    <PackageReference Include="AWSSDK.CloudFormation" Version="3.7.401.11" />
    <PackageReference Include="AWSSDK.EC2" Version="3.7.425" />
    <PackageReference Include="AWSSDK.S3" Version="3.7.410.6" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Targeted .NET Platform

.NET 8.,0

Operating System and version

Compiling on Windows 10

@grochoge grochoge added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 16, 2024
@normj
Copy link
Member

normj commented Dec 17, 2024

I can reproduce the issue. Looking into what is happening.

@bhoradc bhoradc added p2 This is a standard priority issue annotations investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotations bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants