GithubHelp home page GithubHelp logo

Comments (13)

slozier avatar slozier commented on July 28, 2024 2

If you don't mind I'll re-open the issue since this is technically a regression. I'm thinking a try/catch of NotImplementedException would do the trick (although not sure how I'd go about testing it)...

private TryGetProperty TryGetByJit(MethodInfo method) {
    try {
        return method.DeclaringType!.IsAssignableFrom(typeof(TSelfType))
            ? TryGetByJitWithoutCast(method)
            : TryGetByJitRequiringCast(method);
    } catch (NotImplementedException) { // Mono can throw this...
        return TryGetByReflection;
    }
}

from ironpython3.

BCSharp avatar BCSharp commented on July 28, 2024

Cannot reproduce, the Python sample is incomplete. What are arguments to set_generated_rules? Which version of .NET are you using?

from ironpython3.

thislooksfun avatar thislooksfun commented on July 28, 2024

Cannot reproduce, the Python sample is incomplete.

I'm not sure what you mean. That's the exact script I've been running that has the issue for me.

What are arguments to set_generated_rules?

I'm not actually calling set_generated_rules at any point yet, that's the next step. I'm just calling compiled.Execute() so I can attach the script to the scope so I can then get the function out to call it later (if there's an easier way to do that let me know, but I couldn't find one).

Which version of .NET are you using?

I'm using .NET 4.7.2.

from ironpython3.

BCSharp avatar BCSharp commented on July 28, 2024

OK, it wasn't clear to me at which place you were getting the exception. As I understand it now, it is compiled.Execute(scope); and not when calling set_generated_rules. Still, I cannot reproduce your issue. I tried .NET Framework 4.8 and .NET 6.0 — the script, as it is, executes just fine.

On a side note, your script uses TRUE rather than True? This variable will be undefined unless you define it explicitly before calling set_generated_rules if you get that far (though it should not have any consequence on the problem you are facing now).

I'm using .NET 4.7.2.

Not using Mono? Strange that I see System.Reflection.MonoMethod.Invoke in the stack trace.

from ironpython3.

thislooksfun avatar thislooksfun commented on July 28, 2024

OK, it wasn't clear to me at which place you were getting the exception. As I understand it now, it is compiled.Execute(scope); and not when calling set_generated_rules.

Correct, sorry I didn't make that clear at first.

Still, I cannot reproduce your issue. I tried .NET Framework 4.8 and .NET 6.0 — the script, as it is, executes just fine.

Huh. Weird. I'll do some more digging to try to find a better MRE.

On a side note, your script uses TRUE rather than True? This variable will be undefined unless you define it explicitly before calling set_generated_rules if you get that far (though it should not have any consequence on the problem you are facing now).

Good to know. I don't know python. That being said I'm sourcing the final script from elsewhere, so I'm not too concerned if my test script doesn't work 100%.

Not using Mono? Strange that I see System.Reflection.MonoMethod.Invoke in the stack trace.

I'll be honest, I have no idea. I'm not a C# dev, I'm just trying to make a mod for a Unity game. All I know is my .csproj says <TargetFramework>net472</TargetFramework>.

from ironpython3.

BCSharp avatar BCSharp commented on July 28, 2024

Ah, Unity… Just to make sure: are you running your mod on Unity on a desktop platform? If so, which one? Windows, macOS, UWP, Linux?

The "TargetFramework" moniker in .csproj specifies the .NET API, not necessarily the .NET platform. net472 means it is either .NET Framework or Mono. If you run on something else than Windows, then for sure it's Mono. Unfortunately, Mono does not implement the complete .NET API. Sometimes workarounds are possible.

from ironpython3.

thislooksfun avatar thislooksfun commented on July 28, 2024

I'm developing the mod on Windows, but the game itself (Hollow Knight) is cross platform. Also, after doing some more digging through the project setup I see references to Mono.Cecil, so I'm pretty sure it's Mono.

That being said, I don't understand why Mono would be a problem here. The error being thrown looks like a missing/bugged IronPython language feature error to me (but one I can't find where it's thrown from), not a .NET vs Mono error. Though admittedly I know almost no C#, so it's possible I'm overlooking something.

from ironpython3.

BCSharp avatar BCSharp commented on July 28, 2024

It does look like a something in Mono not being fully implemented in the version of Mono you are using. I have found a similar report in mono/mono#21534. This issue is still open, however I was able to run your example without problems with Mono v6.12 on Linux, so maybe it got implemented anyway and you are simply using an old Mono version.

I haven't worked on any Unity mod before, so I don't know anything about Unity toolset, but if it is possible, I'd recommend to migrate your mod project to .NET 6.0 or later. If you point me to some resources on Unity mod development in C#, I might be able to look into it (I have Unity on Windows installed).

from ironpython3.

thislooksfun avatar thislooksfun commented on July 28, 2024

Ah, I see. Well that's a shame. Unfortunately I don't think I have a way to adjust the Mono version used. I'm merely creating a dll that is then loaded by a Unity game outside of my control. I'll keep poking around though, see if there's some other solution I can find.

from ironpython3.

slozier avatar slozier commented on July 28, 2024

@thislooksfun Does your code fail with v3.4.0? You're hitting a code path that was recently modified for performance (#1706) so if v3.4.0 works it might be possible to change some stuff to make it work again...

from ironpython3.

thislooksfun avatar thislooksfun commented on July 28, 2024

It does! Thank you!

However I now have a new problem in that now calling scope.GetVariable() is throwing System.TypeLoadException: Failure has occurred while loading a type., but that feels like a problem with my code rather than the library.

from ironpython3.

BCSharp avatar BCSharp commented on July 28, 2024

not sure how I'd go about testing it

.NET is being tested by several test runs on all supported versions, maybe something similar for Mono: one test run on the latest Mono version and one on the oldest that we support (though I don't know which one that is).

from ironpython3.

slozier avatar slozier commented on July 28, 2024

Well in theory the ".NET Framework" tests on Linux/macOS are Mono. Not sure which version, but I'm assuming they're on 6.12.something as that's the latest? As for the oldest that we should support probably depends on whats bundled with Unity as that appears to popular among users.

from ironpython3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.