none
.NET 4.0 compatibility unexpectedly broken by class refactoring RRS feed

  • Question

  • In the simplified before and after below, "Class A Property A_ToStayWithDerived" is referenced in other binaries.  Those references are failing, even though the property is not moved into the base class.  In fact, the entire Public+Friend interface for Class A remains identical.  Some methods are moved back to the base class, that's all.  Is there a project compile setting I could have used to prevent this?

    BEFORE:

    Class A

    Public Property A_ToBecomeBase

    Public Property A_ToStayWithDerived

    End Class

    AFTER:

    Class A Inherits B

    Property A_ToStayWithDerived

    End Class

    Class B

    Property A_ToBecomeBase

    End Class

    Wednesday, February 15, 2012 7:28 PM

Answers

  • "In fact, the entire Public+Friend interface for Class A remains identical."

    Unfortunately, it isn't identical here.  The problem is that you've introduced a new part of the interface - the inheritance itself.  By making Class A inherit class B, you're changing the public API, which will break compability.

    Also, in your sample code above, your Property "A_ToStayWithDerived" is no longer Public - which again, would change the public API surface.  I'm not sure if this is intentional or not...

    That being said, provided you make the properties Public, you should still have compile time compability here, but this does change the public API, which will force a recompile in order to work. 


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Paul Zhou Thursday, February 23, 2012 8:52 AM
    Wednesday, February 15, 2012 7:33 PM
    Moderator