Skip to content

Commit

Permalink
Temporary workaround for Mono incorrectly treating "Dispose" as action (
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Mar 23, 2017
1 parent 12a4c8a commit ac882ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Daniel15.Web/BugfixApplicationModelProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.Extensions.Options;

namespace Daniel15.Web
{
/// <summary>
/// Temporary hack to work around https://github.com/aspnet/Routing/issues/391
/// </summary>
public class BugfixApplicationModelProvider : DefaultApplicationModelProvider
{
public BugfixApplicationModelProvider(IOptions<MvcOptions> mvcOptionsAccessor) : base(mvcOptionsAccessor) {}

protected override bool IsAction(TypeInfo typeInfo, MethodInfo methodInfo)
{
return methodInfo.Name != "Dispose" && base.IsAction(typeInfo, methodInfo);
}
}
}
5 changes: 5 additions & 0 deletions Daniel15.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using React.AspNet;

Expand Down Expand Up @@ -42,6 +44,9 @@ public void ConfigureServices(IServiceCollection services)
services.AddReact();
services.AddDaniel15();
services.AddDaniel15Config(Configuration);

// Temporary workaround for https://github.com/aspnet/Routing/issues/391
services.Replace(ServiceDescriptor.Transient<IApplicationModelProvider, BugfixApplicationModelProvider>());
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
Expand Down

0 comments on commit ac882ce

Please sign in to comment.