Hi Arcady,
You need some kind of facade or adapter in front of your .NET class when your .NET object structure is outside the supported structures of PB's native .NET interop. The exact same issues occur when you use COM Callable Wrapper as .NET Interop technology.
About 10 years ago I worked on app that called national databases exposing their interfaces via web-services. We could not connect directly from PB 11.5, nor PB 12.5 later on. We had to write facade in C#. We used COM callable wrapper to call C# written assembly from PowerScript.
Data structures passed back and forth were very complex highly nested data structures. Arrays of structs of arrays of structs of . . . You get the picture I assume.
Now, such structure is impossible to pass directly via COM. Same if using PB native .NET interop. Here is what we did:
* Each public API of our C# facade followed this pattern:
function CreateSuperFundSite( string IN-data )
return string // OUT-data
throws exceptions
The IN-data was an XML-string encapsulating the complete input data structure. Often 5+ nested layers of arrays of structs.
The OUT-data return value was also an XML-string encapsulating similar complete data structure.
These days I would use JSON instead of XML but same design pattern: Facade to hide complexity. Typically one PB facade class taking whatever PB data structures marshall to interchange format; call .NET facade; accept return data and unmarshall from interchange format.
On the .NET side the front-end C# class simply unmarshalled the IN-data; initiated whatever processing required; marshalled result and returned it.
It works! /Michael
You ask why native .NET interop at all when it doesn't met your "basic needs" in "release 1.0"? => Native .NET interop eliminates dependency on COM! User feedback informs PB future development.
Current interop feature was sufficient for my immediate needs so I replaced most COM-based interop. But I would love to see enhancements, just like you! Support for more complex data exchange or object access eliminates most code for marshalling/unmarshalling in both PowerScript and C#.
On the other hand, I skipped native WebBrowser in PB 2019 R2. It lacked EvaluateJavaScript. That API is new with PB 2019 R3 so I will probably make the switch when R3 releases.
HTH /Michael
* COM does not have access to static methods - it is strictly object based
* COM requires parameter less constructor - PB's .NET interop already supports parameterized constructors
* Hard to use enumerated types. You have to know the numeric value of each enum value.
* COM requires extra work outside PowerScript to define the COM callable object.
* No MS plans AFAIK to improve COM - so no chance of improvements to current lacking features.
HTH /Michael