Namespace clash in generated handler
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C#
- 星标
- 1.7k
- 派生
- 505
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/aws-lambda-dotnet 的其他 Issue
-
bug module/aspnetcore-support p2 queued
难度 2/5 1-3 小时 新手友好度 68/100
aws/aws-lambda-dotnet#1123 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
feature-request needs-triage
难度 3/5 1-2 天 新手友好度 55/100
aws/aws-lambda-dotnet#2588 ·
维护者通常 1 天内回复
-
Generated XML doc `cref` contains unescaped generic arguments: CS1584 / CS1658 / CS1570 warnings可能已有人在做 @reginaldalfret 于 5 天前认领。 未关闭bug needs-triage
难度 3/5 1-2 天 新手友好度 68/100
aws/aws-lambda-dotnet#2587 ·
维护者通常 1 天内回复
-
feature-request p2
难度 4/5 3-5 天 新手友好度 48/100
aws/aws-lambda-dotnet#2551 · 1 条评论 ·
维护者通常 1 天内回复
-
JSON log format pairs ILogger message template placeholders with state values by position, garbling ASP.NET Core hosting logs可能已有人在做 @Pybsama 于 75 天前认领。 未关闭bug investigating p2
难度 3/5 1-2 天 新手友好度 70/100
aws/aws-lambda-dotnet#2468 · 2 条评论 ·
维护者通常 1 天内回复
查看 aws/aws-lambda-dotnet 的全部 Issue
相似的 Issue
-
documentation
难度 1/5 1-3 小时 新手友好度 62/100
-
bug misleading tooling trivial
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Docs example projects pinned to a literal library version instead of 3.*可能已有人在做 @DaveSkender 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
facioquo/stock-indicators-dotnet#2372 ·
维护者通常 1 天内回复
-
[Docs] officecli-docx SKILL.md still describes `\n` as a soft line break after #262可能已有人在做 @giprime 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
Facepunch/sbox-public#12097 ·
维护者通常 2 天内回复