Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Add AddUserSecrets<TStartup>() #544

Merged
merged 1 commit into from
Nov 10, 2016
Merged

Conversation

natemcmaster
Copy link
Contributor

@natemcmaster natemcmaster commented Nov 3, 2016

Mitigates #543. A full fix requires templates to start using this overload instead of .AddUserSecrets().

Also fixes the NRE for null entry assemblies to be more user-friendly.

Copy link

@divega divega left a comment

Choose a reason for hiding this comment

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

:shipit: Subject to approval.

@@ -120,6 +120,9 @@
<data name="Common_StringNullOrEmpty" xml:space="preserve">
<value>Value cannot be null or an empty string.</value>
</data>
<data name="Error_EntryAssemblyNull" xml:space="preserve">
<value>This method could not find a user secret ID because the application's entry assembly is not set.</value>
Copy link

Choose a reason for hiding this comment

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

Consider suggesting calling the generic version of the method.

/// <param name="configuration"></param>
/// <typeparam name="TStartup">The startup class</typeparam>
/// <returns></returns>
public static IConfigurationBuilder AddUserSecrets<TStartup>(this IConfigurationBuilder configuration)
Copy link

Choose a reason for hiding this comment

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

Isn't TStartup a bit arbitrary? I get why it is nice but I feel guilty for lying 😄 I don't feel strongly though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel strongly about the method either. But the thinking was that we would switch templates to use this. .AddUserSecrets<Startup>() seemed cleaner than .AddUserSecrets(typeof(Startup).GetTypeInfo().Assembly).

FWIW as long as we're consider API for the sake of templates, may we should just template .AddUserSecrets(string userSecretId) instead.

Copy link

@divega divega Nov 4, 2016

Choose a reason for hiding this comment

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

Sorry I wasn't clear. I just meant that the method could any T to find the assembly containing the attribute, not necessarily the type of the Startup class, even if in template code we do use Startup. But it doesn't matter. TStartup is nice even uf not necessarily accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, that clarifies.

@natemcmaster
Copy link
Contributor Author

Ping for re-review. Now includes assembly scanning logic to find UserSecretsIdAttribute. cc @Eilon @divega

@natemcmaster
Copy link
Contributor Author

Nevermind. We won't do the scan of assemblies.

@Eilon
Copy link
Member

Eilon commented Nov 10, 2016

This patch fix is approved!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants