From a9888ab4fc6b59e38551086f90cd6c7b31d79f0b Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Wed, 12 Feb 2025 11:15:22 +0100 Subject: [PATCH] Fix new compilation errors introduced in 9.0.200 This addresses new compilation errors that were introduced with .NET SDK 9.0.200 --- build/CommandLine.fs | 4 +++- build/build.fsproj | 2 -- .../Diagnostics/DiagnosticsChannel.cs | 2 +- .../Framework/ErrorCollectorAssertions.fs | 18 ++++++++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build/CommandLine.fs b/build/CommandLine.fs index 9af384bd5..60af3d86c 100644 --- a/build/CommandLine.fs +++ b/build/CommandLine.fs @@ -74,7 +74,9 @@ with seq { for c in cases do if c.GetFields().Length = 0 then - FSharpValue.MakeUnion(c, [| |]) :?> Build + match FSharpValue.MakeUnion(c, [| |]) with + | NonNull u -> u :?> Build + | _ -> failwithf $"%s{c.Name} can not be cast to Build enum" } static member Ignore (_: Build) _ = () diff --git a/build/build.fsproj b/build/build.fsproj index e68967acf..dd45f5a01 100644 --- a/build/build.fsproj +++ b/build/build.fsproj @@ -12,8 +12,6 @@ - - diff --git a/src/Elastic.Markdown/Diagnostics/DiagnosticsChannel.cs b/src/Elastic.Markdown/Diagnostics/DiagnosticsChannel.cs index d6848520d..bc80aa84e 100644 --- a/src/Elastic.Markdown/Diagnostics/DiagnosticsChannel.cs +++ b/src/Elastic.Markdown/Diagnostics/DiagnosticsChannel.cs @@ -56,7 +56,7 @@ public readonly record struct Diagnostic public interface IDiagnosticsOutput { - public void Write(Diagnostic diagnostic); + void Write(Diagnostic diagnostic); } public class DiagnosticsCollector(IReadOnlyCollection outputs) diff --git a/tests/authoring/Framework/ErrorCollectorAssertions.fs b/tests/authoring/Framework/ErrorCollectorAssertions.fs index c23d80751..95c4c9033 100644 --- a/tests/authoring/Framework/ErrorCollectorAssertions.fs +++ b/tests/authoring/Framework/ErrorCollectorAssertions.fs @@ -27,8 +27,14 @@ module DiagnosticsCollectorAssertions = .Where(fun d -> d.Severity = Severity.Error) .ToArray() |> List.ofArray - let message = errorDiagnostics.FirstOrDefault().Message - test <@ message.Contains(expected) @> + |> List.tryHead + + match errorDiagnostics with + | Some e -> + let message = e.Message + test <@ message.Contains(expected) @> + | None -> failwithf "Expected errors but no errors were logged" + let hasNoWarnings (actual: Lazy) = let actual = actual.Value @@ -43,5 +49,9 @@ module DiagnosticsCollectorAssertions = .Where(fun d -> d.Severity = Severity.Warning) .ToArray() |> List.ofArray - let message = errorDiagnostics.FirstOrDefault().Message - test <@ message.Contains(expected) @> + |> List.tryHead + match errorDiagnostics with + | Some e -> + let message = e.Message + test <@ message.Contains(expected) @> + | None -> failwithf "Expected errors but no errors were logged"