Skip to content

v2.0.0 #94

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

Merged
merged 54 commits into from
May 6, 2017
Merged

v2.0.0 #94

merged 54 commits into from
May 6, 2017

Conversation

jaredcnance
Copy link
Contributor

@jaredcnance jaredcnance commented Apr 25, 2017

Closes #84
Closes #93
Closes #95

this is reprensentative of the kind of breaking change this introduces
also affects the service collection extensions
Since AddJsonApiInternals<T> was previously exposed, it needs to remain. Also, this is where the DbContext service should be added to the service collection since users could call this instead of UseJsonApi. It would be unreasonable to expect users to inject their dbContexts as the DbContext base type
as far as I can tell, .Net's native DI will check all pathways for resolution even if they shouldn't be resolved. Specifically, the Internal.Generics classes require DbContext to be injected. However, they would never be resolved if the app does not actually use EF and implements their own IResourceService
…once

there is really no reason to store the proper cased entity name
this also lays the ground work so that later users can specify different cases for entity type names
failing with duplicate key value violates unique constraint "pg_database_datname_index"
there should be very few places .Dasherize is actually used. most of the time we should stick to using either the Internal or Public attr/relationship names
jaredcnance and others added 6 commits April 19, 2017 16:29
these tests are not currently setup correctly. they assume that a resource can be routed based on a different name (todo-items-test -> todo-items). this is not currently supported and is out of scope for this PR. I am open to discussion, but don't believe this is going to be on the roadmap.

Other changes (todoitems -> todo-items) is for the dame reason. TodoItems have been mapped to todo-items in this example so the tests would fail.
@jaredcnance jaredcnance changed the title [WIP] v2.0.0 v2.0.0 Apr 27, 2017
@jaredcnance
Copy link
Contributor Author

jaredcnance commented Apr 27, 2017

I'm going to let this sit for another day or two and then release. As of right now I have no additional changes planned.

Copy link
Contributor

@JanMattner JanMattner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending of the scope of the PR, the open issue about the dasherized routing convention should be fixed now or in a later version. If fixed later, then it should be documented somewhere that multiple stacked Route attributes are not supported.

if (IsDasherizedJsonApiController(controller))
template = $"{_namespace}/{controller.ControllerName.Dasherize()}";
else
template = GetTemplate(controller);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should anything be changed if the dasherized routing convention does not apply? Why not just leave it as is? E.g. imagine a controller with several stacked routes:

[Route("/api/v1/MyController")]
[Route("/api/v2/MyController")]
public class MyController(...) { ... }

This is a valid use case: I want the same controller to be hosted for various routes. (not even restricted to API controllers, this also applies to static content or MVC controllers for documentation, login, ...)

Currently in this case, line 47 var routeAttr = type.GetCustomAttribute<RouteAttribute>(); throws an exception that multiple attributes of the same type are found. Why not just leaving everything as is if the dasherized convention is disabled or the controller base type does not match? Of course then the user is responsible to actually define the routing and this is not done by the dasherized routing convention. Actually, if you think about it: even if you explicitly disable the dasherized routing convention, it still does apply a routing convention i.e. just the name of the controller. As a developer, I don't expect that component to do anything if I disable it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for bringing this to my attention and you're absolutely right. I hadn't considered multiple route attributes which is totally valid.

The ideal scenario would be to not apply the convention at all for a particular controller. But, I'm not sure if this is possible (I'll be digging deeper this week). The line you commented on is more of a hack to try and determine what the intended route should be. In my limited experimentation, the simple fact that a convention is added seems to alter the behavior. Even if I detect that the convention should not be applied and don't alter the AttributeRouteModel it still doesn't seem to recognize attribute defined routes.

I'll explore this further this week and hopefully come up with a better solution. I would expect this PR to be on hold till next weekend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disregard ^^ i had bad tests.
opening PR to fix it now

@jaredcnance jaredcnance merged commit 4d8294f into master May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants