1
- #region Copyright notice and license
1
+ #region Copyright notice and license
2
2
3
3
// Copyright 2019 The gRPC Authors
4
4
//
@@ -47,7 +47,7 @@ public static IHttpClientBuilder ConfigureChannel(this IHttpClientBuilder builde
47
47
throw new ArgumentNullException ( nameof ( configureChannel ) ) ;
48
48
}
49
49
50
- ValidateGrpcClient ( builder ) ;
50
+ ValidateGrpcClient ( builder , nameof ( ConfigureChannel ) ) ;
51
51
52
52
builder . Services . AddTransient < IConfigureOptions < GrpcClientFactoryOptions > > ( services =>
53
53
{
@@ -78,7 +78,7 @@ public static IHttpClientBuilder ConfigureChannel(this IHttpClientBuilder builde
78
78
throw new ArgumentNullException ( nameof ( configureChannel ) ) ;
79
79
}
80
80
81
- ValidateGrpcClient ( builder ) ;
81
+ ValidateGrpcClient ( builder , nameof ( ConfigureChannel ) ) ;
82
82
83
83
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
84
84
{
@@ -119,7 +119,7 @@ public static IHttpClientBuilder AddInterceptor(this IHttpClientBuilder builder,
119
119
throw new ArgumentNullException ( nameof ( configureInvoker ) ) ;
120
120
}
121
121
122
- ValidateGrpcClient ( builder ) ;
122
+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
123
123
124
124
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
125
125
{
@@ -147,7 +147,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
147
147
throw new ArgumentNullException ( nameof ( authInterceptor ) ) ;
148
148
}
149
149
150
- ValidateGrpcClient ( builder ) ;
150
+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
151
151
152
152
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
153
153
{
@@ -181,7 +181,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
181
181
throw new ArgumentNullException ( nameof ( authInterceptor ) ) ;
182
182
}
183
183
184
- ValidateGrpcClient ( builder ) ;
184
+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
185
185
186
186
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
187
187
{
@@ -215,7 +215,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
215
215
throw new ArgumentNullException ( nameof ( credentials ) ) ;
216
216
}
217
217
218
- ValidateGrpcClient ( builder ) ;
218
+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
219
219
220
220
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
221
221
{
@@ -270,7 +270,7 @@ public static IHttpClientBuilder AddInterceptor(this IHttpClientBuilder builder,
270
270
throw new ArgumentNullException ( nameof ( configureInvoker ) ) ;
271
271
}
272
272
273
- ValidateGrpcClient ( builder ) ;
273
+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
274
274
275
275
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
276
276
{
@@ -308,7 +308,7 @@ public static IHttpClientBuilder AddInterceptor<TInterceptor>(this IHttpClientBu
308
308
throw new ArgumentNullException ( nameof ( builder ) ) ;
309
309
}
310
310
311
- ValidateGrpcClient ( builder ) ;
311
+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
312
312
313
313
builder . AddInterceptor ( scope , serviceProvider =>
314
314
{
@@ -337,7 +337,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
337
337
throw new ArgumentNullException ( nameof ( configureCreator ) ) ;
338
338
}
339
339
340
- ValidateGrpcClient ( builder ) ;
340
+ ValidateGrpcClient ( builder , nameof ( ConfigureGrpcClientCreator ) ) ;
341
341
342
342
builder . Services . AddTransient < IConfigureOptions < GrpcClientFactoryOptions > > ( services =>
343
343
{
@@ -369,7 +369,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
369
369
throw new ArgumentNullException ( nameof ( configureCreator ) ) ;
370
370
}
371
371
372
- ValidateGrpcClient ( builder ) ;
372
+ ValidateGrpcClient ( builder , nameof ( ConfigureGrpcClientCreator ) ) ;
373
373
374
374
builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
375
375
{
@@ -379,7 +379,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
379
379
return builder ;
380
380
}
381
381
382
- private static void ValidateGrpcClient ( IHttpClientBuilder builder )
382
+ private static void ValidateGrpcClient ( IHttpClientBuilder builder , string caller )
383
383
{
384
384
// Validate the builder is for a gRPC client
385
385
foreach ( var service in builder . Services )
@@ -395,6 +395,6 @@ private static void ValidateGrpcClient(IHttpClientBuilder builder)
395
395
}
396
396
}
397
397
398
- throw new InvalidOperationException ( $ "{ nameof ( AddInterceptor ) } must be used with a gRPC client.") ;
398
+ throw new InvalidOperationException ( $ "{ caller } must be used with a gRPC client.") ;
399
399
}
400
400
}
0 commit comments