Modified JavascriptClientGenerator to handle nullable types and indicate them by ?type instead of Nullable<>. Bumped package version to 1.9.4

This commit is contained in:
2025-10-19 09:17:22 -07:00
parent 54de2def1f
commit ab96e86a0e
3 changed files with 8 additions and 4 deletions

View File

@@ -50,7 +50,7 @@ namespace MontoyaTech.Rest.Net.Example
public string[] Array = null;
public ulong Property { get; set; }
public ulong? Property { get; set; }
public User() { }

View File

@@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.9.3</Version>
<Version>1.9.4</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>

View File

@@ -186,7 +186,11 @@ namespace MontoyaTech.Rest.Net
{
var typeCode = Type.GetTypeCode(type);
if (typeof(Array).IsAssignableFrom(type))
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
return $"?{GetTypeFullyResolvedName(Nullable.GetUnderlyingType(type))}";
}
else if (typeof(Array).IsAssignableFrom(type))
{
return $"Array<{this.GetTypeFullyResolvedName(type.GetElementType())}>";
}