Namespace clash in generated handler
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 67/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- C#
- Sterne
- 1.7k
- Forks
- 505
- Ø Merge
- 1 T. 6 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws/aws-lambda-dotnet
-
bug module/aspnetcore-support p2 queued
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
aws/aws-lambda-dotnet#1123 · 4 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
feature-request needs-triage
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
aws/aws-lambda-dotnet#2588 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Generated XML doc `cref` contains unescaped generic arguments: CS1584 / CS1658 / CS1570 warningsEvtl. vergeben @reginaldalfret hat das vor 7 Tagen übernommen. Offenbug needs-triage
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
aws/aws-lambda-dotnet#2587 ·
Maintainer antworten meist innerhalb von 1 Tag
-
feature-request p2
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
aws/aws-lambda-dotnet#2551 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
JSON log format pairs ILogger message template placeholders with state values by position, garbling ASP.NET Core hosting logsEvtl. vergeben @Pybsama hat das vor 78 Tagen übernommen. Offenbug investigating p2
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
aws/aws-lambda-dotnet#2468 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in aws/aws-lambda-dotnet
Ähnliche Issues
-
python triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
microsoft/semantic-kernel#14615 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
vzeol/DeployCraft#125 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
fboucher/2d6-dungeon-app#245 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: settings good first issue priority: p2 type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
AmineChr54/umbra#3 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag