Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal sealed class EditAndContinueFeedbackDiagnosticFileProvider : IFeedbackD
/// Watching the file is currently the only way to detect the feedback session.
/// </summary>
private readonly string _vsFeedbackSemaphoreFullPath;
private readonly FileSystemWatcher _vsFeedbackSemaphoreFileWatcher;
private readonly FileSystemWatcher? _vsFeedbackSemaphoreFileWatcher;

private readonly int _vsProcessId;
private readonly DateTime _vsProcessStartTime;
Expand All @@ -65,6 +65,12 @@ public EditAndContinueFeedbackDiagnosticFileProvider(
var vsFeedbackTempDir = Path.Combine(_tempDir, VSFeedbackSemaphoreDir);
_vsFeedbackSemaphoreFullPath = Path.Combine(vsFeedbackTempDir, VSFeedbackSemaphoreFileName);

// Directory may not exist in scenarios such as Razor integration tests
if (!Directory.Exists(vsFeedbackTempDir))
Copy link
Member

Choose a reason for hiding this comment

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

File watcher throws when the directory does not exist? What is the exact exception trace?
That'd be unfortunate since the intent was to detect when the file in that directory is created. The directory indeed might not exist at this time because VS Feedback didn't created it yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Integration tests are struggling to run locally on my machine right now (trying to figure it out) so I don't have the exact stack trace at the moment, but the exception was:

ArgumentException: The directory name C:\Users\allichou\AppData\Local\Temp\Microsoft\VSFeedbackCollector is invalid.

and it was definitely originating from trying to initialize EditAndContinueFeedbackDiagnosticFileProvider. Looking at the constructor code, it seems the most likely culprit is from FileSystemWatcher, as the documentation for the FileSystemWatcher constructor says it can throw:

        //   T:System.ArgumentException:
        //     The path parameter is an empty string (""). -or- The path specified through the
        //     path parameter does not exist.
        //

Copy link
Member

Choose a reason for hiding this comment

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

I see. ok.

{
return;
}

_vsFeedbackSemaphoreFileWatcher = new FileSystemWatcher(vsFeedbackTempDir, VSFeedbackSemaphoreFileName);
_vsFeedbackSemaphoreFileWatcher.Created += (_, _) => OnFeedbackSemaphoreCreatedOrChanged();
_vsFeedbackSemaphoreFileWatcher.Changed += (_, _) => OnFeedbackSemaphoreCreatedOrChanged();
Expand Down Expand Up @@ -93,7 +99,9 @@ private string GetZipFilePath()
=> Path.Combine(Path.Combine(_tempDir, $"EnC_{_vsProcessId}", ZipFileName));

public IReadOnlyCollection<string> GetFiles()
=> new[] { GetZipFilePath() };
=> _vsFeedbackSemaphoreFileWatcher is null
? Array.Empty<string>()
: (IReadOnlyCollection<string>)(new[] { GetZipFilePath() });

private void OnFeedbackSemaphoreCreatedOrChanged()
{
Expand Down