jspuij / Cortex.Net

State management like MobX for .NET and Blazor
https://jspuij.github.io/Cortex.Net.Docs
MIT License
81 stars 11 forks source link

Cortex.net prevents hot reloading using "dotnet watch" (vs2022, .net 6.0.100-rc.2.21505.57) #62

Open johnhamm opened 3 years ago

johnhamm commented 3 years ago

I'm so bummed out because there currently isn't an alternative to this library for Blazor but not being able to hot reload is a deal breaker. Installing the Cortex.Net and Cortex.Net.Blazor nuget packages stops hot reloading from working once you inject a store with [Observable] on it.

Steps to reproduce:

  1. Create a new BlazorWasm application:
    dotnet new blazorwasm
  2. Start dotnet watch in the same folder:
    dotnet watch
  3. Open the project in Visual Studio 2022
  4. Open Pages\Index.razor and edit text of the H1 element.
  5. Command window will say
    watch : File changed: ...\blazrwasm\Pages\Index.razor.
    watch : Hot reload of changes succeeded.
  6. Install the Cortext.Net and Cortex.Net.Blazor nuget packages, then try to edit the text of the H1 element again - it still works!
  7. Add a class AppStore to your project:
    using Cortex.Net.Api;

namespace blazrwasm { [Observable] public class AppStore { public string? Name { get; set; } } }

  1. Inject it in program.cs on line 10: builder.Services.AddSingleton<AppStore>();
  2. Restart dotnet watch
  3. Try to edit the H1 element. Hot reloading now fails. Command window will say
    watch : File changed: D:\Temp\blazrwasm\Pages\Index.razor.
    watch : No hot reload changes to apply.