-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Incorrect error codes reported #47736
Comments
This is an intended result of the "better obsoletion" feature (#42119). Per the proposal:
Tagging @terrajobst |
@RikkiGibson I think the complaint here is because the explicit id is shown in Visual Studio but not Visual Studio Code. |
@RikkiGibson the problem is that build fails without clear indication of what is wrong - see the failed builds I've linked. VS doesn't fail the build, it only shows warnings (this is another big issue), but those warnings are too totally misleading. And only by hovering with a mouse I found that in fact I need to suppress different warnings. This is a very-very bad user experience. I've lost 3 hours yesterday because of this. |
The screen shots you indicate of the compilation process have clear error messages associated with them. Is your complaint about how the IDE displays them? If so then can you show us what the error list looks like?
Not easy to tell from your issue description what the VS behavior is. The screen shots you provided demonstrate the command line compiler issuing an error and a quick info screen shot. |
No, it tells me that it failed due to CS0618, which are suppressed in the code. In fact it failed due to SYSLIB0011, which I needed to suppress. |
Sorry, I misunderstood the issue to mean "I updated my .NET SDK version and now my CS0618 suppressions no longer work".
Is this a bug? e.g. you have a property in your project like
My best guess for what is wrong is the compiler is pinned to an old version in command line builds (i.e. pre Roslyn 3.6/VS 16.6) but not in VS design time builds. I believe common methods of pinning the compiler version, such as adding a MicrosoftNetCompilersToolsetVersion in an arcade project, are not respected in the VS editor, and only affect command line builds. I tried to create a minimal reproducer for the problem: using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public class C
{
static void M1(
BinaryFormatter binaryFormatter,
Stream stream)
{
#pragma warning disable CS0618
binaryFormatter.Serialize(stream, new object());
#pragma warning restore CS0618
}
} Using dotnet sdk: > dotnet --version
5.0.100-rc.1.20452.10
> dotnet build /t:rebuild
Microsoft (R) Build Engine version 16.8.0-preview-20451-02+51a1071f8 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
C:\Users\rikki\src\net5scratch\Program.cs(11,9): warning SYSLIB0011: 'BinaryFormatter.Serialize(Stream, object)' is obsolete: 'BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.' [C:\Users\rikki\src\net5scratch\net5scratch.csproj]
net5scratch -> C:\Users\rikki\src\net5scratch\bin\Debug\net5.0\net5scratch.dll
Build succeeded.
C:\Users\rikki\src\net5scratch\Program.cs(11,9): warning SYSLIB0011: 'BinaryFormatter.Serialize(Stream, object)' is obsolete: 'BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.' [C:\Users\rikki\src\net5scratch\net5scratch.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.77 Building in VS 16.8-preview3:
Also found equivalent behavior when hovering on the squiggle or checking the Error List in VS or VS Code--the text mentions SYSLIB0011, not CS0618. |
Would you be able to point me where is this set? I'm not quite sure what's going on. I also built it in VS 16.8.0 Preview 4.0 [30515.18.main] and it failed for some other unrelated reason (cmake). So there are two issues here.
What am I missing? |
I apologies if I come across rude, I don't mean it. This is just stressing me out. |
Please try adding
Thanks, I appreciate you saying that. |
From VS I get this:
|
From cli I get this:
|
Hmm. The versions are different but only by about a week: a Sept 11th build in VS and a Sept 2nd build in CLI. 90e570d...d885b79. I do not think changes that would affect handling custom obsolete diagnostics went in during that time. My next guess is that the SDKs in use are different between the different build environments, and the Obsolete attributes on standard library types are different between the two SDKs. It seems like the Obsolete attribute changes went in preview8: dotnet/runtime#39269 |
I tried reproducing this on my machine using VS 30514.8 and I'm getting what I believe is the correct behavior:
To reproduce I just cloned the winforms repo, opened in VS and hit build. This matches my intuition about how the feature is expected to work. Essentially the diagnostic produced by the compiler now prefers the one in the attribute over our generic diagnostic code. It appears we are consistently doing this in the repo and it's flowing through the IDE correctly. Maybe I'm missing a step in the repro but this appears correct. I agree this diagnostic code change can be a bit jarring but it was part of the explicit design: @GrabYourPitchforks @terrajobst can comment on their desire for having this experience and what the motivations were. @mavasani just for visibility that there may be some experience inconsistency here in the various VS builds. Compiler Output Error List |
One thing I totally forgot to mention (sorry), to start Windows Forms solution in VS you need to run:
This will restore the necessary dependencies and set env vars for VS. |
@jmarolf and I are taking a look at this now |
Thank you heaps. I had an offline chat with @jaredpar, few things may be worth adding here:
But because we need to point VS to the SDK/tooling we want we prepend the local dotnet path to the process PATH (via start-vs.cmd). So VS should use of the following:
|
I agree with the premise that the console output should clearly show the Related issue #47310 might also help here. In the case of |
I found that |
Thanks to @jmarolf for helping me track this down. I suppose this bug didn't have the chance to negatively impact more people since corefx didn't add custom diagnostic IDs until recently. |
Do I need to raise a separate issue for VS not failing a build, or would this be related? |
Well, it appears that .\Build.cmd somehow or another is passing |
@RikkiGibson |
With |
Ah okay. That would definitely explain the results I saw when I tried to reproduce this. I was using it without warnings as errors hence everything looked just fine. Good catch! |
@RussKie for a short-term workaround you might be able to change your pragmas to suppress the custom diagnostic ID as well as the old non-custom ID, e.g. edit: Actually the workaround I suggested is pointless 😉 disabling the explicit diagnostic ID works, even if the diagnostic ID is reported incorrectly. |
Version Used:
I'm updating Windows Forms SDK/toolset from P6 to RC1, and our builds fail with errors which we have already suppressed. E.g.:
It appears instead of
CS0618
we must now be suppressingSYSLIB0011
but I had to spend time to figure it out on my own.Likewise we have other failures, e.g.
...and only VS is telling me that I now need to suppress a different one:
Few builds:
Steps to Reproduce:
.\build.cmd
Expected Behavior:
Errors must either correctly report codes or use the existing suppression rules.
The text was updated successfully, but these errors were encountered: