Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider creating abstractions package #42

Open
stevendarby opened this issue Feb 5, 2020 · 2 comments
Open

Consider creating abstractions package #42

stevendarby opened this issue Feb 5, 2020 · 2 comments

Comments

@stevendarby
Copy link

stevendarby commented Feb 5, 2020

If you like to have your models in a separate library that doesn't have references to framework specific packages like ASP.NET Core, MVC etc. then this is undermined if you want to apply HybridBindProperty attributes to their properties, as the dependencies of your package include ASP.NET Core packages. This could be avoided with a separate package for just abstractions/attributes. Arguably the naming of these attributes and their arguments somewhat undermines the abstraction of the models anyway, but at least without the additional packages.

Just something to consider! :)

@billbogaiv
Copy link
Owner

billbogaiv commented Feb 7, 2020

Seems like a reasonable use-case. I'll probably call the package HybridModelBinding.Core. I'm working to push a 1.0-release and can plan to tie this issue to that release.

@stevendarby
Copy link
Author

I’ve actually changed my mind on this! But of course feel free to do what you think is best. I’ll explain why I changed my mind.

Previously I was thinking of attributes like Required, MaxLength etc. that MS abstracted into the ComponentModel package. These are then used by certain frameworks, like MVC for validation in the controller and entity framework for modelling the database.

However, their FromBody etc. attributes are in MVC and I think that’s probably fair enough as their meaning can’t really be abstracted from MVC.

In the use-case I described, the ‘proper’ thing for me to do is probably have an interface/base class in a shared abstract library and then implement/override the properties in the MVC project to apply the Hybrid attributes to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants