Skip to content

Commit 92af444

Browse files
authored
Sort callback parameters per API review (Azure#21658)
1 parent 755b7e2 commit 92af444

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

sdk/extensions/Microsoft.Extensions.Azure/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void ConfigureServices(IServiceCollection services)
125125
services.AddAzureClients(builder =>
126126
{
127127
// Register a client using MyApplicationOptions to get constructor parameters
128-
builder.AddClient<SecretClient, SecretClientOptions>((provider, credential, options) =>
128+
builder.AddClient<SecretClient, SecretClientOptions>((options, credential, provider) =>
129129
{
130130
var appOptions = provider.GetService<IOptions<MyApplicationOptions>>();
131131
return new SecretClient(appOptions.Value.KeyVaultEndpoint, credential, options);

sdk/extensions/Microsoft.Extensions.Azure/api/Microsoft.Extensions.Azure.netstandard2.0.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public static partial class AzureClientBuilderExtensions
1313
public sealed partial class AzureClientFactoryBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder, Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration<Microsoft.Extensions.Configuration.IConfiguration>, Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential
1414
{
1515
internal AzureClientFactoryBuilder() { }
16-
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<Azure.Core.TokenCredential, TOptions, TClient> factory) where TOptions : class { throw null; }
17-
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<System.IServiceProvider, Azure.Core.TokenCredential, TOptions, TClient> factory) where TOptions : class { throw null; }
18-
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<System.IServiceProvider, TOptions, TClient> factory) where TOptions : class { throw null; }
16+
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<TOptions, Azure.Core.TokenCredential, System.IServiceProvider, TClient> factory) where TOptions : class { throw null; }
17+
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<TOptions, Azure.Core.TokenCredential, TClient> factory) where TOptions : class { throw null; }
18+
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<TOptions, System.IServiceProvider, TClient> factory) where TOptions : class { throw null; }
1919
public Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(System.Func<TOptions, TClient> factory) where TOptions : class { throw null; }
2020
Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> Azure.Core.Extensions.IAzureClientFactoryBuilder.RegisterClientFactory<TClient, TOptions>(System.Func<TOptions, TClient> clientFactory) { throw null; }
2121
Azure.Core.Extensions.IAzureClientBuilder<TClient, TOptions> Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration<Microsoft.Extensions.Configuration.IConfiguration>.RegisterClientFactory<TClient, TOptions>(Microsoft.Extensions.Configuration.IConfiguration configuration) { throw null; }

sdk/extensions/Microsoft.Extensions.Azure/samples/StartupWithOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void ConfigureServices(IServiceCollection services)
2525
services.AddAzureClients(builder =>
2626
{
2727
// Register a client using MyApplicationOptions to get constructor parameters
28-
builder.AddClient<SecretClient, SecretClientOptions>((provider, credential, options) =>
28+
builder.AddClient<SecretClient, SecretClientOptions>((options, credential, provider) =>
2929
{
3030
var appOptions = provider.GetService<IOptions<MyApplicationOptions>>();
3131
return new SecretClient(appOptions.Value.KeyVaultEndpoint, credential, options);

sdk/extensions/Microsoft.Extensions.Azure/src/AzureClientFactoryBuilder.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public AzureClientFactoryBuilder ConfigureDefaults(IConfiguration configuration)
9191

9292
IAzureClientBuilder<TClient, TOptions> IAzureClientFactoryBuilderWithCredential.RegisterClientFactory<TClient, TOptions>(Func<TOptions, TokenCredential, TClient> clientFactory, bool requiresCredential)
9393
{
94-
return RegisterClientFactory<TClient, TOptions>((_, options, credential) => clientFactory(options, credential), requiresCredential);
94+
return RegisterClientFactory<TClient, TOptions>((options, credential, _) => clientFactory(options, credential), requiresCredential);
9595
}
9696

9797
/// <summary>
@@ -123,7 +123,7 @@ public AzureClientFactoryBuilder UseCredential(Func<IServiceProvider, TokenCrede
123123
/// <returns>The <see cref="IAzureClientBuilder{TClient, TOptions}"/> to allow client configuration.</returns>
124124
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<TOptions, TClient> factory) where TOptions : class
125125
{
126-
return RegisterClientFactory<TClient, TOptions>((_, options, _) => factory(options), false);
126+
return RegisterClientFactory<TClient, TOptions>((options, _, _) => factory(options), false);
127127
}
128128

129129
/// <summary>
@@ -132,9 +132,9 @@ public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<
132132
/// <typeparam name="TClient">The type of the client.</typeparam>
133133
/// <typeparam name="TOptions">The type of the client options.</typeparam>
134134
/// <returns>The <see cref="IAzureClientBuilder{TClient, TOptions}"/> to allow client configuration.</returns>
135-
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<TokenCredential, TOptions, TClient> factory) where TOptions : class
135+
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<TOptions, TokenCredential, TClient> factory) where TOptions : class
136136
{
137-
return RegisterClientFactory<TClient, TOptions>((_, options, credential) => factory(credential, options), true);
137+
return RegisterClientFactory<TClient, TOptions>((options, credential, _) => factory(options, credential), true);
138138
}
139139

140140
/// <summary>
@@ -144,9 +144,9 @@ public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<
144144
/// <typeparam name="TClient">The type of the client.</typeparam>
145145
/// <typeparam name="TOptions">The type of the client options.</typeparam>
146146
/// <returns>The <see cref="IAzureClientBuilder{TClient, TOptions}"/> to allow client configuration.</returns>
147-
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<IServiceProvider, TOptions, TClient> factory) where TOptions : class
147+
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<TOptions, IServiceProvider, TClient> factory) where TOptions : class
148148
{
149-
return RegisterClientFactory<TClient, TOptions>((provider, options, _) => factory(provider, options), true);
149+
return RegisterClientFactory<TClient, TOptions>((options, _, provider) => factory(options, provider), true);
150150
}
151151

152152
/// <summary>
@@ -156,14 +156,14 @@ public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<
156156
/// <typeparam name="TClient">The type of the client.</typeparam>
157157
/// <typeparam name="TOptions">The type of the client options.</typeparam>
158158
/// <returns>The <see cref="IAzureClientBuilder{TClient, TOptions}"/> to allow client configuration.</returns>
159-
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<IServiceProvider, TokenCredential, TOptions, TClient> factory) where TOptions : class
159+
public IAzureClientBuilder<TClient, TOptions> AddClient<TClient, TOptions>(Func<TOptions, TokenCredential, IServiceProvider, TClient> factory) where TOptions : class
160160
{
161-
return RegisterClientFactory<TClient, TOptions>((provider, options, credential) => factory(provider, credential, options), true);
161+
return RegisterClientFactory<TClient, TOptions>((options, credential, provider) => factory(options, credential, provider), true);
162162
}
163163

164-
private IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<IServiceProvider, TOptions, TokenCredential, TClient> clientFactory, bool requiresCredential) where TOptions : class
164+
private IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TokenCredential, IServiceProvider, TClient> clientFactory, bool requiresCredential) where TOptions : class
165165
{
166-
var clientRegistration = new ClientRegistration<TClient>(DefaultClientName, (provider, options, credential) => clientFactory(provider, (TOptions) options, credential));
166+
var clientRegistration = new ClientRegistration<TClient>(DefaultClientName, (provider, options, credential) => clientFactory((TOptions) options, credential, provider));
167167
clientRegistration.RequiresTokenCredential = requiresCredential;
168168

169169
_serviceCollection.AddSingleton(clientRegistration);

sdk/extensions/Microsoft.Extensions.Azure/tests/AzureClientFactoryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public void CanRegisterCustomClientWithOptionsAndCredential()
376376
{
377377
var serviceCollection = new ServiceCollection();
378378
serviceCollection.AddAzureClients(builder =>
379-
builder.AddClient<TestClientWithCredentials, TestClientOptions>((credential, options) => new TestClientWithCredentials(new Uri("http://localhost/"), credential, options))
379+
builder.AddClient<TestClientWithCredentials, TestClientOptions>((options, credential) => new TestClientWithCredentials(new Uri("http://localhost/"), credential, options))
380380
);
381381
ServiceProvider provider = serviceCollection.BuildServiceProvider();
382382
TestClientWithCredentials client = provider.GetService<TestClientWithCredentials>();
@@ -392,7 +392,7 @@ public void CanRegisterCustomClientProvider()
392392
var serviceCollection = new ServiceCollection();
393393
serviceCollection.AddSingleton("conn str");
394394
serviceCollection.AddAzureClients(builder =>
395-
builder.AddClient<TestClient, TestClientOptions>((p, options) => new TestClient(p.GetService<string>(), options))
395+
builder.AddClient<TestClient, TestClientOptions>((options, p) => new TestClient(p.GetService<string>(), options))
396396
);
397397
ServiceProvider provider = serviceCollection.BuildServiceProvider();
398398
TestClient client = provider.GetService<TestClient>();
@@ -407,7 +407,7 @@ public void CanRegisterCustomClientWithOptionsAndCredentialProvider()
407407
var serviceCollection = new ServiceCollection();
408408
serviceCollection.AddSingleton(new Uri("http://localhost/"));
409409
serviceCollection.AddAzureClients(builder =>
410-
builder.AddClient<TestClientWithCredentials, TestClientOptions>((p, credential, options) => new TestClientWithCredentials(p.GetService<Uri>(), credential, options))
410+
builder.AddClient<TestClientWithCredentials, TestClientOptions>((options, credential, p) => new TestClientWithCredentials(p.GetService<Uri>(), credential, options))
411411
);
412412
ServiceProvider provider = serviceCollection.BuildServiceProvider();
413413
TestClientWithCredentials client = provider.GetService<TestClientWithCredentials>();

0 commit comments

Comments
 (0)