1- #region Copyright notice and license
1+ #region Copyright notice and license
22
33// Copyright 2019 The gRPC Authors
44//
@@ -47,7 +47,7 @@ public static IHttpClientBuilder ConfigureChannel(this IHttpClientBuilder builde
4747 throw new ArgumentNullException ( nameof ( configureChannel ) ) ;
4848 }
4949
50- ValidateGrpcClient ( builder ) ;
50+ ValidateGrpcClient ( builder , nameof ( ConfigureChannel ) ) ;
5151
5252 builder . Services . AddTransient < IConfigureOptions < GrpcClientFactoryOptions > > ( services =>
5353 {
@@ -78,7 +78,7 @@ public static IHttpClientBuilder ConfigureChannel(this IHttpClientBuilder builde
7878 throw new ArgumentNullException ( nameof ( configureChannel ) ) ;
7979 }
8080
81- ValidateGrpcClient ( builder ) ;
81+ ValidateGrpcClient ( builder , nameof ( ConfigureChannel ) ) ;
8282
8383 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
8484 {
@@ -119,7 +119,7 @@ public static IHttpClientBuilder AddInterceptor(this IHttpClientBuilder builder,
119119 throw new ArgumentNullException ( nameof ( configureInvoker ) ) ;
120120 }
121121
122- ValidateGrpcClient ( builder ) ;
122+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
123123
124124 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
125125 {
@@ -147,7 +147,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
147147 throw new ArgumentNullException ( nameof ( authInterceptor ) ) ;
148148 }
149149
150- ValidateGrpcClient ( builder ) ;
150+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
151151
152152 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
153153 {
@@ -181,7 +181,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
181181 throw new ArgumentNullException ( nameof ( authInterceptor ) ) ;
182182 }
183183
184- ValidateGrpcClient ( builder ) ;
184+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
185185
186186 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
187187 {
@@ -215,7 +215,7 @@ public static IHttpClientBuilder AddCallCredentials(this IHttpClientBuilder buil
215215 throw new ArgumentNullException ( nameof ( credentials ) ) ;
216216 }
217217
218- ValidateGrpcClient ( builder ) ;
218+ ValidateGrpcClient ( builder , nameof ( AddCallCredentials ) ) ;
219219
220220 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
221221 {
@@ -270,7 +270,7 @@ public static IHttpClientBuilder AddInterceptor(this IHttpClientBuilder builder,
270270 throw new ArgumentNullException ( nameof ( configureInvoker ) ) ;
271271 }
272272
273- ValidateGrpcClient ( builder ) ;
273+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
274274
275275 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
276276 {
@@ -308,7 +308,7 @@ public static IHttpClientBuilder AddInterceptor<TInterceptor>(this IHttpClientBu
308308 throw new ArgumentNullException ( nameof ( builder ) ) ;
309309 }
310310
311- ValidateGrpcClient ( builder ) ;
311+ ValidateGrpcClient ( builder , nameof ( AddInterceptor ) ) ;
312312
313313 builder . AddInterceptor ( scope , serviceProvider =>
314314 {
@@ -337,7 +337,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
337337 throw new ArgumentNullException ( nameof ( configureCreator ) ) ;
338338 }
339339
340- ValidateGrpcClient ( builder ) ;
340+ ValidateGrpcClient ( builder , nameof ( ConfigureGrpcClientCreator ) ) ;
341341
342342 builder . Services . AddTransient < IConfigureOptions < GrpcClientFactoryOptions > > ( services =>
343343 {
@@ -369,7 +369,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
369369 throw new ArgumentNullException ( nameof ( configureCreator ) ) ;
370370 }
371371
372- ValidateGrpcClient ( builder ) ;
372+ ValidateGrpcClient ( builder , nameof ( ConfigureGrpcClientCreator ) ) ;
373373
374374 builder . Services . Configure < GrpcClientFactoryOptions > ( builder . Name , options =>
375375 {
@@ -379,7 +379,7 @@ public static IHttpClientBuilder ConfigureGrpcClientCreator(this IHttpClientBuil
379379 return builder ;
380380 }
381381
382- private static void ValidateGrpcClient ( IHttpClientBuilder builder )
382+ private static void ValidateGrpcClient ( IHttpClientBuilder builder , string caller )
383383 {
384384 // Validate the builder is for a gRPC client
385385 foreach ( var service in builder . Services )
@@ -395,6 +395,6 @@ private static void ValidateGrpcClient(IHttpClientBuilder builder)
395395 }
396396 }
397397
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.") ;
399399 }
400400}
0 commit comments