Search

CallerMemberNameAttribute is not filled by Harry-vB

Active

1
0
Sign in
to vote
Type: Bug
ID: 776904
Opened: 1/18/2013 7:56:59 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Under some circumstances an overload for a method using the CallerMemberNameAttribute confuses the compiler.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5

What category (if any) best represents this feedback?

 

Steps to reproduce

Use this code in a VB project in VS 2012 and start Test.Run() from the Immeadiate Window:

Imports System.Runtime.CompilerServices

Public Class C
End Class

Public Class Test
    Public Sub TestCmm(ByVal c As C, <CallerMemberName> Optional ByVal member As String = Nothing)
        Debug.WriteLine(String.Format("member=""{0}""", member))
    End Sub

    Public Sub TestCmm(ByVal x As String)
        ' If you remove this overload, everything works fine
        Debug.Write("You'll never see this")
    End Sub

    Public Shared Sub Run()
        ' Output:
        'member="Run"
        'member=""
        Dim c = New C

        Dim t As New Test

        t.TestCmm(c) ' This works
        t.TestCmm(DirectCast(c, Object))

    End Sub
End Class

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

German

Actual results

member="Run"
member=""

Expected results

member="Run"
member="Run"

Locale

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/12/2013 at 2:52 PM
Hi. The VB late binder does not pass the caller's name. Since it doesn't know if it would be calling something that takes the caller's name, VB choses not to store the name for every method in case it late binds to a callee that takes it.

Bill
Posted by Microsoft on 1/20/2013 at 9:37 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/18/2013 at 8:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.