|
5 | 5 | using System.Diagnostics.CodeAnalysis;
|
6 | 6 | using System.Globalization;
|
7 | 7 | using System.Reflection;
|
| 8 | +#if COMPONENTS |
| 9 | +using Microsoft.AspNetCore.Components.Routing; |
| 10 | +#endif |
8 | 11 | using Microsoft.Extensions.DependencyInjection;
|
9 | 12 |
|
10 | 13 | namespace Microsoft.AspNetCore.Routing;
|
@@ -37,12 +40,8 @@ internal static class ParameterPolicyActivator
|
37 | 40 | {
|
38 | 41 | // Error if type is not a parameter policy
|
39 | 42 | throw new RouteCreationException(
|
40 |
| -#if !COMPONENTS |
41 | 43 | Resources.FormatDefaultInlineConstraintResolver_TypeNotConstraint(
|
42 | 44 | parameterPolicyType, parameterPolicyKey, typeof(T).Name));
|
43 |
| -#else |
44 |
| - $"The constraint type '{parameterPolicyType}' which is mapped to constraint key '{parameterPolicyKey}' must implement the '{typeof(T).Name}' interface."); |
45 |
| -#endif |
46 | 45 | }
|
47 | 46 |
|
48 | 47 | // Return null if type is parameter policy but is not the exact type
|
@@ -122,12 +121,8 @@ private static IParameterPolicy CreateParameterPolicy(IServiceProvider? serviceP
|
122 | 121 | if (matchingConstructors.Count == 0)
|
123 | 122 | {
|
124 | 123 | throw new RouteCreationException(
|
125 |
| -#if !COMPONENTS |
126 | 124 | Resources.FormatDefaultInlineConstraintResolver_CouldNotFindCtor(
|
127 | 125 | parameterPolicyType.Name, arguments.Length));
|
128 |
| -#else |
129 |
| - $"Could not find a constructor for constraint type '{parameterPolicyType.Name}' with the following number of parameters: {arguments.Length}."); |
130 |
| -#endif |
131 | 126 | }
|
132 | 127 | else
|
133 | 128 | {
|
@@ -187,13 +182,8 @@ private static ConstructorInfo GetLongestConstructor(List<ConstructorInfo> const
|
187 | 182 | if (multipleBestLengthFound)
|
188 | 183 | {
|
189 | 184 | throw new RouteCreationException(
|
190 |
| -#if !COMPONENTS |
191 | 185 | Resources.FormatDefaultInlineConstraintResolver_AmbiguousCtors(
|
192 | 186 | parameterPolicyType.Name, longestLength));
|
193 |
| -#else |
194 |
| - $"The constructor to use for activating the constraint type '{parameterPolicyType.Name}' " + |
195 |
| - $"is ambiguous. Multiple constructors were found with the following number of parameters: {longestLength}."); |
196 |
| -#endif |
197 | 187 | }
|
198 | 188 |
|
199 | 189 | return longest!;
|
|
0 commit comments