-
Notifications
You must be signed in to change notification settings - Fork 8
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
Treat all IEnumerable<T> Properties as arrays #13
base: master
Are you sure you want to change the base?
Conversation
After digging through the code some more, I realized that this too was possible without modifying the original source code, rather I was able to inherit from the
I'll leave this open as I still feel that this should be the default behavior, but I would understand your position if you disagree. |
I agree with you. The intent in nearly all cases will be to emit the array representation. In fact, in practice I run a custom version of this code with a While I personally wouldn't design a class this way, someone else might.
The PR would generate the following,
Might someone want an array of Groups? My own solution to this problem was the following.
The difference is it is more selective about when it emits the array form.
Since I cannot say everyone will want the representation in this PR, I think the solution needs to preserve the general purpose type translation logic currently in
Thoughts? |
I'm still not sold on the idea that treating all I like your solution of adding a How about instead of Separately, I think you did a great job of making everything flexible by making most methods virtual and therefore easily extensible, so with proper documentation (I know, I know, I'm asking for a lot here 😝 ), users will easily be able to tweak it however they see fit. Once you decide, I'm willing to contribute. Thanks again for a great library! (PS as of now, it's the only one I've found that works with .Net Core) |
I agree on all points. I am not particularly fond of requiring developers to opt-in to defaults. I would prefer Regarding extensibility and documentation. This project was born out of a personal need to expose server side models to front end developers writing in TypeScript. So I went pretty heavy on OO to achieve the goal with the mindset that I could override behaviors as necessary for each project. However, that scheme requires a fairly deep understanding of the various components, as you have experienced. I don't think the current scheme is ideally suited for general purpose usage like most folks would expect from a NuGet package. So, where I would like to see this go is to preserve the OO foundation but overlay it with a more sensible API for public consumption that allows people to tweak behaviors more easily. Perhaps it is as simple as providing a set of default implementations of things like Anyway, I am glad you are finding this library useful and would be willing to contribute once we come up with an agreed upon solution. |
Often times, there are classes that have properties of type
IEnumerable<T>
. The wayTypeScripter
currently deals with this is by generating a definition forIEnumerable<T>
in Typescript. I feel like this isn't really the intent of a user trying to convert a C# class to Typescript. This PR makes it so that any property that implementsIEnumerable<T>
will get emitted as an array of that type in Typescript.