Skip to content

Conversation

@YoshiRulz
Copy link
Member

@YoshiRulz YoshiRulz commented May 20, 2025

This should be delayed until at least 2026-01 so people have time to update their toolchains. C# 14 is sorely needed. VS2026 and Rider 2025.3 are out and ready for .NET 10.

A change for all our Analyzers which use marker attributes (such as [CoreSettings], [FeatureNotImplemented], or [PeripheralOption], except none of those 3 are eligible in master) is to call initContext.AddEmbeddedAttributeDefinition();, new in Roslyn 4.14, and add [Embedded] on those attributes.

C# 14 brings the field keyword, which will help clean up a lot. And then I could write a Source Generator to clean up even more. Neither will be adopted in this PR though.

C# 14 expands on extension methods with extension props, which newer versions of Meziantou.Polyfill are already taking advantage of to add more polyfills. (Incidentally, bumping it to >= 1.0.53 causes MSBuild to fail, will investigate later.) I'm sure we could replace some of our extension methods with extension props too but that's not for this PR.

Remember to update the ApiHawk quickstart guide after this.

Resolves #4097, but while that's working, let's maybe not migrate until the format is fully-documented (read: drop commit before merging).

@YoshiRulz YoshiRulz added this to the 2.10.2 milestone May 20, 2025
@YoshiRulz YoshiRulz force-pushed the dotnet-sdk-10 branch 2 times, most recently from 7959d59 to 51e0c3a Compare September 8, 2025 07:51
@YoshiRulz YoshiRulz added the Meta Relating to code organisation or to things that aren't code label Sep 26, 2025
@YoshiRulz YoshiRulz added the re: Metaprogramming Roslyn Analyzers and Source Generators label Oct 14, 2025
I think this is or was for ReSharper? Needs testing, and if it turns out
this did something useful, hopefully it can be re-added as EditorConfig
temporarily muting IDE0031 "Use null propagation" (because of new `?=`)
@YoshiRulz YoshiRulz force-pushed the dotnet-sdk-10 branch 2 times, most recently from 84b347b to a503d43 Compare November 16, 2025 11:55
@YoshiRulz YoshiRulz marked this pull request as ready for review November 16, 2025 11:57
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested whether this is even still necessary? I feel like I remember that [ ] for ArraySegments was changed to now resolve to a useful (non-null) value, but I haven't checked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you revert 83d04b0 and invoke with -p:TestProjTargetFrameworkOverride=net8.0, a couple Lua unit tests fail. That's still the case after updating to .NET 10 (passing -p:TestProjTargetFrameworkOverride=net10.0, and you'll also need to revert the Lock alias in MainSlnCommon.props because ¯\_(ツ)_/¯).

I tried this as a sanity check, but it passes regardless of TestProjTargetFrameworkOverride, so the failure must be elsewhere in the BCL.

ArraySegment<int> a = [ ];
Assert.IsNull(a.Array);

ArraySegment<T>.Empty is .NET Standard 2.1 or later, but it might be polyfillable now with extension props.

private static readonly DiagnosticDescriptor DiagBrokenCollectionExpression = new(
id: "BHI1234",
title: "don't this",
messageFormat: "don't this",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO these were obviously meant to be placeholders

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: VS2026 supports DefaultStartup="true" in <Project element (in 2022 it's a no-op).

<Folder Name="/Client/">
<Project Path="src/BizHawk.Client.Common/BizHawk.Client.Common.csproj" />
<Project Path="src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj" />
<Project Path="src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Project Path="src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj" />
<Project Path="src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj" DefaultStartup="true" />

Apparently changes which is shown in VS2026's launch toolbar when a dev first loads the solution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem to work on VS2026, but only if the solution has't been opened before.

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

Labels

Meta Relating to code organisation or to things that aren't code re: Metaprogramming Roslyn Analyzers and Source Generators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate solution files to .slnx

4 participants