Binary compatibility?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michi Henning

    Binary compatibility?

    Hi,

    I'm interested in figuring out exactly what kind of change to an assembly
    is binary compatible. I've browsed the doc a fair bit, but I can't find a
    comprehensive list of what actually constitutes binary compatibility.
    Could someone point me at an authoritative list?

    One question in particular I am interested in. Consider an object such as this:

    class SomeClass
    {
    // ...
    public void destroy()
    {
    lock(this)
    {
    // Clean up some things here...
    _destroyed = true;
    }
    }

    #if DEBUG
    ~SomeClass()
    {
    if(!System.Envi ronment.HasShut downStarted)
    {
    lock(this)
    {
    if(!_destroyed)
    {
    System.Console. Error.WriteLine ("SomeClass wasn't
    destroyed!");
    }
    }
    }
    }
    #endif

    private bool _destroyed = false;
    }

    Note that the destructor simply checks whether destroy() was called before the
    instance is collected and that this is required only for a debug build. In
    order to
    save the cost of acquiring the lock (and to avoid the cost of calling the
    destructor
    altogether), the entire destructor is made conditional.

    Suppose I build the assembly without DEBUG defined and install it in the GAC.
    I also compile a program that uses the assembly, but both the program and the
    assembly are compiled *with* DEBUG defined. If I then later take the program
    (but not the assembly) and run the program compiled *with* DEBUG against
    the assembly compiled *without* DEBUG, will the program still work?

    Cheers,

    Michi.

    --
    Michi Henning Ph: +61 4 1118-2700
    ZeroC, Inc. http://www.zeroc.com

  • Mattias Sjögren

    #2
    Re: Binary compatibility?

    >I'm interested in figuring out exactly what kind of change to an assembly[color=blue]
    >is binary compatible. I've browsed the doc a fair bit, but I can't find a
    >comprehensiv e list of what actually constitutes binary compatibility.
    >Could someone point me at an authoritative list?
    >
    >One question in particular I am interested in. Consider an object such as this:
    >
    >class SomeClass[/color]

    Changes to non-public classes will not break compatibility.

    [color=blue]
    >Suppose I build the assembly without DEBUG defined and install it in the GAC.
    >I also compile a program that uses the assembly, but both the program and the
    >assembly are compiled *with* DEBUG defined. If I then later take the program
    >(but not the assembly) and run the program compiled *with* DEBUG against
    >the assembly compiled *without* DEBUG, will the program still work?[/color]

    For public classes, removing the finalizer is indeed a potentially
    breaking change (unless the class is sealed). But unless you have
    other classes derived from such a class, it doesn't matter and it
    should work anyway.



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Richard Blewett [DevelopMentor]

      #3
      Re: Binary compatibility?

      Why would removing the finalizer be a breaking change?

      Regards

      Richard Blewett - DevelopMentor




      For public classes, removing the finalizer is indeed a potentially
      breaking change (unless the class is sealed). But unless you have
      other classes derived from such a class, it doesn't matter and it
      should work anyway.



      Comment

      • Mattias Sjögren

        #4
        Re: Binary compatibility?

        [color=blue]
        >Why would removing the finalizer be a breaking change?[/color]

        My bad, it isn't. I seemed to remember that removing an override
        somewhere in the middle of the inheritance hierarchy would generate a
        MissingMethodEx ception when a derived class called the base method,
        but clearly it doesn't and I guess that's a good thing.



        Mattias

        --
        Mattias Sjögren [MVP] mattias @ mvps.org
        http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
        Please reply only to the newsgroup.

        Comment

        Working...