In the previous article, we briefly introduced the interaction between the framework and winrt, which is much more powerful than that. We can implement cross-language calls, and this call is very simple.
For example, we have written some class libraries in C # And then we can use js to call our writing method.
Create a new class library project
public sealed class WinRT { public int Test(int a, int b) { return a + b; } }
Select winmd for the output type (for the winrt type, the framework is DLL), and then compile
We can reference this winrttest. winmd in a JS Orc ++ project.
Here, JS is used as an example. VS can only be sensed and prompt us, which is very powerful.
Of course, these are also limited.
- The API signature only uses the Windows runtime type.
- Struct can only have public data fields
- Only inheritance is allowed for the XAML control. The sealed keyword must be used for other types.
- Only built-in generics are supported.
For details, see:
Winrt APIs that can be called by C # and Visual Basic
Using the Windows runtime from C # and Visual Basic
I 'd like to talk about it much better here (I 'd like to thank boolan for its hard-working translation)
Although there are no more detailed documents, it is not difficult to find out through decompilation.
When we select to generate the winmd type, the compiler not only generates the class we wrote, but also generates a corresponding interface
Here, I guess this interface is used to intelligently prompt the compiler.