Skip to content

Commit

Permalink
temporary fix for kobake#19
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaspierre1990 committed Dec 19, 2018
1 parent 93554a1 commit d052d42
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;

namespace AspNetCore.RouteAnalyzer.SampleWebProject.Controllers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace AspNetCore.RouteAnalyzer.SampleWebProject.Pages
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace AspNetCore.RouteAnalyzer.SampleWebProject.Pages
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace AspNetCore.RouteAnalyzer.SampleWebProject.Pages
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace AspNetCore.RouteAnalyzer.SampleWebProject.Pages
{
Expand Down
9 changes: 1 addition & 8 deletions AspNetCore.RouteAnalyzer.SampleWebProject/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace AspNetCore.RouteAnalyzer.SampleWebProject
{
Expand Down
14 changes: 8 additions & 6 deletions AspNetCore.RouteAnalyzer.SampleWebProject/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics;
Expand All @@ -23,7 +22,8 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddRouting();
services.AddRouteAnalyzer();
}

Expand Down Expand Up @@ -51,12 +51,14 @@ IRouteAnalyzer routeAnalyzer

app.UseMvc(routes =>
{
routes.MapRouteAnalyzer("/routes");
//routes.MapRouteAnalyzer("/routes", app.ApplicationServices);
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});

app.MapRouteAnalyzer("/routes");

// Lifetime events
applicationLifetime.ApplicationStarted.Register(OnStarted);
applicationLifetime.ApplicationStopping.Register(OnStopping);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;

namespace AspNetCore.RouteAnalyzer.Controllers
{
Expand Down
32 changes: 26 additions & 6 deletions AspNetCore.RouteAnalyzer/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
using AspNetCore.RouteAnalyzer.Inner;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using System.Linq;
using System.Diagnostics;

namespace AspNetCore.RouteAnalyzer
{
public static class RouteAnalyzerServiceCollectionExtensions
{
public static IServiceCollection AddRouteAnalyzer(this IServiceCollection services)
{
services.AddSingleton<IRouteAnalyzer, RouteAnalyzer.Inner.RouteAnalyzerImpl>();
services.AddSingleton<IRouteAnalyzer, RouteAnalyzerImpl>();
return services;
}
}

public static class RouteAnalyzerRouteBuilderExtensions
{
private static string AspNetCoreRouteAnalyzerRoute = "AspNetCore.RouteAnalyzer.Route";
public static string RouteAnalyzerUrlPath { get; private set; } = "";

public static IRouteBuilder MapRouteAnalyzer(this IRouteBuilder routes, string routeAnalyzerUrlPath)
{
RouteAnalyzerUrlPath = routeAnalyzerUrlPath;
routes.Routes.Add(new Router(routes.DefaultHandler, routeAnalyzerUrlPath));
return routes;
public static IApplicationBuilder MapRouteAnalyzer(this IApplicationBuilder app, string routeAnalyzerUrlPath)
{
var aspnetCorErouteHandler = new RouteHandler(context =>
{
return Task.Run(() =>
{
context.Response.Redirect("RouteAnalyzer_Main/ShowAllRoutes");
});
});

var routeBuilder = new RouteBuilder(app, aspnetCorErouteHandler);

routeBuilder.MapRoute(AspNetCoreRouteAnalyzerRoute, routeAnalyzerUrlPath);

var routes = routeBuilder.Build();
app.UseRouter(routes);

return app;
}
}
}
4 changes: 1 addition & 3 deletions AspNetCore.RouteAnalyzer/IRouteAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;

namespace AspNetCore.RouteAnalyzer
{
Expand Down
3 changes: 0 additions & 3 deletions AspNetCore.RouteAnalyzer/Inner/Router.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Routing;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AspNetCore.RouteAnalyzer.Inner
Expand Down

0 comments on commit d052d42

Please sign in to comment.