Skip to content

Commit 8b4fdd9

Browse files
[release/7.0] Don't throw exception for unresolved type (#46078)
* Don't throw exception for unresolved type * Add Microsoft.AspNetCore.Http.HttpResults reference --------- Co-authored-by: Safia Abdalla <[email protected]>
1 parent b208053 commit 8b4fdd9

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
@@ -95,13 +95,7 @@ public static partial class RequestDelegateFactory
9595
// but users still need to assert on it as in https://github.com/dotnet/aspnetcore/issues/45063
9696
// so we temporarily work around this here by using reflection to get the actual type.
9797
private static readonly object? EmptyHttpResultInstance = Type.GetType("Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult, Microsoft.AspNetCore.Http.Results")?.GetProperty("Instance")?.GetValue(null, null);
98-
#if DEBUG
99-
private static readonly NewExpression EmptyHttpResultValueTaskExpr = EmptyHttpResultInstance is not null
100-
? Expression.New(typeof(ValueTask<object>).GetConstructor(new[] { typeof(IResult) })!, Expression.Constant(EmptyHttpResultInstance))
101-
: throw new UnreachableException("The EmptyHttpResult type could not be found.");
102-
#else
10398
private static readonly NewExpression EmptyHttpResultValueTaskExpr = Expression.New(typeof(ValueTask<object>).GetConstructor(new[] { typeof(IResult) })!, Expression.Constant(EmptyHttpResultInstance));
104-
#endif
10599
private static readonly ParameterExpression TempSourceStringExpr = ParameterBindingMethodCache.TempSourceStringExpr;
106100
private static readonly BinaryExpression TempSourceStringNotNullExpr = Expression.NotEqual(TempSourceStringExpr, Expression.Constant(null));
107101
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.Extensions.DependencyInjection" />
1314
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />

0 commit comments

Comments
 (0)