Is your feature request related to a problem? Please describe.
I am trying to test using aborted cancellation tokens to check request abort logic within a filter. However, there is no way to do so. A CancellationToken on MyMvc.Pipeline() must be explicitly set as CancellationToken.None or default(CancellationToken). If I use an aborted token, such as new CancellationToken(true), then the route value logic will fail as no matching RouteValue token because new CancellationToken(true) doesn't match default(CancellationToken). There does not seem to be any way to ignore an Action's method argument outside of using the With and From classes.
Describe the solution you'd like
It would be helpful to be able to provide a non-default value while still having that route key ignored. Perhaps it would be simplest to add another method to the From class, similar to From.Services<>, that returns a value (or a value from an expression). Because anything coming through the From static class gets a value but is ignored via ExpressionParser, the Action will still get the resolved value, but the value will not be checked against RouteData.
public static class From
{
/* Omitted */
public static TValue Value<TValue>(TValue value) => value;
}
Use:
MyMvc.Pipeline()
.ShouldMap(request => request.WithLocation("/system/dosomething"))
.To<SystemController>(controller => controller.DoSomething( From.Value(new CancellationToken(true) ))
Additional context
I would be happy to provide a PR if it would be helpful.
Or maybe I'm just missing something.
Is your feature request related to a problem? Please describe.
I am trying to test using aborted cancellation tokens to check request abort logic within a filter. However, there is no way to do so. A CancellationToken on
MyMvc.Pipeline()must be explicitly set asCancellationToken.Noneordefault(CancellationToken). If I use an aborted token, such asnew CancellationToken(true), then the route value logic will fail as no matching RouteValue token becausenew CancellationToken(true)doesn't matchdefault(CancellationToken). There does not seem to be any way to ignore an Action's method argument outside of using theWithandFromclasses.Describe the solution you'd like
It would be helpful to be able to provide a non-default value while still having that route key ignored. Perhaps it would be simplest to add another method to the
Fromclass, similar toFrom.Services<>, that returns a value (or a value from an expression). Because anything coming through theFromstatic class gets a value but is ignored via ExpressionParser, the Action will still get the resolved value, but the value will not be checked against RouteData.Use:
Additional context
I would be happy to provide a PR if it would be helpful.
Or maybe I'm just missing something.