Skip to content

Commit

Permalink
Update SDK to preview 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Apr 14, 2023
1 parent c234463 commit 221aec7
Show file tree
Hide file tree
Showing 40 changed files with 523 additions and 366 deletions.
2 changes: 1 addition & 1 deletion build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<MicrosoftAspNetCoreApp31PackageVersion>3.1.3</MicrosoftAspNetCoreApp31PackageVersion>
<MicrosoftBuildLocatorPackageVersion>1.5.5</MicrosoftBuildLocatorPackageVersion>
<MicrosoftBuildPackageVersion>16.9.0</MicrosoftBuildPackageVersion>
<MicrosoftCodeAnalysisNetAnalyzersPackageVersion>7.0.0-preview1.22518.1</MicrosoftCodeAnalysisNetAnalyzersPackageVersion>
<MicrosoftCodeAnalysisNetAnalyzersPackageVersion>8.0.0-preview1.23165.1</MicrosoftCodeAnalysisNetAnalyzersPackageVersion>
<MicrosoftCrankEventSourcesPackageVersion>0.2.0-alpha.21255.1</MicrosoftCrankEventSourcesPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.1</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsPackageVersion>7.0.0</MicrosoftExtensionsPackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.100-preview.3.23164.23"
"version": "8.0.100-preview.3.23178.7"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Integration of ASP.NET Core health checks with Grpc.HealthCheck</Description>
Expand All @@ -18,6 +18,8 @@

<ProjectReference Include="..\Grpc.AspNetCore.Server\Grpc.AspNetCore.Server.csproj" />
<ProjectReference Include="..\Grpc.HealthCheck\Grpc.HealthCheck.csproj" />

<Compile Include="..\Shared\ThrowHelpers\ArgumentNullThrowHelper.cs" Link="Internal\ArgumentNullThrowHelper.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -17,6 +17,7 @@
#endregion

using Grpc.AspNetCore.HealthChecks.Internal;
using Grpc.Shared;
using Microsoft.AspNetCore.Routing;

namespace Microsoft.AspNetCore.Builder;
Expand All @@ -34,10 +35,7 @@ public static class GrpcHealthChecksEndpointRouteBuilderExtensions
/// <returns>An <see cref="GrpcServiceEndpointConventionBuilder"/> for endpoints associated with the service.</returns>
public static GrpcServiceEndpointConventionBuilder MapGrpcHealthChecksService(this IEndpointRouteBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
ArgumentNullThrowHelper.ThrowIfNull(builder);

return builder.MapGrpcService<HealthServiceIntegration>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -18,8 +18,10 @@

using Grpc.AspNetCore.HealthChecks;
using Grpc.HealthCheck;
using Grpc.Shared;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;

namespace Microsoft.Extensions.DependencyInjection;

Expand All @@ -35,10 +37,7 @@ public static class GrpcHealthChecksServiceExtensions
/// <returns>An instance of <see cref="IHealthChecksBuilder"/> from which health checks can be registered.</returns>
public static IHealthChecksBuilder AddGrpcHealthChecks(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
ArgumentNullThrowHelper.ThrowIfNull(services);

return AddGrpcHealthChecksCore(services);
}
Expand All @@ -51,15 +50,8 @@ public static IHealthChecksBuilder AddGrpcHealthChecks(this IServiceCollection s
/// <returns>An instance of <see cref="IHealthChecksBuilder"/> from which health checks can be registered.</returns>
public static IHealthChecksBuilder AddGrpcHealthChecks(this IServiceCollection services, Action<GrpcHealthChecksOptions> configure)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}

if (configure == null)
{
throw new ArgumentNullException(nameof(configure));
}
ArgumentNullThrowHelper.ThrowIfNull(services);
ArgumentNullThrowHelper.ThrowIfNull(configure);

var builder = AddGrpcHealthChecksCore(services);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>HttpClientFactory integration the for gRPC .NET client when running in ASP.NET Core</Description>
Expand All @@ -19,5 +19,7 @@
<ProjectReference Include="..\Grpc.AspNetCore.Server\Grpc.AspNetCore.Server.csproj" />
<!-- PrivateAssets set to None to ensure the build targets/props are propagated to parent project -->
<ProjectReference Include="..\Grpc.Net.ClientFactory\Grpc.Net.ClientFactory.csproj" PrivateAssets="None" />

<Compile Include="..\Shared\ThrowHelpers\ArgumentNullThrowHelper.cs" Link="Internal\ArgumentNullThrowHelper.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -19,6 +19,7 @@
using Grpc.AspNetCore.ClientFactory;
using Grpc.Core;
using Grpc.Net.ClientFactory;
using Grpc.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand All @@ -38,10 +39,7 @@ public static class GrpcServerHttpClientBuilderExtensions
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
public static IHttpClientBuilder EnableCallContextPropagation(this IHttpClientBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
ArgumentNullThrowHelper.ThrowIfNull(builder);

EnableCallContextPropagationCore(builder, new GrpcContextPropagationOptions());

Expand All @@ -57,15 +55,8 @@ public static IHttpClientBuilder EnableCallContextPropagation(this IHttpClientBu
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
public static IHttpClientBuilder EnableCallContextPropagation(this IHttpClientBuilder builder, Action<GrpcContextPropagationOptions> configureOptions)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}

if (configureOptions == null)
{
throw new ArgumentNullException(nameof(configureOptions));
}
ArgumentNullThrowHelper.ThrowIfNull(builder);
ArgumentNullThrowHelper.ThrowIfNull(configureOptions);

var options = new GrpcContextPropagationOptions();
configureOptions(options);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Automatic discovery of services for Grpc.Reflection</Description>
Expand All @@ -19,6 +19,8 @@

<ProjectReference Include="..\Grpc.AspNetCore.Server\Grpc.AspNetCore.Server.csproj" />
<ProjectReference Include="..\Grpc.Reflection\Grpc.Reflection.csproj" />

<Compile Include="..\Shared\ThrowHelpers\ArgumentNullThrowHelper.cs" Link="Internal\ArgumentNullThrowHelper.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -17,6 +17,7 @@
#endregion

using Grpc.Reflection;
using Grpc.Shared;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -35,10 +36,7 @@ public static class GrpcReflectionEndpointRouteBuilderExtensions
/// <returns>An <see cref="IEndpointConventionBuilder"/> for endpoints associated with the service.</returns>
public static IEndpointConventionBuilder MapGrpcReflectionService(this IEndpointRouteBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
ArgumentNullThrowHelper.ThrowIfNull(builder);

ValidateServicesRegistered(builder.ServiceProvider);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -21,6 +21,7 @@
using Grpc.AspNetCore.Server;
using Grpc.Core;
using Grpc.Reflection;
using Grpc.Shared;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
Expand All @@ -39,10 +40,7 @@ public static class GrpcReflectionServiceExtensions
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
public static IServiceCollection AddGrpcReflection(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
ArgumentNullThrowHelper.ThrowIfNull(services);

services.TryAddSingleton<GrpcReflectionMarkerService>();

Expand Down
2 changes: 2 additions & 0 deletions src/Grpc.AspNetCore.Server/Grpc.AspNetCore.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<Compile Include="..\Shared\Server\UnaryServerMethodInvoker.cs" Link="Model\Internal\UnaryServerMethodInvoker.cs" />
<Compile Include="..\Shared\NullableAttributes.cs" Link="Internal\NullableAttributes.cs" />
<Compile Include="..\Shared\CodeAnalysisAttributes.cs" Link="Internal\CodeAnalysisAttributes.cs" />
<Compile Include="..\Shared\ThrowHelpers\ObjectDisposedThrowHelper.cs" Link="Internal\ObjectDisposedThrowHelper.cs" />
<Compile Include="..\Shared\ThrowHelpers\ArgumentNullThrowHelper.cs" Link="Internal\ArgumentNullThrowHelper.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -19,6 +19,7 @@
using System.Diagnostics.CodeAnalysis;
using Grpc.AspNetCore.Server.Internal;
using Grpc.AspNetCore.Server.Model.Internal;
using Grpc.Shared;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -41,10 +42,7 @@ public static GrpcServiceEndpointConventionBuilder MapGrpcService<
#endif
TService>(this IEndpointRouteBuilder builder) where TService : class
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
ArgumentNullThrowHelper.ThrowIfNull(builder);

ValidateServicesRegistered(builder.ServiceProvider);

Expand Down
14 changes: 4 additions & 10 deletions src/Grpc.AspNetCore.Server/GrpcMethodMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -19,6 +19,7 @@
using System.Diagnostics.CodeAnalysis;
using Grpc.AspNetCore.Server.Internal;
using Grpc.Core;
using Grpc.Shared;

namespace Grpc.AspNetCore.Server;

Expand All @@ -39,15 +40,8 @@ public GrpcMethodMetadata(
Type serviceType,
IMethod method)
{
if (serviceType == null)
{
throw new ArgumentNullException(nameof(serviceType));
}

if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ArgumentNullThrowHelper.ThrowIfNull(serviceType);
ArgumentNullThrowHelper.ThrowIfNull(method);

ServiceType = serviceType;
Method = method;
Expand Down
16 changes: 4 additions & 12 deletions src/Grpc.AspNetCore.Server/GrpcServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Grpc.AspNetCore.Server.Internal;
using Grpc.AspNetCore.Server.Model;
using Grpc.AspNetCore.Server.Model.Internal;
using Grpc.Shared;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
Expand All @@ -41,10 +42,7 @@ public static class GrpcServicesExtensions
/// <returns>The same instance of the <see cref="IGrpcServerBuilder"/> for chaining.</returns>
public static IGrpcServerBuilder AddServiceOptions<TService>(this IGrpcServerBuilder grpcBuilder, Action<GrpcServiceOptions<TService>> configure) where TService : class
{
if (grpcBuilder == null)
{
throw new ArgumentNullException(nameof(grpcBuilder));
}
ArgumentNullThrowHelper.ThrowIfNull(grpcBuilder);

grpcBuilder.Services.AddSingleton<IConfigureOptions<GrpcServiceOptions<TService>>, GrpcServiceOptionsSetup<TService>>();
grpcBuilder.Services.Configure(configure);
Expand All @@ -58,10 +56,7 @@ public static IGrpcServerBuilder AddServiceOptions<TService>(this IGrpcServerBui
/// <returns>An <see cref="IGrpcServerBuilder"/> that can be used to further configure the gRPC services.</returns>
public static IGrpcServerBuilder AddGrpc(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
ArgumentNullThrowHelper.ThrowIfNull(services);

services.AddRouting(options =>
{
Expand Down Expand Up @@ -103,10 +98,7 @@ public static IGrpcServerBuilder AddGrpc(this IServiceCollection services)
/// <returns>An <see cref="IGrpcServerBuilder"/> that can be used to further configure the gRPC services.</returns>
public static IGrpcServerBuilder AddGrpc(this IServiceCollection services, Action<GrpcServiceOptions> configureOptions)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
ArgumentNullThrowHelper.ThrowIfNull(services);

return services.Configure(configureOptions).AddGrpc();
}
Expand Down
14 changes: 5 additions & 9 deletions src/Grpc.AspNetCore.Server/InterceptorCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand All @@ -19,6 +19,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using Grpc.Core.Interceptors;
using Grpc.Shared;

namespace Grpc.AspNetCore.Server;

Expand Down Expand Up @@ -52,10 +53,8 @@ public void Add(
#endif
Type interceptorType, params object[] args)
{
if (interceptorType == null)
{
throw new ArgumentNullException(nameof(interceptorType));
}
ArgumentNullThrowHelper.ThrowIfNull(interceptorType);

if (!interceptorType.IsSubclassOf(typeof(Interceptor)))
{
throw new ArgumentException($"Type must inherit from {typeof(Interceptor).FullName}.", nameof(interceptorType));
Expand All @@ -70,10 +69,7 @@ public void Add(
/// <param name="registrations">The set of interceptor registrations to add.</param>
internal void AddRange(IEnumerable<InterceptorRegistration> registrations)
{
if (registrations == null)
{
throw new ArgumentNullException(nameof(registrations));
}
ArgumentNullThrowHelper.ThrowIfNull(registrations);

foreach (var interceptorRegistration in registrations)
{
Expand Down
Loading

0 comments on commit 221aec7

Please sign in to comment.