Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Span<T>/ReadOnlySpan<T> in net40 #68

Merged
merged 9 commits into from
Apr 14, 2024

Conversation

NightOwl888
Copy link
Owner

@NightOwl888 NightOwl888 commented Apr 14, 2024

This fixes the net40 target so it supports key features in

  • System.Memory
  • System.Buffers
  • System.Runtime.CompilerServices.Unsafe

which can significantly reduce allocations when used. All of the features in these libraries can now be utilized without conditionally compiling. It also means that the ref struct ValueStringBuilder can now be utilized on net40 as well, further reducing conditional compilation.

This PR does not (yet) remove the conditional compilation. But with this in place, we can remove:

  1. FEATURE_SPAN
  2. FEATURE_ARRAYPOOL
  3. Most code generation, since we can normalize to ReadOnlySpan<char> and Memory<char>
  4. A lot of duplicated code, since all platforms will be able to support ReadOnlySpan<char> and Memory<char>
  5. All ICharSequence overloads that accept char[], StringBuilder, and ICharSequence

The plan is to use ReadOnlySpan<char> to replace the Java-like ICharSequence in most places. Where the stack is not available (types that would be difficult to convert to ref structs), we can use ReadOnlyMemory<char>. To match the BCL, we will provide overloads that accept string that simply cascade the call to the ReadOnlySpan<char> or ReadOnlyMemory<char> implementation.

StringBuilder internally will be replaced with ValueStringBuilder, which is readily convertible to ReadOnlySpan<char>.

This PR also disables the tests that require IKVM and removes the reference, since it no longer compiles. This will need to be revisited again at some point.

@NightOwl888 NightOwl888 merged commit c67c761 into main Apr 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant