From 1dc0fe281f99807c987703b4b8a59e6ba595470d Mon Sep 17 00:00:00 2001 From: Petr Date: Fri, 7 Oct 2022 17:28:56 +0200 Subject: [PATCH 1/2] Fixed an NullReferenceException for F# projects --- src/Buildalyzer/AnalyzerResult.cs | 2 +- tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Buildalyzer/AnalyzerResult.cs b/src/Buildalyzer/AnalyzerResult.cs index 2523b9f1..4132af28 100644 --- a/src/Buildalyzer/AnalyzerResult.cs +++ b/src/Buildalyzer/AnalyzerResult.cs @@ -90,7 +90,7 @@ public string GetProperty(string name) => && !string.Equals(Path.GetFileName(x.Item2), "csc.exe", StringComparison.OrdinalIgnoreCase)) .Select(x => AnalyzerManager.NormalizePath(Path.Combine(Path.GetDirectoryName(ProjectFilePath), x.Item2))) .ToArray() ?? _fscCommandLineArguments - ?.Where(x => x.Item1 == null + ?.Where(x => x.Item1 == null && x.Item2 != null && !x.Item2.Contains("fsc.dll") && !x.Item2.Contains("fsc.exe")) .Select(x => AnalyzerManager.NormalizePath(Path.Combine(Path.GetDirectoryName(ProjectFilePath), x.Item2))) diff --git a/tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs b/tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs index 73b31eac..8c93c45c 100644 --- a/tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs +++ b/tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs @@ -557,6 +557,7 @@ public void BuildsFSharpProject() // Then results.Count.ShouldBeGreaterThan(0, log.ToString()); + results.First().SourceFiles.ShouldNotBeNull(); results.OverallSuccess.ShouldBeTrue(log.ToString()); results.ShouldAllBe(x => x.Succeeded, log.ToString()); } From 04bfac123a90b1e959261ec1ba52bf235be6c833 Mon Sep 17 00:00:00 2001 From: Petr Date: Fri, 7 Oct 2022 17:32:41 +0200 Subject: [PATCH 2/2] More clear like this --- src/Buildalyzer/AnalyzerResult.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Buildalyzer/AnalyzerResult.cs b/src/Buildalyzer/AnalyzerResult.cs index 4132af28..1da9b3a5 100644 --- a/src/Buildalyzer/AnalyzerResult.cs +++ b/src/Buildalyzer/AnalyzerResult.cs @@ -90,9 +90,9 @@ public string GetProperty(string name) => && !string.Equals(Path.GetFileName(x.Item2), "csc.exe", StringComparison.OrdinalIgnoreCase)) .Select(x => AnalyzerManager.NormalizePath(Path.Combine(Path.GetDirectoryName(ProjectFilePath), x.Item2))) .ToArray() ?? _fscCommandLineArguments - ?.Where(x => x.Item1 == null && x.Item2 != null - && !x.Item2.Contains("fsc.dll") - && !x.Item2.Contains("fsc.exe")) + ?.Where(x => x.Item1 == null + && x.Item2?.Contains("fsc.dll") == false + && x.Item2?.Contains("fsc.exe") == false) .Select(x => AnalyzerManager.NormalizePath(Path.Combine(Path.GetDirectoryName(ProjectFilePath), x.Item2))) .ToArray() ?? _vbcCommandLineArguments ?.Where(x => x.Item1 == null && !_assemblyObjects.Contains(Path.GetFileName(x.Item2), StringComparer.OrdinalIgnoreCase))