Skip to content

Upgrade to .NET 8, C# 14 - #114

Merged
JeremyCaney merged 26 commits into
developfrom
maintenance/C#-14
Jul 1, 2026
Merged

JeremyCaney merged 26 commits into
developfrom
maintenance/C#-14

Conversation

@JeremyCaney

Copy link
Copy Markdown
Member

This migrates the library and its build tooling from .NET Standard 2.1 and C# 9 to .NET 8 and C# 14, while upgrading dependencies, package management, and the test infrastructure to the corresponding, stable versions. The upgrade to .NET 8 is a breaking change for the public interface, and will be part of a major release, even though in practice it shouldn't affect current consumers since most are already on .NET 9 or 10.

Language and Framework

  • Upgraded the project to C# 14 (1707d35, d48cff2)
    • nameof() in attributes: Used nameof() within nullability annotations like [NotNullIfNotNull] (ed48706)
      • Removed references which targeted obsolete members, which now trip the obsolete-usage check (d2ddce9, d4f85df)
  • Updated .NET 7 test (7513d52), ASP.NET Core 3 (f59d4a8), and .NET Standard 2.1 (ee75916) projects to .NET 8
    • Set the .NET SDK version to 8.0.0 explicitly via global.json (1d4d257), previously only implied via build targets
    • .NET 8 is the oldest supported LTS and unblocks capabilities .NET Standard didn't allow
  • Removed .NET Standard polyfills for [MemberNotNull], [MemberNotNullWhen], and IsExternalInit, now that the .NET 8 provides them natively (ab4372c)
  • Updated copyright date to 2026 (2c3f049)

Bug Fixes

  • Fixed typeLookupServices.Reverse() being passed directly to AddRange() (98676f7)
    • Reverse() now reverses in place rather than returning a new sequence, so the reversal is applied before the original collection is passed
  • Stopped setting the obsolete IsHidden property in the constructor (dbb5438)

Dependency Management

  • Migrated to Central Package Management via Directory.Packages.props (f41a7a0)
    • Now dependency versions are managed centrally rather than repeated per project
    • Added alongside global.json as "Solution Items" so they're visible in Visual Studio and Rider (a79dd1c)
  • Updated Microsoft.Data.SqlClient from 2.0.0 to 6.1.5 (451d825)
    • This addresses accumulated security vulnerabilities in it and its transient dependencies
    • This avoids forcing consumers onto the newer 7.x version—though they're welcome to use it
  • Removed the Annotations (8989404) and GitHub SourceLink (2cba7e4) packages, now bundled with .NET 8.0
  • Removed the legacy Code Analysis preview package, no longer relevant (f4d2742)

Test Infrastructure

There's no impact on consumers; these changes are scoped to the test apparatus only.

  • Updated .NET Test SDK from 17.4.0 to 18.6.0 (227ff5f)
  • Upgraded xUnit from 2.x to xUnit 3.x (b3eb81d, d1ba9f8)
    • Upgraded the xUnit test runner from 2.4.5 to 3.1.5 (11ab725)
    • Converted test project output to executables as required by the migration (5db055b)
    • Fixed a test case that returned void instead of a Task (c06354f)
  • Updated the ASP.NET Core MVC test runner (Microsoft.AspNetCore.Mvc.Testing) to 8.0.28 to align with the .NET 8 upgrade (4723b02)

C# 11 released on Tuesday alongside .NET 7. This updates the project to use C# 11 so we can take advantage of new language features.
C# 11 allows `nameof()` to be used within attributes. This is especially useful for nullability annotations, such as `[NotNullIfNotNull]` since it doesn't make them dependent on unverified string representations of parameter names. I've updated these references to use the new `nameof()` syntax.
While the C# version had previously been updated to C# 10, that had never been deployed to a production version. This updates it all the way to C# 14, the latest current version.
This hadn't previously been explicitly established via project configuration, even if it was set as part of the build targets.
This updates the tests and test harnesses from .NET 7 to .NET 8. The library updates will be done subsequently.
Previously, using `nameof()` on an obsolete reference within an `[obsolete]` attribute was accepted. Now that very reference, even when referencing itself, trips the obsolete check. Annoying, but easy fix; we'll remove the `nameof()` reference.
As this is obsolete, it needn't and shouldn't be set in the constructor.
The `Reverse()` method now (?) reverses the contents of the collection it's applied to, but doesn't return a new collection. As such, passing `typeLookupServices.Reverse()` to `AddRange()` is an error. This does the reverse first, then passes the original collection in.
The `AttributeValueCollection` that was the new target has actually been renamed to `AttributeCollection`. As a result, due to the issue previously cited (d2ddce9), the `nameof()` breaks. This updates the reference to the correct target.
This is no longer relevant. We may later update to the 10.0.100 version, though it ships with the SDK OOTB and thus may not be necessary to define as an explicit dependency.
This updates the MCV and All libraries from ASP.NET Core 3 to .NET 8. The `netcoreapp` identifier is no longer used for TPMs, so `net8.0` covers ASP.NET Core 8.
Previously, to maximize compatibility, our core libraries all referenced .NET Standard 2.1, which was originally intended to provide backward compatibility with .NET Framework. (We've had no deployments used with Unity or Xamarin.)

At this point, .NET 8 targets a broad range of potential customers, as the oldest supported LTS release of .NET, while also allowing us to target a broad range of new capabilities that weren't previously permitted in .NET Standard.

This is obviously a breaking change—though, in practice, we don't anticipate it will have any affect on any current users of .NET, most of whom are already using .NET 9 or 10.
This replaces repeating the version of shared NuGet dependencies within each project that uses them with a `Directory.Packages.props` which centrally manages the versions of each dependencies, leaving each project to manage only the dependency itself, without needing to be responsible for keeping the versions in sync.
It's been a number of years since we've released a new version of OnTopic and, during that time, our primary dependency—the `Microsoft.Data.SqlClient` as well its transient dependencies—has accumulated quite a few security vulnerabilities. While technically we could get away with a floor of 5.2.x to address those, 6.1.5 is widely adopted while not forcing customers to update to the new 7.x.
This will allow the `Directory.Packages.prop` (f41a7a0) and `global.json` (1d4d257) files  to be displayed in the "Solution Items" sections in Visual Studio and JetBrains Rider.
These are now packaged with .NET 8.0 and don't need to be included as a standalone package.
This is now packaged with .NET 8.0 and doesn't need to be included as a standalone package.
This has no impact on consumers of the OnTopic packages since it only impacts the test apparatus.
This has no impact on consumers of the OnTopic packages since it only impacts the test apparatus.

In a future update, we'll migrate to the newer xunit v3 package, but that introduces some breaking changes we'll need to address.
This has no impact on consumers of the OnTopic packages since it only impacts the test apparatus.
Since we upgraded the .NET projects from .NET 7 (7513d52), ASP.NET Core 3.1 (f59d4a8), and .NET Standard 2.1 (ee75916) to .NET 8 (1d4d257), we need to update the ASP.NET Core MVC test runner (`Microsoft.AspNetCore.Mvc.Testing` package) to the latest .NET 8 version, which is currently 8.0.28.

This has no impact on consumers of the OnTopic packages since it only impacts the test apparatus.
The `[MemberNotNull()]` and `[MemberNotNullWhen()]` attributes plus the `IsExternalInit` class are all available out-of-the-box in .NET 5+, but weren't available in .NET Standard 2.1, and thus required a polyfill to maintain compatibility. With .NET Standard 2.1 upgraded to .NET 8 (ee75916), we can safely remove these.
This is a major upgrade from the deprecated 2.x version to the new, well-maintained 3.x version.

This has no impact on consumers of the OnTopic packages since it only impacts the test apparatus.
This is required as part of the upgrade from xunit 2.x to 3.x (d1ba9f8).
While we had typically done this, there was one test case which returned a `void` instead of a test.
@JeremyCaney JeremyCaney added Type: Improvement Improves the functionality or interface of an existing feature. Status 5: Complete Task is considered complete, and ready for deployment. Area: Packages Relates to packaging the library as a NuGet package. labels Jul 1, 2026
@JeremyCaney
JeremyCaney merged commit 1d0cd1b into develop Jul 1, 2026
1 check passed
@JeremyCaney
JeremyCaney deleted the maintenance/C#-14 branch July 1, 2026 02:33
JeremyCaney added a commit that referenced this pull request Jul 3, 2026
As a follow-up to the platform and language modernization (#114), this applies the associated code analysis cleanup, working through the full backlog of static analysis warnings across CS, CA, and xUnit diagnostic categories. IN addition, this adopts several C# modernization patterns now unlocked by C# 14 / .NET 8 and upgrades GitVersion to its current 6.x release, which had been deferred from the initial update.

For extensive details on what was fixed, see PR #115.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Packages Relates to packaging the library as a NuGet package. Priority: 0 Severity 1: Minor Status 5: Complete Task is considered complete, and ready for deployment. Type: Improvement Improves the functionality or interface of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant