Closed as not planned
Closed as not planned
Description
Background and motivation
Currently, AddUserSecrets
relies on doing reflection to read the assembly-level attribute emitted via MSBuild.
This makes the consuming API less intuitive, since you have to pass either a type (which one? what for? not obvious) or an assembly (leaky implementation detail).
The user secrets ID property could be made visible to the compiler and a source generator could emit a parameterless AddUserSecrets
that already had the right string in place.
API Proposal
namespace Microsoft.Extensions.Configuration;
public static class UserSecretsConfigurationExtensions
{
public static IConfigurationBuilder AddUserSecrets(this IConfigurationBuilder configuration)
where T : class
=> configuration.AddUserSecrets("[$(UserSecretsId) via MSBuild])", optional: true, reloadOnChange: false);
API Usage
configuration.AddUserSecrets();