Dresel / RouteLocalization

RouteLocalization is an MVC and Web API package that allows localization of your attribute routes.
MIT License
67 stars 13 forks source link

Asp.Net VNext #51

Closed mdmoura closed 7 years ago

mdmoura commented 9 years ago

Hello,

Is RouteLocalization already compatible with Asp.Net VNext?

Thank You, Miguel

Dresel commented 9 years ago

Hi,

I'm afraid not yet. Are you already developing applications with Asp.Net VNext? When will it be released?

I plan to look over this at end of June / begin of July.

mdmoura commented 9 years ago

Hello,

I am developing my first application with ASP.NET VNext ...

Windows 10 will be released, if I am not mistaken, on 29 of July. Visual Studio 2015 RC was released in May including ASP.NET VNext Beta 5. I suppose Visual Studio 2015 and ASP.NET VNext will be launched along Windows 10.

What do you think?

ASP.NET team decided to go for a Beta 6 where 22% is completed: https://github.com/aspnet/Mvc/milestones

On ASP.NET VNext MVC and Web API Controllers were unified in only one. So I suppose there would be only one RouteLocalization library for VNext.

You can use Attribute Routing and Convention routing as usual ... But if you don't use any, the routes are generated from controllers automatically.

Dresel commented 9 years ago

Yeah I never found any official statements but I think July / August will be likely.

I guess there will be only one library, which will make further development easier but I don't know how much changes will be required to make it work for vNext.

But if you don't use any, the routes are generated from controllers automatically.

Interesting. Do you have more information about how this works?

mdmoura commented 9 years ago

I read that information about automatically creating routes in: http://stephenwalther.com/archive/2015/02/07/asp-net-5-deep-dive-routing

Check down the article:

First, in ASP.NET 5, there is no longer a distinction between MVC and Web API controllers. Both MVC and Web API controllers derive from the very same Controller base class.

This means that the same routing framework is used for both MVC and the Web API. With ASP.NET 5, anything that is true of routing for MVC is also true for the Web API.

Second, unlike earlier versions of MVC, default routes are created for you automatically. You don’t need to configure anything to route a request to a controller action. A set of default routes is created for you automatically.

I also read the following which goes in more detail: http://blogs.msdn.com/b/webdev/archive/2014/06/20/asp-net-vnext-routing-overview.aspx

He talks about ASP.NET VNext routing being built as a Component Middleware ... So I believe it might be simpler to integrate RL in it and future development.

In ASP.NET vNext, Routing is built as a middleware component that can be added to the request pipeline.

And the source, which seems pretty stable and finished, is here: https://github.com/aspnet/Routing

Dresel commented 9 years ago

I recently installed the Visual Studio 2015 RC and played around with the current MVC6 project template. They changed a lot within the framework and it seems that there is no DirectRouteProvider anymore which was used in the current RouteLocalization for intercepting attribute routes.

They added an ApplicationModel which can be used to add / modfiy existing attribute routes (see here), but I don't think that this will be enough to add the current functionality.

I'll have to think about it and look for other possibilities.

mdmoura commented 9 years ago

I am not sure about it but couldn't this be done through a middleware: http://www.mikesdotnetting.com/Article/269/asp-net-5-middleware-or-where-has-my-httpmodule-gone

BTW about ASP.NET MVC 6 timings are different from what I though:

Beta 6, end of July.
Beta 7, end of August.
Beta 8, end of September. Tentative.
RC, november. Very tentative.
RTM, early 2016. 

This was a video that was released recently: https://www.youtube.com/watch?v=vqTGJGy3D9s#t=13m18

Dresel commented 9 years ago

And how would you design this middleware or what should it do?

Dresel commented 9 years ago

I doesn't seem that there is an easy way to integrate RouteLocalization for Asp.Net 6. I opened an issue in the aspnet github repository anyway to clarify that.

Dresel commented 9 years ago

I will try to use the IApplicationConvention approach (it seems it is the only possibility anyway), but we have to see how much functionality can be implemented with the new system. Any help on that topic is appreciated.

mdmoura commented 9 years ago

Hi Dresel, sorry for the delay ... I have been overwhelmed with work.

I was reading Ryan Nowak answer to your issue in Github ... In NameSpaceRoutingConvention they are doing a simple replacing.

What is your idea of how to do route replacing in the convention?

mdmoura commented 9 years ago

And BTW what features do you think can be integrated with ASP.NET MVC 6 and cannot?

mdmoura commented 8 years ago

Hi Dresel,

I have been reading this post on Route Localization: http://www.strathweb.com/2015/11/localized-routes-with-asp-net-5-and-mvc-6/

It relies on the Route Name which I think it could be avoidable ...

And it defines a LocalizedRoute to hold the culture of that route ... ... But I think no need for that with RouteLocalization since there is a DefaulCulture value.

Anyway, does that post help in integrating RouteLocalization with MVC VNext?

Thank You, Miguel

Dresel commented 8 years ago

Hi, I'm sorry for my late reply - there a lot of things going on in the moment (personal + business things) and I did not have time to go through MVC Next and RouteLocalization yet.

I still have it on my to-do list and can go through it hopefully in February.

Dresel commented 8 years ago

I'm now diving deeper into MVC 6, as far as see now it should be possible to integrate almost all of the features of the current version.

As I have to start (almost) from scratch, I will also try to add http://www.appveyor.com/ for the MVC 6 version as suggested by @JobaDiniz a long time ago.

I'm still thinking how to restructure the project, for example moving the current master branch to MVC5 and making MVC6 the new master...

mdmoura commented 8 years ago

@Dresel What about naming it only RouteLocalization since MVC and API are now unified or maybe RouteLocalization.Core. Microsoft did a rename of the project as you can see here: http://www.hanselman.com/blog/ASPNET5IsDeadIntroducingASPNETCore10AndNETCore10.aspx

They didn't want the new technology to be seen as a sequence of ASP.Net 4 MVC 5 since is something quite new. To avoid future confusion I might not call it RouteLocalization.MVC6

Just an idea ...

Dresel commented 8 years ago

Yeah that's the question. The VS2015 template I used includes the classic "Microsoft.AspNet.Mvc" nuget package, but there is another "Microsoft.AspNet.Mvc.Core" package out there. You know more about that?

mdmoura commented 8 years ago

If you look at MVC in Github (https://github.com/aspnet/Mvc) in Dev branch and even on RC1 there are two projects:

Microsoft.AspNetCore.Mvc.Core Where all Mvc code is ... In RC1 was Microsoft.AspNet.Mvc.Core https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNetCore.Mvc.Core

Microsoft.AspNetCore.Mvc Here there is only the class MvcServiceCollectionExtensions with a few extensions which are responsible for adding MVC to the pipeline on the Startup of an Asp.Net project. https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNetCore.Mvc

Not sure why they keep this class on this assembly ... Even on RC1 the structure is the same.

So maybe:

RouteLocalization.AspNetCore.Mvc?

Or if you want to distinguish between work for RC1 and RC2 onward:

RouteLocalization.AspNet.Mvc for RC1?

And

RouteLocalization.AspNetCore.Mvc for RC2?

What do you think?

Dresel commented 8 years ago

I think I'll change the code namespace to RouteLocalization but I will add AspNetCore and possibly MVC6 to the nuget package description, to make finding it easier.

Dresel commented 8 years ago

I have finished most of my tests with the latest (nightly RC3) version and I think that almost all features should be possible in AspNetCore. I will setup an aspnetcore branch soon and propose a possible implementation.

Dresel commented 8 years ago

I have created a proof of concept branch for the vNext version. It's far from complete, but it shows the basic idea of translating routes with model conventions. The current workflow im using is the following:

If you find some time feel free to go over it (you might have to add the nightly nuget package repository for asp.net vnext: https://www.myget.org/F/aspnetvnext/api/v3/index.json). If you have suggestions for the API usage I guess now is the perfect time.

Dresel commented 8 years ago

Since we (have to) follow another approach in asp.net core we need special treatment for route names - to avoid duplicate route name errors each translated route with route name set will be renamed and gets the culture appended - something like "originalroutename:culture".

lgoudriaan commented 7 years ago

Hi @Dresel,

I just looked at your proof of concept and it looks promising. Is there anyway I can help you with to get this published into NuGet?

Dresel commented 7 years ago

Thanks for your feedback.

Well any contribution is welcome. Since VS 2017 is now released and the tool chain for net core is now more or less settled I'm trying to release a preview version end of this month.

Defining requirements and test cases, testing, writing documentation or just giving feedback... do whatever you can / want.

Dresel commented 7 years ago

FYI: Refactoring the proof of concept takes longer than expected but I'm almost done with an initial productive version.

Dresel commented 7 years ago

Still a draft, but you can try

Install-Package RouteLocalization.AspNetCore -Pre

See the sample project of aspnet-core/dev branch for more infos.

Dresel commented 7 years ago

I will finally close this now, don't hesitate opening new issues for feedback and similar.