-
Notifications
You must be signed in to change notification settings - Fork 25
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
Override type generation #12
Comments
I started to look at this but i can't get my fork to run on my machine. I might have a look later in the week. But please respond if guys this this is even a viable feature req. |
I understand the need but currently any kind of type annotation is not feasible because the code is not compiled. I've been considering compiling the c# to use reflection so if I do then this could be added. |
That was an experimental build that accidently got pushed to main. MTT doesn't actually use code analysis so I removed the references, you should now be able to restore and build the project. |
I'd also love this. It's more of a preferential thing but I'd prefer that my Guid's come down as string in TS. Like I said it's a personal bias so being able to override that would be a nice to have. |
I played around with this idea back when the issue was created and it seemed like the best approach would be using type annotations. However the code is not compiled so those annotations would have to be parsed somehow, without losing what field is supposed to be overridden and what its supposed to be overridden with. It seemed like it could get messy so I never bothered, but someone is more than welcome to add this in a PR and I would approve if it doesn't break anything. |
When sending data from a backend service to the client the data is in many cases converted to JSON. Complex data types such as DateTime is serialized into strings.
Therefor it would be a much needed feature to be able to override the output type in the generator, so that in this example the DateTime becomes strings. Otherwise the TS interfaces would need a concrete class implementation to be useful (someone that creates a
new Date()
from the JSON).One way to solve this, and this is indeed how we solves it now in my project, is to simple let the date times be strings on the C# end as well and then we parse them manually. But this could be done all by magic by the JSON serializer.
Suggestion:
Imlement a overide feature that take From>To type by config that is valid for all types in folder.
Or a To type in a data annotation.
The text was updated successfully, but these errors were encountered: