-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Don't write files in CompilerPackage if not needed #21928
Conversation
@@ -6,6 +6,7 @@ | |||
using System.Reflection; | |||
using System.IO; | |||
using EnvDTE; | |||
using System.Collections.Generic; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
ebb9e2d
to
abe47f7
Compare
continue; | ||
} | ||
|
||
File.WriteAllText(fileAndContents.Key, fileAndContents.Value); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dotnet-bot retest this please. |
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.