>>> import clr
>>> clr.AddReference("System")
<System.Reflection.Assembly object at 0x899c94c>
>>> clr.AddReference("System")
<System.Reflection.Assembly object at 0x8990eac>
>>> clr.AddReference("System")
<System.Reflection.Assembly object at 0x899c98c>
>>> list(clr.ListAssemblies(False))
[u'Mono.Posix', u'System', u'System.Configuration', u'System.Xml', u'Mono.Security', u'e__NativeCall_Assembly', u'Python.Runtime', u'mscorlib', u'System', u'System', u'System']
1) I don't see existence of, the [...,, u'System', u'System', u'System'] artifact in the current (CLR 2.0) implementation. There are no checks in the AssemblyLoadHandler() method, but it is not called multiple times for a repeated load of a particular assemble by the framework (on Windows, anyway).
2) Two possible solutions for the unique object reference returned by AddReference() (it does seem reasonable to always get the same instance):
a) Implement Assembly as a managed type
b) (I've done this in my version) Wrap the assembly in a ModuleObject and store it CLRModle.dict on the first call. On subsequent calls, retrieve it from the dict.
Any comment?
- Barton
In either case, Converter.ToPython(value, type) must allow some type of ManagedType to be returned OR some Attribute may be applied in order to return the raw results.