RTTI / Reflection as new feature for Sugar

It will be cool to have some cross-platform Reflection-like API.

Sugar’s TestFramework already have some cross-platform code to list members and invoke them. So, some big pert of this feature actually is implemented in code.

All we need is proper API and refactoring to TestFramework to use this new API!

Maybe Reflection can have limited, but working API, it’s ok for early stage of development!

Cool idea, yes. Create a mapped type around System.Type (.NET) and Class (Cocoa) (and whatever there is on Java). have a way to instantiate instances, check/list for members, set/get properties and call methods by (string) name…

You wanna get this started? i’d be happy to chip in.

I ll try with some parts of API, but maybe i have not enough exp in different platform!

if you get started with .NET, i can add Cocoa.

I added a Type class for both .Net and Java…
Needs more work but then we can start somewhere…

Cool. i merged stable into develop, so it will build with latest ;). i’ll have a look and see if i can expand it for nougat, tomorrow.

For instance creation, do we add the methods for that to the Type class?
Or like it is in .NET now? (a separate factory class)
A method on Type can also create an object of the Type Object.

i’d say add a “create instance” it on Type. Of course this only covers parameterless ctors. doing ctors with parameters will be a lot trickier, especially for Cocoa, because it means they’ll be named ctors…

We need to think about the usage of this part of Sugar.
I have have a library for example that uses Attributes on fields to serialize /deserialize them to a old style ASCII transfer protocol we still need to support.
With this new reflection part of Sugar I can probably make that cross-platform.
But if you use this part of Sugar then it makes no sense for features that not all platforms support.
For example: Getting the names of parameters in Java is very hard and you need to have debug info enabled, release builds cannot ever get that info.
So To make sure that people do not write code that depends on that, is it not better to remove that Name property?
Maybe we should only support creating of objects via the parameter-less constructor.