-
Notifications
You must be signed in to change notification settings - Fork 233
Rare MyClass case converts incorrectly #827
Copy link
Copy link
Open
Labels
Good for coding agentCoding agent might get it in one - small change with reproCoding agent might get it in one - small change with reproVB -> C#Specific to VB -> C# conversionSpecific to VB -> C# conversionoutput logic errorA bug where the converted output behaves differently to the input codeA bug where the converted output behaves differently to the input code
Description
Accessing backing field of the autogenerated property where MyClass is involved:
Class Foo
Overridable Property Prop As Integer = 5
Sub Test()
_Prop = 10 ' This should convert to MyClassProp = 10 not to Prop = 10
Dim isCorrect = MyClass.Prop = 10 ' After conversion this will return 5instead of 10 because we wrote to Child.Prop
End Sub
End Class
Class Child
Inherits Foo
Overrides Property Prop As Integer = 20
End Class public class Foo
{
public int MyClassProp { get; set; } = 5;
public virtual int Prop
{
get => MyClassProp;
set => MyClassProp = value;
}
public void Test()
{
Prop = 10; // This should convert to MyClassProp = 10 not to Prop = 10
bool isCorrect = MyClassProp == 10; // After conversion this will return 5 instead of 10 because we wrote to Child.Prop
}
}
public class Child : Foo
{
public override int Prop { get; set; } = 20;
}Originally posted by @Yozer in #822 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Good for coding agentCoding agent might get it in one - small change with reproCoding agent might get it in one - small change with reproVB -> C#Specific to VB -> C# conversionSpecific to VB -> C# conversionoutput logic errorA bug where the converted output behaves differently to the input codeA bug where the converted output behaves differently to the input code