Skip to content

Disable CS8002 warning when targeting .NET Core#80596

Merged
jaredpar merged 10 commits intomainfrom
copilot/disable-cs8002-warning-dotnet-core
Oct 14, 2025
Merged

Disable CS8002 warning when targeting .NET Core#80596
jaredpar merged 10 commits intomainfrom
copilot/disable-cs8002-warning-dotnet-core

Conversation

Copy link
Contributor

Copilot AI commented Oct 8, 2025

  • Add CS8002 suppression to Microsoft.CSharp.Core.targets for .NETCoreApp
  • Add CS8002 suppression to Microsoft.VisualBasic.Core.targets for .NETCoreApp
  • Add tests to verify target files can be imported for different frameworks
  • Update comment text to be more specific about why CS8002 is not relevant
  • Convert test code snippets to use raw string literals (""")
  • Rename tests and add documentation about expected behavior for NoWarn property
  • Rename suppressStrongName to expectStrongNameSuppression in test methods
  • Build and test the changes - all tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Disable CS8002 when targeting .NET Core</issue_title>
<issue_description>The warning CS8002 is not relevant when targeting .NET core and should be disabled. This needs to be done at the MSBuild level because that understands target frameworks while the compiler does not. Specifically the Microsoft.CSharp.Core.targets and Microsoft.VisualBasic.Core.targets files should be updated to include <NoWarn>$(NoWarn);8002</NoWarn> when the MSBuild property TargetFrameworkIdentifier is .NETCoreApp.

This should look similar to and be placed next to existing <NoWarn> suppressions for target frameworks. Example being here

<PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
<NoWarn>$(NoWarn);1701;1702</NoWarn>
</PropertyGroup>

Note: this is a dupe of #76197</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #80595

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 8, 2025 18:43
Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com>
Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com>
Copilot AI changed the title [WIP] Disable CS8002 warning when targeting .NET Core Disable CS8002 warning when targeting .NET Core Oct 8, 2025
Copilot AI requested a review from jaredpar October 8, 2025 18:49
…ests

Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com>
Copilot AI requested a review from jaredpar October 9, 2025 00:05
<PackageReference Include="Mono.Options" />
<PackageReference Include="MSBuild.StructuredLogger" />
<PackageReference Include="Basic.CompilerLog.Util" />
<packageReference Include="MessagePack" VersionOverride="3.1.4" />
Copy link
Member

Choose a reason for hiding this comment

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

Basic.CompilerLog.Util uses the 3.x flavor of MessagePack. Cannot upgrade our core version so had to do a version override here.

@jaredpar
Copy link
Member

@dotnet/roslyn-compiler PTAL

@jaredpar jaredpar marked this pull request as ready for review October 10, 2025 20:57
@jaredpar jaredpar requested review from a team as code owners October 10, 2025 20:57
Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

Note that you do need to enable strong naming in a compilation, in order to get any warnings about references lacking strong naming. That means that people who get this warning have that setting enabled by some mechanism.

That said, there's nothing wrong with blocking the warning regardless due to lack of platform support in netcore.

[InlineData("net6.0", true)]
[InlineData("netstandard2.0", false)]
[InlineData("net472", false)]
public void StrongNameWarningCSharp(string tfm, bool suppressStrongName)
Copy link
Member

Choose a reason for hiding this comment

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

I think suppressStrongName should be renamed to expectStrongNameSuppression to reflect its purpose (whether the tfm argument results in strong name warnings being suppressed.)

Copy link
Member

Choose a reason for hiding this comment

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

@copilot rename suppressStrongName to expectStrongNameSuppression

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to expectStrongNameSuppression in commit that will be pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to expectStrongNameSuppression in commit that will be pushed.

[InlineData("net6.0", true)]
[InlineData("netstandard2.0", false)]
[InlineData("net472", false)]
public void StrongNameWarningVisualBasic(string tfm, bool suppressStrongName)
Copy link
Member

Choose a reason for hiding this comment

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

Suggest doing the same rename here.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot rename suppressStrongName to expectStrongNameSuppression

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to expectStrongNameSuppression in commit that will be pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to expectStrongNameSuppression in commit that will be pushed.

Co-authored-by: Rikki Gibson <rigibson@microsoft.com>
…ationTests

Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com>
Copilot AI requested a review from jaredpar October 10, 2025 21:44
@jaredpar jaredpar enabled auto-merge (squash) October 10, 2025 22:09
@jaredpar jaredpar merged commit 6e00487 into main Oct 14, 2025
27 of 28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 14, 2025
@CyrusNajmabadi CyrusNajmabadi deleted the copilot/disable-cs8002-warning-dotnet-core branch December 2, 2025 11:53
@davidwengier davidwengier modified the milestones: Next, 18.3 Jan 6, 2026
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.

Disable CS8002 when targeting .NET Core

6 participants