diff --git a/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2.cs b/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2.cs
index 07113b6d7e..91669db836 100644
--- a/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2.cs
+++ b/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2.cs
@@ -41,7 +41,7 @@ public interface IAttributes2 : IAttributes
///
/// The attribute index (zero-based).
/// true if the attribute was declared in the DTD, false otherwise.
- /// When the supplied index does not identify an attribute.
+ /// When the supplied index does not identify an attribute.
bool IsDeclared(int index);
///
@@ -79,7 +79,7 @@ public interface IAttributes2 : IAttributes
///
/// The attribute index (zero-based).
/// true if the value was found in the XML text, false if the value was provided by DTD defaulting.
- /// When the supplied index does not identify an attribute.
+ /// When the supplied index does not identify an attribute.
bool IsSpecified(int index);
///
diff --git a/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2Impl.cs b/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2Impl.cs
index 88e2319067..5756ddc756 100644
--- a/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2Impl.cs
+++ b/src/Lucene.Net.Benchmark/Support/Sax/Ext/Attributes2Impl.cs
@@ -74,8 +74,10 @@ public Attributes2(IAttributes atts)
public bool IsDeclared(int index)
{
if (index < 0 || index >= Length)
- throw new IndexOutOfRangeException(
- "No attribute at index: " + index);
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), $"No attribute at index: {index}");
+ }
+
return declared[index];
}
@@ -114,12 +116,14 @@ public bool IsDeclared(string qName)
///
/// The attribute index (zero-based).
/// current flag value
- /// When the supplied index does not identify an attribute.
+ /// When the supplied index does not identify an attribute.
public bool IsSpecified(int index)
{
if (index < 0 || index >= Length)
- throw new IndexOutOfRangeException(
- "No attribute at index: " + index);
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), $"No attribute at index: {index}");
+ }
+
return specified[index];
}
@@ -128,7 +132,7 @@ public bool IsSpecified(int index)
///
/// The Namespace URI, or the empty string if the name has no Namespace URI.
/// The attribute's local name.
- /// current flag value
+ /// current flag value
/// When the supplied names do not identify an attribute.
public bool IsSpecified(string uri, string localName)
{
@@ -146,7 +150,7 @@ public bool IsSpecified(string uri, string localName)
///
/// The XML qualified (prefixed) name.
/// current flag value
- /// When the supplied name does not identify an attribute.
+ /// When the supplied name does not identify an attribute.
public bool IsSpecified(string qName)
{
int index = GetIndex(qName);
@@ -253,12 +257,14 @@ public override void RemoveAttribute(int index)
///
/// The index of the attribute (zero-based).
/// The desired flag value.
- /// When the supplied index does not identify an attribute.
+ /// When the supplied index does not identify an attribute.
public virtual void SetDeclared(int index, bool value)
{
if (index < 0 || index >= Length)
- throw new IndexOutOfRangeException(
- "No attribute at index: " + index);
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), $"No attribute at index: {index}");
+ }
+
declared[index] = value;
}
@@ -269,12 +275,14 @@ public virtual void SetDeclared(int index, bool value)
///
/// The index of the attribute (zero-based).
/// The desired flag value.
- /// When the supplied index does not identify an attribute.
+ /// When the supplied index does not identify an attribute.
public virtual void SetSpecified(int index, bool value)
{
if (index < 0 || index >= Length)
- throw new IndexOutOfRangeException(
- "No attribute at index: " + index);
+ {
+ throw new ArgumentOutOfRangeException(nameof(index), $"No attribute at index: {index}");
+ }
+
specified[index] = value;
}
}
diff --git a/src/Lucene.Net.Benchmark/Support/Sax/Helpers/AttributesImpl.cs b/src/Lucene.Net.Benchmark/Support/Sax/Helpers/AttributesImpl.cs
index 84ad4ecbf1..4f6c86b552 100644
--- a/src/Lucene.Net.Benchmark/Support/Sax/Helpers/AttributesImpl.cs
+++ b/src/Lucene.Net.Benchmark/Support/Sax/Helpers/AttributesImpl.cs
@@ -30,9 +30,9 @@ namespace Sax.Helpers
/// - to construct or modify an Attributes object in a SAX2 driver or filter.
///
///
- /// This class replaces the now-deprecated SAX1 AttributeListImpl
+ /// This class replaces the now-deprecated SAX1 AttributeListImpl
/// class; in addition to supporting the updated Attributes
- /// interface rather than the deprecated IAttributeList
+ /// interface rather than the deprecated IAttributeList
/// interface, it also includes a much more efficient
/// implementation using a single array rather than a set of Vectors.
///
@@ -322,7 +322,7 @@ public virtual string GetValue(string qName)
/// Clear the attribute list for reuse.
///
/// Note that little memory is freed by this call:
- /// the current array is kept so it can be
+ /// the current array is kept so it can be
/// reused.
///
public virtual void Clear()
@@ -391,7 +391,7 @@ public virtual void AddAttribute(string uri, string localName, string qName,
///
/// Set an attribute in the list.
- ///
+ ///
/// For the sake of speed, this method does no checking
/// for name conflicts or well-formedness: such checks are the
/// responsibility of the application.
@@ -406,9 +406,9 @@ public virtual void AddAttribute(string uri, string localName, string qName,
/// if qualified names are not available.
/// The attribute type as a string.
/// The attribute value.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetAttribute(int index, string uri, string localName,
string qName, string type, string value)
{
@@ -430,7 +430,7 @@ public virtual void SetAttribute(int index, string uri, string localName,
/// Remove an attribute from the list.
///
/// The index of the attribute (zero-based).
- /// When the supplied index does not point to an attribute in the list.
+ /// When the supplied index does not point to an attribute in the list.
public virtual void RemoveAttribute(int index)
{
if (index >= 0 && index < length)
@@ -460,9 +460,9 @@ public virtual void RemoveAttribute(int index)
/// The index of the attribute (zero-based).
/// The attribute's Namespace URI, or the empty
/// string for none.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetURI(int index, string uri)
{
if (index >= 0 && index < length)
@@ -481,9 +481,9 @@ public virtual void SetURI(int index, string uri)
/// The index of the attribute (zero-based).
/// The attribute's local name, or the empty
/// string for none.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetLocalName(int index, string localName)
{
if (index >= 0 && index < length)
@@ -502,9 +502,9 @@ public virtual void SetLocalName(int index, string localName)
/// The index of the attribute (zero-based).
/// The attribute's qualified name, or the empty
/// string for none.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetQName(int index, string qName)
{
if (index >= 0 && index < length)
@@ -522,9 +522,9 @@ public virtual void SetQName(int index, string qName)
///
/// The index of the attribute (zero-based).
/// The attribute's type.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetType(int index, string type)
{
if (index >= 0 && index < length)
@@ -542,9 +542,9 @@ public virtual void SetType(int index, string type)
///
/// The index of the attribute (zero-based).
/// The attribute's value.
- /// When the
+ /// When the
/// supplied index does not point to an attribute
- /// in the list.
+ /// in the list.
public virtual void SetValue(int index, string value)
{
if (index >= 0 && index < length)
@@ -601,12 +601,12 @@ private void EnsureCapacity(int n)
/// Report a bad array index in a manipulator.
///
/// The index to report.
- /// Always.
+ /// Always.
+ [DoesNotReturn]
private static void BadIndex(int index) // LUCENENET: CA1822: Mark members as static
{
- string msg =
- "Attempt to modify attribute at illegal index: " + index;
- throw new IndexOutOfRangeException(msg);
+ string msg = $"Attempt to modify attribute at illegal index: {index}";
+ throw new ArgumentOutOfRangeException(nameof(index), msg);
}
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index 8b8b08e6e0..ee42307ff8 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -178,8 +178,10 @@ public override long Get(int docId)
try
{
if (docId < 0 || docId >= _outerInstance.maxDoc)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) +
- "; got " + docId);
+ {
+ throw new ArgumentOutOfRangeException(nameof(docId),
+ $"docID must be 0 .. {_outerInstance.maxDoc - 1}; got {docId}");
+ }
_input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId);
SimpleTextUtil.ReadLine(_input, _scratch);
@@ -273,8 +275,10 @@ public override void Get(int docId, BytesRef result)
try
{
if (docId < 0 || docId >= _outerInstance.maxDoc)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) +
- "; got " + docId);
+ {
+ throw new ArgumentOutOfRangeException(nameof(docId),
+ $"docID must be 0 .. {_outerInstance.maxDoc - 1}; got {docId}");
+ }
_input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId);
SimpleTextUtil.ReadLine(_input, _scratch);
@@ -396,8 +400,8 @@ public override int GetOrd(int docId)
{
if (docId < 0 || docId >= _outerInstance.maxDoc)
{
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) + "; got " +
- docId);
+ throw new ArgumentOutOfRangeException(nameof(docId),
+ $"docID must be 0 .. {_outerInstance.maxDoc - 1}; got {docId}");
}
try
@@ -428,8 +432,10 @@ public override void LookupOrd(int ord, BytesRef result)
{
if (ord < 0 || ord >= _field.NumValues)
{
- throw new IndexOutOfRangeException($"ord must be 0 .. {(_field.NumValues - 1)}; got {ord}");
+ throw new ArgumentOutOfRangeException(nameof(ord),
+ $"ord must be 0 .. {_field.NumValues - 1}; got {ord}");
}
+
_input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength));
SimpleTextUtil.ReadLine(_input, _scratch);
// LUCENENET specific - use wrapper BytesRefFormatter struct to defer building the string unless string.Format() is called
@@ -505,8 +511,10 @@ public override long NextOrd()
public override void SetDocument(int docID)
{
if (docID < 0 || docID >= _outerInstance.maxDoc)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) + "; got " +
- docID);
+ {
+ throw new ArgumentOutOfRangeException(nameof(docID),
+ $"docID must be 0 .. {_outerInstance.maxDoc - 1}; got {docID}");
+ }
try
{
@@ -529,7 +537,8 @@ public override void LookupOrd(long ord, BytesRef result)
{
if (ord < 0 || ord >= _field.NumValues)
{
- throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " + ord);
+ throw new ArgumentOutOfRangeException(nameof(ord),
+ $"ord must be 0 .. {_field.NumValues - 1}; got {ord}");
}
_input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength));
diff --git a/src/Lucene.Net.Memory/MemoryIndexNormDocValues.cs b/src/Lucene.Net.Memory/MemoryIndexNormDocValues.cs
index a6dc2a9dbd..7040151a7b 100644
--- a/src/Lucene.Net.Memory/MemoryIndexNormDocValues.cs
+++ b/src/Lucene.Net.Memory/MemoryIndexNormDocValues.cs
@@ -19,13 +19,14 @@ namespace Lucene.Net.Index.Memory
* limitations under the License.
*/
- ///
+ ///
///
/// @lucene.internal
///
internal class MemoryIndexNormDocValues : NumericDocValues
{
private readonly long value;
+
public MemoryIndexNormDocValues(long value)
{
this.value = value;
@@ -35,7 +36,7 @@ public override long Get(int docID)
{
if (docID != 0)
{
- throw new IndexOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(docID));
}
else
{
@@ -43,4 +44,4 @@ public override long Get(int docID)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net/Codecs/Lucene40/BitVector.cs b/src/Lucene.Net/Codecs/Lucene40/BitVector.cs
index 6b3f68d823..0afe5a7b88 100644
--- a/src/Lucene.Net/Codecs/Lucene40/BitVector.cs
+++ b/src/Lucene.Net/Codecs/Lucene40/BitVector.cs
@@ -97,8 +97,9 @@ public void Set(int bit)
{
if (bit >= size)
{
- throw new IndexOutOfRangeException("bit=" + bit + " size=" + size);
+ throw new ArgumentOutOfRangeException(nameof(bit), $"bit={bit} size={size}");
}
+
bits[bit >> 3] |= (byte)(1 << (bit & 7));
count = -1;
}
@@ -111,8 +112,9 @@ public bool GetAndSet(int bit)
{
if (bit >= size)
{
- throw new IndexOutOfRangeException("bit=" + bit + " size=" + size);
+ throw new ArgumentOutOfRangeException(nameof(bit), $"bit={bit} size={size}");
}
+
int pos = bit >> 3;
int v = bits[pos];
int flag = 1 << (bit & 7);
@@ -139,8 +141,9 @@ public void Clear(int bit)
{
if (bit >= size)
{
- throw new IndexOutOfRangeException(bit.ToString());
+ throw new ArgumentOutOfRangeException(nameof(bit), bit.ToString());
}
+
bits[bit >> 3] &= (byte)(~(1 << (bit & 7)));
count = -1;
}
@@ -149,8 +152,9 @@ public bool GetAndClear(int bit)
{
if (bit >= size)
{
- throw new IndexOutOfRangeException(bit.ToString());
+ throw new ArgumentOutOfRangeException(nameof(bit), bit.ToString());
}
+
int pos = bit >> 3;
int v = bits[pos];
int flag = 1 << (bit & 7);
diff --git a/src/Lucene.Net/Index/DocValues.cs b/src/Lucene.Net/Index/DocValues.cs
index 77039091c0..73aa67fdef 100644
--- a/src/Lucene.Net/Index/DocValues.cs
+++ b/src/Lucene.Net/Index/DocValues.cs
@@ -101,14 +101,14 @@ public override void SetDocument(int docID)
public override void LookupOrd(long ord, BytesRef result)
{
- throw new IndexOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(ord));
}
public override long ValueCount => 0;
public override long OrdAt(int index)
{
- throw new IndexOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(index));
}
public override int Cardinality => 0;
diff --git a/src/Lucene.Net/Index/SegmentReader.cs b/src/Lucene.Net/Index/SegmentReader.cs
index fbc04a0300..b08bfdc419 100644
--- a/src/Lucene.Net/Index/SegmentReader.cs
+++ b/src/Lucene.Net/Index/SegmentReader.cs
@@ -309,7 +309,7 @@ public override FieldInfos FieldInfos
}
///
- /// Expert: retrieve thread-private
+ /// Expert: retrieve thread-private
///
///
/// @lucene.internal
@@ -376,7 +376,8 @@ private void CheckBounds(int docID)
{
if (docID < 0 || docID >= MaxDoc)
{
- throw new IndexOutOfRangeException("docID must be >= 0 and < maxDoc=" + MaxDoc + " (got docID=" + docID + ")");
+ throw new ArgumentOutOfRangeException(nameof(docID),
+ $"docID must be >= 0 and < maxDoc={MaxDoc} (got docID={docID})");
}
}
@@ -590,10 +591,10 @@ public override NumericDocValues GetNormValues(string field)
///
/// @lucene.experimental
///
- public interface ICoreDisposedListener
+ public interface ICoreDisposedListener
{
///
- /// Invoked when the shared core of the original
+ /// Invoked when the shared core of the original
/// has disposed.
///
void OnDispose(object ownerCoreCacheKey);
@@ -671,4 +672,4 @@ public override void CheckIntegrity()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net/Support/ExceptionHandling/ExceptionExtensions.cs b/src/Lucene.Net/Support/ExceptionHandling/ExceptionExtensions.cs
index 49a954f50e..f7b9c1e512 100644
--- a/src/Lucene.Net/Support/ExceptionHandling/ExceptionExtensions.cs
+++ b/src/Lucene.Net/Support/ExceptionHandling/ExceptionExtensions.cs
@@ -137,7 +137,7 @@ public static bool IsException(this Exception e)
/// Used to check whether corresponds to a RuntimeException
/// in Java. RuntimeException in Java indicates an unchecked exception. Unchecked
/// exceptions don't force the developer to make a decision whether to handle or re-throw
- /// the excption, it can safely be ignored and allowed to propagate.
+ /// the exception, it can safely be ignored and allowed to propagate.
///
/// This exception.
/// true if corresponds to a RuntimeException type
@@ -152,7 +152,7 @@ public static bool IsRuntimeException(this Exception e)
// Some Java errors derive from SystemException in .NET, but we don't want to include them here
e.IsError() ||
- // .NET made IOException a SystemExcpetion, but those should not be included here
+ // .NET made IOException a SystemException, but those should not be included here
e.IsIOException() ||
// .NET made System.Threading.ThreadInterruptedException a SystemException, but we need to ignore it
@@ -160,7 +160,7 @@ public static bool IsRuntimeException(this Exception e)
e is System.Threading.ThreadInterruptedException ||
// ObjectDisposedException is a special case because in Lucene the AlreadyClosedException derived
- // from IOException and was therefore a checked excpetion type.
+ // from IOException and was therefore a checked exception type.
e is ObjectDisposedException ||
// These seem to correspond closely to java.lang.ReflectiveOperationException, which are not derived from RuntimeException
@@ -172,9 +172,9 @@ e is AmbiguousMatchException
return false;
}
- // Known implemetnations of IRuntimeException
+ // Known implementations of IRuntimeException
- // LuceneExcpetion
+ // LuceneException
// BytesRefHash.MaxBytesLengthExceededException
// CollectionTerminatedException
// TimeLimitingCollector.TimeExceededException
@@ -229,8 +229,8 @@ public static bool IsArrayIndexOutOfBoundsException(this Exception e)
{
if (e is null || e.IsAlwaysIgnored()) return false;
- return e is ArgumentOutOfRangeException ||
- e is IndexOutOfRangeException;
+ return e is ArgumentOutOfRangeException
+ or IndexOutOfRangeException;
}
///
@@ -245,8 +245,8 @@ public static bool IsStringIndexOutOfBoundsException(this Exception e)
{
if (e is null || e.IsAlwaysIgnored()) return false;
- return e is ArgumentOutOfRangeException ||
- e is IndexOutOfRangeException;
+ return e is ArgumentOutOfRangeException
+ or IndexOutOfRangeException;
}
///
@@ -261,13 +261,13 @@ public static bool IsIndexOutOfBoundsException(this Exception e)
{
if (e is null || e.IsAlwaysIgnored()) return false;
- return e is ArgumentOutOfRangeException ||
- e is IndexOutOfRangeException;
+ return e is ArgumentOutOfRangeException
+ or IndexOutOfRangeException;
}
///
/// Used to check whether corresponds to a NoSuchFileException
- /// or a FileNotFoundExcpetion in Java.
+ /// or a FileNotFoundException in Java.
///
/// NOTE: In Java, there is no distinction between file and directory, and FileNotFoundException is thrown
/// in either case. Therefore, this handler also catches .
@@ -278,11 +278,11 @@ public static bool IsIndexOutOfBoundsException(this Exception e)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsNoSuchFileExceptionOrFileNotFoundException(this Exception e)
{
- return e is FileNotFoundException ||
- // Java doesn't have an equivalent to DirectoryNotFoundExcption, but
+ return e is FileNotFoundException
+ // Java doesn't have an equivalent to DirectoryNotFoundException, but
// Lucene added one that subclassed java.io.FileNotFoundException
// that we didn't add to the .NET port.
- e is DirectoryNotFoundException;
+ or DirectoryNotFoundException;
}
///
@@ -305,7 +305,7 @@ public static bool IsNoSuchFileExceptionOrFileNotFoundException(this Exception e
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsParseException(this Exception e)
{
- // LUCENNET: Added this exception in J2N to cover this case because it is not a RuntimeException
+ // LUCENENET: Added this exception in J2N to cover this case because it is not a RuntimeException
// which makes it different from NumberFormatException in Java and FormatException in .NET.
return e is ParseException;
}
@@ -348,8 +348,8 @@ public static bool IsInvocationTargetException(this Exception e)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsIllegalAccessException(this Exception e)
{
- return e is MemberAccessException ||
- e is TypeAccessException;
+ return e is MemberAccessException
+ or TypeAccessException;
}
///
@@ -385,8 +385,8 @@ public static bool IsNullPointerException(this Exception e)
{
if (e is null || e.IsAlwaysIgnored()) return false;
- return e is ArgumentNullException ||
- e is NullReferenceException; // LUCENENET TODO: These could be real problems where excptions can be prevevented that our catch blocks are hiding
+ return e is ArgumentNullException
+ or NullReferenceException; // LUCENENET TODO: These could be real problems where exceptions can be prevented that our catch blocks are hiding
}
///
@@ -407,10 +407,10 @@ public static bool IsInstantiationException(this Exception e)
// described in the javadoc that the class might not be created when using Activator.CreateInstance().
// The TestFactories class also seems to rule out that this is supposed to catch TargetInvocationException
// or security exceptions such as MemberAccessException or TypeAccessException.
- return e is MissingMethodException ||
- e is TypeLoadException ||
- e is ReflectionTypeLoadException ||
- e is TypeInitializationException; // May happen due to a class initializer that throws an uncaught exception.
+ return e is MissingMethodException
+ or TypeLoadException
+ or ReflectionTypeLoadException
+ or TypeInitializationException; // May happen due to a class initializer that throws an uncaught exception.
}
///
@@ -438,8 +438,8 @@ public static bool IsUnsupportedEncodingException(this Exception e)
{
// According to the docs, this maps to 2 potential exceptions:
// https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.getencoding?view=net-5.0
- return e is ArgumentException ||
- e is PlatformNotSupportedException;
+ return e is ArgumentException
+ or PlatformNotSupportedException;
}
///
@@ -573,8 +573,8 @@ public static bool IsEOFException(this Exception e)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsIllegalStateException(this Exception e)
{
- return e is InvalidOperationException &&
- e is not ObjectDisposedException; // In .NET, ObjectDisposedException subclases InvalidOperationException, but Lucene decided to use IOException for AlreadyClosedException
+ return e is InvalidOperationException
+ and not ObjectDisposedException; // In .NET, ObjectDisposedException subclases InvalidOperationException, but Lucene decided to use IOException for AlreadyClosedException
}
///
@@ -591,7 +591,7 @@ public static bool IsIllegalStateException(this Exception e)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsStackOverflowError(this Exception e)
{
- return e is StackOverflowException; // Uncatchable in .NET core, be sure to use with
+ return e is StackOverflowException; // Uncatchable in .NET core, be sure to use with
}
///
diff --git a/src/Lucene.Net/Util/BytesRefArray.cs b/src/Lucene.Net/Util/BytesRefArray.cs
index 717c4dcb0a..9ffe5cf6ba 100644
--- a/src/Lucene.Net/Util/BytesRefArray.cs
+++ b/src/Lucene.Net/Util/BytesRefArray.cs
@@ -105,7 +105,8 @@ public BytesRef Get(BytesRef spare, int index)
pool.ReadBytes(offset, spare.Bytes, spare.Offset, spare.Length);
return spare;
}
- throw new IndexOutOfRangeException("index " + index + " must be less than the size: " + lastElement);
+
+ throw new ArgumentOutOfRangeException(nameof(index), $"index {index} must be less than the size: {lastElement}");
}
private int[] Sort(IComparer comp)
diff --git a/src/Lucene.Net/Util/UnicodeUtil.cs b/src/Lucene.Net/Util/UnicodeUtil.cs
index 5974af1a16..41cb5a21a2 100644
--- a/src/Lucene.Net/Util/UnicodeUtil.cs
+++ b/src/Lucene.Net/Util/UnicodeUtil.cs
@@ -835,7 +835,7 @@ public static void UTF8toUTF32(BytesRef utf8, Int32sRef utf32)
/// The number of code points.
/// a String representing the code points between offset and count.
/// If an invalid code point is encountered.
- /// If the offset or count are out of bounds.
+ /// If the offset or count are out of bounds.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NewString(int[] codePoints, int offset, int count)
{