C# /Script auto gen doesn't handle comments

@eirannejad
not sure if know, but auto gen C# nodes with comment in param input cause small bug, see attach images and snippet. When i paste code below in empty node,

and press enter, this results in

so left what i get, right what I expect

#region Usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
#endregion

public class Script_Instance : GH_ScriptInstance
{
    private void RunScript(
        Brep target_brep,
        int curve_direction, // ADD THIS INPUT: 0 for U, 1 for V
        int n_count,
        int iterations)
    {

    }
}

This is not really a bug, ‘for’ is a reserved with specialy word in C#. You would get similar bugs if you use “while” or “if”.

Here’s the complete list:
C# Keywords and contextual keywords - C# reference | Microsoft Learn

ok, i would assume “//” would ignore that. Good to know … learning it :wink:

Tbh I just think @arendvw failed to read your post properly.

You are correct. Its a bug.
The code interpretting and auto-formatting the RunScript arguments seems to indeed handle the comments incorrectly… :man_shrugging:

On that note - since you say you are learning:
You wouldn’t usually write comments in between function argument like this. At least not in typical style people use with C#.

If you want add comments about arguments, what you will see used in practice, are these tripple slash ‘docstring’ comments. If you use an IDE (like Visual Studio), these will then also be shown in the tooltip when you hover over a function name or it’s arguments.

/// <summary> This function does something... </summary>
/// <param name="curve_direction">0 for U, 1 for V.</param>
private void RunScript(
    Brep target_brep,
    int curve_direction,
    int n_count,
    int iterations)
{

}

happens while blindly copy / pasting from chat windows also happens sonetime when using dedicate AI plugins. Am probably not the first, and yes blame the user :0, but if it can be handle in editor side it would be more user friendly :wink: Notice it place the comment on a new line , replacing an input parms that is actually needed. @eirannejad>left C# editor > right AI dialog

Thanks for reporting and clarifying this. I created a YT issue for this:

RH-94747 C# gh script removes inline comments in RunScript signature

Ooh, I misread, sorry for the confusion!