Skip to content

Commit

Permalink
fix: Fixed IndexOutOfRange exception when building a project with ana…
Browse files Browse the repository at this point in the history
…lyzers

When building a project with analyzers, Roslyn expects that SyntaxTree length equals to the sourceFileAnalyzerConfigOptions length. However, because we add one more script to SyntaxTree, their lengths don't match and it causes the IndexOutOfRange exception. We don't need to check autogenerated files with analyzers, so skipping them resolves the issue.
  • Loading branch information
SolidAlloy committed Jan 12, 2021
1 parent 8c5f2fd commit 8f0fe7e
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,11 @@ private int RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, Cancellat
int i = 0;
foreach (var syntaxTree in syntaxTrees)
{
// Skip auto-generated files. No need to check them with analyzers.
if (syntaxTree.FilePath.Length == 0)
{
continue;
}

var options = sourceFileAnalyzerConfigOptions[i].AnalyzerOptions;

Expand Down

0 comments on commit 8f0fe7e

Please sign in to comment.