IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

How should clr.AddReference handle type forwarder? #697

Open ironpythonbot opened 9 years ago

ironpythonbot commented 9 years ago

Given a to-be-forwarded type,
namespace NSwForwardee { public class Foo { public static int A = 120; } }

and the forwarder:
[assembly: TypeForwardedTo(typeof(NSwForwardee.Foo))]

the following python code fails:
clr.AddReference("typeforwarder")
import NSwForwardee  # will fail

But if the forwarder has another non-forwarding type, say:
namespace NSwForwardee { public class Bar { public static int A = -120; } }

the same sequence:
clr.AddReference("typeforwarder")
import NSwForwardee  # works
NSwForwardee.Foo.A  # works
NSwForwardee.Bar.A  # works

In the current reflection implementation, Assembly.GetTypes will not return the forwarded type, but Assembly.GetType(name) will try to load the forwarded type.

Work Item Details

Original CodePlex Issue: Issue 24030 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 28, 2009 at 12:36 AM Reported by: dfugate Updated on: Feb 22, 2013 at 2:11 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. Test: test_reachtype.py CreatedDate: 8/14/2007 NewInternalID: 410017 OldInternalID: 291692 AreaPath: IronPython

Plaintext Attachments

CodePlex Issue #24030 Plain Text Attachments

ironpythonbot commented 9 years ago

On 2011-01-08 22:11:11 UTC, rjnienaber commented:

The following error is produced in 2.6.2/2.7b1 on .NET 4.0.30319.1:

Traceback (most recent call last): File "24030.py", line 55, in ImportError: No module named Forwardee

Added a testcase that reproduces the behaviour.