-
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
Take MetadataAsSource out of Roslyn package startup path #73360
Conversation
@@ -28,8 +28,6 @@ internal interface IMetadataAsSourceFileService | |||
|
|||
bool TryRemoveDocumentFromWorkspace(string filePath); | |||
|
|||
void CleanupGeneratedFiles(); |
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.
made private, and not part of the interface.
|
||
if (deletedEverything) | ||
{ | ||
Directory.Delete(_rootTemporaryPath); |
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.
no need to delete the topmost directory. It's fine for there to be one top level temp folder we create once and which sticks around across sessions (note: we delete the contents within). This just keeps thigns simpler.
|
||
public int OnAfterCloseSolution(object pUnkReserved) | ||
{ | ||
_metadataAsSourceFileService.CleanupGeneratedFiles(); |
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.
this existed to hear about solution close, so we could clean things up. but we can already just clean things up when we startup anyways.
return _rootTemporaryPathWithGuid; | ||
var guidString = Guid.NewGuid().ToString("N"); | ||
_rootTemporaryPathWithGuid = Path.Combine(_rootTemporaryPath, guidString); | ||
_mutex = new Mutex(initiallyOwned: true, name: CreateMutexName(guidString)); | ||
} |
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.
can initialize all these values when teh type is created.
|
||
// We're being initialized the first time. Use this time to clean up any stale metadata-as-source files | ||
// from previous VS sessions. | ||
CleanupGeneratedFiles(_rootTemporaryPath); |
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 logic here inverts, becoming much simpler. Instead of trying to hook up to shutdown logic to try to clean things at that point, we simply cleanup stale data when we create our first MAS file.
// Release our mutex to indicate we're no longer using our directory and reset state | ||
if (_mutex != null) | ||
{ | ||
_mutex.Dispose(); |
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.
no need to dispose our own mutex. when VS shuts down that will automatically happen.
@jasonmalinowski For review when you get back. |
One of hte paths called out in https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1812707.