From c8cf161cb88f1e9b667199aa0f1b6e16ace606b5 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Jul 2026 13:14:50 +0200 Subject: [PATCH] Add pretty tests for nullable postcondition attributes MaybeNullWhen, NotNull, and return-targeted MaybeNull had no coverage anywhere in the suite. Assisted-by: Claude:claude-fable-5:Claude Code --- .../TestCases/Pretty/NullableRefTypes.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs index 775709b0e..bb13103e7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { @@ -184,4 +185,27 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty throw new NotImplementedException(); } } + + public class T08_NullablePostconditionAttributes + { + public bool TryGet(string key, [MaybeNullWhen(false)] out string value) + { + value = null; + return false; + } + + public static void ThrowIfNull([NotNull] object? o) + { + if (o == null) + { + throw new ArgumentNullException("o"); + } + } + + [return: MaybeNull] + public T FirstOrDefault(IEnumerable source) + { + return default(T); + } + } }