From 3e736b707b611794a657109c83231a1724af0382 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 1 Oct 2025 10:52:29 +0530 Subject: [PATCH 1/2] fix: dotnet template issues --- src/SDK/Language/DotNet.php | 8 ++++---- templates/dotnet/Package/Models/Model.cs.twig | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/SDK/Language/DotNet.php b/src/SDK/Language/DotNet.php index c85ea10c0..ac5c33f16 100644 --- a/src/SDK/Language/DotNet.php +++ b/src/SDK/Language/DotNet.php @@ -478,13 +478,13 @@ public function getFunctions(): array if (isset($property['sub_schema']) && !empty($property['sub_schema'])) { if ($property['type'] === 'array') { - $result = 'List<' . \ucfirst($property['sub_schema']) . '>'; + $result = 'List<' . $this->toPascalCase($property['sub_schema']) . '>'; } else { - $result = \ucfirst($property['sub_schema']); + $result = $this->toPascalCase($property['sub_schema']); } } elseif (isset($property['enum']) && !empty($property['enum'])) { $enumName = $property['enumName'] ?? $property['name']; - $result = \ucfirst($enumName); + $result = $this->toPascalCase($enumName); } else { $result = $this->getTypeName($property); } @@ -497,8 +497,8 @@ public function getFunctions(): array }), new TwigFunction('property_name', function (array $definition, array $property) { $name = $property['name']; - $name = \ucfirst($name); $name = \str_replace('$', '', $name); + $name = $this->toPascalCase($name); if (\in_array(\strtolower($name), $this->getKeywords())) { $name = '@' . $name; } diff --git a/templates/dotnet/Package/Models/Model.cs.twig b/templates/dotnet/Package/Models/Model.cs.twig index bc024073d..b4f8aebeb 100644 --- a/templates/dotnet/Package/Models/Model.cs.twig +++ b/templates/dotnet/Package/Models/Model.cs.twig @@ -1,3 +1,4 @@ + using System; using System.Linq; using System.Collections.Generic; @@ -11,7 +12,7 @@ namespace {{ spec.title | caseUcfirst }}.Models { {%~ for property in definition.properties %} [JsonPropertyName("{{ property.name }}")] - public {{ sub_schema(property) }} {{ property_name(definition, property) | overrideProperty(definition.name) }} { get; private set; } + public {{ sub_schema(property) | raw }} {{ property_name(definition, property) | overrideProperty(definition.name) }} { get; private set; } {%~ endfor %} {%~ if definition.additionalProperties %} @@ -20,7 +21,7 @@ namespace {{ spec.title | caseUcfirst }}.Models {%~ endif %} public {{ definition.name | caseUcfirst | overrideIdentifier }}( {%~ for property in definition.properties %} - {{ sub_schema(property) }} {{ property.name | caseCamel | escapeKeyword }}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %} + {{ sub_schema(property) | raw }} {{ property.name | caseCamel | escapeKeyword }}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %} {%~ endfor %} {%~ if definition.additionalProperties %} From 112022a47aa4a2f91a05330444953b98c2ef548a Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 1 Oct 2025 11:02:41 +0530 Subject: [PATCH 2/2] fix: escape --- src/SDK/Language/DotNet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDK/Language/DotNet.php b/src/SDK/Language/DotNet.php index ac5c33f16..085a503a3 100644 --- a/src/SDK/Language/DotNet.php +++ b/src/SDK/Language/DotNet.php @@ -499,7 +499,7 @@ public function getFunctions(): array $name = $property['name']; $name = \str_replace('$', '', $name); $name = $this->toPascalCase($name); - if (\in_array(\strtolower($name), $this->getKeywords())) { + if (\in_array($name, $this->getKeywords())) { $name = '@' . $name; } return $name;