Browse Source

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
pull/3857/head
Siegfried Pammer 3 days ago committed by Siegfried Pammer
parent
commit
c8cf161cb8
  1. 24
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs

24
ICSharpCode.Decompiler.Tests/TestCases/Pretty/NullableRefTypes.cs

@ -2,6 +2,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
@ -184,4 +185,27 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
throw new NotImplementedException(); 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<T>(IEnumerable<T> source)
{
return default(T);
}
}
} }

Loading…
Cancel
Save