You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Project supported OS version attribute information as SupportedOSPlatform attributes #411
.NET 5 has introduced a SupportedOSPlatformAttribute and UnsupportedOSPlatformAttribute along with a few other attributes that integrates with the .NET SDK's support for platforms in the TFMs. Additionally, the SDK provides an analyzer to verify that the APIs the user calls are available in their target min platform version.
C#/WinRT should project any OS version information it finds on APIs as either the SupportedOSPlatformAttribute or UnsupportedOSPlatformAttribute as needed to enable developers to use the standard .NET tools for validating what in what OS version APIs were introduced and when it is safe to call them.
Would this be a replacement for ApiInformation.IsApiContractPresent?
Right now, those APIs are not working as-is on WinUI desktop (for example), so this would be very welcome, since the winmds are not present on the output folder. Steven Brix (@stevenbrix) helped me a while ago with a workaround:
Alexandre Zollinger Chohfi (@azchohfi)ApiInformation.IsApiContractPresent works for .NET 5 long as you use the full TFM. OSVersionHelper 1.1.18-preview has this working just fine.
Set your TFM to net5.0-windows10.0.19041 and multi-target to netstandard2.0 or uap10.0.16299 as needed.
WinMD's don't exist (or work) anymore with .NET 5, there's a new reference library based on CSWinRT that contains the projections.
Alexandre Zollinger Chohfi (@azchohfi) - what exactly is your scenario? do you need to write a component that can work against different versions of WinUI?
Claire Novotny (@clairernovotny) , I can't use that TFM with WinUI3 yet since WinUI3 Preview2 still requires Net5 Preview5 to work, but I'm glad to hear that this was fixed on newer versions, so I'll be able to remove the workaround whenever WinUI3 Preview3 ships.
AdamBr (@AdamBraden) We do have some conditional code that we required to run on older version that are not related to XAML, for example, Bluetooth LE, but they might be all irrelevant now since we did bump our min version a while back, so all of it should be always available.
The latest one is XamlRoot, which we added to support Xaml Islands, but again, it shouldn't be a problem on WinUI3. I'll go thru all of them to make sure that is dead code, but there might still be something, and I'm sure there is an RS5+ API that is new enough to make ApiInformation.IsApiContractPresent relevant. Having a unified API with Net5 is even better!
The ApiInformation checks should still work for querying system APIs though. Those APIs are implemented in native code, and so they aren't affected by .NET removing support for winmds.
To clarify - ApiInformation works by looking at the winmd. Typically apps are doing lightup against OS versions and devices (desktop, xbox, holo), and the api knows where to look for the installed system metadata. Its tricker with WinUI as I think Alexandre Zollinger Chohfi (@azchohfi) has a unique scenario - in this case he has a library that extens WinUI so they need to know what version of WinUI they are running with. In this scenario, since WinUI is not part of the OS winmds, WinUI winmds need to be included as part of the app in order for ApiInformation to find the winmd and query its metadata for support.
That model could still work, but it looks like there is a new model with attributes we need to investigate.
Activity
azchohfi commentedon Sep 15, 2020
Would this be a replacement for ApiInformation.IsApiContractPresent?
Right now, those APIs are not working as-is on WinUI desktop (for example), so this would be very welcome, since the winmds are not present on the output folder. Steven Brix (@stevenbrix) helped me a while ago with a workaround:
clairernovotny commentedon Sep 15, 2020
Alexandre Zollinger Chohfi (@azchohfi)
ApiInformation.IsApiContractPresentworks for .NET 5 long as you use the full TFM.OSVersionHelper1.1.18-preview has this working just fine.Set your TFM to
net5.0-windows10.0.19041and multi-target tonetstandard2.0oruap10.0.16299as needed.WinMD's don't exist (or work) anymore with .NET 5, there's a new reference library based on CSWinRT that contains the projections.
AdamBraden commentedon Sep 15, 2020
Alexandre Zollinger Chohfi (@azchohfi) - what exactly is your scenario? do you need to write a component that can work against different versions of WinUI?
azchohfi commentedon Sep 15, 2020
Claire Novotny (@clairernovotny) , I can't use that TFM with WinUI3 yet since WinUI3 Preview2 still requires Net5 Preview5 to work, but I'm glad to hear that this was fixed on newer versions, so I'll be able to remove the workaround whenever WinUI3 Preview3 ships.
AdamBr (@AdamBraden) We do have some conditional code that we required to run on older version that are not related to XAML, for example, Bluetooth LE, but they might be all irrelevant now since we did bump our min version a while back, so all of it should be always available.
The latest one is XamlRoot, which we added to support Xaml Islands, but again, it shouldn't be a problem on WinUI3. I'll go thru all of them to make sure that is dead code, but there might still be something, and I'm sure there is an RS5+ API that is new enough to make ApiInformation.IsApiContractPresent relevant. Having a unified API with Net5 is even better!
stevenbrix commentedon Sep 15, 2020
The
ApiInformationchecks should still work for querying system APIs though. Those APIs are implemented in native code, and so they aren't affected by .NET removing support for winmds.AdamBraden commentedon Sep 15, 2020
To clarify - ApiInformation works by looking at the winmd. Typically apps are doing lightup against OS versions and devices (desktop, xbox, holo), and the api knows where to look for the installed system metadata. Its tricker with WinUI as I think Alexandre Zollinger Chohfi (@azchohfi) has a unique scenario - in this case he has a library that extens WinUI so they need to know what version of WinUI they are running with. In this scenario, since WinUI is not part of the OS winmds, WinUI winmds need to be included as part of the app in order for ApiInformation to find the winmd and query its metadata for support.
That model could still work, but it looks like there is a new model with attributes we need to investigate.