NightOwl888 opened a new pull request, #1192:
URL: https://github.com/apache/lucenenet/pull/1192

   <!-- Thank you for submitting a pull request to our repo. -->
   
   <!-- Please do NOT submit PRs for features in newer versions of Lucene. We 
should keep the target version consistent across our repository to make the 
upgrade process to newer versions of Lucene go smoothly. -->
   
   <!-- If this is your first PR in the Lucene.NET repo, please run through the 
checklist
   below to ensure a smooth review and merge process for your PR. -->
   
   - [x] You've read the [Contributor 
Guide](https://github.com/apache/lucenenet/blob/master/CONTRIBUTING.md) and 
[Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
   - [x] You've included unit or integration tests for your change, where 
applicable.
   - [x] You've included inline docs for your change, where applicable.
   - [ ] There's an open issue for the PR that you are making. If you'd like to 
propose a change, please [open an 
issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the 
change or find an existing issue.
   
   <!-- Once all that is done, you're ready to go. Open the PR with the content 
below. -->
   
   Added `AsSpan()` and `AsMemory()` methods to `ICharTermAttribute`, 
`CharsRef`, and `BytesRef`
   
   ## Description
   
   This is part of an ongoing effort to broaden support for System.Memory 
types. While there are many types in Lucene.NET that manage memory, these 3 
types are used the most widely.
   
   `CharsRef` and `BytesRef` have an `Offset` property which this takes into 
account and eliminates the burden of having to deal with it for callers when 
slicing into memory.
   
   Note that this does not deal with the broken encapsulation of the designs of 
these types, nor does it add explicit backing fields to optimize performance.
   
   This PR also adds a reference to `Microsoft.Bcl.Memory` for 
`netstandard2.1`, `netstandard2.0` and `net462` to polyfill support for 
`System.Index`, `System.Range`. and `System.Text.Unicode.Utf8`.
   
   ### New APIs
   
   ```c#
   namespace Lucene.Net
   {
       public static class MemoryExtensions
       {
           public static ReadOnlySpan<char> AsSpan(this ICharTermAttribute text)
           public static ReadOnlySpan<char> AsSpan(this ICharTermAttribute 
text, int start)
           public static ReadOnlySpan<char> AsSpan(this ICharTermAttribute 
text, int start, int length)
           public static ReadOnlySpan<char> AsSpan(this ICharTermAttribute 
text, System.Index startIndex)
           public static ReadOnlySpan<char> AsSpan(this ICharTermAttribute 
text, System.Range range)
           public static ReadOnlyMemory<char> AsMemory(this ICharTermAttribute 
text)
           public static ReadOnlyMemory<char> AsMemory(this ICharTermAttribute 
text, int start)
           public static ReadOnlyMemory<char> AsMemory(this ICharTermAttribute 
text, int start, int length)
           public static ReadOnlyMemory<char> AsMemory(this ICharTermAttribute 
text, System.Index startIndex)
           public static ReadOnlyMemory<char> AsMemory(this ICharTermAttribute 
text, System.Range range)
       }
   }
   namespace Lucene.Net.Util
   {
       public class BytesRef
       {
           public BytesRef(ReadOnlySpan<byte> value)
           public BytesRef(ReadOnlySpan<char> text)
           public void Append(ReadOnlySpan<byte> other)
           public ReadOnlySpan<byte> AsSpan()
           public ReadOnlySpan<byte> AsSpan(int start)
           public ReadOnlySpan<byte> AsSpan(int start, int length)
           public ReadOnlySpan<byte> AsSpan(System.Index startIndex)
           public ReadOnlySpan<byte> AsSpan(System.Range range)
           public ReadOnlyMemory<byte> AsMemory()
           public ReadOnlyMemory<byte> AsMemory(int start)
           public ReadOnlyMemory<byte> AsMemory(int start, int length)
           public ReadOnlyMemory<byte> AsMemory(System.Index startIndex)
           public ReadOnlyMemory<byte> AsMemory(System.Range range)
           public void CopyChars(ReadOnlySpan<char> text)
       }
       public class CharsRef
       {
           public CharsRef(ReadOnlySpan<char> value)
           public void Append(ReadOnlySpan<char> otherChars)
           public ReadOnlySpan<char> AsSpan()
           public ReadOnlySpan<char> AsSpan(int start)
           public ReadOnlySpan<char> AsSpan(int start, int length)
           public ReadOnlySpan<char> AsSpan(System.Index startIndex)
           public ReadOnlySpan<char> AsSpan(System.Range range)
           public ReadOnlyMemory<char> AsMemory()
           public ReadOnlyMemory<char> AsMemory(int start)
           public ReadOnlyMemory<char> AsMemory(int start, int length)
           public ReadOnlyMemory<char> AsMemory(System.Index startIndex)
           public ReadOnlyMemory<char> AsMemory(System.Range range)
           public void CopyChars(ReadOnlySpan<char> otherChars)
       }
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to