dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.28k stars 5.91k forks source link

We should add a note that CS0169 is a "Build-only" diagnostic #26708

Open mavasani opened 3 years ago

mavasani commented 3 years ago

CS0169 warning is reported by the compiler only during explicit "Build" or "Rebuild" operations, it does not get reported during typing in the IDE, i.e. as part of intellisense diagnostics. This means that if the user edits code such that it fixes the warning OR deletes the unused field, the warning still remains in the error list and the corresponding stale squiggle also persists until the user builds or rebuilds the project again.

As this behavior is different from majority of compiler warnings/errors, which automatically refresh while typing, it leads to lot of user confusion. We have had multiple feedback tickets, such as https://developercommunity.visualstudio.com/t/CS0169-Warnings-do-not-vanish-after-prob/1551348, and adding this note to the doc page for this warning will likely help. We can also point to this documentation note while resolving such feedback tickets.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

mavasani commented 3 years ago

Another feedback ticket for the same issue: https://developercommunity.visualstudio.com/t/Intellisense-continue-reporting-errors-a/1547853

Youssef1313 commented 3 years ago

Should also apply to all these warnings/errors?

https://github.com/dotnet/roslyn/blob/5c3f1e9ddadfc5c5190a5f283fd00db4b456ab78/src/Compilers/CSharp/Portable/Compilation/CSharpCompilerDiagnosticAnalyzer.cs#L43-L79

I'm also wondering what were the reasons for live error to not support this?

BillWagner commented 2 years ago

Related to #24002

mavasani commented 2 years ago

Reported again by a customer in https://github.com/dotnet/roslyn/issues/63164.

@BillWagner can we please add this documentation note for CS0169 first? Multiple users have now reported this issue for this ID.

mavasani commented 2 years ago

Reported again by a customer in https://developercommunity.visualstudio.com/t/Showing-suggestion-for-thing-that-is-no-/10150898, but for another build-only compiler diagnostic CS0649.

All the C# compiler error codes which are build-only diagnostics are listed here: https://github.com/dotnet/roslyn/blob/e263437db49b0650dbc72fca3331df654e05987c/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs#L531-L573 and will have the same behavior as CS0169. All the C# error codes are defined in this file.

We should update the documentation for all these error codes to add a note about them being build-only diagnostics.

mavasani commented 2 years ago

Tagging @arkalyanms as an FYI. We have been receiving quite a few VS user feedback reports for stale compiler diagnostic squiggles/error list entries for build-only compiler diagnostics, that can only be refreshed with explicit build/rebuild command and not from background analysis.

mavasani commented 2 years ago

Reported again by another customer at https://developercommunity.visualstudio.com/t/VS-2022-C-editor-has-gone-nuts/10162597.

Apart from this docs issue, I am also going to prioritize https://github.com/dotnet/roslyn/issues/64659.