From 9119433ab778d7adf04c4601917809f2f4582a93 Mon Sep 17 00:00:00 2001 From: Hossam Barakat Date: Fri, 2 Feb 2018 01:22:08 +1100 Subject: [PATCH] Add the middleware name to the exception message UseMiddlewareNoInvokeMethod (#993) Addresses #927 Addresses aspnet/Home#2692 --- .../Extensions/UseMiddlewareExtensions.cs | 2 +- .../Properties/Resources.Designer.cs | 8 ++++---- src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx | 2 +- .../UseMiddlewareTest.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs index 88a79d7daa..c07fe1e9f1 100644 --- a/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Builder if (invokeMethods.Length == 0) { - throw new InvalidOperationException(Resources.FormatException_UseMiddlewareNoInvokeMethod(InvokeMethodName, InvokeAsyncMethodName)); + throw new InvalidOperationException(Resources.FormatException_UseMiddlewareNoInvokeMethod(InvokeMethodName, InvokeAsyncMethodName, middleware)); } var methodinfo = invokeMethods[0]; diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs index 0db61768ee..6af7d138be 100644 --- a/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Http.Abstractions => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareIServiceProviderNotAvailable"), p0); /// - /// No public '{0}' or '{1}' method found. + /// No public '{0}' or '{1}' method found for middleware of type '{2}'. /// internal static string Exception_UseMiddlewareNoInvokeMethod { @@ -33,10 +33,10 @@ namespace Microsoft.AspNetCore.Http.Abstractions } /// - /// No public '{0}' or '{1}' method found. + /// No public '{0}' or '{1}' method found for middleware of type '{2}'. /// - internal static string FormatException_UseMiddlewareNoInvokeMethod(object p0, object p1) - => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareNoInvokeMethod"), p0, p1); + internal static string FormatException_UseMiddlewareNoInvokeMethod(object p0, object p1, object p2) + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareNoInvokeMethod"), p0, p1, p2); /// /// '{0}' or '{1}' does not return an object of type '{2}'. diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx b/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx index 176d3a80c6..dfdfeaf7d1 100644 --- a/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx @@ -121,7 +121,7 @@ '{0}' is not available. - No public '{0}' or '{1}' method found. + No public '{0}' or '{1}' method found for middleware of type '{2}'. '{0}' or '{1}' does not return an object of type '{2}'. diff --git a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs index 342aa54a06..07c1aa4e8d 100644 --- a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs +++ b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs @@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Http Assert.Equal( Resources.FormatException_UseMiddlewareNoInvokeMethod( UseMiddlewareExtensions.InvokeMethodName, - UseMiddlewareExtensions.InvokeAsyncMethodName), + UseMiddlewareExtensions.InvokeAsyncMethodName, typeof(MiddlewareNoInvokeStub)), exception.Message); }