Skip to content
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

Merged
merged 6 commits into from
Dec 23, 2022

Conversation

maxkatz6
Copy link
Member

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.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0027843-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0027875-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 merged commit 2bf384c into master Dec 23, 2022
@maxkatz6 maxkatz6 deleted the better-trimming branch December 23, 2022 16:34
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0027878-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants