Skip to content

Commit a527ac5

Browse files
authored
Don't throw exception for unresolved type (#46070)
* Don't throw exception for unresolved type * Add Microsoft.AspNetCore.Http.HttpResults reference
1 parent d27c95d commit a527ac5

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,7 @@ public static partial class RequestDelegateFactory
100100
// but users still need to assert on it as in https://github.com/dotnet/aspnetcore/issues/45063
101101
// so we temporarily work around this here by using reflection to get the actual type.
102102
private static readonly object? EmptyHttpResultInstance = Type.GetType("Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult, Microsoft.AspNetCore.Http.Results")?.GetProperty("Instance")?.GetValue(null, null);
103-
#if DEBUG
104-
private static readonly NewExpression EmptyHttpResultValueTaskExpr = EmptyHttpResultInstance is not null
105-
? Expression.New(typeof(ValueTask<object>).GetConstructor(new[] { typeof(IResult) })!, Expression.Constant(EmptyHttpResultInstance))
106-
: throw new UnreachableException("The EmptyHttpResult type could not be found.");
107-
#else
108103
private static readonly NewExpression EmptyHttpResultValueTaskExpr = Expression.New(typeof(ValueTask<object>).GetConstructor(new[] { typeof(IResult) })!, Expression.Constant(EmptyHttpResultInstance));
109-
#endif
110104
private static readonly ParameterExpression TempSourceStringExpr = ParameterBindingMethodCache.TempSourceStringExpr;
111105
private static readonly BinaryExpression TempSourceStringNotNullExpr = Expression.NotEqual(TempSourceStringExpr, Expression.Constant(null));
112106
private static readonly BinaryExpression TempSourceStringNullExpr = Expression.Equal(TempSourceStringExpr, Expression.Constant(null));

src/Http/Routing/test/UnitTests/Microsoft.AspNetCore.Routing.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<Reference Include="Microsoft.AspNetCore.Http" />
11+
<Reference Include="Microsoft.AspNetCore.Http.Results" />
1112
<Reference Include="Microsoft.AspNetCore.Routing" />
1213
<Reference Include="Microsoft.AspNetCore.Http.Results" />
1314
<Reference Include="Microsoft.Extensions.DependencyInjection" />

0 commit comments

Comments
 (0)