Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotloading throws when upgrading instances of abstract classes #28

Closed
Tracked by #23
MuffinTastic opened this issue Jan 26, 2023 · 1 comment
Closed
Tracked by #23
Assignees
Labels
context/managed type/bug Something isn't working

Comments

@MuffinTastic
Copy link
Contributor

MuffinTastic commented Jan 26, 2023

Reproduction

  1. Put this in Game.cs
// ...

public abstract class Abstract { }

public class Implementation : Abstract
{
	public int Field;
	public string Property { get; set; }
}

public class Game : BaseGame
{
	// ...

	public Abstract _instance;

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

		_instance = new Implementation
		{
			Field = 123,
			Property = "!olleH dlroW"
		};

		// ...
	}

	// ...
}
  1. Start Mocha, wait for the game to start
  2. Save Game.cs to trigger a hotload
  3. Witness
    image

Notes

Abstract classes and their implementations can obviously be from different assemblies, not sure what a clean way to handle that would be. Maybe something like this would work:

  1. If the old implementation type is from the assembly we're swapping out, attempt to get a class of the same name from the new assembly and instantiate that
  2. Else, just make a new instance of the old implementation type (It's probably from some .NET or Mocha assembly or something)

Just spitballing though

@MuffinTastic MuffinTastic changed the title Hotloading an abstract class throws an exception Hotloading throws when upgrading abstract classes Jan 26, 2023
@MuffinTastic MuffinTastic changed the title Hotloading throws when upgrading abstract classes Hotloading throws when upgrading instances of abstract classes Jan 26, 2023
@xezno xezno self-assigned this Jan 26, 2023
@xezno xezno added type/bug Something isn't working context/managed labels Jan 26, 2023
@xezno xezno mentioned this issue Jan 26, 2023
24 tasks
@xezno
Copy link
Member

xezno commented Jan 27, 2023

Think I fixed this in 7207eee, please re-open if that's not the case

@xezno xezno closed this as completed Jan 27, 2023
@xezno xezno added this to the Initial Release milestone Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context/managed type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants