DYN-10430: Fix DesignScript ToString() method not found in code block nodes#17074
ToString() method not found in code block nodes#17074Conversation
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10430
ToString() method not found in code block nodes
|
@ivaylo-matov I asked the agent to look at this issue, does the fix make sense to you here? |
|
Thanks, @zeusongit |
There was a problem hiding this comment.
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.ToStringplus the corresponding"ToString"entry in the built-in method name table, and registered it as a built-in method returningstring. - Routed
MethodID.ToStringexecution through the existingToStringFromObject/ToStringFromArrayconversion path (StringUtils.ConvertToString). - Added smoke tests covering
ToStringforint,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"); |
There was a problem hiding this comment.
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).
| thisTest.Verify("result", "1.000000,2.000000"); | |
| thisTest.Verify("result", "1.000000,2.000000"); | |
| Assert.AreEqual(0, core.RuntimeStatus.WarningCount); |
|
@zeusongit, yes this makes sense - |
2485278 to
a79d0b0
Compare
|
Agent-Logs-Url: https://github.com/DynamoDS/Dynamo/sessions/287aacd6-0918-482c-bbc1-f554d6ee2efa Co-authored-by: zeusongit <32665108+zeusongit@users.noreply.github.com>
a79d0b0 to
6cde9a0
Compare
|



Calling
ToString(x)in a DesignScript code block produced "Method 'ToString()' not found" and returnednull. The engine only registered internal__ToStringFromObject/__ToStringFromObjectAndFormatbuilt-ins (double-underscore prefix = implementation-internal); no publicToStringwas ever wired up, despite being documented inBuiltIn.xml.Changes
BuiltInMethods.cs— AddedToStringtoMethodIDenum and the parallelmethodNamesarray (index-ordered); registered aBuiltInMethodentry with a single rank-0varparameter (DesignScript replication handles lists automatically)BuiltInFunctionEndPoint.cs— AddedMethodID.ToStringto the existingToStringFromObject/ToStringFromArraydispatch case, delegating toStringUtils.ConvertToString(formalParameters[0], ...)StringTest.cs— Added tests forint,double,boolinputs andToStringused inside a function body