Skip to content

Fix (ReadOnly)Span.Contains with System.Memory NuGet Package#72

Closed
GerardSmit wants to merge 3 commits into
Tyrrrz:masterfrom
GerardSmit:fix/memory-extensions
Closed

Fix (ReadOnly)Span.Contains with System.Memory NuGet Package#72
GerardSmit wants to merge 3 commits into
Tyrrrz:masterfrom
GerardSmit:fix/memory-extensions

Conversation

@GerardSmit

@GerardSmit GerardSmit commented Jan 21, 2026

Copy link
Copy Markdown

Closes #71

  1. Added tests for methods that were being tested (mostly AI generated and validated)
  2. Created a new test project that checks the behavior with System.Memory installed.
  3. Changed the #if-directives so Contains is added.

I need to check the new lines, since there is no .editorconfig in this repo, always fun the differences between Windows, Linux and Git configuration 😅

@GerardSmit GerardSmit changed the title Fix/memory extensions Fix (ReadOnly)Span.Contains with System.Memory NuGet Package Jan 21, 2026
@GerardSmit GerardSmit force-pushed the fix/memory-extensions branch from ded03f9 to 4dbdcf6 Compare January 21, 2026 22:56
@GerardSmit GerardSmit force-pushed the fix/memory-extensions branch from 4dbdcf6 to 73a55a4 Compare January 21, 2026 22:58

// https://learn.microsoft.com/dotnet/api/system.memoryextensions.asspan#system-memoryextensions-asspan-1(-0()-system-int32)
public Span<T> AsSpan(int start) => array.AsSpan(start, array?.Length ?? 0 - start);
public Span<T> AsSpan(int start) => array.AsSpan(start, (array?.Length ?? 0) - start);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a bug fix.

Before the compile would do the following: array?.Length ?? (0 - start)
Instead of: (array?.Length ?? 0) - start

Do you want me to lift this to another PR?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please

@Tyrrrz Tyrrrz added the bug Something isn't working label Feb 10, 2026
@Tyrrrz

Tyrrrz commented Feb 16, 2026

Copy link
Copy Markdown
Owner

Superseded by #74

@Tyrrrz Tyrrrz added duplicate This issue or pull request already exists and removed bug Something isn't working labels Feb 16, 2026
@Tyrrrz Tyrrrz closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(ReadOnly)Span.Contains(T value) is not available with .NET Framework when System.Memory is installed

2 participants