Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings CS1701 and CS1702 should be removed #19640

Open
nguerrera opened this issue May 19, 2017 · 7 comments · May be fixed by #66313
Open

Warnings CS1701 and CS1702 should be removed #19640

nguerrera opened this issue May 19, 2017 · 7 comments · May be fixed by #66313

Comments

@nguerrera
Copy link
Contributor

nguerrera commented May 19, 2017

These warnings assume runtime behavior that only holds on full .NET framework: that you need to supply "policy" to bind a ref to a lower assembly to a higher version. This means that the warnings have to be disabled when targeting other .NET platforms

Furthermore, even when targeting .NET Framework, msbuild will also warn and so removing these warnings doesn't prevent our greater build ecosystem from diagnosing the issue where it actually applies. Plus, msbuild actually understands app.config binding redirects in making the call on whether to warn, and it can even generate a correct one for you (via AutoGenerateBindingRedirects=true), which it recommends in its warning.

These warnings have had to be disabled in project templates for a long time. Searching for "NoWarn" 1701 on GitHub yields 250K results: https://github.com/search?q=NoWarn+1701&type=Code&utf8=%E2%9C%93

dotnet/sdk disables them for you to avoid cluttering your csproj, but this opens up issues around the ordering of NoWarn between user and SDK. I'd like to get the SDK out of the business of disabling warnings. Over the past several years, the only times I see 1701 is when a build misconfiguration has undone a vital NoWarn, and nobody can decipher the message. e.g. dotnet/sdk#1205

@nguerrera
Copy link
Contributor Author

Just found something funny: The core compiler targets actually try to disable it for anything other than ancient .NETFramework v1.0 or v1.1:

<!-- These two compiler warnings are raised when a reference is bound to a different version
than specified in the assembly reference version number. MSBuild raises the same warning in this case,
so the compiler warning would be redundant. -->
<PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
<NoWarn>$(NoWarn);1701;1702</NoWarn>
</PropertyGroup>

This doesn't check TFM so it started showing up in .NETStandard and .NETCoreApp 1.0 and 1.1!

We should just remove this from the targets and delete the warnings.

vincentkam added a commit to vincentkam/mongo-csharp-driver that referenced this issue Aug 20, 2018
Suppress warnings in test projects caused by a bug in the Roslyn compiler when targeting .NET Core 1.0 (see dotnet/roslyn#19640)
vincentkam added a commit to vincentkam/mongo-csharp-driver that referenced this issue Aug 27, 2018
Suppress warnings in test projects caused by a bug in the Roslyn compiler when targeting .NET Core 1.0 (see dotnet/roslyn#19640)
vincentkam added a commit to vincentkam/mongo-csharp-driver that referenced this issue Aug 27, 2018
Suppress warnings in test projects caused by a bug in the Roslyn compiler when targeting .NET Core 1.0 (see dotnet/roslyn#19640)
@jinujoseph jinujoseph modified the milestones: 16.0, 16.3 Jun 9, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 8, 2019
menees added a commit to menees/SharpScript that referenced this issue Mar 14, 2022
These two warnings have been deprecated for years in project templates and by the SDK.  dotnet/roslyn#19640

In .NET Framework 4.8 these warnings cause complaints about System.IO.Compression.FileSystem, Version=4.0.0.0 not matching with System.IO.Compression, Version=4.2.0.0. However, the default runtime policy of using the newer version is fine.
@Dean-NC
Copy link

Dean-NC commented Aug 6, 2022

Still hanging around in VS 2022 17.2

@stevenvolckaert
Copy link

I confirm this is still the case in Visual Studio 2022 17.4.2

@Youssef1313
Copy link
Member

It looks like if a project doesn't define <NoWarn>, the SDK will automatically set CS1701 and CS1702.

https://github.com/dotnet/sdk/blob/1139facea93c648f5afe8f8e8d802396dc6fdabc/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L15

So it looks like a typical simple project will have these suppressed automatically by the SDK.

@jcouv Any concerns removing these from the compiler?

@jcouv
Copy link
Member

jcouv commented Jan 4, 2023

@Youssef1313 I conferred with Jared and he'd be fine to remove them.

@jaredpar
Copy link
Member

jaredpar commented Jan 4, 2023

The only issue is I'm not exactly sure if there is any particular process we need to follow when removing a warning from the compiler. Items that need to be considered are:

  1. What happens when a /nowarn for a non-existent diagnostic happens?
  2. What happens when a /warn or /warnaserror happens for a non-existent diagnostic?

These may have simple answers, I haven't looked, but they need to be validated. Another option may be to just leave the diagnostics in place but set them to disabled by default.

@Youssef1313
Copy link
Member

@jaredpar I think they will (or at least should) be ignored

@Youssef1313 Youssef1313 linked a pull request Jan 8, 2023 that will close this issue
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
@jcouv jcouv moved this to Active/Investigating in Compiler: Julien's umbrellas Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants