Home

Rename method does not affect symbol used inside nameof()

edited September 2015
Hi, first of all, thank You for creating LinqPad. I love it!

During preparing examples for my what's new in c# 6.0 presentation i discovered a behavior that might be considered a bug.

In the following example if I try to apply rename (F2) to the method name, it does change the name in method header, but does not change the symbol used with nameof operator:
void Main()
{
        nameof(SomeMethod).Dump();
}

public static void SomeMethod()
{
        return;
}

Comments

  • Additionally, it appears, the the `nameof` operator is not displayed with color.
    It would be expected for it to be displayed similarly to `typeof`.
  • The rename failure occurs in VB.NET too. NameOf is seen as a keyword (coloured blue) but it is not known to the autocompletion dropdown.
  • Thanks for the repro. A new beta has just been uploaded to fix this.
  • It's working for simple VB.NET names, but fails to change all keyworded name references. I know it's a pedantic case, but easily reproed:
    Sub Main
        Dim t = New [Module]
        t.[Module] = NameOf(UserQuery.[Module]).Length
        t.Module = NameOf(UserQuery.Module).Length
        Dim m = GetType(Type).Module
        Dim n As System.Reflection.Module = m
    End Sub
    
    ' Define other methods and classes here
    Class [Module]
        Public [Module] As Integer
    End Class
    Attempting to change either the class or field Module, although it includes the [] in the new name irrespective of what's selected, it only changes the declaration and non-bracketed references.

    Also, note the different treatment of the tooltip for System.Reflection.Module to UserQuery.Module. Neither requires the [] when preceded by a dot and both require [] when attempted to be referred to on their own, so I don't know why there's a difference here.
  • Yes, the renamer doesn't consider [] or @ characters. This has just been fixed:

    http://www.linqpad.net/download.aspx
Sign In or Register to comment.