You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the lib in my app extensively (thank you!) and this is the first time I have a need for generics but I am getting a runtime issue.
Here is my defenition
using BlazorState;
namespace TPL.Client.Core.States.ListPageFilter
{
public partial class ListPageFilterState<T> where T : Domain.Core.Bases.SearchCritBase
{
public class SetCritAction : IAction
{
public T Crit { get; set; }
}
}
}
using BlazorState;
using MediatR;
namespace TPL.Client.Core.States.ListPageFilter
{
public partial class ListPageFilterState<T> where T : Domain.Core.Bases.SearchCritBase
{
public class SetCritHandler : ActionHandler<SetCritAction>
{
public SetCritHandler(IStore aStore) : base(aStore) { }
ListPageFilterState<T> state => Store.GetState<ListPageFilterState<T>>();
public override Task<Unit> Handle(SetCritAction action, CancellationToken aCancellationToken)
{
state.Crit = action.Crit;
return Unit.Task;
}
}
}
}
using BlazorState;
namespace TPL.Client.Core.States.ListPageFilter
{
public partial class ListPageFilterState<T> : State<ListPageFilterState<T>> where T : Domain.Core.Bases.SearchCritBase
{
public T Crit { get; private set; }
public override void Initialize() { Crit = null; }
}
}
Then upon actually setting the value of the Store await Mediator.Send(new ListPageFilterState<TSearchCrit>.SetCritAction { Crit = null });
I get the following monstorsity
Microsoft.AspNetCore.Components.Web.ErrorBoundary[0]
System.MemberAccessException: Cannot create an instance of TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1[T] because Type.ContainsGenericParameters is true.
at System.Reflection.RuntimeConstructorInfo.CheckCanCreateInstance(Type declaringType, Boolean isVarArg)
at System.Reflection.RuntimeConstructorInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at BlazorState.Store.GetState(Type aType) in /_/Source/BlazorState/Store/Store.cs:line 70
at BlazorState.Pipeline.State.CloneStateBehavior`2.<Handle>d__4[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext() in /_/Source/BlazorState/Pipeline/CloneState/CloneStateBehavior.cs:line 35
at MediatR.Pipeline.RequestPreProcessorBehavior`2.<Handle>d__2[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext()
at MediatR.Pipeline.RequestPostProcessorBehavior`2.<Handle>d__2[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext()
at TPL.Client.Core.Bases.ListPage`2.<OnParametersSetAsync>d__12[[Domain.Session.Session, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in C:\Users\ameri\source\repos\TPL.APP\TPL\Client\Core\Bases\ListPage.razor:line 40
at TPL.Client.Pages.Session.Mine.Mine.OnParametersSetAsync() in C:\Users\ameri\source\repos\TPL.APP\TPL\Client\Pages\Session\Mine\Mine.razor:line 179
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
System.MemberAccessException: Cannot create an instance of TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1[T] because Type.ContainsGenericParameters is true.
at System.Reflection.RuntimeConstructorInfo.CheckCanCreateInstance(Type declaringType, Boolean isVarArg)
at System.Reflection.RuntimeConstructorInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at BlazorState.Store.GetState(Type aType) in /_/Source/BlazorState/Store/Store.cs:line 70
at BlazorState.Pipeline.State.CloneStateBehavior`2.<Handle>d__4[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext() in /_/Source/BlazorState/Pipeline/CloneState/CloneStateBehavior.cs:line 35
at MediatR.Pipeline.RequestPreProcessorBehavior`2.<Handle>d__2[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext()
at MediatR.Pipeline.RequestPostProcessorBehavior`2.<Handle>d__2[[TPL.Client.Core.States.ListPageFilter.ListPageFilterState`1.SetCritAction[[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TPL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MediatR.Unit, MediatR.Contracts, Version=2.0.1.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2]].MoveNext()
at TPL.Client.Core.Bases.ListPage`2.<OnParametersSetAsync>d__12[[Domain.Session.Session, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Domain.Session.SearchCrit, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in C:\Users\ameri\source\repos\TPL.APP\TPL\Client\Core\Bases\ListPage.razor:line 40
at TPL.Client.Pages.Session.Mine.Mine.OnParametersSetAsync() in C:\Users\ameri\source\repos\TPL.APP\TPL\Client\Pages\Session\Mine\Mine.razor:line 179
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
The text was updated successfully, but these errors were encountered:
Is BlazorState supposed to work with Generics?
I am using the lib in my app extensively (thank you!) and this is the first time I have a need for generics but I am getting a runtime issue.
Here is my defenition
Then upon actually setting the value of the Store
await Mediator.Send(new ListPageFilterState<TSearchCrit>.SetCritAction { Crit = null });
I get the following monstorsity
The text was updated successfully, but these errors were encountered: