Skip to content

fix(http-server-csharp): resolve declared service namespace - #11908

Draft
sophia-ramsey wants to merge 2 commits into
mainfrom
sramsey/csharp-service-namespace
Draft

fix(http-server-csharp): resolve declared service namespace#11908
sophia-ramsey wants to merge 2 commits into
mainfrom
sramsey/csharp-service-namespace

Conversation

@sophia-ramsey

Copy link
Copy Markdown
Member

This pull request updates the logic for determining the generated C# service namespace in the @typespec/http-server-csharp package. Now, the namespace explicitly declared with @service is always used for the generated C# service namespace, even if an imported or unrelated namespace appears first. The changes also refactor and clarify related code, and add new tests to ensure correct behavior.

Service namespace resolution improvements:

  • Added a new function getServiceNamespace in service-discovery.ts to reliably select the namespace declared with @service, falling back to the first non-standard namespace with content if no service is declared.
  • Updated getServiceNamespaceName to use the new getServiceNamespace logic, ensuring the correct namespace is used for C# code generation.
  • Refactored resolveServiceTypes in service-resolution.ts to use getServiceNamespace instead of the previous custom logic, and updated documentation/comments for clarity. [1] [2]

Testing and documentation:

  • Added and updated tests in service-resolution.test.ts to verify that the namespace declared with @service is used, and to cover fallback behavior when no service is declared. [1] [2]
  • Added a changelog entry describing the fix and its effect on generated C# service namespaces. (.chronus/changes/http-server-csharp-service-namespace-2026-09-08.md)

Co-authored-by: GitHub Copilot <copilot@github.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-server-csharp@11908

commit: 2094f03

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-server-csharp
Show changes

@typespec/http-server-csharp - fix ✏️

Use the namespace declared with @service as the generated C# service namespace, even when an imported or unrelated namespace is encountered first.

@azure-sdk-automation

azure-sdk-automation Bot commented Sep 9, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant