mocha-engine / mocha

Mocha: A work-in-progress 3D game engine
GNU Lesser General Public License v3.0
53 stars 7 forks source link

Hotload: Implement upgrader for interface instances #31

Closed MuffinTastic closed 1 year ago

MuffinTastic commented 1 year ago

Putting this in Game.cs...

public interface ITest
{
    public string TestProperty { get; set; }
}

public class TestImplementation : ITest
{
    public string TestProperty { get; set; }
}

public class Game : BaseGame
{
    // ...

    private ITest _instance;

    public override void Startup()
    {
        // ...

        _instance = new TestImplementation();

        // ...
    }

    // ...
}

... and then triggering a hotload by saving the file again results in this, and leaves the field/property null. image

xezno commented 1 year ago

Fixed with https://github.com/xezno/mocha/commit/1cd0ef74d585b77c586e57cec2fd7231bb026f05