Open Ablu opened 5 years ago
Sounds hard to implement, but useful. What will ConstructorInfo contain? Can you distinguish between the C# class instance (maps to the JavaScript object) and the C# method definitions (maps to the JavaScript object's prototype)?
With ConstructorInfo
I meant https://docs.microsoft.com/en-us/dotnet/api/system.reflection.constructorinfo?view=netframework-4.7.2. So I get full access to the type via DeclaringType
.
I will break it into small self-contained tasks:
This hopefully keeps the individual PRs reviewable and small(er)
It was simpler than anticipated before. The linked PR (#71) should fix/add this. The only thing which might need more work is inheritance on .NET side... However, I guess that could be handled as a separate issue (not sure whether we need it at the moment)?
Also we just realized that overloaded constructors would need additional support
Problem
Currently JavaScript.Net does not fully support prototype related use cases:
While it is possible to register a function which creates a new object like this:
problems with this approach:
instanceOf
checks are not working.c instanceof TestClass
is falseTestClass.prototype.newMethod = function() {...}
)Things to consider for the solution
Solution proposal
SetConstructor(ConstructorInfo constructor)
to the context which generates a prototype and registers under the nameSide notes
This could also improve performance of wrapping objects since the analysis of type is only required once, repetitive passing could become a lot faster.
/cc @spahnke
@oliverbock do you think the proposal above is sane? Then I would start to implement it.