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

FileNotFoundException is thrown when analysis is invoked on temporary build files #2696

Closed
2 tasks done
rita-gorokhod opened this issue Oct 12, 2021 · 1 comment
Closed
2 tasks done
Assignees
Milestone

Comments

@rita-gorokhod
Copy link
Contributor

rita-gorokhod commented Oct 12, 2021

Description

When opening a project for the first time, an exception is thrown:

Failed to analyze Temp.txt: System.IO.FileNotFoundException: Could not find file 'C:\Projects\sonarlint-visualstudio\src\Integration.Vsix\bin\Debug\VS2019\net46\Temp.txt'.
File name: 'C:\Projects\sonarlint-visualstudio\src\Integration.Vsix\bin\Debug\VS2019\net46\Temp.txt'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.OpenFileGuts(String filePath, DateTime& lastModifiedTimeUtc, Int64& fileSize)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.OpenFile(String filePath, DateTime& lastModifiedTimeUtc, Int64& fileSize)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.CreateAndLoadTextDocument(String filePath, IContentType contentType, Boolean attemptUtf8Detection, Boolean allowCompressedStorage, Boolean throwOnInvalidCharactersIfUnknownEncoding, Boolean& characterSubstitutionsOccurred)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.CreateAndLoadTextDocument(String filePath, IContentType contentType)
   at SonarLint.VisualStudio.CloudSecrets.SecretsAnalyzer.ExecuteAnalysis(String filePath, String charset, IEnumerable`1 detectedLanguages, IIssueConsumer consumer, IAnalyzerOptions analyzerOptions, CancellationToken cancellationToken)

TODO:

  • Check if there is a way not to invoke analysis on temp files
  • Verify that the file exists before attempting to read it
@rita-gorokhod rita-gorokhod self-assigned this Oct 12, 2021
@rita-gorokhod rita-gorokhod added Type: Bug-WIP Bug in an unreleased feature (which we don't want to appear in the release notes) Type: Task labels Oct 12, 2021
@rita-gorokhod rita-gorokhod reopened this Sep 7, 2022
@rita-gorokhod
Copy link
Contributor Author

rita-gorokhod commented Sep 7, 2022

Happens with latest master build 6.8

Analyzing Temp.txt
Failed to analyze Temp.txt: System.IO.FileNotFoundException: Could not find file 'C:\Windows\system32\Temp.txt'.
File name: 'C:\Windows\system32\Temp.txt'
   at [System.IO](http://system.io/).__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at [System.IO](http://system.io/).FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at [System.IO](http://system.io/).FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.OpenFileGuts(String filePath, DateTime& lastModifiedTimeUtc, Int64& fileSize)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.CreateAndLoadTextDocument(String filePath, IContentType contentType, Boolean attemptUtf8Detection, Boolean allowCompressedStorage, Boolean throwOnInvalidCharactersIfUnknownEncoding, Boolean& characterSubstitutionsOccurred)
   at Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.CreateAndLoadTextDocument(String filePath, IContentType contentType)
   at SonarLint.VisualStudio.CloudSecrets.SecretsAnalyzer.ExecuteAnalysis(String filePath, String charset, IEnumerable`1 detectedLanguages, IIssueConsumer consumer, IAnalyzerOptions analyzerOptions, CancellationToken cancellationToken)

@rita-gorokhod rita-gorokhod added Type: Bug and removed Type: Bug-WIP Bug in an unreleased feature (which we don't want to appear in the release notes) labels Sep 22, 2022
@rita-gorokhod rita-gorokhod added this to the 6.9 milestone Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant