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

Add .NET 8 target (Avalonia 11.1) #14535

Merged
merged 25 commits into from
Mar 5, 2024
Merged

Add .NET 8 target (Avalonia 11.1) #14535

merged 25 commits into from
Mar 5, 2024

Conversation

maxkatz6
Copy link
Member

@maxkatz6 maxkatz6 commented Feb 8, 2024

What does the pull request do?

There is a number of features that we need from .NET 8 SDK and targets.
Primarily:

  1. Keep mobile support up to date. Xamarin team actively drops support for .NET TFM versions, and right now it's not possible to build mobile app with .NET 6 TFM. .NET 7 still works, but this PR is going one step ahead.
  2. UnsafeAccessor which is going to be helpful with SkiaSharp 3.0 compatibility
  3. Up-to-date SDK analyzers.
  4. Other potential optimizations available only on .NET 8 SDK. Though we still can't use .NET 8 only features in our Public API (like, DateOnly primitives), but it can go to Avalonia.Labs.

And also, we are likely to drop .NET 6 in Avalonia 12.0 (while still likely to support .NET Standard 2.0). Targeting .NET 8 is a preparation before that.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044613-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@workgroupengineering
Copy link
Contributor

workgroupengineering commented Feb 8, 2024

Instead of directly using TargetFramework net8.0 for each project, add to Directory.Build.props a property like

<PropertyGroup>
  <AvaloniaDefaultTargetFramework Condition="'$(AvaloniaDefaultTargetFramework)' == ''">net8.0</AvaloniaDefaultTargetFramework>
</PropertyGroup>

eg. using in packages/Avalonia/Avalonia.csproj

  <PropertyGroup>
      <TargetFrameworks>$(AvaloniaDefaultTargetFramework);netstandard2.0</TargetFrameworks>
      <PackageId>Avalonia</PackageId>
  </PropertyGroup>

eg: samples/MobileSandbox.Browser/MobileSandbox.Browser.csproj

 <PropertyGroup>
    <TargetFramework>$(AvaloniaDefaultTargetFramework)-browser</TargetFramework>
    <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
    <Nullable>enable</Nullable>
    <EmccTotalMemory>16777216</EmccTotalMemory>
 </PropertyGroup>

For example, when you switch to net9.0 targte you will only need to change it in one point.

@maxkatz6
Copy link
Member Author

maxkatz6 commented Feb 8, 2024

Yeah, we discussed that internally.
I had an idea for DotNetCurrent=net8.0, DotNetPrevious=net6.0, DotNetFramework=net461, DotNetStandard=netstandard2.0.

But we couldn't find if it really would make anything better. It does make it easier to update version, but at the same time harder to quickly check csproj version for users no used to the repo. And in general, it's not like we change these versions often. Next time probably will happen around .NET 10 haha.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044637-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044701-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@kekekeks
Copy link
Member

Can we have <LegacyTargetFrameworks Condition="'$(AvaloniaSkipLegacyTargetFrameworks)' != 'True'>net6.0</LegacyTargetFrameworks> so building for net6.0 can be disabled during development?

@maxkatz6
Copy link
Member Author

@kekekeks it would complicate msbuild logic quite a bit. Will think about it. It would also add DotNetCurrent/DotNetPrevious props anyway, which is fine.

@kekekeks
Copy link
Member

it would complicate msbuild logic quite a bit

Why?
It would be something like this in common props:

<DotNetCurrentFramework>net9.0</DotNetCurrentFramework>
<DotNetCompatibilityFrameworks>net8.0;net6.0<DotNetCompatibilityFrameworks>
<CommonTargetFrameworks>$(DotNetCurrentFramework);netstandard2.0</CommonTargetFrameworks>
<CommonTargetFrameworks Condition="'$(AvaloniaSkipLegacyTargetFrameworks)' != 'True'>$(CommonTargetFrameworks);$(DotNetCompatibilityFrameworks)</CommonTargetFrameworks>

and <TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks> in csproj files.

@workgroupengineering
Copy link
Contributor

If you decide to add properties, it may be best to add the Avalonia prefix to the properties to try to avoid conflicts.

@maxkatz6
Copy link
Member Author

maxkatz6 commented Feb 11, 2024

It would be something like this in common props:

So, how would we add "-ios", "-android", "-browser" suffix?
It would require quite a bit of duplication. Possible, but exactly what I meant before by quite complicated.

@kekekeks
Copy link
Member

OK, it's out of the scope of this PR anyway.

@maxkatz6 maxkatz6 requested a review from a team February 20, 2024 08:01
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045118-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045301-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045371-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045525-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 force-pushed the target-net-8 branch 2 times, most recently from d40cac4 to b6acaa9 Compare March 5, 2024 04:18
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045700-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 5, 2024
@maxkatz6 maxkatz6 removed this pull request from the merge queue due to a manual request Mar 5, 2024
@maxkatz6 maxkatz6 merged commit 326ef7c into master Mar 5, 2024
7 checks passed
@maxkatz6 maxkatz6 deleted the target-net-8 branch March 5, 2024 21:37
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.

6 participants