abp icon indicating copy to clipboard operation
abp copied to clipboard

Support strong typing of ids and other controller action parameters

Open pdegenhardt opened this issue 2 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I am try to implement strongly typed identifiers for my entities. These identifiers are created in the Domain.Shared project and are available to application service clients. Most of this is working, however, the ConventionalRouteBuilder, does not view these types as being primitives (because TypeHelper.IsPrimitiveExtended(...) returns false, and so the route builder creates query parameters for all of the properties of the type.

Describe the solution you'd like

I would like to see the logic currently implemented in TypeHelper.IsPrimitiveExtended() moved out to a separate dependency so that this mechanism is not so brittle. This would assist those of us wanting to tweak the way application services are exposed conventionally as controllers.

While it is possible to replace ConventionalRouteBuilder, this introduces potential inconsistencies in the way strongly typed values, are then treated in other areas that also call `TypeHelper.IsPrimitiveExtended()', such as validation, api description providers and object extending.

I note that ABP have recently had to modify this method to support the new DateOnly and TimeOnly types in .NET. Having this logic separated out might assist with these type of modifications in future.

Alternatively, TypeHelper.IsPrimitiveExtended() should better match the approach built into ASP.NET Core - i.e. if the type has a type converter that supports conversion from a single string, then it can be assumed to be a 'primitive type' when used as an action parameter.

Additional context

No response

pdegenhardt avatar Oct 30 '23 23:10 pdegenhardt

hi @hikalkan

What do you think?

maliming avatar Nov 01 '23 06:11 maliming

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 27 '25 03:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 26 '25 23:06 stale[bot]

hi @hikalkan

What do you think?

RobertoFiocchiMCSI avatar Jun 27 '25 06:06 RobertoFiocchiMCSI