dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

Errors in ErrorList pane on lines with #line pragma doesn't navigate to the source file #34950

Closed ajaybhargavb closed 3 weeks ago

ajaybhargavb commented 5 years ago

Version Used: VS 16.1 Preview 1

Steps to Reproduce:

  1. dotnet new console
  2. Replace content of Main method with
        static void Main(string[] args)
        {
    #line 2 "Test.txt"
            Console.WriteLin("Hello World!"); // Intentional typo to show error
    #line default
        }
  3. Create a file called Test.txt and put some content in it.

Expected Behavior: Error shows in error list. Double clicking it navigates to Test.txt

Actual Behavior: Error shows in error list. Double clicking it navigates to Program.cs or does nothing. This happens on both live and build errors

Note: Putting a breakpoint in Test.txt and F5ing correctly hits that breakpoint. So it's not a file path issue.

cc @heejaechang

heejaechang commented 5 years ago

@ajaybhargavb this is by design. we could change behavior for build if we want. let me talk with other people whether we want to change this behavior.

heejaechang commented 5 years ago

@ajaybhargavb can you give us your scenario and what you are trying to do. I will bring this to design discussion.

heejaechang commented 5 years ago

this is how we work currently.

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
#line 2 "Test.txt"
            Console.WriteLin("Hello World!"); // Intentional typo to show error
#line default
        }
    }
}

we show squiggles like this

image

we show errors in error list like this for live error image

if one double click the item, it goes to where the squiggle is.

we show errors in the error list like this for build error image

if one double click the item, it goes no where.

...

duplicated item is a bug - https://github.com/dotnet/roslyn/issues/35448

but except that, other is by design.

need to decide whether we want to change design and how.

ajaybhargavb commented 5 years ago

if one double click the item, it goes to where the squiggle is.

I don't understand why this is by design. Isn't the whole point of adding a line pragma is so that the diagnostics and breakpoints actually point to the file specified in the pragma?

if one double click the item, it goes no where.

Same question.

heejaechang commented 5 years ago

@ajaybhargavb could be. people will either lose squiggle or squiggle show up in original location but error list show mapped location but, that might be completely fine for people. squiggle won't show up since we can't currently show our squiggle in some random file we don't own.

but that is the current design. our current design could be wrong, but that is how it is now.

...

except for those bug, what it currently does is trying to move users to where it can actually fix the issue.

sharwell commented 5 years ago

This went to a design review 6 May 2019. We reached the following conclusion:

CyrusNajmabadi commented 3 weeks ago

Closing out as these experiences were entirely rewritten.