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

Don't write files in CompilerPackage if not needed #21928

Conversation

jasonmalinowski
Copy link
Member

CompilerPackage was previously being lazy and would just delete and
rewrite files as needed when the package was loaded, even if the
machine would ultimately be left in the same state at the end.
For the old project system (which didn't monitor such file changes)
this wasn't bad, but with the new project system it now reloads projects
in response to changes which can be quite expensive.

Fixes #21838.

@@ -6,6 +6,7 @@
using System.Reflection;
using System.IO;
using EnvDTE;
using System.Collections.Generic;
Copy link
Member

@jaredpar jaredpar Sep 6, 2017

Choose a reason for hiding this comment

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

Sort usings #Resolved

// First we want to ensure any Roslyn files with our hive name that we aren't writing -- this is probably
// leftovers from older extensions
var msbuildDirectory = new DirectoryInfo(GetMSBuildPath());
if (msbuildDirectory.Exists)
Copy link
Member

@jaredpar jaredpar Sep 6, 2017

Choose a reason for hiding this comment

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

Grumble grumble #Resolved

foreach (var fileAndContents in filesToWrite)
{
var parentDirectory = new DirectoryInfo(Path.GetDirectoryName(fileAndContents.Key));
if (!parentDirectory.Exists)
Copy link
Member

Choose a reason for hiding this comment

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

The if is unnecessary here. The Create method is a no-op if the directory exists.

CompilerPackage was previously being lazy and would just delete and
rewrite files as needed when the package was loaded, even if the
machine would ultimately be left in the same state at the end.
For the old project system (which didn't monitor such file changes)
this wasn't bad, but with the new project system it now reloads projects
in response to changes which can be quite expensive.

Fixes dotnet#21838.
@jasonmalinowski jasonmalinowski force-pushed the dont-write-compilerpackage-files-if-not-needed branch from ebb9e2d to abe47f7 Compare September 6, 2017 16:58
@jasonmalinowski jasonmalinowski self-assigned this Sep 6, 2017
@jasonmalinowski jasonmalinowski requested a review from a team September 6, 2017 17:04
continue;
}

File.WriteAllText(fileAndContents.Key, fileAndContents.Value);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: consider using an explicit encoding in all the file ops here. I often find this useful when doing content comparison. Reduces chances of enocding probs. Not a blocker.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM

@jasonmalinowski
Copy link
Member Author

@dotnet-bot retest this please.

@jasonmalinowski jasonmalinowski merged commit ff4d885 into dotnet:master Sep 6, 2017
@jasonmalinowski jasonmalinowski deleted the dont-write-compilerpackage-files-if-not-needed branch September 6, 2017 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants