Skip to content
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

Support generic types #39

Open
michaelaird opened this issue Feb 26, 2017 · 6 comments
Open

Support generic types #39

michaelaird opened this issue Feb 26, 2017 · 6 comments

Comments

@michaelaird
Copy link

Rosetta should support generic types. Generic types can be used for fields, properties, variables, class types and base class types.

@michaelaird
Copy link
Author

I spent a while poking at implementing this and going in circles.

Here are some issues/thoughts:

  • GenericNameSyntax inherits from SimpleNameSyntax so it should be straightforward to differentiate between them and handle them separately
  • The list of type arguments are also TypeSyntax nodes so they need to be walked recursively
  • TypeReference is a likely candidate for handling generics
    • There are 2 TypeReference helpers, one specifically for BaseTypes of classes. They both need to handle generics properly
  • Currently, type name mapping from C# to TypeScript is taking place outside of TypeReference ( in TypeMappings.MapType which only accepts a string)
    • Many type checks are being done using String.Contains. This could lead odd errors. (eg. a user defined type named UnavoidableIncident would be treated as void )

@andry-tino I'm not sure where to go with this right now so let me know what you think.

@andry-tino
Copy link
Owner

Hello and sorry for the long wait. I am pretty busy at the moment, I will get back to you soon! Let me also go through your code and points...

@michaelaird
Copy link
Author

No worries. We're continuing to crank through implementing some more things. On our radar:

  • Switch statements
  • Try/catch blocks
  • CastExpression
  • ArrayCreationExpression
  • ElementAccessExpression
  • LogicalAndExpression
  • LessThanExpression
  • GreaterThanExpression
  • ConditionalExpression
  • LogicalOrExpression
  • AsExpression

@andry-tino
Copy link
Owner

Very cool. I have some work I need to prioritize at the moment on the ScriptSharp definition generator. Once done, I will start integrating those changes.

@michaelaird
Copy link
Author

michaelaird commented Apr 21, 2017

Here's my initial crack at handling generic types(and nullable types, and arrays and some other bits).

michaelaird@e7e92dc

Over the weekend, I'm going to try to also put in calling generic methods.

@andry-tino
Copy link
Owner

Yes seems a good start. I am finalizing my changes for supporting ScriptSharp TS definition file generation via assembly only. After that I will have more times for integrating your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants