[Mono-devel-list] Assembly binary compatibility?

Ben Maurer bmaurer at ximian.com
Wed May 4 18:59:55 EDT 2005


On Wed, 2005-05-04 at 11:45 -0400, Ben Maurer wrote:
> > Safe to add a private method or data member?
> 
> Private method -- always.

I take this back. There is a corner case where it is not safe:

foo.cs:

public class BaseThingy {
	public virtual void DoIt () {
		Console.WriteLine ("BaseThingy.DoIt");
	}
}

public class Thingy : BaseThingy {
#if V2
	private new void DoIt () {
		Console.Write ("Thingy.DoIt");
	}
#endif
}

client.cs:

using System;

class Foo : Thingy {
	static void Main ()
	{
		new Foo ().DoIt ();
	}
	
	public override void DoIt () {
		System.Console.WriteLine ("Foo is about to do it");
		base.DoIt ();
	}
}

-----

If client.cs is compiled with v1 of foo.cs and run with v2, it will end
up calling the DoIt method in Thingy, which is private, and will cause
an assertion (mono may not enforce this assertion today).

I added this comment in the bug.

-- Ben




More information about the Mono-devel-list mailing list