Skip to content

Commit

Permalink
fix: add ability to ignore some code generator errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dupdob committed Mar 23, 2024
1 parent df38a05 commit 64cf618
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public IEnumerable<SemanticModel> GetSemanticModels(IEnumerable<SyntaxTree> synt
return semanticModels;
}


private static readonly string[] _ignoredErrors = { "RZ3600" };
private CSharpCompilation RunSourceGenerators(IAnalyzerResult analyzerResult, Compilation compilation)
{
var generators = analyzerResult.GetSourceGenerators(_logger);
Expand All @@ -125,12 +127,24 @@ private CSharpCompilation RunSourceGenerators(IAnalyzerResult analyzerResult, Co
{
return outputCompilation as CSharpCompilation;
}

var fail = false;
foreach (var diagnostic in errors)
{
_logger.LogError("Failed to generate source code for mutated assembly: {0}", diagnostic);
if (_ignoredErrors.Contains(diagnostic.Id))
{
_logger.LogWarning("Stryker encountered a known error from a coe generator but it will keep on. Compilation may still fail later on: {0}", diagnostic);
}
else
{
_logger.LogError("Failed to generate source code for mutated assembly: {0}", diagnostic);
fail = true;
}
}
if (fail)
{
throw new CompilationException("Source Generator Failure");
}
throw new CompilationException("Source Generator Failure");
return outputCompilation as CSharpCompilation;
}

private CSharpCompilation GetCSharpCompilation(IEnumerable<SyntaxTree> syntaxTrees)
Expand Down

0 comments on commit 64cf618

Please sign in to comment.