Call Windows APIs with new TFMs in .NET 5
C#/WinRT provides support for WinRT APIs in .NET 5 by generating Windows SDK projections and including them in the .NET 5.0 SDK along with a small runtime assembly. With this new support, Windows APIs should now be accessed using the new Target Framework Monikers feature. The new TFMs provide a simple and streamlined access to the Windows APIs in a .NET 5 app. The following TFMs and corresponding SDK versions are supported:- 0-windows10.0.17763.0 (Windows 10, version 1809)
- 0-windows10.0.18362.0 (Windows 10, version 1903)
- 0-windows10.0.19041.0 (Windows 10, version 2004)
net5.0-windows10.0.19041.0For more details on how to use Windows TFMs in your app, check out the blog post on Calling Windows APIs in .NET 5 as well as the developer docs for Windows desktop apps.
Latest Windows Runtime Updates
Version 1.0 of C#/WinRT includes the latest runtime updates that are shipped through our runtime assembly, winrt.runtime.dll, as part of the .NET 5.0 SDK. The runtime assembly and the Windows SDK projections are accessed through the .NET 5 TFMs mentioned above. Some of the latest .NET 5 features we have added include C# function pointers for improved performance and implementing natural C#-style casts. To learn more about these updates, take a look at the blog post on improvements in native code interop in .NET 5. We have made performance improvements and fixed several critical bugs raised by the team as well as from developer feedback through our repo. Some of these fixes include:- Added projection support for ref const C# parameters
- Fixes for NullReferenceExceptions when using C# IDictionary objects
- Resolved issues with using WindowsRuntimeBufferExtensions methods
- Several bug-fixes involving InvalidCastExceptions
C#/WinRT Projection Support for Component Authors
The C#/WinRT project provides support for component authors to build C# projection assemblies of their components which can then be consumed by C# app developers. By referencing the CsWinRT NuGet package, component authors can generate an assembly using our improved project tooling in Visual Studio. An end-to-end sample has been added to our repo showing how to generate a .NET 5 projection from a C++/WinRT component, and how to distribute and consume the projection assembly as a NuGet package. This walkthrough of the sample in the C#/WinRT docs provides more details. You can read more about the tooling experience for generating a projection in the last C#/WinRT blog post.Closing
C#/WinRT has enabled .NET 5 to remove built-in WinRT support so that the WinRT ecosystem and .NET runtime can now innovate independently. We have also provided the tools for component authors to build C# projection assemblies for their .NET 5 consumers to use. Up next for the team, we are working on authoring support for C# .NET 5 developers to create their own C#/WinRT components. These new capabilities will be available in a future release of C#/WinRT—keep up to date with the latest changes on the CSWinRT repo.from Windows Blog https://ift.tt/2Uebnak https://ift.tt/eA8V8J