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

Prevent EditAndContinueFeedbackDiagnosticFileProvider from throwing an exception in Razor scenarios #68619

Merged

Conversation

allisonchou
Copy link
Contributor

This line in Razor's integration test logic throws an exception since one of the found providers is EditAndContinueFeedbackDiagnosticFileProvider, which seems to only account for Roslyn scenarios. This PR mitigates the issue by ensuring that we don't initialize a FileSystemWatcher (which threw the original exception) unless the provided directory is valid.

@allisonchou allisonchou requested a review from tmat June 14, 2023 19:13
@allisonchou allisonchou requested a review from a team as a code owner June 14, 2023 19:13
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Interactive untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 14, 2023
@@ -65,6 +65,12 @@ internal sealed class EditAndContinueFeedbackDiagnosticFileProvider : IFeedbackD
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.

@allisonchou
Copy link
Contributor Author

allisonchou commented Jun 14, 2023

Thanks for the review @tmat! To close out the convo, I was finally able to get integration tests running again, and the below was the more detailed exception:

Microsoft.VisualStudio.Composition.CompositionFailedException: 'An exception was thrown while initializing part "Microsoft.VisualStudio.LanguageServices.EditAndContinue.EditAndContinueFeedbackDiagnosticFileProvider".'

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

@allisonchou allisonchou enabled auto-merge (squash) June 14, 2023 20:24
@allisonchou allisonchou merged commit f8cada0 into dotnet:main Jun 14, 2023
@ghost ghost added this to the Next milestone Jun 14, 2023
@allisonchou allisonchou deleted the FixDiagnosticFileProviderException branch June 14, 2023 20:39
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interactive untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants