NightOwl888 commented on code in PR #1195:
URL: https://github.com/apache/lucenenet/pull/1195#discussion_r2392710488


##########
src/Lucene.Net.TestFramework/Store/MockIndexOutputWrapper.cs:
##########
@@ -103,6 +104,48 @@ private void CheckDiskFull(byte[] b, int offset, DataInput 
@in, long len)
             }
         }
 
+        // LUCENENET specific overload
+        private void CheckDiskFull(ReadOnlySpan<byte> source)

Review Comment:
   One of the limitations of ref structs is that they [cannot be captured in a 
lambda](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/ref-struct).
 They could be used as a parameter of a delegate, though.
   
   I suppose I could invert the condition to check the `null` on the 
`DataInput` instead of the `ReadOnlySpan` and then do a straight swap 
`ReadOnlySpan` for `byte[]`, keeping the `offset` and `len` parameters.
   
   ```c#
                       if (@in == null)
                       {
                           @delegate.WriteBytes(source.Slice(/*offset*/ 0, 
(int)freeSpace));
                       }
                       else
                       {
                           @delegate.CopyBytes(@in, len);
                       }
   ```
   
   Much like the original implementation, it wouldn't be very clean because 
there would be unused parameters by each caller. 
   
   I will consider a bit more whether there are any alternatives worth 
considering.
   
   > Also, I think the method(s) could use XML doc comments explaining what 
exactly it's doing, since I think doing I/O in a method with a name and 
signature like this is a little counterintuitive.
   
   Agreed. If it is possible to figure out what it is doing to document it :). 
Otherwise, it will just be the blind leading the blind.
   
   I am pretty sure this is mocking a disk full condition, but I could be wrong 
about that.



-- 
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