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

Generate different DocumentIds for duplicate generators #64729

Commits on Oct 14, 2022

  1. Generate different DocumentIds for duplicate generators

    We've seen a few places in the wild where a customer ends up with
    a generator installed twice into their project. This was causing an
    issue with how we generate DocumentIds for generated documents:
    we compute that as a stable hash over some pieces of information so
    that way we geneate consistent IDs in different processes, and
    a generated file that disappears due to an edit and comes back can also
    have the same ID.
    
    The hashing algorithm for a DocumentId included the generator's type
    name and the generator's assembly name, but if you have two generators
    with the same assembly name we'd collide. This could happen if you
    have two different generators with the same name, or your project file
    is messed up and causing a generator to be added from two different
    paths at once. This latter case isn't a scenario we support, but this
    change at least ensures Roslyn won't be throwing exceptions which
    ends up requiring investigation.
    
    Related to dotnet#56619, but doesn't
    entirely close it, a duplicate generator producing duplicate files
    will still be confusing. This may also address
    dotnet#57660 but the belief is there's
    a race condition there too, as the dumps I've seen don't show duplicate
    references in the project.
    jasonmalinowski committed Oct 14, 2022
    Configuration menu
    Copy the full SHA
    5e8f77b View commit details
    Browse the repository at this point in the history