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

Connect open source generated files to the workspace #52094

Commits on Apr 24, 2021

  1. Delete blank line

    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    c02935e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1eb4e64 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f390925 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3a1bc6f View commit details
    Browse the repository at this point in the history
  5. Parse generated text the same way we do regular files

    Now that the compiler doesn't actually parse generated files eagerly,
    we can use the same parsing mechanism we do for parsing regular trees.
    This removes some duplication and also will set us up to have forked
    solutions where we have generated trees that didn't come from the
    compiler at all.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    513570f View commit details
    Browse the repository at this point in the history
  6. Extract out the common DocumentId/hint name/generator identity values

    We pass these around as a group on a fairly regular basis, so let's
    just make them a single type.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    8eebd97 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    11f1d4b View commit details
    Browse the repository at this point in the history
  8. Extract out an interface for CompilationTracker

    This is just the invocation of the extract interface refactoring and
    then some immediate follow-ups to trivially retarget types.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    4d36e8c View commit details
    Browse the repository at this point in the history
  9. Allow GetOpenDocumentInCurrentContextWithChanges to return generated …

    …documents
    
    The overall approach here is to make
    GetOpenDocumentInCurrentContextWithChanges work to return
    SourceGeneratedDocuments like anything else. The strange bit is we have
    to ensure the source generated document matches the text that's
    currently in the buffer. Consider a case where:
    
    1. The user makes a change in another file which means the generator
       will produce new results. That generator is running async.
    2. The user switches back to the generated file and immediately invokes
       a command on it before we refresh the buffer contents.
    
    In that case, the buffer contents are stale, but we need to ensure the
    SourceGeneratedDocument given to all our features is in sync with the
    actual text buffer, or otherwise spans and everything won't align. This
    is very similar to the general concept of the "with changes" portion of
    that API: you may always get a forked version of the world that doesn't
    represent an entirely consistent view of the entire world, but it's at
    least going to ensure your document matches your starting point.
    
    In the "regular case" that the generator has already ran and we're able
    to confirm the contents of the text buffer still matches the generated
    output, this (like for regular documents) doesn't fork anything at all
    -- you end up with the Solution object that matches
    Workspace.CurrentSolution.
    
    The implementation approach here is to ensure that when we do fork a
    snapshot the final Compilation has the tree matching the text present no
    matter what. One approach would have been to fork the compilation
    tracker with some extra special state that remembers to fix that up in
    the end but I had two concerns with that approach:
    
    1. The compilation tracker implementation is already crazy complicated.
    2. Forking the compilation tracker while a generator is running potentially
       now running generators twice depending on the timing.
    
    I decided to take the approach that CompilationTracker has an interface
    extracted for it's actual surface area, and then when we do the forked
    solution we create a different implementation of that interface that
    forwards to the underlying implementation and then replaces out the tree
    at the very end. This means we don't ever have generators running twice,
    and the magic of swapping out the tree is all contained in the special
    implementation and the core implementation is untouched.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    d14879f View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d3670be View commit details
    Browse the repository at this point in the history
  11. Ensure GeneratedFileReplacingCompilationTracker.ContainsAssemblyOrMod…

    …uleOrDynamic works
    
    This is a naive implementation that simply ensures we don't get
    different behavior from the main implementation. Most of this change
    is just moving the creation and matching logic into UnrootedSymbolSet.cs
    itself.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    25ddeb7 View commit details
    Browse the repository at this point in the history
  12. Update GetRelatedDocumentsWithChanges to work with open generated files

    This works the same as the GetOpenDocumentInCurrentContextWithChanges.
    This fixes navigation bars specifically which use this.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    67a0994 View commit details
    Browse the repository at this point in the history
  13. Stop holding onto ISourceGenerators in our document identity

    We were holding onto the ISourceGenerator instance and passing it around
    for various reasons; this decomposes it into holding onto the assembly
    name and type name strings, so we can serialize this across processes.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    715efec View commit details
    Browse the repository at this point in the history
  14. Dynamically connect the source generated file to the workspace

    We don't know up-front whether a generated file exists in the workspace,
    and our APIs to grab a document from a buffer are intended to complete
    quickly. If it turns out later the file isn't in the workspace anymore
    we will fake it and add it back so that way features aren't surprised by
    this. However, that means semantics in that file may be inaccurate.
    Disconnecting the document means that once the file is gone, then we
    won't be in this incorrect state for long.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    af6ba45 View commit details
    Browse the repository at this point in the history
  15. Rename infoChecksum to attributesChecksum

    It's a checksum of the attributes, not info, which can be confusing
    here.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    5311268 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    eb50444 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    a0736e8 View commit details
    Browse the repository at this point in the history
  18. Remove WellKnownSynchronizationKind.RecoverableSourceText

    This isn't actually used by anything.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    1ca9662 View commit details
    Browse the repository at this point in the history
  19. Add an assert when we are sending a null value

    We already had an assert that we shouldn't read one, but this adds the
    same assert on the sending side where it's easier to debug the source
    of the problem.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    4ef0074 View commit details
    Browse the repository at this point in the history
  20. Tweak how null checksums are handled during solution sync

    There are a number of asserts which try to ensure that we don't try
    to sync a null across the wire during solution sync. If you wanted to
    try using Checksum.Null as a placeholder for an optional value during
    synchronization, you'd hit these asserts because not everything would
    filter them out. This change filters them out during some parts of
    the synchronization process, allowing it to be used as an optional
    value.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    f8fd45e View commit details
    Browse the repository at this point in the history
  21. Synchronize the state of frozen source generated documents

    The solution has the concept of "frozen" source generated documents
    where we force a solution snapshot to have a source generated document
    of a certain content, even if the generator is producing something new.
    This allows us to isolate features operating on a source generated
    document open in the editor that hasn't been updated yet -- we freeze
    the contents of the source generated file to match the open buffer,
    so taggers and the like can still function normally. This commit ensures
    that we synchronize those to the OOP process so everything stays in
    sync.
    
    The primary counter-intuitive bit is why we're holding onto this
    information at the SolutionState level, but that's because the place
    where the information is ultimately needed is the compilation trackers,
    which are held by the Solution object and nowhere else. This allows us
    to reuse the underlying project states for maximum efficiency.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    b615e21 View commit details
    Browse the repository at this point in the history
  22. Add an option to control source generated files being opened

    Since we want to put this into 16.10 but we're past the feature cutoff,
    we'll put this behind an experimental flag.
    jasonmalinowski committed Apr 24, 2021
    Configuration menu
    Copy the full SHA
    02e62fa View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    cc4961d View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    7020a27 View commit details
    Browse the repository at this point in the history