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

Reduce length of the paths we make for temporary generated files #49059

Conversation

jasonmalinowski
Copy link
Member

Right now when we open a generated file, we make a temporary file on disk to placate parts of the VS API that need a file on disk. (If we had the ability to have our own URI or moniker that'd be fine, but for now we don't have such an ability.) The original plan was to pack in the necessary information we need into the path so we can figure out what file that represents so we can re-open generated files between runs of VS without requiring actual state.

In practice, that didn't work yet (if nothing else, because we're packing in a project ID which is random GUID that isn't persisted across process runs). But the bigger problem is this also runs into MAX_PATH issues, if the generator assembly or type names are fairly long. So for now, let's just generate a GUID for the name and store the extra information in a little lookup table.

This, and also just renaming the parent directory we put things in, shaves off a fair number of characters, and also means the name of the generator assembly or type name are no longer something being added into the overall path length. The only "controllable" parts of the path that can vary in length is the file name (which must match the hint name from the compiler), and the user's username.

Fixes #47782, or at least as well as we can.

Right now when we open a generated file, we make a temporary file on
disk to placate parts of the VS API that need a file on disk. (If we had
the ability to have our own URI or moniker that'd be fine, but for now
we don't have such an ability.) The original plan was to pack in the
necessary information we need into the path so we can figure out what
file that represents so we can re-open generated files between runs of
VS without requiring actual state.

In practice, that didn't work yet (if nothing else, because we're
packing in a project ID which is random GUID that isn't persisted across
process runs). But the bigger problem is this also runs into MAX_PATH
issues, if the generator assembly or type names are fairly long. So
for now, let's just generate a GUID for the name and store the extra
information in a little lookup table.

This, and also just renaming the parent directory we put things in,
shaves off a fair number of characters, and also means the name of the
generator assembly or type name are no longer something being added
into the overall path length. The only "controllable" parts of the
path that can vary in length is the file name (which must match the hint
name from the compiler), and the user's username.

Fixes dotnet#47782, or at least as well
as we can.
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner October 29, 2020 23:32
@jasonmalinowski jasonmalinowski self-assigned this Oct 29, 2020
@CyrusNajmabadi
Copy link
Member

So for now, let's just generate a GUID for the name and store the extra information in a little lookup table.

This seems like this would be a problem for LSIF generation. If we don't have a well known location for the files, how do we find them or refer to them in a sensible fashion?

@jasonmalinowski
Copy link
Member Author

@CyrusNajmabadi: I'm a bit confused by the question. The IDE doesn't read the source generated files on disk since we may not even have such a feature on. I'm not sure @chsienki whether we've see issues there too, but people may have not used it much in the wild yet.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Oct 30, 2020

@CyrusNajmabadi: I'm a bit confused by the question. The IDE doesn't read the source generated files on disk since we may not even have such a feature on. I'm not sure @chsienki whether we've see issues there too, but people may have not used it much in the wild yet.

I'm saying: for LSIF generation we'd want to generate these into a well known location/path. If part of the path is a guid, that doesn't seem possible. Or am i missing something there?

@jasonmalinowski jasonmalinowski merged commit 82a0e85 into dotnet:master Oct 30, 2020
@jasonmalinowski jasonmalinowski deleted the reduce-chances-of-hitting-max-path branch October 30, 2020 03:53
@ghost ghost added this to the Next milestone Oct 30, 2020
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when navigating to generated code
5 participants