Repository navigation
Upgrade to .NET 8, C# 14 - #114
Merged
Merged
Conversation
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.
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
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.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
nameof()in attributes: Usednameof()within nullability annotations like[NotNullIfNotNull](ed48706)global.json(1d4d257), previously only implied via build targets[MemberNotNull],[MemberNotNullWhen], andIsExternalInit, now that the .NET 8 provides them natively (ab4372c)Bug Fixes
typeLookupServices.Reverse()being passed directly toAddRange()(98676f7)Reverse()now reverses in place rather than returning a new sequence, so the reversal is applied before the original collection is passedIsHiddenproperty in the constructor (dbb5438)Dependency Management
Directory.Packages.props(f41a7a0)global.jsonas "Solution Items" so they're visible in Visual Studio and Rider (a79dd1c)Microsoft.Data.SqlClientfrom 2.0.0 to 6.1.5 (451d825)Annotations(8989404) and GitHub SourceLink (2cba7e4) packages, now bundled with .NET 8.0Test Infrastructure
There's no impact on consumers; these changes are scoped to the test apparatus only.
voidinstead of aTask(c06354f)Microsoft.AspNetCore.Mvc.Testing) to 8.0.28 to align with the .NET 8 upgrade (4723b02)