Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ConfigurationBinder source gen on components by default #535

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<!-- AOT-compat blocked by https://github.com/dotnet/runtime/issues/93498, extern alias doesn't work because Pdb2Pdb extern error -->
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
<IsAotCompatible>false</IsAotCompatible>
<PackageTags>$(ComponentAzurePackageTags) tables table</PackageTags>
<Description>A client for Azure Table Storage that integrates with Aspire, including health checks, logging, and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzureTable_256x.png</PackageIconFullPath>
Expand All @@ -17,6 +20,7 @@
<PackageReference Include="Azure.Data.Tables" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Azure.Core.Extensions;
using Azure.Data.Tables;
using HealthChecks.Azure.Data.Tables;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

Expand Down Expand Up @@ -76,6 +78,18 @@ protected override IAzureClientBuilder<TableServiceClient, TableClientOptions> A
}, requiresCredential: false);
}

protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<TableServiceClient, TableClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I should just make IDE0200 a suggestion? This seems like a pretty aggressive warning.

clientBuilder.ConfigureOptions(options => configuration.Bind(options));
#pragma warning restore IDE0200
}

protected override void BindSettingsToConfiguration(AzureDataTablesSettings settings, IConfiguration configuration)
{
configuration.Bind(settings);
}

protected override IHealthCheck CreateHealthCheck(TableServiceClient client, AzureDataTablesSettings settings)
=> new AzureTableServiceHealthCheck(client, new AzureTableServiceHealthCheckOptions());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<!-- AOT-compat blocked by https://github.com/dotnet/runtime/issues/93498, extern alias doesn't work because Pdb2Pdb extern error -->
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
<IsAotCompatible>false</IsAotCompatible>
<PackageTags>$(ComponentAzurePackageTags) servicebus amqp</PackageTags>
<Description>A client for Azure Service Bus that integrates with Aspire, including health checks, logging and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzureServiceBus_256x.png</PackageIconFullPath>
Expand All @@ -17,6 +20,7 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Messaging.ServiceBus" />
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Azure.Messaging.ServiceBus;
using HealthChecks.AzureServiceBus;
using HealthChecks.AzureServiceBus.Configuration;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

Expand Down Expand Up @@ -93,6 +95,18 @@ protected override IHealthCheck CreateHealthCheck(ServiceBusClient client, Azure
Credential = settings.Credential
});

protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<ServiceBusClient, ServiceBusClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
clientBuilder.ConfigureOptions(options => configuration.Bind(options));
#pragma warning restore IDE0200
}

protected override void BindSettingsToConfiguration(AzureMessagingServiceBusSettings settings, IConfiguration config)
{
config.Bind(settings);
}

protected override bool GetHealthCheckEnabled(AzureMessagingServiceBusSettings settings)
=> !string.IsNullOrEmpty(settings.HealthCheckQueueName) || !string.IsNullOrEmpty(settings.HealthCheckTopicName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<!-- AOT-compat blocked by https://github.com/dotnet/runtime/issues/94071 -->
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
<IsAotCompatible>false</IsAotCompatible>
<PackageTags>$(ComponentAzurePackageTags) keyvault secrets</PackageTags>
<Description>A client for Azure Key Vault that integrates with Aspire, including health checks, logging and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzureKeyVault_256x.png</PackageIconFullPath>
Expand All @@ -18,6 +21,7 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using HealthChecks.Azure.KeyVault.Secrets;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
Expand Down Expand Up @@ -131,6 +132,18 @@ protected override IAzureClientBuilder<SecretClient, SecretClientOptions> AddCli
protected override IHealthCheck CreateHealthCheck(SecretClient client, AzureSecurityKeyVaultSettings settings)
=> new AzureKeyVaultSecretsHealthCheck(client, new AzureKeyVaultSecretOptions());

protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<SecretClient, SecretClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
clientBuilder.ConfigureOptions(options => configuration.Bind(options));
#pragma warning restore IDE0200
}

protected override void BindSettingsToConfiguration(AzureSecurityKeyVaultSettings settings, IConfiguration configuration)
{
configuration.Bind(settings);
}

protected override bool GetHealthCheckEnabled(AzureSecurityKeyVaultSettings settings)
=> settings.HealthChecks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<!-- AOT-compat blocked by https://github.com/dotnet/runtime/issues/94071 -->
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
<IsAotCompatible>false</IsAotCompatible>
<PackageTags>$(ComponentAzurePackageTags) storage blobs blob</PackageTags>
<Description>A client for Azure Blob Storage that integrates with Aspire, including health checks, logging and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzureStorageContainer_256x.png</PackageIconFullPath>
Expand All @@ -17,6 +20,7 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Storage.Blobs" />
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Azure.Core.Extensions;
using Azure.Storage.Blobs;
using HealthChecks.Azure.Storage.Blobs;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

Expand Down Expand Up @@ -76,6 +78,18 @@ protected override IAzureClientBuilder<BlobServiceClient, BlobClientOptions> Add
}, requiresCredential: false);
}

protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<BlobServiceClient, BlobClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
clientBuilder.ConfigureOptions(options => configuration.Bind(options));
#pragma warning restore IDE0200
}

protected override void BindSettingsToConfiguration(AzureStorageBlobsSettings settings, IConfiguration configuration)
{
configuration.Bind(settings);
}

protected override IHealthCheck CreateHealthCheck(BlobServiceClient client, AzureStorageBlobsSettings settings)
=> new AzureBlobStorageHealthCheck(client);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<!-- AOT-compat blocked by https://github.com/dotnet/runtime/issues/94071 -->
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
<IsAotCompatible>false</IsAotCompatible>
<PackageTags>$(ComponentAzurePackageTags) storage queue queues</PackageTags>
<Description>A client for Azure Queue Storage that integrates with Aspire, including health checks, logging and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzureStorageQueue_256x.png</PackageIconFullPath>
Expand All @@ -17,6 +20,7 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Storage.Queues" />
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Azure.Core.Extensions;
using Azure.Storage.Queues;
using HealthChecks.Azure.Storage.Queues;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

Expand Down Expand Up @@ -76,6 +78,18 @@ protected override IAzureClientBuilder<QueueServiceClient, QueueClientOptions> A
}, requiresCredential: false);
}

protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<QueueServiceClient, QueueClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
clientBuilder.ConfigureOptions(options => configuration.Bind(options));
#pragma warning restore IDE0200
}

protected override void BindSettingsToConfiguration(AzureStorageQueuesSettings settings, IConfiguration configuration)
{
configuration.Bind(settings);
}

protected override IHealthCheck CreateHealthCheck(QueueServiceClient client, AzureStorageQueuesSettings settings)
=> new AzureQueueStorageHealthCheck(client, new AzureQueueStorageHealthCheckOptions());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<IsAotCompatible>true</IsAotCompatible>
<PackageTags>$(ComponentDatabasePackageTags) sqlserver sql</PackageTags>
<Description>A Microsoft SQL Server client that integrates with Aspire, including health checks, metrics and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)SQL_256x.png</PackageIconFullPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.EventCounters" />
<PackageReference Include="OpenTelemetry.Instrumentation.SqlClient" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Data.SqlClient" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<IsAotCompatible>true</IsAotCompatible>
<PackageTags>$(ComponentEfCorePackageTags) sqlserver sql</PackageTags>
<Description>A Microsoft SQL Server provider for Entity Framework Core that integrates with Aspire, including connection pooling, health check, logging, and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)SQL_256x.png</PackageIconFullPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.EventCounters" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<IsAotCompatible>true</IsAotCompatible>
<PackageTags>$(ComponentEfCorePackageTags) postgressql postgres npgsql sql</PackageTags>
<Description>A PostgreSQL® provider for Entity Framework Core that integrates with Aspire, including connection pooling, health checks, logging, and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)PostgreSQL_logo.3colors.540x557.png</PackageIconFullPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Npgsql.DependencyInjection" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Npgsql.OpenTelemetry" />
Expand Down
2 changes: 0 additions & 2 deletions src/Components/Aspire.Npgsql/Aspire.Npgsql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<IsAotCompatible>true</IsAotCompatible>
<PackageTags>$(ComponentDatabasePackageTags) postgressql postgres npgsql sql</PackageTags>
<Description>A PostgreSQL® client that integrates with Aspire, including health checks, metrics, logging, and telemetry.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
<PackageTags>$(ComponentCachePackageTags) redis</PackageTags>
<Description>A generic Redis® client that integrates with Aspire, including health checks, logging, and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)redis-cube-red_white-rgb.png</PackageIconFullPath>
<NoWarn>$(NoWarn);SYSLIB1100;SYSLIB1101</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.Redis" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="StackExchange.Redis" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="StackExchange.Redis" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

global using System.Net.Security; // needed to work around https://github.com/dotnet/runtime/issues/94065

using System.Text;
using Aspire.StackExchange.Redis;
using Microsoft.Extensions.Configuration;
Expand Down
Loading