Skip to content

DYN-10430: Fix DesignScript ToString() method not found in code block nodes - #17074

Open
zeusongit with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-tostring-method-issue
Open

DYN-10430: Fix DesignScript ToString() method not found in code block nodes#17074
zeusongit with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-tostring-method-issue

Conversation

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Calling ToString(x) in a DesignScript code block produced "Method 'ToString()' not found" and returned null. The engine only registered internal __ToStringFromObject/__ToStringFromObjectAndFormat built-ins (double-underscore prefix = implementation-internal); no public ToString was ever wired up, despite being documented in BuiltIn.xml.

def tostr(pt : Point)
{
    // Previously: "Method 'ToString()' not found" + nulls
    return = ToString(pt.X) + "," + ToString(pt.Y) + "," + ToString(pt.Z);
};

Changes

  • BuiltInMethods.cs — Added ToString to MethodID enum and the parallel methodNames array (index-ordered); registered a BuiltInMethod entry with a single rank-0 var parameter (DesignScript replication handles lists automatically)
  • BuiltInFunctionEndPoint.cs — Added MethodID.ToString to the existing ToStringFromObject/ToStringFromArray dispatch case, delegating to StringUtils.ConvertToString(formalParameters[0], ...)
  • StringTest.cs — Added tests for int, double, bool inputs and ToString used inside a function body

Copilot AI linked an issue Apr 23, 2026 that may be closed by this pull request
@github-actions github-actions Bot changed the title [WIP] Fix DesignScript 'ToString' method not found warning DYN-10430: [WIP] Fix DesignScript 'ToString' method not found warning Apr 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10430

Copilot AI changed the title DYN-10430: [WIP] Fix DesignScript 'ToString' method not found warning DYN-10430: Fix DesignScript ToString() method not found in code block nodes Apr 23, 2026
Copilot AI requested a review from zeusongit April 23, 2026 18:28
@zeusongit

Copy link
Copy Markdown
Contributor

@ivaylo-matov I asked the agent to look at this issue, does the fix make sense to you here?

@ivaylo-matov

Copy link
Copy Markdown
Contributor

Thanks, @zeusongit
I'll look into that.

@zeusongit
zeusongit marked this pull request as ready for review April 27, 2026 16:16
Copilot AI review requested due to automatic review settings April 27, 2026 16:16

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

Fixes DesignScript code block resolution for the documented ToString(...) built-in by wiring a public ToString method ID to the existing string-conversion implementation and adding regression tests.

Changes:

  • Added MethodID.ToString plus the corresponding "ToString" entry in the built-in method name table, and registered it as a built-in method returning string.
  • Routed MethodID.ToString execution through the existing ToStringFromObject/ToStringFromArray conversion path (StringUtils.ConvertToString).
  • Added smoke tests covering ToString for int, double, bool, and use within a function body.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/Engine/ProtoTest/TD/MultiLangTests/StringTest.cs Adds regression tests validating ToString(...) behavior in code blocks.
src/Engine/ProtoCore/Lang/BuiltInMethods.cs Introduces MethodID.ToString, maps it to "ToString", and registers the built-in signature.
src/Engine/ProtoCore/Lang/BuiltInFunctionEndPoint.cs Dispatches MethodID.ToString to the existing string conversion implementation.

result = formatValues(1.0, 2.0);
";
thisTest.RunScriptSource(code);
thisTest.Verify("result", "1.000000,2.000000");

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

Test name says "ThenNoWarning" but the test only asserts the computed string. To make the regression explicit (and avoid the test passing while still emitting a runtime warning), also assert that the runtime warning count is 0 (or rename the test to match what it verifies).

Suggested change
thisTest.Verify("result", "1.000000,2.000000");
thisTest.Verify("result", "1.000000,2.000000");
Assert.AreEqual(0, core.RuntimeStatus.WarningCount);

Copilot uses AI. Check for mistakes.
@ivaylo-matov

Copy link
Copy Markdown
Contributor

@zeusongit, yes this makes sense - ToString wasn't properly registered for scalar values. We’re noticing it now because Dynamo is doing a bit more work to inspect the code inside the CBN.

@johnpierson
johnpierson force-pushed the copilot/fix-tostring-method-issue branch 2 times, most recently from 2485278 to a79d0b0 Compare May 6, 2026 14:41
@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@jasonstratton jasonstratton 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.

LGTM

@jasonstratton

Copy link
Copy Markdown
Contributor

@johnpierson
johnpierson force-pushed the copilot/fix-tostring-method-issue branch from a79d0b0 to 6cde9a0 Compare June 23, 2026 21:15
@sonarqubecloud

Copy link
Copy Markdown

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.

DesignScript 'ToString' Method Not Found

5 participants