C#/WinRT authoring: Yo dawg, we heard you like components so we made a component that makes components
(2021/02/11)
- Reference: 1613041204
- News link: https://www.theregister.co.uk/2021/02/11/winrt_csharp_authoring/
- Source link:
Microsoft has [1]nudged out an update to the C#/WinRT NuGet package and added a preview of C#/WinRT authoring to an otherwise relatively humdrum release.
Lurking among the tweaks and bugfixes, the arrival of authoring (in preview) means that C# .NET 5 component authors can create their own Windows Runtime types and package them as Windows Runtime components.
[2]
"You can implement runtime classes in a C# library project, generate its WinMD metadata file, and distribute the WinRT component as a NuGet package," explained Microsoft. "C#/WinRT provides hosting support which loads the .NET runtime."
It's a neat bit of functionality, and the preview permits a C# authored component to be consumed by the likes of C++ and Rust. Sadly, WinUI3 is not, as Microsoft delicately put it, "fully supported". It is instead due to receive some love in the coming months.
[3]
We took our copy of Visual Studio out for a spin and, having created a new C# project using the Class Library template and pointing it at .NET 5, creating the usual "Hello World" was relatively straightforward once a NuGet reference to the C#/WinRT package was made.
Persuading another language to consume it was a little more complicated. We went down the package reference route with a C++ console application and, after some tinkering with JSON and poking at the manifest, were rewarded with that "Hello World".
The authoring functionality, when in a state that doesn't require quite so much hand-holding, will allow C# .NET 5 fans to package their own Windows Runtime components that can be consumed in native applications. As it stands, however, that Preview label is well deserved – there is plenty of potential for coders that would benefit from this functionality but, as Microsoft would agree, more work remains before it can be allowed near production code.
[4]
The plan is to "continue to improve the project support for a more streamlined end-to-end authoring experience," according to Microsoft, as well as "working on support for more authoring scenarios such as integration with WinUI 3 desktop applications and authoring out-of-process components." ®
Get our [5]Tech Resources
[1] https://blogs.windows.com/windowsdeveloper/2021/02/09/c-winrt-authoring-preview-and-updates/
[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0
[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[5] https://whitepapers.theregister.com/
Lurking among the tweaks and bugfixes, the arrival of authoring (in preview) means that C# .NET 5 component authors can create their own Windows Runtime types and package them as Windows Runtime components.
[2]
"You can implement runtime classes in a C# library project, generate its WinMD metadata file, and distribute the WinRT component as a NuGet package," explained Microsoft. "C#/WinRT provides hosting support which loads the .NET runtime."
It's a neat bit of functionality, and the preview permits a C# authored component to be consumed by the likes of C++ and Rust. Sadly, WinUI3 is not, as Microsoft delicately put it, "fully supported". It is instead due to receive some love in the coming months.
[3]
We took our copy of Visual Studio out for a spin and, having created a new C# project using the Class Library template and pointing it at .NET 5, creating the usual "Hello World" was relatively straightforward once a NuGet reference to the C#/WinRT package was made.
Persuading another language to consume it was a little more complicated. We went down the package reference route with a C++ console application and, after some tinkering with JSON and poking at the manifest, were rewarded with that "Hello World".
The authoring functionality, when in a state that doesn't require quite so much hand-holding, will allow C# .NET 5 fans to package their own Windows Runtime components that can be consumed in native applications. As it stands, however, that Preview label is well deserved – there is plenty of potential for coders that would benefit from this functionality but, as Microsoft would agree, more work remains before it can be allowed near production code.
[4]
The plan is to "continue to improve the project support for a more streamlined end-to-end authoring experience," according to Microsoft, as well as "working on support for more authoring scenarios such as integration with WinUI 3 desktop applications and authoring out-of-process components." ®
Get our [5]Tech Resources
[1] https://blogs.windows.com/windowsdeveloper/2021/02/09/c-winrt-authoring-preview-and-updates/
[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0
[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YCVirpT9sUb-IyS5roJjwwAAAEQ&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[5] https://whitepapers.theregister.com/