abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.86k stars 3.43k forks source link

Support strong typing of ids and other controller action parameters #18031

Open pdegenhardt opened 11 months ago

pdegenhardt commented 11 months ago

Is there an existing issue for this?

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

maliming commented 11 months ago

hi @hikalkan

What do you think?