-
Notifications
You must be signed in to change notification settings - Fork 229
Fix explicit interface implementations #822
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
Conversation
GrahamTheCoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look to be in the right place doing the right sorts of things and the tests look as extensive as this complicated area requires. I haven't gone through and followed the logic of it all for myself, but based on those things and your previous contributions I'm happy to merge.
I'll just give you a chance to fix the minor style point and/or flag (with an inline github comment) any areas you're not sure of or would particularly like a second pair of eyes on, thanks!
|
@GrahamTheCoder Thanks, I tried to write as many tests as I can to cover some weird cases. I can still think of some rare cases that will convert incorrectly. Should I create issues for them so others are at least aware?
Interface IFoo
Property Prop As Integer
End Interface
Class Foo
Implements IFoo
Property Prop As Integer Implements IFoo.Prop
Get
End Get
Friend Set
End Set
End Property
End ClassThe converter will generate a property with an internal setter.
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;
} |
|
Great work, thanks! Sometimes I consolidate things so the overall number of issues stays managable, but I think these are sufficiently distinct so I've created them as separate issues. |
Fixes #813
Reworked explicit interface implementations for properties/parametrized properties and methods.
Now all explicit implementations have a delegate call to the implementation.
This simplifies the generated code (no casting is required) and fixes some issues like:
Property A As Integer Implements IBar.A, IFoo.B