RouteTemplates.ParameterTypeAndConstraintsMismatch warning with custom types and model binding
Hi there,
I wonder how to proceed with correctly fixing the warning “Type of parameter 'userId' doesn't satisfy route constraints (e.g. 'GuidRouteConstraint')” that we get in Rider.
Setup:
- We define our routes with route constraints, e.g.
[HttpGet("{userId:guid}")] - The controller endpoint has a function parameter
UserId userId. - The custom type is defined as
UserId : StrongGuid. - We have a custom model binder that successfully processes the string from the route into the required
StrongGuidtype.
We already tried adding a StrongGuidRouteConstraint which's Match function does return true for any StrongGuid, hoping that the analyzer would pick it up somehow, but the warning remains. Is the connection between :guid and the Guid type hardcoded in the analyzer or can we influence that?
Kind regards,
Alex
Please sign in to leave a comment.
Hello Alex
Thanks for the report about these constraints. I was able to reproduce your issue and can confirm you’ ran into a false positive.
I already created a new ticket for this bug, so you can subscribe to RSRP-503427 for further updates and upvote it so that we can see the real number of affected users.