chore(dotnet): allow nullable channels (#36114)

This commit is contained in:
Max Schmitt 2025-05-28 12:45:37 -07:00 committed by GitHub
parent eb5e3b3740
commit a6f71a6740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,7 +144,10 @@ function properties(properties, indent, onlyOptional, parentName, level) {
continue;
ts.push('');
ts.push(`${indent}[JsonPropertyName("${name}")]`);
ts.push(`${indent}public ${inner.ts}${nullableSuffix(inner)} ${toTitleCase(name)} { get; set; }`);
let suffix = ''
if (!['bool', 'int', 'System.Text.Json.JsonElement'].includes(inner.ts))
suffix = ' = null!;'
ts.push(`${indent}public ${inner.ts}${nullableSuffix(inner)} ${toTitleCase(name)} { get; set; }${suffix}`);
const wrapped = inner.optional ? `tOptional(${inner.scheme})` : inner.scheme;
scheme.push(`${indent}${name}: ${wrapped},`);
}