Skip to content

Fix generated handler namespace resolution - #2597

Open
sean0407 wants to merge 1 commit into
aws:masterfrom
sean0407:codex/fix-namespace-shadowed-fromservices-type
Open

sean0407 wants to merge 1 commit into
aws:masterfrom
sean0407:codex/fix-namespace-shadowed-fromservices-type

Conversation

@sean0407

Copy link
Copy Markdown

Issue #, if available: #2586

Description of changes:

Qualify a [FromServices] parameter type with global:: when a namespace member beneath the handler's containing namespace can shadow the type's root namespace. This prevents the generated handler from binding the service type to a sibling namespace.

Summary

  • Detect a shadowing namespace member for [FromServices] parameter types.
  • Use Roslyn's fully qualified display name only when the namespace is shadowed; preserve existing generated output otherwise.
  • Add a regression test that compiles a generated handler with an Acme.Common namespace shadowing a global Common service type.

Evidence

  • Baseline regression reproduction failed with CS0234 resolving Common.Lambda.Queue.Processor as Acme.Common.Lambda.Queue.Processor.
  • Focused regression test passed: dotnet test Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Amazon.Lambda.Annotations.SourceGenerators.Tests.csproj --framework net8.0 -p:TargetFrameworks=net8.0 --no-restore --filter FullyQualifiedName~FromServicesType_IsResolvedFromGlobalNamespaceWhenNestedNamespaceShadowsIt (1 passed).
  • Existing AuthorizerBindingFailureTests passed (11 passed).
  • git diff --check passed.

Merge Danger

Door: Generated service type names derive from Roslyn symbols and are only globally qualified when the handler namespace contains a shadowing member with the same root name.

Blast Radius: This affects generated dependency resolution for [FromServices] parameters in the conflicting namespace case. Existing type-name comparisons for Lambda context and generated request types are preserved.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sean0407
sean0407 requested review from a team as code owners October 18, 2026 01:50
@sean0407
sean0407 requested review from normj and sichanyoo October 18, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant