Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Namespace clash in generated handler

Aperta
#2,586 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
aws, csharp
Ambito
backend

Direzione di ricerca

Start by locating the source generator that emits <Class>_<Method>_Generated.g.cs for Amazon.Lambda.Annotations and inspect how it writes parameter type names. Reproduce the namespace clash with the attached AnnotationsNamespaceClash.zip sample and run dotnet build; done when generated code uses globally qualified names and the sample builds without CS0234.

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

Descrizione

bug needs-triage
Describe the bug

Generated handler doesn't use global:: for type names: build fails with CS0234 when a sibling namespace shadows the root namespace

The generated handler (<Class>_<Method>_Generated.g.cs) refers to parameter types by their
namespace-qualified name without a global:: prefix. The generated class is declared inside the handler's own
namespace, so if a namespace with the same first segment exists alongside it, C# name lookup stops at that
namespace and never reaches the top-level one. The result is CS0234 in generated code that the user cannot edit.

Regression Issue
  • Select this option if this issue appears to be a regression.
Expected Behavior

Generated code compiles regardless of which other namespaces exist. Emitting fully qualified global:: names for
every type in the generated file avoids the problem. The generator already emits some types with full names
(Amazon.Lambda.Core.ILambdaContext, Amazon.Lambda.SQSEvents.SQSEvent); they are only safe because nobody has an
Acme.Amazon namespace. The same bug applies to any root namespace.

Current Behavior

Build fails with error: error CS0234: The type or namespace name 'Lambda' does not exist in the namespace 'Acme.Common' (are you missing an assembly reference?)

The generated class is in namespace Acme.EventDistributor.Trigger. Resolving Common there searches
Acme.EventDistributor.Trigger, Acme.EventDistributor, Acme, and only then the global namespace. It finds
Acme.Common and stops, so Common.Lambda is looked up inside Acme.Common and fails.

In general, with a handler in A.B.C and a [FromServices] type in X.Y, the build breaks if A.X or A.B.X
exists without a matching Y below it.

Reproduction Steps

Run dotnet build for attached sample project AnnotationsNamespaceClash.zip

Possible Solution

Update source generator to emit fully qualified global:: names for all types referenced in generated code.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.Annotations v 2.4.1

Targeted .NET Platform

.NET SDK 10.0.401, net10.0

Operating System and version

Windows 11

Lingua principale
C#
Stelle
1.7k
Fork
504
Merge medio
2g 9h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-lambda-dotnet

Tutte le issue di aws/aws-lambda-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.