-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove IRuntimePlatform.OperatingSystem API and replace with trimmable OperatingSystem API #9760
Conversation
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
What is the current behavior?
Before this PR we used IRuntimePlatform.OperatingSystem which was too complex for the compiler to analyze and trim.
What is the updated/expected behavior with this PR?
With this PR OperatingSystem API is used, and when developers build project with specific runtime identifier (win7-x64, linux-x64...) or target framework, unused code will be removed from the assembly, including whole dependency assemblies.
It is especially useful with
Avalonia.Desktop
package, which previously references platform specific packages for all three main platforms. Even though it was actually loading into the memory only one of them previously, and it was possible to safely remove others, now it will do it automatically.Also makes OnPlatform to use OperatingSystem which also improves generated and trimmed code. (CC @robloo in context of #1434).
Keep in mind that if DataGrid usage can be trimmed-out from the OnPlatform branches, but assembly is still likely to be referenced, as we include its styles in the App.xaml. Alternatively, styles might be included inside of the OnPlatform branch, but I did not try this.
Breaking changes
Yes, IRuntimePlatform.GetRuntimeInfo() interface has lost most of its properties. This API ideally should have been replaced with RuntimeInformation or OperatingSystem standard BCL APIs long time ago.