This may just be how Python works, but I wanted to check with you guys first.

Say I have an assembly named MyLibrary that contains the following code:
namespace MyLibrary
{
 public interface IMyInterface
 {
   string MyProperty{ get;}
 }
 public class MyClass : IMyInterface
 {
   string IMyInterface.MyProperty
   {
     get { return "MyInterface version of MyProperty"; }
   }
   public string MyProperty
   {
     get { return "MyClass version of MyProperty"; }
   }
   public static IMyInterface GetInterface(){ return new MyClass();}
   public static MyClass GetClass() { return new MyClass(); }
 }
}
-------------------------------------------------------------
A console application with the following code
 MyLibrary.IMyInterface a = MyLibrary.MyClass.GetInterface();
 Console.WriteLine("MyInterface call = " + a.MyProperty);
 MyLibrary.MyClass b = MyLibrary.MyClass.GetClass();
 Console.WriteLine("MyClass call = " + b.MyProperty);

Will produce the following output:
 MyInterface call = MyInterface version of MyProperty
 MyClass call = MyClass version of MyProperty
-------------------------------------------------------------

Now if I use IronPython and write a script that looks like the following

import clr
clr.AddReference("MyLibrary")
import MyLibrary
a = MyLibrary.MyClass.GetInterface()
print "MyInterface call = ", a.MyProperty
b = MyLibrary.MyClass.GetClass()
print "MyClass call = ", b.MyProperty

The output of this script is
MyInterface call = MyClass version of MyProperty
MyClass call = MyClass version of MyProperty

I've been testing IronPython on our CAD application and everything has been working great except for this issue. It is actually a pretty big issue for me because the way I wrapped our C++ SDK for .NET uses this feature quite a bit. If this is the expected result in python, is there a way to force the interface version of the property_get function to be called?

Thanks,
-Steve

Steve Baer
Robert McNeel & Associates
www.rhino3d.com
www.mcneel.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to