Skip to content

Clear warnings about conflicting types#579

Merged
notfood merged 1 commit intorwmt:devfrom
ianleeder:clear-warnings-cs0436
Jul 19, 2025
Merged

Clear warnings about conflicting types#579
notfood merged 1 commit intorwmt:devfrom
ianleeder:clear-warnings-cs0436

Conversation

@ianleeder
Copy link

This resolves 4 compiler warnings.

Based off this comment, CS0436 looks like this:

\Source\Common\Util\Endpoints.cs(10,66): warning CS0436: The type NotNullWhenAttribute in \Source\Common\Util\CompilerTypes.cs conflicts with the imported type NotNullWhenAttribute in mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Using the type defined in \Source\Common\Util\CompilerTypes.cs.

Basically some newer features from .NET Core have been replicated in this codebase to support .NET Framework. In other languages we'd call this a polyfill.

It turns out to be harder to disable this in-code than expected, because the compiler warns on a generated file:

\Source\MultiplayerLoader\obj\Debug\MultiplayerLoader.AssemblyInfo.cs(13,44): warning CS0436: The type 'IgnoresAccessChecksToAttribute'...

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

// The class IgnoresAccessChecksToAttribute triggers this warning
[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute("0Harmony")]
[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute("Assembly-CSharp")]

And the generated file is... regenerated on each build. Changes do not persist.

So instead of suppressing on a case-by-case basis (which was already a flimsy solution), we can simply suppress this warning in .editorconfig.

There is also some serious irony that the file specifying that trailing whitespace should be eliminated contained trailing whitespace:
image

@notfood notfood merged commit c8caa89 into rwmt:dev Jul 19, 2025
1 check passed
@ianleeder ianleeder deleted the clear-warnings-cs0436 branch July 19, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants