Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions TUnit.FsCheck/FsCheckPropertyTestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace TUnit.FsCheck;
#pragma warning disable IL2072 // DynamicallyAccessedMembers warning
public class FsCheckPropertyTestExecutor : ITestExecutor
{
#if NET8_0_OR_GREATER
private static readonly System.Buffers.SearchValues<char> LineEndings = System.Buffers.SearchValues.Create("\r\n");
#endif

private readonly FsCheckPropertyAttribute _propertyAttribute;

public FsCheckPropertyTestExecutor(FsCheckPropertyAttribute propertyAttribute)
Expand Down Expand Up @@ -192,7 +196,11 @@ private static string FormatCounterexample(MethodInfo methodInfo, Exception ex)
var afterShrunk = message[(shrunkIndex + 7)..].TrimStart();

// Take only the first line
#if NET8_0_OR_GREATER
var newlineIndex = afterShrunk.AsSpan().IndexOfAny(LineEndings);
#else
var newlineIndex = afterShrunk.IndexOfAny(['\r', '\n']);
#endif
var shrunkLine = newlineIndex >= 0 ? afterShrunk[..newlineIndex] : afterShrunk;

if (shrunkLine.StartsWith('('))
Expand Down
Loading