NightOwl888 / ICU4N

International Components for Unicode for .NET
Apache License 2.0
27 stars 7 forks source link

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

Closed NightOwl888 closed 7 months ago

NightOwl888 commented 7 months ago

This fixes the net40 target so it supports key features in

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.