Skip to content

Comments

Add DoubleCarrier test in C# and TypeScript; fix TypeScript undefined output in XML#27

Merged
jogibear9988 merged 3 commits intomainfrom
copilot/add-new-test-in-csharp
Feb 21, 2026
Merged

Add DoubleCarrier test in C# and TypeScript; fix TypeScript undefined output in XML#27
jogibear9988 merged 3 commits intomainfrom
copilot/add-new-test-in-csharp

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

Adds DoubleCarrierTest to both the C# and TypeScript test suites, verifying XML code generation for a nested And/Eq/Distributor/Or/Coil ladder logic network. Also fixes a TypeScript bug where undefined optional properties were rendered as the literal string "undefined" in generated XML.

Changes

Bug fix – TypeScript XML generation

Optional string fields (titleEnglish, comment, commentEnglish on Block; description, descriptionEnglish on Network) were interpolated directly into template literals, producing <Text>undefined</Text> instead of <Text></Text>.

Fixed with nullish coalescing in Block.ts and KopCodeHelper.ts:

// Before
<Text>${this.titleEnglish}</Text>

// After
<Text>${this.titleEnglish ?? ''}</Text>

After the fix, TypeScript and C# produce identical XML output.

New tests

Both tests build the same network and assert the exact generated XML (newline-normalized):

nw.Add(
    new And(
        new Eq(new Signal("#Configuration.General.SingleDoubleCarrier", SignalType.Int), new Signal(2)),
        new Distributor(
            new And(
                new Or(
                    new Signal("#DoubleCarrier.Sensors.V[#Configuration.General.CoordinationAxisConveyor, 1]"),
                    new Signal("#DoubleCarrier.Sensors.R[#Configuration.General.CoordinationAxisConveyor, 1]")
                ),
                new Coil(new Signal("#CarrierGeneral.States.CarriageOccupied[2]"))
            ),
            new And(
                new Signal("#DoubleCarrierData.MOrder.DataPresent"),
                new Coil(new Signal("#CarrierGeneral.States.CarriageDataPresent[2]"))
            )
        )
    )
);

Housekeeping

Added TiaCodegen-ts/.gitignore to exclude dist/ and node_modules/ from version control.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create a new test</issue_title>
<issue_description>create a new test in c#, wich contains this code:

       nw.Add(
          new And(
            new Eq(new Signal("#Configuration.General.SingleDoubleCarrier", SignalType.Int),new Signal(2)),
            new Distributor(
              new And(
                new Or(
                  new Signal("#DoubleCarrier.Sensors.V[#Configuration.General.CoordinationAxisConveyor, 1]"),
                  new Signal("#DoubleCarrier.Sensors.R[#Configuration.General.CoordinationAxisConveyor, 1]")
                ),
                new Coil(new Signal("#CarrierGeneral.States.CarriageOccupied[2]"))
              ),
              new And(
                new Signal("#DoubleCarrierData.MOrder.DataPresent"),
                new Coil(new Signal("#CarrierGeneral.States.CarriageDataPresent[2]"))
              )
            )
          )
        );

then run the test once, get the xml output. Adjust the test now so it always checks for the xml output.
Then create the same test in Typescript and compare it to the same xml output</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 21, 2026 14:37
…output

Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
…ed dist artifacts

Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
Copilot AI changed the title [WIP] Create a new test in C# Add DoubleCarrier test in C# and TypeScript; fix TypeScript undefined output in XML Feb 21, 2026
Copilot AI requested a review from jogibear9988 February 21, 2026 14:41
@jogibear9988 jogibear9988 marked this pull request as ready for review February 21, 2026 14:42
@jogibear9988 jogibear9988 merged commit ac15a59 into main Feb 21, 2026
1 check passed
@jogibear9988 jogibear9988 deleted the copilot/add-new-test-in-csharp branch February 21, 2026 14:42
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.

Create a new test

2 participants