NightOwl888 commented on code in PR #1170: URL: https://github.com/apache/lucenenet/pull/1170#discussion_r2301614067
########## src/Lucene.Net.Replicator/SessionToken.cs: ########## @@ -112,6 +114,33 @@ public void Serialize(DataOutputStream writer) } } + /// <summary> + /// Asynchronously serialize the token data for communication between server and client. + /// </summary> + /// <param name="output">The <see cref="Stream"/> to write the token data to.</param> + /// <param name="cancellationToken">A cancellation token to observe while waiting for the flush to complete.</param> + /// <returns>A task representing the asynchronous operation.</returns> + public async Task SerializeAsync(Stream output, CancellationToken cancellationToken = default) + { + using var writer = new DataOutputStream(output); + writer.WriteUTF(Id); Review Comment: Gotcha. Maybe it would make more sense to make `ReadUTF` and `WriteUTF` into extension methods of `BinaryReader`/`BinaryWriter` or even `Stream`. I think there are one or two other methods that didn't exist in the BCL that we would need. Other than that, the error handling might be slightly different than in the BCL, but that may not matter very much. Once you have the extension methods battle tested, we can move them into J2N and integrate them into `DataInputStream` and `DataOutputStream`. So, it would be sensible to make low-level methods that accept `ReadOnlySpan<T>` and `Span<T>` to do the actual UTF conversions that can then be utilized to write to the various types of streams. The exceptions should also be changed from `FormatException` to `DecoderFallbackException` and `EncoderFallbackException` to match the BCL, which also means that catch blocks will need to be re-evaluated. -- 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: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org