Rosetta
Rosetta copied to clipboard
Support generic types
Rosetta should support generic types. Generic types can be used for fields, properties, variables, class types and base class types.
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 asvoid
)
- Many type checks are being done using String.Contains. This could lead odd errors. (eg. a user defined type named
@andry-tino I'm not sure where to go with this right now so let me know what you think.
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...
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
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.
Here's my initial crack at handling generic types(and nullable types, and arrays and some other bits).
https://github.com/michaelaird/Rosetta/commit/e7e92dca146660de1123c391bfcb46f10f2a0eb3
Over the weekend, I'm going to try to also put in calling generic methods.
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.