Closed pierophp closed 1 year ago
When using a dynamic property, it throws the error: "object reference not set to an instance of an object"
public class TestDTO { public dynamic Name { get; set; } }
Template:
{{- # Helper classes }} {{- func ImportType(type) useType = Type.Unwrap(type) if (useType.ArrayType != null) useType = useType.ArrayType end path = "./" if (useType.Attributes) ret "import { " | String.Append useType.Name | String.Append " } from '" | String.Append path | String.Append useType.Name | String.Append "';\r" end ret null end }} }} {{ for class in data.Classes | Symbols.WhereNameEndsWith "DTO" capture output -}} {{- for type in class | Type.AllReferencedTypes | Array.Uniq -}} {{- ImportType type}} {{- end}} export class {{ class.BareName }} { {{- for property in class.Properties | Symbols.ThatArePublic }} {{ property.Name | String.ToCamelCase }}: {{ property.Type | Type.ToTypeScriptType }}; {{- end}} } {{- end Save output class.BareName + ".ts" end }}
The error throws at the "class | Type.AllReferencedTypes"
It should resolve "dynamic" as "any".
When using a dynamic property, it throws the error: "object reference not set to an instance of an object"
Template:
The error throws at the "class | Type.AllReferencedTypes"
It should resolve "dynamic" as "any".