Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: DefaultMemberAttribute marked properties are lost #1144

Open
TymurGubayev opened this issue Oct 25, 2024 · 0 comments
Open

VB -> C#: DefaultMemberAttribute marked properties are lost #1144

TymurGubayev opened this issue Oct 25, 2024 · 0 comments
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@TymurGubayev
Copy link
Contributor

VB.Net input code

We need a C# project with a class like this:

[System.Reflection.DefaultMember(nameof(Caption))]
public class ClassWithReflectionDefaultMember
{
    public string Caption { get; set; }
}

Then in VB.NET, access its DefaultMember:

<System.Reflection.DefaultMember(NameOf(LoosingProperties.Caption))>
Public Class LoosingProperties
    Public Property Caption As String

    Sub S()
        Dim x = New LoosingProperties()
        x.Caption = "Hello"

        Dim y = New ClassWithReflectionDefaultMember() 'from C#
        y.Caption = "World"
    End Sub
End Class

Erroneous output

[System.Reflection.DefaultMember(nameof(Caption))]
public class LoosingProperties
{
    public string Caption { get; set; }

    public void S()
    {
        var x = new LoosingProperties();
        x.Caption = "Hello"; // works differently for equivalent VB.NET class

        var y = new ClassWithReflectionDefaultMember(); // from C#
        y = "World"; // <----- notice `.Caption` is missing here
    }
}

Expected output

[System.Reflection.DefaultMember(nameof(Caption))]
public class LoosingProperties
{
    public string Caption { get; set; }

    public void S()
    {
        var x = new LoosingProperties();
        x.Caption = "Hello";

        var y = new ClassWithReflectionDefaultMember(); // from C#
        y.Caption = "World";
    }
}

Details

  • Product in use: VS extension
  • Version in use: bc365b0
  • Did you see it working in a previous version, which? no
  • Any other relevant information to the issue, or your interest in contributing a fix.
@TymurGubayev TymurGubayev added the VB -> C# Specific to VB -> C# conversion label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

1 participant