You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
F# records are not accesssible if generic and inside a module #574
fromclrimportMyNamespaceMyNamespace.MyRecordA# OkMyNamespace.MyRecordB[System.String] # OkMyNamespace.MyModule.MyRecordC# OkMyNamespace.MyModule.MyRecordD[System.String] # AttributeError: type object 'MyModule' has no attribute 'MyRecordD'
I noticed that dir(MyNamespace) contains 'MyRecordA', 'MyRecordB', 'MyRecordB`1' while dir(MyNamespace.MyModule) only contains 'MyRecordC', 'MyRecordD`1' but no 'MyRecordD'.
@stevehv also what happens when you try accessing your F# record without clr.? That should not be required for .NET namespaces imported properly through pythonnet - they should act like normal Python namespaces.
Owing to some sleep deprivation the problematic F# code was not what I originally thought it was.
I have updated the original issue so that it is now reproducible, apologies for any confusion.
Accessing without clr. did not make a difference. getattr did not work either:
getattr(MyNamespace.MyModule, 'MyRecordD`1')[System.String] # TypeError: no type matches params
MyNamespace.MyModule.MyRecordD.Overloads
AttributeError: type object 'MyModule' has no attribute 'MyRecordD'
System.Reflection dll.GetType("MyNamespace.MyModule+MyRecordD`1")) seems to work ok, but doing every function call using reflection makes code unreadable.
changed the title [-]F# record MyRecord becomes MyRecord`1 in pythonnet[/-][+]F# record not accesssible if generic and inside a module[/+]on Nov 20, 2017
changed the title [-]F# record not accesssible if generic and inside a module[/-][+]F# records are not accesssible if generic and inside a module[/+]on Nov 20, 2017
Activity
den-run-ai commentedon Nov 18, 2017
Can you show your F# version and the code for
MyRecord?Did you try accessing this F# type via System.Reflection in Python?
den-run-ai commentedon Nov 18, 2017
Or using
getattrdmitriyse commentedon Nov 18, 2017
Your clr.MyNamespace.MyRecord is generic with one argument, that's why CLR shows `1
den-run-ai commentedon Nov 18, 2017
@stevehv also what happens when you try accessing your F# record without
clr.? That should not be required for .NET namespaces imported properly through pythonnet - they should act like normal Python namespaces.stevehv commentedon Nov 19, 2017
Owing to some sleep deprivation the problematic F# code was not what I originally thought it was.
I have updated the original issue so that it is now reproducible, apologies for any confusion.
Accessing without
clr.did not make a difference.getattrdid not work either:den-run-ai commentedon Nov 19, 2017
Can you show output of MyNamespace.MyModule.MyRecordD.Overloads?
stevehv commentedon Nov 19, 2017
System.Reflection
dll.GetType("MyNamespace.MyModule+MyRecordD`1"))seems to work ok, but doing every function call using reflection makes code unreadable.[-]F# record MyRecord becomes MyRecord`1 in pythonnet[/-][+]F# record not accesssible if generic and inside a module[/+][-]F# record not accesssible if generic and inside a module[/-][+]F# records are not accesssible if generic and inside a module[/+]den-run-ai commentedon Nov 27, 2017
@stevehv any idea how this F# code looks like in C#? i'm not sure if this is only IL feature or available in C# too?
lostmsu commentedon Sep 17, 2022
This should be added to #1374