Repository navigation
Commit f929ed2
Use camelCase parameter names in projected struct constructors (#2346)
* Use camelCase parameter names in projected struct constructors
Add a to_camel_case helper (invariant ASCII lowering) and update the
struct constructor codegen to use camelCase parameter names instead of
underscore-prefixed field names. For example, a struct with a 'Stage'
field now generates a constructor parameter named 'stage' rather than
'_Stage', producing a cleaner public API surface.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fall back to underscore prefix for non-PascalCase field names
If the first character of a struct field name is not an uppercase ASCII
letter (e.g. '_Foo'), prepend an underscore instead of lowering, so the
generated parameter name won't collide with the field name.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Escape C# keywords and precompute camelCase param names
Address PR review feedback:
- Route camelCase parameter names through write_escaped_identifier so
that field names like 'Event' or 'Class' produce '@event'/'@Class'
instead of bare C# keywords.
- Precompute param_name once per field in field_info instead of calling
to_camel_case twice (parameter list + assignment).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add missing C# contextual keywords to is_keyword list
Add all 46 contextual keywords from the C# language reference to the
keyword list used by write_escaped_identifier. This ensures generated
identifiers like 'value', 'var', 'dynamic', 'async', 'await', 'record',
'required', 'get', 'set', 'init', 'when', 'where', 'yield', etc. are
properly escaped with '@' when they appear as parameter names.
Reference: https://learn.microsoft.com/dotnet/csharp/language-reference/keywords
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent e2da074 commit f929ed2
2 files changed
Lines changed: 32 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
677 | 681 | | |
678 | 682 | | |
679 | 683 | | |
| |||
9836 | 9840 | | |
9837 | 9841 | | |
9838 | 9842 | | |
| 9843 | + | |
9839 | 9844 | | |
9840 | 9845 | | |
9841 | 9846 | | |
| |||
9845 | 9850 | | |
9846 | 9851 | | |
9847 | 9852 | | |
| 9853 | + | |
9848 | 9854 | | |
9849 | 9855 | | |
9850 | 9856 | | |
| |||
9866 | 9872 | | |
9867 | 9873 | | |
9868 | 9874 | | |
9869 | | - | |
| 9875 | + | |
9870 | 9876 | | |
9871 | 9877 | | |
9872 | 9878 | | |
9873 | 9879 | | |
9874 | | - | |
| 9880 | + | |
9875 | 9881 | | |
9876 | 9882 | | |
9877 | 9883 | | |
9878 | | - | |
| 9884 | + | |
| 9885 | + | |
| 9886 | + | |
| 9887 | + | |
| 9888 | + | |
| 9889 | + | |
| 9890 | + | |
| 9891 | + | |
| 9892 | + | |
| 9893 | + | |
9879 | 9894 | | |
9880 | 9895 | | |
9881 | 9896 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
16 | 30 | | |
17 | 31 | | |
18 | 32 | | |
| |||
0 commit comments