HttpAbstractions 349 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. commit 9119433ab778d7adf04c4601917809f2f4582a93
  2. Author: Hossam Barakat <[email protected]>
  3. Date: Fri Feb 2 01:22:08 2018 +1100
  4. Add the middleware name to the exception message UseMiddlewareNoInvokeMethod (#993)
  5. Addresses #927
  6. Addresses aspnet/Home#2692
  7. diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs
  8. index 88a79d7daab..c07fe1e9f1c 100644
  9. --- a/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs
  10. +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs
  11. @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Builder
  12. if (invokeMethods.Length == 0)
  13. {
  14. - throw new InvalidOperationException(Resources.FormatException_UseMiddlewareNoInvokeMethod(InvokeMethodName, InvokeAsyncMethodName));
  15. + throw new InvalidOperationException(Resources.FormatException_UseMiddlewareNoInvokeMethod(InvokeMethodName, InvokeAsyncMethodName, middleware));
  16. }
  17. var methodinfo = invokeMethods[0];
  18. diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs
  19. index 0db61768eeb..6af7d138bee 100644
  20. --- a/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs
  21. +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Properties/Resources.Designer.cs
  22. @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Http.Abstractions
  23. => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareIServiceProviderNotAvailable"), p0);
  24. /// <summary>
  25. - /// No public '{0}' or '{1}' method found.
  26. + /// No public '{0}' or '{1}' method found for middleware of type '{2}'.
  27. /// </summary>
  28. internal static string Exception_UseMiddlewareNoInvokeMethod
  29. {
  30. @@ -33,10 +33,10 @@ namespace Microsoft.AspNetCore.Http.Abstractions
  31. }
  32. /// <summary>
  33. - /// No public '{0}' or '{1}' method found.
  34. + /// No public '{0}' or '{1}' method found for middleware of type '{2}'.
  35. /// </summary>
  36. - internal static string FormatException_UseMiddlewareNoInvokeMethod(object p0, object p1)
  37. - => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareNoInvokeMethod"), p0, p1);
  38. + internal static string FormatException_UseMiddlewareNoInvokeMethod(object p0, object p1, object p2)
  39. + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_UseMiddlewareNoInvokeMethod"), p0, p1, p2);
  40. /// <summary>
  41. /// '{0}' or '{1}' does not return an object of type '{2}'.
  42. diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx b/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx
  43. index 176d3a80c6b..dfdfeaf7d11 100644
  44. --- a/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx
  45. +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx
  46. @@ -121,7 +121,7 @@
  47. <value>'{0}' is not available.</value>
  48. </data>
  49. <data name="Exception_UseMiddlewareNoInvokeMethod" xml:space="preserve">
  50. - <value>No public '{0}' or '{1}' method found.</value>
  51. + <value>No public '{0}' or '{1}' method found for middleware of type '{2}'.</value>
  52. </data>
  53. <data name="Exception_UseMiddlewareNonTaskReturnType" xml:space="preserve">
  54. <value>'{0}' or '{1}' does not return an object of type '{2}'.</value>
  55. diff --git a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs
  56. index 342aa54a06a..07c1aa4e8d7 100644
  57. --- a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs
  58. +++ b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs
  59. @@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Http
  60. Assert.Equal(
  61. Resources.FormatException_UseMiddlewareNoInvokeMethod(
  62. UseMiddlewareExtensions.InvokeMethodName,
  63. - UseMiddlewareExtensions.InvokeAsyncMethodName),
  64. + UseMiddlewareExtensions.InvokeAsyncMethodName, typeof(MiddlewareNoInvokeStub)),
  65. exception.Message);
  66. }