mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.27k stars 146 forks source link

AddFluxor ScanAssemblies not working as expected #399

Closed mohaaron closed 1 year ago

mohaaron commented 1 year ago

I have just added Fluxor to a project and during the setup in the WASM client, I have found that passing a collection of assemblies is not working. I would rather use the second method of passing all the assemblies to search.

This code works.

var library = Assembly.Load("BlazorApp.Client.Shared");

builder.Services.AddFluxor(options =>
{
    options.ScanAssemblies(typeof(Program).Assembly, library);
    options.AddMiddleware<ProfilingMiddleware>();
#if DEBUG
    options.UseReduxDevTools(options =>
    {
        options.Name = "App";
    });
#endif
});

This code does not work.

var assemblies = AppDomain.CurrentDomain.GetAssemblies();

builder.Services.AddFluxor(options =>
{
    options.ScanAssemblies(typeof(Program).Assembly, assemblies);
    options.AddMiddleware<ProfilingMiddleware>();
#if DEBUG
    options.UseReduxDevTools(options =>
    {
        options.Name = "App";
    });
#endif
});
mrpmorris commented 1 year ago

To ensure the code is the same, could you remove

AppDomain.CurrentDomain.GetAssemblies();

And change it to

new Assembly[] { library };

If like to ensure its not a problem with what is passed in.

mohaaron commented 1 year ago

Hello Peter,

I was just surprised by this test. This code is now working using the assemblies variable that didn't work yesterday. I don't know why it's now working. I'm going to investigate more and let you know if anything changes. Sorry for the inconvenience.

mrpmorris commented 1 year ago

I wonder if it is because it's now cached? Try deleting the locally cached files.

mohaaron commented 1 year ago

Thanks, I also thought about that after the fact.