Skip to content
Permalink
Browse files

React to changes in the latest .NET Core SDK (#172)

  • Loading branch information...
JamesNK committed Mar 18, 2019
1 parent a521d5f commit 3bd15f9ff1158087dac9df315f16f0e7cc6eccf4
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100-preview4-010737"
"version": "3.0.100-preview4-010898"
}
}
@@ -77,9 +77,9 @@ public void GlobalSetup()

_httpContext = new DefaultHttpContext();
_httpContext.RequestServices = _requestServices;
_httpContext.Request.BodyPipe = _requestPipe;
_httpContext.Request.BodyReader = _requestPipe;
_httpContext.Request.ContentType = GrpcProtocolConstants.GrpcContentType;
_httpContext.Response.BodyPipe = new TestPipeWriter();
_httpContext.Response.BodyWriter = new TestPipeWriter();

_httpContext.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
{
@@ -88,7 +88,12 @@ private void AddMethodCore(IMethod method, RequestDelegate requestDelegate, List
resolvedMetadata.Add(method);
resolvedMetadata.AddRange(metadata);

EndpointConventionBuilders.Add(_builder.MapPost(method.FullName, $"gRPC - {method.FullName}", requestDelegate, resolvedMetadata.ToArray()));
var endpointBuilder = _builder
.MapPost(method.FullName, requestDelegate)
.WithDisplayName($"gRPC - {method.FullName}")
.WithMetadata(resolvedMetadata.ToArray());

EndpointConventionBuilders.Add(endpointBuilder);
}

internal void CreateUnimplementedEndpoints()
@@ -124,7 +129,9 @@ internal void CreateUnimplementedEndpoints()
private void CreateUnimplementedEndpoint(string pattern, string displayName, RequestDelegate requestDelegate)
{
var routePattern = RoutePatternFactory.Parse(pattern, defaults: null, new { contentType = GrpcContentTypeConstraint.Instance });
_builder.Map(routePattern, displayName, requestDelegate, new HttpMethodMetadata(new[] { "POST" }));
_builder.Map(routePattern, requestDelegate)
.WithDisplayName(displayName)
.WithMetadata(new HttpMethodMetadata(new[] { "POST" }));
}

private class GrpcContentTypeConstraint : IRouteConstraint
@@ -26,7 +26,6 @@
using Grpc.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Testing;
@@ -265,7 +264,7 @@ public void ConsolidateTrailers_Base64EncodesBinaryTrailers(string trailerName)

private class TestHttpResponseTrailersFeature : IHttpResponseTrailersFeature
{
public IHeaderDictionary Trailers { get; set; } = new HttpResponseTrailers();
public IHeaderDictionary Trailers { get; set; } = new HeaderDictionary();
}

private static readonly ISystemClock TestClock = new TestSystemClock(new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc));
@@ -26,7 +26,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Tokens;
@@ -100,7 +99,7 @@ public void Configure(IApplicationBuilder app)
{
context.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
{
Trailers = new HttpResponseTrailers()
Trailers = new HeaderDictionary()
});
}

0 comments on commit 3bd15f9

Please sign in to comment.
You can’t perform that action at this time.