Skip to content

Accept whole-number ATS values for integral parameters - #15636

Merged
Sébastien Ros (sebastienros) merged 3 commits into
mainfrom
sebros/debug-java-polyglot-builds
Mar 27, 2026
Merged

Sébastien Ros (sebastienros) merged 3 commits into
mainfrom
sebros/debug-java-polyglot-builds

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

This change updates the shared ATS marshaller to accept whole-number JSON values for integral CLR parameters.

Motivation/context:
Java playground AppHosts can currently pass integral values through the ATS number wire type, which caused runtime TYPE_MISMATCH failures when the server expected CLR integral types such as System.Int32. This change makes the marshaller coerce whole-number payloads into the requested integral CLR type while still rejecting fractional values for integral parameters.

Validation:

  • Ran ./dotnet.sh test tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj -- --filter-method "*.ConvertPrimitive_ConvertsIntFromWholeDouble" --filter-method "*.ConvertPrimitive_ThrowsForIntFromFractionalDouble" --filter-method "*.ConvertPrimitive_ConvertsLongFromWholeDouble" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • Reproduced playground/polyglot/Java/Aspire.Hosting.SqlServer/ValidationAppHost with the local CLI and confirmed the previous withHostPort type mismatch no longer occurs; execution now proceeds to a separate runtime issue.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings March 27, 2026 02:44
@github-actions

github-actions Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15636

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15636"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the shared ATS marshaller so integral CLR parameters (e.g., int, long) can accept JSON number payloads that are whole numbers (including values represented as doubles like 11433.0), while still rejecting fractional numbers.

Changes:

  • Added numeric parsing helpers (ReadNumericValue / ReadIntegralNumericValue) and expanded integral-type handling in ConvertPrimitive.
  • Added unit tests verifying whole-double → int/long coercion and fractional-double rejection for int.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs Adds numeric coercion logic for integral CLR types and refactors numeric primitive conversion.
tests/Aspire.Hosting.RemoteHost.Tests/AtsMarshallerTests.cs Adds tests for whole-double integral conversion and fractional rejection.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall — the coercion logic is correct and well-tested. Two minor nits inline, neither blocking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go once comments addressed.

@sebastienros
Sébastien Ros (sebastienros) merged commit 9f4a610 into main Mar 27, 2026
501 of 504 checks passed
@sebastienros
Sébastien Ros (sebastienros) deleted the sebros/debug-java-polyglot-builds branch March 27, 2026 05:34
@github-actions

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit ea3c0f8)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23632090148

Adam Ratzman (adamint) pushed a commit to adamint/aspire that referenced this pull request Mar 28, 2026
* Accept whole-number ATS values for integral parameters

Co-authored-by: Copilot <[email protected]>

* Refine ATS numeric conversions

Co-authored-by: Copilot <[email protected]>

* Clarify ATS numeric safety checks

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
@joperezr Jose Perez Rodriguez (joperezr) added this to the 13.3 milestone Apr 14, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

Reason: This is an internal bug fix that updates the ATS marshaller to coerce whole-number JSON values into integral CLR types (e.g., System.Int32). It does not introduce any new public APIs, configuration options, or user-facing behavior changes. The fix is transparent to end users and the existing documentation already covers the relevant behavior sufficiently.

Generated by PR Documentation Check · ● 87.4K · ◷

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants