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

Write used references file only if different #90

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

KirillOsenkov
Copy link
Contributor

Since the analyzer runs on every keystroke in the IDE it's important to reduce I/O and first-chance exceptions

Sample exception:

System.IO.IOException: The process cannot access the file 'C:\ReferenceTrimmer\src\Analyzer\obj\Debug\netstandard2.0\_ReferenceTrimmer_UsedReferences.log' because it is being used by another process.
   at void System.IO.File.WriteAllText(string path, string contents)
   at void ReferenceTrimmer.Analyzer.ReferenceTrimmerAnalyzer.WriteUsedReferencesToFile(HashSet<string> usedReferences, string declaredReferencesPath) in C:/ReferenceTrimmer/src/Analyzer/ReferenceTrimmerAnalyzer.cs:line 161
   at void Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteCompilationActions(ImmutableArray<CompilationAnalyzerAction> compilationActions, DiagnosticAnalyzer analyzer, CompilationEvent compilationEvent, CancellationToken cancellationToken)+((Action<CompilationAnalysisContext> action, CompilationAnalysisContext context) data) => { } in C:/Roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs:line 332

Since the analyzer runs on every keystroke in the IDE it's important to reduce I/O and first-chance exceptions
@KirillOsenkov
Copy link
Contributor Author

Fixes #89

@KirillOsenkov
Copy link
Contributor Author

@KirillOsenkov
Copy link
Contributor Author

Note this also sorts the references for easier diffing and stability (even though I'm pretty sure the compiler would return these in a deterministic order anyway). If these are not sorted, comparing them is hell. We should perhaps also sort the declared references list.

@dfederm dfederm merged commit ba5ec8a into dfederm:main Mar 22, 2024
2 checks passed
@KirillOsenkov KirillOsenkov deleted the dev/kirillo/incrementalused branch March 22, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants