Skip to content

Commit

Permalink
fix: Make sure to select valid IAnalyzerResult from Buildalyzer (#2811)
Browse files Browse the repository at this point in the history
Make sure to select valid IAnalyzerResult from Buildalyzer

Just like #1900 but for the InputFileResolver.

This was not an issue until phmonte/Buildalyzer#198 was reverted in phmonte/Buildalyzer@8e85a15 for the Buildalyzer 6.0.1 release. Before this change in Buildalyzer, the empty target framework was sorted last but since v6.0.1 it's sorted first instead.

Also, improve the NotSupportedException message when the language is undefined because `System.NotSupportedException: Specified method is not supported` is a terrible message.
  • Loading branch information
0xced authored Dec 30, 2023
1 parent bd0ba9c commit 70adc60
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private List<IAnalyzerResult> AnalyzeSolution(StrykerOptions options)
var projectLogName = Path.GetRelativePath(options.WorkingDirectory, project.ProjectFile.Path);
_logger.LogDebug("Analyzing {projectFilePath}", projectLogName);
var buildResult = project.Build();
var projectAnalyzerResult = buildResult.Results.FirstOrDefault();
var projectAnalyzerResult = buildResult.Results.FirstOrDefault(a => a.TargetFramework is not null);
if (projectAnalyzerResult is not null)
{
projectsAnalyzerResults.Add(projectAnalyzerResult);
Expand Down Expand Up @@ -386,7 +386,7 @@ private ProjectComponentsBuilder GetProjectComponentBuilder(
_foldersToExclude,
_logger,
FileSystem),
_ => throw new NotSupportedException()
_ => throw new NotSupportedException($"Language not supported: {language}")
};
}
}

0 comments on commit 70adc60

Please sign in to comment.