Skip to content

Update to .NET 10 - #933

Merged
Sergio0694 merged 31 commits into
mainfrom
dev/net10.0
Sep 4, 2026
Merged

Sergio0694 merged 31 commits into
mainfrom
dev/net10.0

Conversation

@Sergio0694

Copy link
Copy Markdown
Owner

Updates the whole repo to .NET 10, including all source generators and code fixers.

Main changes

All projects now target .NET 10. Source generators and code fixers move off .NET Standard 2.0 as well, since the .NET 10 SDK always uses the .NET hosted compiler for SDK-style projects. Roslyn references are bumped to 5.0.0, which is now the minimum supported version.

Because everything is on the same target framework, a fair amount of code can be shared and simplified:

  • PolySharp and all the .NET Standard 2.0 polyfills are gone
  • The HashCode polyfill is replaced by the one from the BCL
  • Several SOURCE_GENERATOR branches are no longer needed, so generators and runtime libraries now compile the exact same code
  • The Roslyn version checks in the shipped .targets files are removed, which leaves four of those files empty and deleted

Other cleanup

  • Feature switches use [FeatureSwitchDefinition] instead of the ILLink substitution XML, which is no longer supported
  • All vtables are built statically with [FixedAddressValueType] instead of RuntimeHelpers.AllocateTypeAssociatedMemory, which removes the allocation and setup work at runtime, and avoids rooting reflection metadata for those types in AOT builds. Each vtable now lives in its own file, one per interface, instead of packing several into a single allocation. This also fixes a latent bug in D2D1DrawInfoUpdateContextImpl, where the vtable pointer for ID2D1DrawInfoUpdateContextInternal was off by one slot, so calling Close() would dispatch to Release() instead.
  • CsWinRT is updated to 2.3.1 and configured from a shared BeforeMicrosoftNETSdkTargets file, so all projects use the same version and options. This enables the highest AOT warning level, which surfaced a cast that wasn't trim safe and a few types missing the partial modifier.

Build fixes

  • CI moves to the windows-2025 image, as the .NET 10 SDK needs MSBuild 18.0 or greater
  • The target Windows SDK is now 10.0.26100.0, which is the one available on that image
  • The Windows SDK projection package is pinned to match CsWinRT, as mixing the two versions made ILLink report spurious trim warnings when publishing
  • Publishing the NativeAOT samples with MSBuild works again, as the runtime identifier no longer implies SelfContained since .NET 8

Notes

The tolerance for the two Bgra32 JPEG imaging tests was slightly increased. Those tests compare the WIC decoder against the ImageSharp one, and the two disagree by a bit on some pixels. The value was tuned so tightly that the current WIC decoder is about 0.1% over it. This is not related to the migration: the same delta reproduces on main with .NET 8. The new value matches the equivalent Rgba32 tests using the same image.

Sergio0694 and others added 11 commits September 3, 2026 08:33
Upgrade the .NET SDK from version 9.0.301 to 10.0.400 with latestFeature rollforward policy.
Update C# language version from preview to latest for build stability, and update copyright year to 2026.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
These packages are automatically available on .NET 10, so referencing them explicitly produces NU1510.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The generators and code fixers now require Roslyn 5.0 (ie. the .NET 10 SDK) as their minimum supported version.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Partial properties and the 'field' keyword are no longer preview features, and .NET 10 projects default to C# 14, so gating [GeneratedCanvasEffectProperty] on 'LangVersion=preview' just disabled the generator.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This version no longer requires the C# 'preview' language version to use [ObservableProperty] on partial properties.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Sergio0694 Sergio0694 added maintenance 鈿欙笍 Issues/PRs about maintenance/CI work dependencies 馃獩 Pull requests that updates some dependencies .NET Pull requests that update .NET code refactoring 馃Ч Code style and architecture improvements unit tests 馃И Proposals or improvements to the unit tests suite optimization 馃殌 Performance improvement to existing APIs labels Sep 4, 2026
Comment thread src/ComputeSharp.SourceGenerators/Dxc/DxcLibraryLoader.cs Dismissed
Sergio0694 and others added 12 commits September 4, 2026 02:36
The .NET 10 SDK always uses the .NET hosted compiler for SDK-style projects, so compiler extensions no longer have to target .NET Standard 2.0. This also removes the HashCode polyfill, which the BCL now provides, and fixes the nullability warnings that the annotated .NET reference assemblies surface.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This switches the test reference assemblies to .NET 10 and the default language version to C# 14, so the tests match the framework and language version the generators actually target.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The packages now target .NET 10, which can only be built with the .NET 10 SDK, so the compiler is always recent enough for the generators to load. This makes the check dead logic, which leaves several .targets files completely empty.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The ILLink substitution XML is no longer supported, and [FeatureSwitchDefinition] is the modern replacement for it. This also lets the switches be defined entirely in code, so the property names no longer have to be kept in sync with a separate file.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Using a [FixedAddressValueType] field instead of RuntimeHelpers.AllocateTypeAssociatedMemory removes the runtime allocation and initialization work, and it also avoids rooting the reflection metadata for all these types in AOT builds. Each vtable now also gets its own type in a dedicated file, instead of merging multiple vtables into a single allocation. This fixes a latent bug in D2D1DrawInfoUpdateContextImpl, where the ID2D1DrawInfoUpdateContextInternal vtable pointer was off by one slot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This removes the last use of RuntimeHelpers.AllocateTypeAssociatedMemory, and it also lets the source generator share the exact same code as the runtime library.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
All projects target .NET 10 now, including the source generators and code fixers, so none of the polyfills are needed anymore.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The .NET 10 SDK requires MSBuild 18.0 or greater, which is only available on images shipping Visual Studio 2026. The windows-2022 image is still on MSBuild 17.x, so it can no longer build .NET 10 projects.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The windows-2025 runner image no longer ships the Windows SDK 10.0.22621.0, which made packaging the UWP and WinUI projects fail with APPX3217.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reference is now added from a shared 'BeforeMicrosoftNETSdkTargets' file, so all projects are guaranteed to use the same version, and all the common CsWinRT options are set in one place. This also enables the highest AOT warning level, which surfaced a non trim-safe cast and a few types that were missing the 'partial' modifier.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The projection assemblies in 'Microsoft.Windows.SDK.NET.Ref' are built against a specific version of 'WinRT.Runtime'. The version the .NET SDK selects by default is built against CsWinRT 2.2.0, so referencing CsWinRT 2.3.1 made ILLink report spurious IL2081 warnings for all the 'ABI.Windows.Foundation' types when publishing with trimming.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
As of .NET 8, the runtime identifier no longer implies 'SelfContained', and that property is only set automatically when publishing through 'dotnet publish'. The samples published with 'msbuild -t:publish' would therefore fail with NETSDK1102, as they also enable size optimizations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sergio0694 and others added 2 commits September 4, 2026 02:36
These tests compare the WIC decoder with the ImageSharp one, which inherently disagree by a bit on some pixels. The tolerance was tuned so tightly that the current WIC decoder is just 0.1% over it, so it's now aligned with the equivalent Rgba32 tests using the same image.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Now that all source generators target .NET 10, the regex source generator can be used to
emit the matching logic at compile time. This replaces the cached interpreted regex-es and
the RegexOptions.Compiled instances, which had to build their matchers at runtime.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
Sergio0694 and others added 6 commits September 4, 2026 03:36
Requiring .NET 10 is a breaking change for consumers, so the next release moves to a new
major version.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
Both libraries only compile against the Win2D API surface, which is resolved from the
reference assembly in the package. They never resolve the native 'Microsoft.Graphics.Canvas.dll',
as that is up to the consuming application, which still gets the Win2D build logic transitively.
That is also why they are packed as 'AnyCPU', which is what made Win2D warn when packing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
Win2D 1.4.0 depends on the split Windows App SDK packages rather than the single one, so the
two updates have to happen together. Mixing them is not possible, as both sets of packages
import the same .targets and the MSIX tooling then fails to wire itself up.

The libraries now only reference what they actually use. 'ComputeSharp.WinUI' takes the WinUI
package instead of the whole SDK, and 'ComputeSharp.D2D1.WinUI' takes only Win2D. The two
packaged apps use the framework dependent deployment model, so they also take the runtime
package, which is what adds the framework package dependency to their MSIX manifest. The CLI
sample is self contained and does not need it.

The Community Toolkit references move to the 8.3 previews, which are the first builds to use
the split packages. The 8.2 releases still pull in the single package.

This also drops the 'Microsoft.Web.WebView2' workaround from both UI libraries. It was pinning
an older version to keep 'WebView2Loader.dll' out of the generated .pri files, and the version
that now comes in no longer has that problem.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
These were just wrapping a single expression over the vtable fields, and being private
they were not adding anything over using the fields directly. With them gone, the fields
no longer need the 'Shared' prefix that was only there to tell them apart.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
Also turn on 'CsWin32RunAsBuildTask', so the interop is generated by a build task rather
than by the source generator. The property is centralized, as it is a no-op for projects
that do not use CsWin32.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
Now that the source generators target .NET 10, the BCL can load the libraries directly,
so the manual 'LoadLibraryW' declaration is no longer needed. The failure is still
surfaced as a Win32Exception, which is what callers catch to report a diagnostic instead
of crashing, and the message from the BCL also names the file and the OS loader error.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8d03bf3b-9de2-465c-a87c-f795178863c4
@Sergio0694
Sergio0694 merged commit 3fe1916 into main Sep 4, 2026
38 of 41 checks passed
@Sergio0694
Sergio0694 deleted the dev/net10.0 branch September 4, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies 馃獩 Pull requests that updates some dependencies maintenance 鈿欙笍 Issues/PRs about maintenance/CI work .NET Pull requests that update .NET code optimization 馃殌 Performance improvement to existing APIs refactoring 馃Ч Code style and architecture improvements unit tests 馃И Proposals or improvements to the unit tests suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants