Skip to content

User Secrets documentation doesn't mention incompatibility with AssemblyInfo.cs #27611

Closed

Description

@TWolverson

AddUserSecrets<T>() depends on the presence of the UserSecretsIdAttribute decorating the calling assembly. This documentation only mentions the project setting and doesn't clarify that what this does is generate an assembly attribute, and in particular, this doesn't happen if the project was migrated from a previous version of .NET using the Migration Assistant, where .NET Framework project conventions were typically to use an AssemblyInfo.cs and therefore migration adds a project setting <GenerateAssemblyInfo>false</GenerateAssemblyInfo> since generated attributes and boilerplate coded attributes conflict. This setting indirectly and silently prevents user secrets from working. It's particularly obtuse in .NET 6 and onwards because the AddUserSecrets call is implicit in the default builder and you wouldn't think look at the method signature and deduce what it's probably doing. Passing optional: false exposes the error more clearly, but again if this is implicit in the default builder, one wouldn't think to set it.

I don't think it's practical to change the API behaviour since user secrets should be an opt-in, but when one does opt-in on a migrated project, it simply doesn't work unless you know to also change something that would seem unrelated. Therefore I think this needs to be documented more clearly.


Document Details

⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 60873

Activity

  1. added
    Source - Docs.ms
    on Nov 12, 2022
  2. added
    reQUEST
    on Jan 26, 2023
  3. added
    seQUESTered
    and removed
    reQUEST
    on Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Source - Docs.msdoc-enhancementseQUESTered

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions