mrpmorris / Fluxor

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

Test case for dispatcher failure in .NET8 with new render modes #487

Open mikeppcom opened 2 months ago

mikeppcom commented 2 months ago

DispatcherTest.zip

mrpmorris commented 1 month ago

This works for me.

Server

Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Client

Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Routes.razor

<Fluxor.Blazor.Web.StoreInitializer/>

Counter.Razor

@page "/counter"
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject Fluxor.IState<CounterState> State
@inject Fluxor.IDispatcher Dispatcher

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @State.Value.Count</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

Counter.Razor.cs

using Fluxor;

namespace BlazorFluxorApp.Client.Pages;

public partial class Counter
{
    private int currentCount = 0;

    private void IncrementCount()
    {
        Dispatcher.Dispatch(new IncrementCounterAction());
    }
}

[FeatureState]
public record class CounterState(int Count)
{
    public CounterState() : this(Count: 0) { }
}

public class IncrementCounterAction { }

public static class Reducers
{
    [ReducerMethod(typeof(IncrementCounterAction))]
    public static CounterState Reduce(CounterState state) => state with { Count = state.Count + 1 };
}
mikeppcom commented 1 month ago

Hi Peter,

In server project do you have the code to enables the new interactive render mode

// Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents();

Fluxor works fine in .NET8 with the original render mode. The problem is due to the render mode.

Does my example fail for you?

Michael

From: Peter Morris @.> Sent: Tuesday, May 14, 2024 3:28 PM To: mrpmorris/Fluxor @.> Cc: Michael Aston @.>; Author @.> Subject: Re: [mrpmorris/Fluxor] Test case for dispatcher failure in .NET8 with new render modes (Issue #487)

EXTERNAL E-MAIL – This email has come from an external source. Verify the sender before responding, clicking on any links or opening attachments. Report suspicious emails.


This works for me. Server Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Client Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Routes.razor

Counter.Razor

@page "/counter"

@inherits Fluxor.Blazor.Web.Components.FluxorComponent

@inject Fluxor.IState State

@inject Fluxor.IDispatcher Dispatcher

Counter

Counter

Current count: @State.Value.Count

<button class="btn btn-primary" @onclick="IncrementCount">Click me

Counter.Razor.cs

using Fluxor;

namespace BlazorFluxorApp.Client.Pages;

public partial class Counter

{

private int currentCount = 0;

private void IncrementCount()

{

    Dispatcher.Dispatch(new IncrementCounterAction());

}

}

[FeatureState]

public record class CounterState(int Count)

{

public CounterState() : this(Count: 0) { }

}

public class IncrementCounterAction { }

public static class Reducers

{

[ReducerMethod(typeof(IncrementCounterAction))]

public static CounterState Reduce(CounterState state) => state with { Count = state.Count + 1 };

}

— Reply to this email directly, view it on GitHubhttps://github.com/mrpmorris/Fluxor/issues/487#issuecomment-2110394628, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6CYAQNMQ4AUALFJ4563WHTZCINQBAVCNFSM6AAAAABG6Q4N2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQGM4TINRSHA. You are receiving this because you authored the thread.Message ID: @.**@.>>


This e-mail message (including any attachments) from PayPoint plc or any member of the PayPoint group of trading companies (collectively referred to as 'PayPoint') is confidential and for the personal use of the recipient(s) identified above. The message may also be legally privileged. If it is not intended for you, do not disclose, copy or distribute the message but delete it immediately and notify the sender.

Any views or opinions expressed in this message are those of the author and not necessarily those of PayPoint. The message shall not form part of any legally binding contract or obligation.

PayPoint electronic communication systems are monitored without user consent to: investigate or to detect unauthorised use; prevent or detect crime; establish the existence of facts relevant to PayPoint; or ascertain compliance with regulatory practices relevant to the business of PayPoint.

This e-mail has been scanned for viruses by a third party e-mail management provider. PayPoint cannot accept liability for any damage which you may suffer as a result of virus infection. We recommend that you carry out your own virus checks before opening any attachment.

PayPoint plc – Registered in England number 3581541 Registered office: 1 The Boulevard, Shire Park, Welwyn Garden City, Hertfordshire, AL7 1EL


mrpmorris commented 1 month ago

BlazorFluxorApp.zip

If you change this counter example and upload then I will do a diff.

mikeppcom commented 1 month ago

Hi Pete,

The difference between our test cases is that you have Fluxor in the client part whereas I have it in the server part. If you run the PoCServerAndClient_Fail test case I uploaded to the GitHub you’ll see that the subscribe code breakpoint is never hit.

Michael

@.***

From: Peter Morris @.> Sent: Wednesday, May 15, 2024 9:08 AM To: mrpmorris/Fluxor @.> Cc: Michael Aston @.>; Author @.> Subject: Re: [mrpmorris/Fluxor] Test case for dispatcher failure in .NET8 with new render modes (Issue #487)

EXTERNAL E-MAIL – This email has come from an external source. Verify the sender before responding, clicking on any links or opening attachments. Report suspicious emails.


BlazorFluxorApp.ziphttps://github.com/mrpmorris/Fluxor/files/15318285/BlazorFluxorApp.zip

If you change this counter example and upload then I will do a diff.

— Reply to this email directly, view it on GitHubhttps://github.com/mrpmorris/Fluxor/issues/487#issuecomment-2111847546, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6CYAQJXVUJDHUA5KEODQ4TZCMJVDAVCNFSM6AAAAABG6Q4N2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJRHA2DONJUGY. You are receiving this because you authored the thread.Message ID: @.**@.>>


This e-mail message (including any attachments) from PayPoint plc or any member of the PayPoint group of trading companies (collectively referred to as 'PayPoint') is confidential and for the personal use of the recipient(s) identified above. The message may also be legally privileged. If it is not intended for you, do not disclose, copy or distribute the message but delete it immediately and notify the sender.

Any views or opinions expressed in this message are those of the author and not necessarily those of PayPoint. The message shall not form part of any legally binding contract or obligation.

PayPoint electronic communication systems are monitored without user consent to: investigate or to detect unauthorised use; prevent or detect crime; establish the existence of facts relevant to PayPoint; or ascertain compliance with regulatory practices relevant to the business of PayPoint.

This e-mail has been scanned for viruses by a third party e-mail management provider. PayPoint cannot accept liability for any damage which you may suffer as a result of virus infection. We recommend that you carry out your own virus checks before opening any attachment.

PayPoint plc – Registered in England number 3581541 Registered office: 1 The Boulevard, Shire Park, Welwyn Garden City, Hertfordshire, AL7 1EL


mrpmorris commented 1 month ago

Doesn't they suggest you have the code in the wrong place?

The client doesn't have access to the server's code, whereas the server has access to both server and client.

mikeppcom commented 1 month ago

We have a Blazor server project that been running for several years that uses lots of Fluxor. We are now adding a new function that requires a single component to run on the client (this is for compliance with PCI for credit cards). To do this we are using the new interactive rendering modes. Your example is only using interactive rendering for client components and here Fluxor appears to work. It’s does not work in interactive server components though.

Michael

From: Peter Morris @.> Sent: Wednesday, May 15, 2024 6:05 PM To: mrpmorris/Fluxor @.> Cc: Michael Aston @.>; Author @.> Subject: Re: [mrpmorris/Fluxor] Test case for dispatcher failure in .NET8 with new render modes (Issue #487)

EXTERNAL E-MAIL – This email has come from an external source. Verify the sender before responding, clicking on any links or opening attachments. Report suspicious emails.


Doesn't they suggest you have the code in the wrong place?

The client doesn't have access to the server's code, whereas the server has access to both server and client.

— Reply to this email directly, view it on GitHubhttps://github.com/mrpmorris/Fluxor/issues/487#issuecomment-2113045281, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6CYAQNF5IVWSN5I24BFVWDZCOIVTAVCNFSM6AAAAABG6Q4N2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJTGA2DKMRYGE. You are receiving this because you authored the thread.Message ID: @.**@.>>


This e-mail message (including any attachments) from PayPoint plc or any member of the PayPoint group of trading companies (collectively referred to as 'PayPoint') is confidential and for the personal use of the recipient(s) identified above. The message may also be legally privileged. If it is not intended for you, do not disclose, copy or distribute the message but delete it immediately and notify the sender.

Any views or opinions expressed in this message are those of the author and not necessarily those of PayPoint. The message shall not form part of any legally binding contract or obligation.

PayPoint electronic communication systems are monitored without user consent to: investigate or to detect unauthorised use; prevent or detect crime; establish the existence of facts relevant to PayPoint; or ascertain compliance with regulatory practices relevant to the business of PayPoint.

This e-mail has been scanned for viruses by a third party e-mail management provider. PayPoint cannot accept liability for any damage which you may suffer as a result of virus infection. We recommend that you carry out your own virus checks before opening any attachment.

PayPoint plc – Registered in England number 3581541 Registered office: 1 The Boulevard, Shire Park, Welwyn Garden City, Hertfordshire, AL7 1EL