Instantly share code, notes, and snippets.

Embed
What would you like to do?
IronPython virtual getter/setter bug
public class Base {
public virtual int Accessor {
get; set;
}
}
public class GetOverride: Base {
public override int Accessor {
get {
return base.Accessor - 1;
}
}
}
public class SetOverride: Base {
public override int Accessor {
set {
base.Accessor = value + 1;
}
}
}
// You can run this using csharp.exe that comes with Mono
// This runs fine, despite that the IronPython version does not.
LoadAssembly("VirtualAccessors.dll");
var s = new SetOverride();
var g = new GetOverride();
s.Accessor = 1;
s.Accessor;
g.Accessor = 1;
g.Accessor;
# This fails with the following messages:
# SetOverride getter failed.
# GetOverride setter failed.
import sys
import clr
clr.AddReference("./VirtualAccessors.dll")
import SetOverride, GetOverride
s = SetOverride()
g = GetOverride()
try:
s.Accessor = 1
except:
print >>sys.stderr, "SetOverride setter failed."
try:
s.Accessor
except:
print >>sys.stderr, "SetOverride getter failed."
try:
g.Accessor = 1
except:
print >>sys.stderr, "GetOverride setter failed."
try:
g.Accessor
except:
print >>sys.stderr, "SetOverride getter failed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment