-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always provide default values for properties #34
Comments
Hi! Can you give an example? Do you mean providing a "global" default value for all properties? |
Currently we have to to this: [TSDefaultValue("")]
public string FirstName { get; set; }
[TSDefaultValue("")]
public string LastName { get; set; } We need to generate the classes with default values because we have another generator to create formgroups in an angular in a special way. |
This seems like a useful feature for some cases. I'll aim to add it in the next release (the next release will also have the fix to #33). I'll keep you updated with any progress in this topic. Cheers! |
Thanks a lot :) Greets! |
I updated the NuGet packages in the dev branch (both regular and .NET CLI tool; {
"generateEmptyValues": [ "string", "number", ... ]
} Can you please check if it works properly in your case? I'd like to make sure it works before releasing. Thanks |
How can I install the nuget-dotnetcli tool to test it? I tested the NuGet package. If we have nullable type. Is it possible to set the default value to null? |
An option with custom default mappings would solve the problem and would be very flexiable. // tgconfig.json
{
"emptyValueMappings: {
"Date | null": "null",
"number": "-1"
}
} And in your |
You can download the
I've dropped support for per-project tools, because they are going to be abandoned by Microsoft anyway (I gave a more detailed 'rationale' for dropping per-project tools in this post), so right now TypeGen.DotNetCli is only a global tool. About empty values, I'm thinking about removing the option that exists right now ( |
You are right, an additional option is not necessary. Thanks again for your work! |
You're welcome! Thanks! I'll let you know when it's implemented. |
There is a new version on the dev branch (nuget package). The option is named "defaultValuesForTypes": {
"number": "-1",
"Date | null": "null"
} It would be cool if you could check again if it works! Thanks! :) |
I tested and it works awesome! Thanks again for your great work! |
No problem! Thanks for the info! I've released version 2.0.1 (major version change is because of the changed syntax in the |
Hey :)
Is there an option to always generate default values in the generated typescript class without annotating every property with
[TSDefaultValue]
?Greets Patrick
The text was updated successfully, but these errors were encountered: