aws / aws/aws-lambda-dotnet

Lambda Generated Main Fails To Compile With Ambiguous Call Error

Aperta
#1,907 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
annotations bug investigating p2
Lingua principale
C#
Stelle
1.7k
Fork
503
Merge medio
1g 18h
PR unite (30g)
21

Descrizione

### 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(Func, ILambdaSerializer)' and 'LambdaBootstrapBuilder.Create(Func, ILambdaSerializer)' PROJECT PROJECTPATH\obj\Release\net8.0\Amazon.Lambda.Annotations.SourceGenerator\Amazon.Lambda.Annotations.SourceGenerator.Generator\Program.g.cs 25`

### Reproduction Steps

```c#
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
{
///
/// AWS EC2 API client
///
private IAmazonEC2 EC2 { get; }

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

///
/// Dispose this object
///
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

```








```

### Targeted .NET Platform

.NET 8.,0

### Operating System and version

Compiling on Windows 10

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci la build di .NET 8 con l'handler mostrato senza input e senza output e ispeziona il Program.g.cs generato prima che venga eliminato. Inizia dalla chiamata generata a LambdaBootstrapBuilder.Create e dai suoi overload in conflitto. Il lavoro è terminato quando il main generato compila per questa forma di handler senza l'ambiguità CS0121.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, csharp
Ambito
backend, build-system, cloud
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.