Home Dashboard Directory Help
Search

Provide automatic resolutions to "The name 'X' does not exist in the current context" compile errors by johndog


Status: 

Closed
 as Won't Fix Help for as Won't Fix


1
0
Sign in
to vote
Type: Suggestion
ID: 366483
Opened: 9/7/2008 12:18:08 AM
Access Restriction: Public
0
Workaround(s)
view

Description

The "The name 'X' does not exist in the current context" error is a fairly common compiler error, but most of the time VS has access to all the information the user will need to resolve the problem.

This suggestion is to provide a context menu option on location for those errors that provide the user ways to resolve it, if VS can find any.


For example: The name 'MessageBox' does not exist in the current context.    

'MessageBox' is an obvious example of a class defined in one of Microsoft's common namespaces. If I right-click on this error, it would save me substantial time if I could select "Resolve with 'using System.Windows.Forms'" from the context menu.
Details
Sign in to post a comment.
Posted by johndog on 9/10/2008 at 8:43 AM
This feature is extremely undiscoverable. For a long time I thought that the smart tag never appeared. However, since I was looking for it, I discovered that if I put the actual insertion point on the item with an error, *then* hovered over it, the smart tag appears. If the insertion point is anywhere else, then hovering over an item simply displays the error messag.e

If one thinks they can resolve something without typing, they have no reason to click on it. This is the model in revising a word document. So, the user develops the practice of not clicking on something to move the insertion point there *unless* they have something to type. Ergo, the smart tag won't appear until the user already knows how to resolve it themselves. And of course if the resolution is to add a 'using' statement, they would never even click on the word with the blue squiggly because the fix is somewhere else.

I'm guessing this is actually a bug, so I'm going to open a feedback item for it.
Posted by Microsoft on 9/8/2008 at 11:05 PM
johndog,

Thanks for submitting this suggestion! Below are some responses to your various suggestions:

- Correct the spelling of the error'd item
>>> [DJ] This is something that we've heard feedback on before. Although we won't be able to address it in this upcoming release, we'll definately be reconsidering as we kick off our planning for the next release.

- Change the name to Qualify it with one of a number of namespaces that provide a definition of the name (putting emphasis on those namespaces whose types actually match the usage)
>>> [DJ] When you have a type that isn't in scope, but is available in another namespace, you can use the Add Using feature to fully qualify the type name. You can access the Add Using feature by invoking the smart tag that shows up under the unbound type name. (you can invoke the smart tag by either hovering over the blue rectangle or by simply pressing ctrl + . when the blue rectable is showing).

- Add 'using <namespace>' to the top of the file for any of a number of namespaces that provide a definition of the name (again putting emphasis on those namespaces whose types actually match the usage)
>>> [DJ] The Add Using feature also offers the option to add a using directive at the top of the file. You can invoke it the same way as described in the previous point.

- Stretch: Add required assembly and namespace for the given type.
>>> [DJ] This is another suggestion we've heard plenty of times but once again, we won't be able to address it in this upcoming release. We'll be reconsidering during our next planning cycle.

Given that we will not be able to address the entire suggestion in this upcoming release, I'm going to resolve this bug as a Won't Fix but please be assured that all these suggestions have been recorded in our internal suggestions list and will be reconsidered as we begin planning for the next release. If you have any questions/concerns, feel free to shoot me an email at djpark@microsoft.com.

Thanks!
DJ Park
C# IDE PM
Sign in to post a workaround.