ploeh / Hyprlinkr

A URI building helper library for ASP.NET Web API
MIT License
197 stars 34 forks source link

Detect WebAPI2 RouteAttribute and use its route name if found #35

Closed MatthewRichards closed 9 years ago

MatthewRichards commented 9 years ago

See issue https://github.com/ploeh/Hyprlinkr/issues/30

This isn't a complete solution - more work required to tidy up, add tests, etc. However I wanted to discuss the approach before going further.

Currently Hyprlinkr doesn't require WebAPI2 / .NET 4.5. Hence we can't use the WebAPI2 RouteAttribute directly. There's a workaround - I've tested that this pull request does the job. But it's not terribly nice having to use reflection for everything.

Options I can see:

  1. This, suitably tidied up (and with enough protection against injection of other classes named System.Web.Http.RouteAttribute!)
  2. A separate library containing an IRouteDispatcher for WebAPI2. This would then require explicit wiring up when people create their RouteLinker.
  3. A separate build of Hyprlinkr for WebAPI2. I assume this isn't really an option because it'd complicate code management a lot.

Any thoughts on how comfortable you'd be with something based on this pull request? If not then I suspect option 2 would be the way to go.

ploeh commented 9 years ago

Thank you for submitting this pull request.

Right now, I'm extraordinarily busy, so may first have time to look at this next week :sweat:

ploeh commented 9 years ago

There's a fourth options, and that's to upgrade Hyprlinkr to Web API 2. Since I don't know how many people use it, or how they use it, I've created this online poll to figure out whether that'd be a good idea.

Please vote and share :smiley:

MatthewRichards commented 9 years ago

I gather ASP.NET vNext (now 5.0) will unify Web API and MVC (http://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6) - I haven't looked into whether this will mean any changes that are significant to Hyprlinkr, but it does mean Web API 1 will soon be one version further out of date - perhaps an additional argument for going with the upgrade!

ploeh commented 9 years ago

OK, the poll is over, and no-one objects to upgrading Hyprlinkr to Web API 2.

This would mean a new major release of Hyprlinkr (Hyprlinkr 2.0), so that needs to happen first. Would you like to get the 'honour' of doing that, or would you rather prefer that I do it?

MatthewRichards commented 9 years ago

Seems conclusive!

I would be up for giving it a go, but might not be very prompt (and might need to call on you for advice if the best approach isn't obvious!). So it depends whether this is something you'd want to get a move on with, and indeed whether you'd have time to be any more prompt!

ploeh commented 9 years ago

@MatthewRichards, I'm in no hurry, so I'm happy to wait if you want to give it a go :smile:

MatthewRichards commented 9 years ago

Closing this PR in favour of https://github.com/ploeh/Hyprlinkr/pull/36.