Skip to content

Commit

Permalink
SWEEP: Changed all applicable NotSupportedException creation statemen…
Browse files Browse the repository at this point in the history
…ts to UnsupportedOperationException.Create() (see #446)
  • Loading branch information
NightOwl888 committed Apr 26, 2021
1 parent 5fa8ebd commit f35f410
Show file tree
Hide file tree
Showing 145 changed files with 452 additions and 423 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public bool MoveNext()

public void Reset()
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ private void ParseAffix(JCG.SortedDictionary<string, IList<int>> affixes,
patternIndex = patterns.Count;
if (patternIndex > short.MaxValue)
{
throw new NotSupportedException("Too many patterns, please report this to dev@lucene.apache.org");
throw UnsupportedOperationException.Create("Too many patterns, please report this to dev@lucene.apache.org");
}
seenPatterns[regex] = patternIndex;
CharacterRunAutomaton pattern = new CharacterRunAutomaton((new RegExp(regex, RegExpSyntax.NONE)).ToAutomaton());
Expand All @@ -609,7 +609,7 @@ private void ParseAffix(JCG.SortedDictionary<string, IList<int>> affixes,
seenStrips[strip] = stripOrd;
if (stripOrd > char.MaxValue)
{
throw new NotSupportedException("Too many unique strips, please report this to dev@lucene.apache.org");
throw UnsupportedOperationException.Create("Too many unique strips, please report this to dev@lucene.apache.org");
}
}

Expand All @@ -628,7 +628,7 @@ private void ParseAffix(JCG.SortedDictionary<string, IList<int>> affixes,
else if (appendFlagsOrd > short.MaxValue)
{
// this limit is probably flexible, but its a good sanity check too
throw new NotSupportedException("Too many unique append flags, please report this to dev@lucene.apache.org");
throw UnsupportedOperationException.Create("Too many unique append flags, please report this to dev@lucene.apache.org");
}

affixWriter.WriteInt16((short)flag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public override void Close()
{
if (!isDisposing)
{
throw new NotSupportedException("Close() is not supported. Call Dispose() instead.");
throw UnsupportedOperationException.Create("Close() is not supported. Call Dispose() instead.");
}
}
#endif
Expand Down
92 changes: 46 additions & 46 deletions src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public virtual void Clear()
[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool Contains(KeyValuePair<string, TValue> item)
public virtual bool Contains(KeyValuePair<string, TValue> item) // LUCENENET TODO: API - rather than marking this DesignerSerializationVisibility.Hidden, it would be better to make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

/// <summary>
Expand Down Expand Up @@ -1124,9 +1124,9 @@ public KeyCollection(CharArrayMap<TValue> outerInstance)

public bool IsReadOnly => outerInstance.IsReadOnly;

public void Add(string item)
public void Add(string item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public void Clear()
Expand All @@ -1153,9 +1153,9 @@ public IEnumerator<string> GetEnumerator()
return new KeyEnumerator(outerInstance);
}

public bool Remove(string item)
public bool Remove(string item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down Expand Up @@ -1212,9 +1212,9 @@ public ValueCollection(CharArrayMap<TValue> outerInstance)

public bool IsReadOnly => outerInstance.IsReadOnly;

public void Add(TValue item)
public void Add(TValue item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public void Clear()
Expand All @@ -1233,19 +1233,19 @@ public bool Contains(TValue item)
return false;
}

public void CopyTo(TValue[] array, int arrayIndex)
public void CopyTo(TValue[] array, int arrayIndex) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public IEnumerator<TValue> GetEnumerator()
{
return new ValueEnumerator(outerInstance);
}

public bool Remove(TValue item)
public bool Remove(TValue item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down Expand Up @@ -1335,17 +1335,17 @@ IEnumerator IEnumerable.GetEnumerator()
[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool Remove(string key)
public virtual bool Remove(string key) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool Remove(KeyValuePair<string, TValue> item)
public virtual bool Remove(KeyValuePair<string, TValue> item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

/// <summary>
Expand Down Expand Up @@ -1440,21 +1440,21 @@ internal UnmodifiableCharArraySet(ICharArrayMap map)
{
}

public override bool Add(object o)
public override bool Add(object o) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
public override bool Add(ICharSequence text)
public override bool Add(ICharSequence text) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
public override bool Add(string text)
public override bool Add(string text) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
public override bool Add(char[] text)
public override bool Add(char[] text) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
}

Expand Down Expand Up @@ -1524,7 +1524,7 @@ public virtual TValue SetValue(TValue value)
{
if (!allowModify)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
TValue old = outerInstance.values[lastPos].Value;
outerInstance.values[lastPos].Value = value;
Expand Down Expand Up @@ -1630,9 +1630,9 @@ public bool Contains(object o)
[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool Remove(KeyValuePair<string, TValue> item)
public bool Remove(KeyValuePair<string, TValue> item) // LUCENENET TODO: API - make an explicit implementation that isn't public
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public int Count => outerInstance.count;
Expand All @@ -1641,7 +1641,7 @@ public void Clear()
{
if (!allowModify)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
outerInstance.Clear();
}
Expand Down Expand Up @@ -1841,55 +1841,55 @@ public UnmodifiableCharArrayMap(ICharArrayMap map)

public override void Clear()
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override TValue Put(char[] text, TValue val)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override TValue Put(ICharSequence text, TValue val)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override TValue Put(string text, TValue val)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override TValue Put(object o, TValue val)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override bool Put(char[] text)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override bool Put(ICharSequence text)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override bool Put(string text)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

public override bool Put(object o)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool Remove(string key)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}

internal override EntrySet_ CreateEntrySet()
Expand All @@ -1900,44 +1900,44 @@ internal override EntrySet_ CreateEntrySet()
#region Added for better .NET support LUCENENET
public override void Add(string key, TValue value)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
public override void Add(KeyValuePair<string, TValue> item)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
public override TValue this[char[] key, int offset, int length]
{
get => base[key, offset, length];
set => throw new NotSupportedException();
set => throw UnsupportedOperationException.Create();
}
public override TValue this[char[] key]
{
get => base[key];
set => throw new NotSupportedException();
set => throw UnsupportedOperationException.Create();
}
public override TValue this[ICharSequence key]
{
get => base[key];
set => throw new NotSupportedException();
set => throw UnsupportedOperationException.Create();
}
public override TValue this[string key]
{
get => base[key];
set => throw new NotSupportedException();
set => throw UnsupportedOperationException.Create();
}
public override TValue this[object key]
{
get => base[key];
set => throw new NotSupportedException();
set => throw UnsupportedOperationException.Create();
}

[Obsolete("Not applicable in this class.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool Remove(KeyValuePair<string, TValue> item)
{
throw new NotSupportedException();
throw UnsupportedOperationException.Create();
}
#endregion
}
Expand Down
Loading

0 comments on commit f35f410

Please sign in to comment.