diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SolrSynonymParser.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SolrSynonymParser.cs index 59236dd458..97bcbea41e 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SolrSynonymParser.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SolrSynonymParser.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Util; using System; using System.Collections.Generic; @@ -134,7 +134,7 @@ public override void Parse(TextReader @in) } } } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { throw new Exception("Invalid synonym rule at line " + lineNumber, e); //ex.initCause(e); diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/WordnetSynonymParser.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/WordnetSynonymParser.cs index ea02d11459..7be8f1e3a8 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/WordnetSynonymParser.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/WordnetSynonymParser.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Util; using System; using System.IO; @@ -78,7 +78,7 @@ public override void Parse(TextReader @in) // final synset in the file AddInternal(synset, synsetSize); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { throw new Exception("Invalid synonym rule at line " + lineNumber.ToString(), e); } diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs index 05c6633d51..2fcea633a5 100644 --- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs +++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs @@ -507,7 +507,7 @@ private static IDictionary> ParseRules(TextReader reader, st } rules.Add(r); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { throw new InvalidOperationException("Problem parsing line '" + currentLine + "' in " + location, e); diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs index 88c92a4bde..f8f8ee8a1a 100644 --- a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs +++ b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs @@ -363,7 +363,7 @@ private static void ParseRules(TextReader scanner, string location, } rules.Add(r); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { throw new InvalidOperationException( "Problem parsing line '" + currentLine + "' in " + location, e); diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/AnalyzerFactoryTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/AnalyzerFactoryTask.cs index d4fd683bac..15e943a7a5 100644 --- a/src/Lucene.Net.Benchmark/ByTask/Tasks/AnalyzerFactoryTask.cs +++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/AnalyzerFactoryTask.cs @@ -304,7 +304,7 @@ public override void SetParams(string @params) clazz = LookupAnalysisClass(argName, typeof(CharFilterFactory)); CreateAnalysisPipelineComponent(stok, clazz); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { try { @@ -313,7 +313,7 @@ public override void SetParams(string @params) CreateAnalysisPipelineComponent(stok, clazz); expectedArgType = ArgType.TOKENFILTER; } - catch (ArgumentException e2) + catch (Exception e2) when (e2.IsIllegalArgumentException()) { throw new Exception("Line #" + GetLineNumber(stok) + ": Can't find class '" + argName + "' as CharFilterFactory or TokenizerFactory", e2); @@ -328,7 +328,7 @@ public override void SetParams(string @params) { clazz = LookupAnalysisClass(className, typeof(TokenFilterFactory)); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { throw new Exception ("Line #" + GetLineNumber(stok) + ": Can't find class '" + className + "' as TokenFilterFactory", e); diff --git a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs index f81b657bf4..8cacc65747 100644 --- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs +++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs @@ -3076,7 +3076,7 @@ public virtual void TestHugeBinaryValues() { w.AddDocument(doc); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) == -1) { @@ -3099,7 +3099,7 @@ public virtual void TestHugeBinaryValues() { r = w.GetReader(); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) == -1) { diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ar/TestArabicFilters.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ar/TestArabicFilters.cs index a17c32a4fa..1e51208f07 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ar/TestArabicFilters.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ar/TestArabicFilters.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -86,7 +86,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ArabicNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -96,7 +96,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Arabicstem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -106,7 +106,7 @@ public virtual void TestBogusArguments() CharFilterFactory("Persian", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -116,7 +116,7 @@ public virtual void TestBogusArguments() TokenizerFactory("ArabicLetter", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Bg/TestBulgarianStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Bg/TestBulgarianStemFilterFactory.cs index 1ddc97838c..ac3044adac 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Bg/TestBulgarianStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Bg/TestBulgarianStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("BulgarianStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Br/TestBrazilianStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Br/TestBrazilianStemFilterFactory.cs index 1283f974e8..dee0ebf581 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Br/TestBrazilianStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Br/TestBrazilianStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("BrazilianStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestHTMLStripCharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestHTMLStripCharFilterFactory.cs index 8d3598d32a..8150e462a8 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestHTMLStripCharFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestHTMLStripCharFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -105,7 +105,7 @@ public virtual void TestBogusArguments() CharFilterFactory("HTMLStrip", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestMappingCharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestMappingCharFilterFactory.cs index ca31d647d4..468cafcb10 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestMappingCharFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/CharFilters/TestMappingCharFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -35,7 +35,7 @@ public virtual void TestParseString() f.ParseString("\\"); fail("escape character cannot be alone."); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { } @@ -48,7 +48,7 @@ public virtual void TestParseString() f.ParseString("\\u000"); fail("invalid length check."); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { } @@ -72,7 +72,7 @@ public virtual void TestBogusArguments() CharFilterFactory("Mapping", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKBigramFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKBigramFilterFactory.cs index 613b7ef881..233992683c 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKBigramFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKBigramFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using System; using NUnit.Framework; using Lucene.Net.Analysis.Util; @@ -65,7 +65,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CJKBigram", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKTokenizerFactory.cs index 81e7f2cf06..896f585bb5 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenizerFactory("CJK", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKWidthFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKWidthFilterFactory.cs index f0027ab459..6b46578e0f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKWidthFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cjk/TestCJKWidthFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CJKWidth", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniNormalizationFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniNormalizationFilterFactory.cs index 81e33d90ec..4f002ca293 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniNormalizationFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniNormalizationFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -48,7 +48,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("SoraniNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniStemFilterFactory.cs index 29e0862399..773264f890 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ckb/TestSoraniStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -48,7 +48,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("SoraniStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseFilterFactory.cs index 03b49d336c..97c205181b 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using System; using System.IO; using NUnit.Framework; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Chinese", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseTokenizerFactory.cs index 73eab10304..9ff4efb5e3 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cn/TestChineseTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using System; using System.IO; using NUnit.Framework; @@ -49,7 +49,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Chinese", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsFilterFactory.cs index cee44affa8..9655b6bd0a 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -89,7 +89,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CommonGrams", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsQueryFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsQueryFilterFactory.cs index 8a8ac55ee0..474053e9b1 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsQueryFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Commongrams/TestCommonGramsQueryFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -89,7 +89,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CommonGramsQuery", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestDictionaryCompoundWordTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestDictionaryCompoundWordTokenFilterFactory.cs index a3c5be2274..8138219a87 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestDictionaryCompoundWordTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestDictionaryCompoundWordTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using System; using System.IO; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("DictionaryCompoundWord", "dictionary", "compoundDictionary.txt", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestHyphenationCompoundWordTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestHyphenationCompoundWordTokenFilterFactory.cs index d56a291653..68d715423f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestHyphenationCompoundWordTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Compound/TestHyphenationCompoundWordTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -66,7 +66,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("HyphenationCompoundWord", "hyphenator", "da_UTF8.xml", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestAllAnalyzersHaveFactories.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestAllAnalyzersHaveFactories.cs index c85525d218..0c486b31d3 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestAllAnalyzersHaveFactories.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestAllAnalyzersHaveFactories.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N.Runtime.CompilerServices; using Lucene.Net.Analysis.Fr; using Lucene.Net.Analysis.In; @@ -134,7 +134,7 @@ public virtual void Test() } assertSame(c, instance.Create(new StringReader("")).GetType()); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { if (e.InnerException is MissingMethodException) { @@ -166,7 +166,7 @@ public virtual void Test() assertSame(c, createdClazz); } } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { if (e.InnerException is MissingMethodException) { @@ -198,7 +198,7 @@ public virtual void Test() assertSame(c, createdClazz); } } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { if (e.InnerException is MissingMethodException) { diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestFactories.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestFactories.cs index 637c031de0..57e9890bb0 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestFactories.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestFactories.cs @@ -179,7 +179,7 @@ private static AbstractAnalysisFactory Initialize(Type factoryClazz) // LUCENENE { // its ok if the right files arent available or whatever to throw this } - catch (ArgumentException) + catch (Exception ignored) when (ignored.IsIllegalArgumentException()) { // is this ok? I guess so } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilterFactory.cs index 55b31d594e..9c8dd8e404 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -69,7 +69,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Stop", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -85,7 +85,7 @@ public virtual void TestBogusFormats() TokenFilterFactory("Stop", "words", "stop-snowball.txt", "format", "bogus"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { string msg = expected.Message; assertTrue(msg, msg.Contains("Unknown")); @@ -98,7 +98,7 @@ public virtual void TestBogusFormats() // implicit default words file fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { string msg = expected.Message; assertTrue(msg, msg.Contains("can not be specified")); diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestTypeTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestTypeTokenFilterFactory.cs index 9ed57938f4..759f114f0f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestTypeTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestTypeTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -71,7 +71,7 @@ public virtual void TestMissingTypesParameter() TokenFilterFactory("Type", "enablePositionIncrements", "false"); fail("not supplying 'types' parameter should cause an IllegalArgumentException"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // everything ok } @@ -87,7 +87,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Type", "types", "stoptypes-1.txt", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cz/TestCzechStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cz/TestCzechStemFilterFactory.cs index d584b97c78..a91c19047a 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cz/TestCzechStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Cz/TestCzechStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CzechStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanLightStemFilterFactory.cs index 86864074db..77a34dc6c0 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GermanLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanMinimalStemFilterFactory.cs index 4409f29101..f13f33dcb9 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GermanMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanNormalizationFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanNormalizationFilterFactory.cs index 343d9c9232..67b5bbfc5d 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanNormalizationFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanNormalizationFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GermanNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanStemFilterFactory.cs index 0db1e64148..9c84f113fc 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/De/TestGermanStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GermanStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekLowerCaseFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekLowerCaseFilterFactory.cs index 9034ca41f7..8df46133c8 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekLowerCaseFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekLowerCaseFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GreekLowerCase", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekStemFilterFactory.cs index 117cdcde98..daaa67e306 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/El/TestGreekStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -48,7 +48,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GreekStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestEnglishMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestEnglishMinimalStemFilterFactory.cs index 26563f71a0..7153351ac1 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestEnglishMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestEnglishMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("EnglishMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestKStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestKStemFilterFactory.cs index 7ad473a0e5..d9ff0e473e 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestKStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestKStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("KStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestPorterStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestPorterStemFilterFactory.cs index 986c4e2971..4542a275e0 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestPorterStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/En/TestPorterStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PorterStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Es/TestSpanishLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Es/TestSpanishLightStemFilterFactory.cs index 7f69ba239c..dfc1415b22 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Es/TestSpanishLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Es/TestSpanishLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("SpanishLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fa/TestPersianNormalizationFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fa/TestPersianNormalizationFilterFactory.cs index 523b1984ba..57b7c19d03 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fa/TestPersianNormalizationFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fa/TestPersianNormalizationFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PersianNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fi/TestFinnishLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fi/TestFinnishLightStemFilterFactory.cs index 10e3ac9e00..4a21c43b90 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fi/TestFinnishLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fi/TestFinnishLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("FinnishLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchLightStemFilterFactory.cs index 02814da72d..92b1668fd4 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("FrenchLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchMinimalStemFilterFactory.cs index b9a37e1629..e48a0aa774 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Fr/TestFrenchMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("FrenchMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ga/TestIrishLowerCaseFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ga/TestIrishLowerCaseFilterFactory.cs index a3e4ba582a..156ce84cb3 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ga/TestIrishLowerCaseFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ga/TestIrishLowerCaseFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("IrishLowerCase", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianMinimalStemFilterFactory.cs index 7a0f8e2f1d..ea6c9ae612 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GalicianMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianStemFilterFactory.cs index 39ef0e2b69..1c389d9854 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Gl/TestGalicianStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("GalicianStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hi/TestHindiFilters.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hi/TestHindiFilters.cs index 1d6b1613b1..5e75521937 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hi/TestHindiFilters.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hi/TestHindiFilters.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -77,7 +77,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("IndicNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -87,7 +87,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("HindiNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -97,7 +97,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("HindiStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hu/TestHungarianLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hu/TestHungarianLightStemFilterFactory.cs index b7b5236538..f9ab107c36 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hu/TestHungarianLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hu/TestHungarianLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("HungarianLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hunspell/TestHunspellStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hunspell/TestHunspellStemFilterFactory.cs index 2171e02be8..b0d8e8009b 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hunspell/TestHunspellStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Hunspell/TestHunspellStemFilterFactory.cs @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("HunspellStem", "dictionary", "simple.dic", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Id/TestIndonesianStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Id/TestIndonesianStemFilterFactory.cs index f1b9d827b1..4dd3db8c56 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Id/TestIndonesianStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Id/TestIndonesianStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -62,7 +62,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("IndonesianStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/It/TestItalianLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/It/TestItalianLightStemFilterFactory.cs index a17a4b5554..eee010f776 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/It/TestItalianLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/It/TestItalianLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ItalianLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Lv/TestLatvianStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Lv/TestLatvianStemFilterFactory.cs index 1f2af4f11b..3966dac80e 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Lv/TestLatvianStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Lv/TestLatvianStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("LatvianStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilterFactory.cs index bdbe4efa92..aed0db5f8f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -258,7 +258,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Capitalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -280,7 +280,7 @@ public virtual void TestInvalidArguments() TokenFilterFactory("Capitalization", "keep", "and the it BIG", "onlyFirstWord", "false", arg, "-3", "okPrefix", "McK", "forceFirstLetter", "true").Create(stream); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains(arg + " must be greater than or equal to zero") || expected.Message.Contains(arg + " must be greater than zero")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilterFactory.cs index b410cfc573..a58baff9c3 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilterFactory.cs @@ -45,7 +45,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("CodepointCount", "min", "4", "max", "5", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -63,7 +63,7 @@ public virtual void TestInvalidArguments() TokenFilterFactory("CodepointCount", CodepointCountFilterFactory.MIN_KEY, "5", CodepointCountFilterFactory.MAX_KEY, "4").Create(stream); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("maximum length must not be greater than minimum length")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeepFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeepFilterFactory.cs index ecc0f359ad..220e6b8a8d 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeepFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeepFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -51,7 +51,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("KeepWord", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordMarkerFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordMarkerFilterFactory.cs index be36b64415..91703de47d 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordMarkerFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordMarkerFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -100,7 +100,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("KeywordMarker", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs index 5e7aad226e..d5a87f0c1c 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using Lucene.Net.Util; using NUnit.Framework; @@ -59,7 +59,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "4", LengthFilterFactory.MAX_KEY, "5", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -77,7 +77,7 @@ public virtual void TestInvalidArguments() TokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "5", LengthFilterFactory.MAX_KEY, "4").Create(stream); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("maximum length must not be greater than minimum length")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs index f9a818ee8c..75cbdeadc3 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -49,7 +49,7 @@ public virtual void TestRequired() TokenFilterFactory("LimitTokenCount"); fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY, StringComparison.Ordinal)); } @@ -66,7 +66,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("LimitTokenCount", LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY, "3", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs index 02adb41e82..8b1e2910e1 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -49,7 +49,7 @@ public virtual void TestMissingParam() TokenFilterFactory("LimitTokenPosition"); fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY, StringComparison.Ordinal)); } @@ -91,7 +91,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("LimitTokenPosition", "maxTokenPosition", "3", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs index e63a26b5a7..f4f353cebf 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N.Text; using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -59,7 +59,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("RemoveDuplicates", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs index f1878eff8d..0a09aee6d1 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -45,7 +45,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ScandinavianFolding", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianNormalizationFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianNormalizationFilterFactory.cs index ed32817c68..4e06ad80f1 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianNormalizationFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianNormalizationFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -45,7 +45,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ScandinavianNormalization", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilterFactory.cs index aed217d1d4..089ca1ccfe 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -61,7 +61,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("StemmerOverride", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTrimFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTrimFilterFactory.cs index a0ae00d483..7fdf5079e6 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTrimFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTrimFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using NUnit.Framework; using System; using System.IO; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Trim", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilterFactory.cs index 85972451f2..1716c22e37 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using NUnit.Framework; using System; using System.IO; @@ -51,7 +51,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Truncate", TruncateTokenFilterFactory.PREFIX_LENGTH_KEY, "5", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameter(s):")); } @@ -68,7 +68,7 @@ public virtual void TestNonPositivePrefixLengthArgument() TokenFilterFactory("Truncate", TruncateTokenFilterFactory.PREFIX_LENGTH_KEY, "-5"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains(TruncateTokenFilterFactory.PREFIX_LENGTH_KEY + " parameter must be a positive number: -5")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenFilterTest.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenFilterTest.cs index bf9f7d66f8..25f976a7b7 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenFilterTest.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenFilterTest.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N; using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.Miscellaneous; @@ -51,7 +51,7 @@ public virtual void TestInvalidInput() new EdgeNGramTokenFilter(TEST_VERSION_CURRENT, input, EdgeNGramTokenFilter.Side.FRONT, 0, 0); #pragma warning restore 612, 618 } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -68,7 +68,7 @@ public virtual void TestInvalidInput2() new EdgeNGramTokenFilter(TEST_VERSION_CURRENT, input, EdgeNGramTokenFilter.Side.FRONT, 2, 1); #pragma warning restore 612, 618 } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -85,7 +85,7 @@ public virtual void TestInvalidInput3() new EdgeNGramTokenFilter(TEST_VERSION_CURRENT, input, EdgeNGramTokenFilter.Side.FRONT, -1, 2); #pragma warning restore 612, 618 } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenizerTest.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenizerTest.cs index 5117288366..f5499cfcd6 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenizerTest.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/EdgeNGramTokenizerTest.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Support; using Lucene.Net.Util; using NUnit.Framework; @@ -46,7 +46,7 @@ public virtual void TestInvalidInput() { new EdgeNGramTokenizer(TEST_VERSION_CURRENT, input, 0, 0); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -61,7 +61,7 @@ public virtual void TestInvalidInput2() { new EdgeNGramTokenizer(TEST_VERSION_CURRENT, input, 2, 1); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -76,7 +76,7 @@ public virtual void TestInvalidInput3() { new EdgeNGramTokenizer(TEST_VERSION_CURRENT, input, -1, 2); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenFilterTest.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenFilterTest.cs index 5f3d67ab71..d45eac1dba 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenFilterTest.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenFilterTest.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N; using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.Miscellaneous; @@ -48,7 +48,7 @@ public virtual void TestInvalidInput() { new NGramTokenFilter(TEST_VERSION_CURRENT, input, 2, 1); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -63,7 +63,7 @@ public virtual void TestInvalidInput2() { new NGramTokenFilter(TEST_VERSION_CURRENT, input, 0, 1); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenizerTest.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenizerTest.cs index cbc8b0f354..1bff63f960 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenizerTest.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/NGramTokenizerTest.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N; using J2N.Text; using Lucene.Net.Analysis.TokenAttributes; @@ -48,7 +48,7 @@ public virtual void TestInvalidInput() { new NGramTokenizer(TEST_VERSION_CURRENT, input, 2, 1); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } @@ -63,7 +63,7 @@ public virtual void TestInvalidInput2() { new NGramTokenizer(TEST_VERSION_CURRENT, input, 0, 1); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { gotException = true; } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/TestNGramFilters.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/TestNGramFilters.cs index 7d5fe94ea6..ffe293ea2c 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/TestNGramFilters.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/NGram/TestNGramFilters.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using Lucene.Net.Util; using NUnit.Framework; @@ -159,7 +159,7 @@ public virtual void TestBogusArguments() TokenizerFactory("NGram", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -169,7 +169,7 @@ public virtual void TestBogusArguments() TokenizerFactory("EdgeNGram", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -179,7 +179,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("NGram", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -189,7 +189,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("EdgeNGram", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianLightStemFilterFactory.cs index c86c8858f7..de14ff8634 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -69,7 +69,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("NorwegianLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs index 5371d0f129..8d0b71482e 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/No/TestNorwegianMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -69,7 +69,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("NorwegianMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs index a6683f5b92..18db2db270 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceCharFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -75,7 +75,7 @@ public virtual void TestBogusArguments() CharFilterFactory("PatternReplace", "pattern", "something", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs index 716b2d59af..efbaf8f58b 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternReplaceFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -49,7 +49,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PatternReplace", "pattern", "something", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs index 458f6125a2..f06b2152f0 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pattern/TestPatternTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Pattern", "pattern", "something", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Payloads/TestDelimitedPayloadTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Payloads/TestDelimitedPayloadTokenFilterFactory.cs index d9e65dc438..003012ae4f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Payloads/TestDelimitedPayloadTokenFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Payloads/TestDelimitedPayloadTokenFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.TokenAttributes; using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -78,7 +78,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("DelimitedPayload", "encoder", "float", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseLightStemFilterFactory.cs index 77d2ecb0fc..5dc7608ea9 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PortugueseLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseMinimalStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseMinimalStemFilterFactory.cs index fcc31f1a75..2cf84da06c 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseMinimalStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseMinimalStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PortugueseMinimalStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseStemFilterFactory.cs index c13b380ff8..a4b0318c44 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Pt/TestPortugueseStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("PortugueseStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Reverse/TestReverseStringFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Reverse/TestReverseStringFilterFactory.cs index 7f68c82cfe..52a2de9b6e 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Reverse/TestReverseStringFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Reverse/TestReverseStringFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -51,7 +51,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ReverseString", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianFilters.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianFilters.cs index 94c630b4ed..e6444e6bcf 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianFilters.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianFilters.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -49,7 +49,7 @@ public virtual void TestBogusArguments() TokenizerFactory("RussianLetter", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianLightStemFilterFactory.cs index 7295602a8d..8e378006aa 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Ru/TestRussianLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("RussianLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/TestShingleFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/TestShingleFilterFactory.cs index a5495e22d9..72fabaabe5 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/TestShingleFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/TestShingleFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -203,7 +203,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Shingle", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs index a1544ab820..471ff8aa4f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N.Text; using Lucene.Net.Analysis.Util; using Lucene.Net.Tartarus.Snowball.Ext; @@ -73,7 +73,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("SnowballPorter", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestStandardFactories.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestStandardFactories.cs index e30f10f9d7..c582ec0504 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestStandardFactories.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestStandardFactories.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using System.Text; using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -160,7 +160,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Standard", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -170,7 +170,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Classic", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -180,7 +180,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Whitespace", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -190,7 +190,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Letter", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -200,7 +200,7 @@ public virtual void TestBogusArguments() TokenizerFactory("LowerCase", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -210,7 +210,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ASCIIFolding", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -220,7 +220,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Standard", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -230,7 +230,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Classic", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestUAX29URLEmailTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestUAX29URLEmailTokenizerFactory.cs index 2b1e3d6953..4119b98dd7 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestUAX29URLEmailTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Standard/TestUAX29URLEmailTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -134,7 +134,7 @@ public virtual void TestBogusArguments() TokenizerFactory("UAX29URLEmail", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -148,7 +148,7 @@ public virtual void TestIllegalArguments() TokenizerFactory("UAX29URLEmail", "maxTokenLength", "-1").Create(new StringReader("hello")); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("maxTokenLength must be greater than zero")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sv/TestSwedishLightStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sv/TestSwedishLightStemFilterFactory.cs index 4f27eb9f4f..6cde52f369 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sv/TestSwedishLightStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sv/TestSwedishLightStemFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -47,7 +47,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("SwedishLightStem", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymFilterFactory.cs index 00a95d4c9c..0bfeab285f 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymFilterFactory.cs @@ -117,7 +117,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Synonym", "synonyms", "synonyms.txt", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMap.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMap.cs index 89e88faccb..816a9aebb6 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMap.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMap.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.NGram; using Lucene.Net.Analysis.Util; using Lucene.Net.Util; @@ -43,7 +43,7 @@ public virtual void TestInvalidMappingRules() SlowSynonymFilterFactory.ParseRules(rules, synMap, "=>", ",", true, null); fail("IllegalArgumentException must be thrown."); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs index 007543bec4..31db2e59fd 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N.Text; using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.TokenAttributes; @@ -960,7 +960,7 @@ public virtual void TestEmpty() new SynonymFilter(tokenizer, (new SynonymMap.Builder(true)).Build(), true); fail("did not hit expected exception"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected assertEquals("fst must be non-null", iae.Message); diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiTokenizerFactory.cs index 0f501ae994..28f0c3362d 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 #if FEATURE_BREAKITERATOR using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -60,7 +60,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Thai", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiWordFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiWordFilterFactory.cs index 93d60ecc36..fa6a5d1c20 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiWordFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiWordFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 #if FEATURE_BREAKITERATOR using Lucene.Net.Analysis.Util; using NUnit.Framework; @@ -63,7 +63,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("ThaiWord", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestApostropheFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestApostropheFilterFactory.cs index 05fefebe31..f20dae0e21 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestApostropheFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestApostropheFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -51,7 +51,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Apostrophe", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameter(s):")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestTurkishLowerCaseFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestTurkishLowerCaseFilterFactory.cs index 6f1fa9f2fc..940794088e 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestTurkishLowerCaseFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Tr/TestTurkishLowerCaseFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -50,7 +50,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("TurkishLowerCase", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs index 4cbebf244d..9e51aef9f2 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestAnalysisSPILoader.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.CharFilters; using Lucene.Net.Analysis.Core; using Lucene.Net.Analysis.Miscellaneous; @@ -59,7 +59,7 @@ public virtual void TestBogusLookupTokenizer() TokenizerFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -69,7 +69,7 @@ public virtual void TestBogusLookupTokenizer() TokenizerFactory.ForName("!(**#$U*#$*", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -91,7 +91,7 @@ public virtual void TestBogusLookupTokenizerClass() TokenizerFactory.LookupClass("sdfsdfsdfdsfsdfsdf"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -101,7 +101,7 @@ public virtual void TestBogusLookupTokenizerClass() TokenizerFactory.LookupClass("!(**#$U*#$*"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -133,7 +133,7 @@ public virtual void TestBogusLookupTokenFilter() TokenFilterFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -143,7 +143,7 @@ public virtual void TestBogusLookupTokenFilter() TokenFilterFactory.ForName("!(**#$U*#$*", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -169,7 +169,7 @@ public virtual void TestBogusLookupTokenFilterClass() TokenFilterFactory.LookupClass("sdfsdfsdfdsfsdfsdf"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -179,7 +179,7 @@ public virtual void TestBogusLookupTokenFilterClass() TokenFilterFactory.LookupClass("!(**#$U*#$*"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -208,7 +208,7 @@ public virtual void TestBogusLookupCharFilter() CharFilterFactory.ForName("sdfsdfsdfdsfsdfsdf", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -218,7 +218,7 @@ public virtual void TestBogusLookupCharFilter() CharFilterFactory.ForName("!(**#$U*#$*", new Dictionary()); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -240,7 +240,7 @@ public virtual void TestBogusLookupCharFilterClass() CharFilterFactory.LookupClass("sdfsdfsdfdsfsdfsdf"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } @@ -250,7 +250,7 @@ public virtual void TestBogusLookupCharFilterClass() CharFilterFactory.LookupClass("!(**#$U*#$*"); fail(); } - catch (ArgumentException) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs index 7e093cc506..8fad83b574 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using J2N; using Lucene.Net.Support; using Lucene.Net.Util; @@ -184,7 +184,7 @@ public virtual void TestNewCharacterBuffer() CharacterUtils.NewCharacterBuffer(1); fail("length must be >= 2"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestElisionFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestElisionFilterFactory.cs index cc4fb007fb..6852c79f9c 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestElisionFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestElisionFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using NUnit.Framework; using System; using System.IO; @@ -73,7 +73,7 @@ public virtual void TestBogusArguments() TokenFilterFactory("Elision", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Wikipedia/TestWikipediaTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Wikipedia/TestWikipediaTokenizerFactory.cs index 33cf61d17f..50ce7e3fe4 100644 --- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Wikipedia/TestWikipediaTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Wikipedia/TestWikipediaTokenizerFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using Lucene.Net.Analysis.Util; using NUnit.Framework; using System; @@ -46,7 +46,7 @@ public virtual void TestBogusArguments() TokenizerFactory("Wikipedia", "bogusArg", "bogusValue"); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/Segmentation/TestICUTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/Segmentation/TestICUTokenizerFactory.cs index d24bc1c165..3fa04f4fd7 100644 --- a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/Segmentation/TestICUTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/Segmentation/TestICUTokenizerFactory.cs @@ -106,7 +106,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUFoldingFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUFoldingFilterFactory.cs index 1f60596569..fadc3c8ecc 100644 --- a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUFoldingFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUFoldingFilterFactory.cs @@ -1,4 +1,4 @@ -// Lucene version compatibility level 4.8.1 +// Lucene version compatibility level 4.8.1 using NUnit.Framework; using System; using System.Collections.Generic; @@ -51,7 +51,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2CharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2CharFilterFactory.cs index 4f715c8ffc..73c92d244f 100644 --- a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2CharFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2CharFilterFactory.cs @@ -50,7 +50,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2FilterFactory.cs b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2FilterFactory.cs index c03ffb5c48..004e338a9a 100644 --- a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2FilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUNormalizer2FilterFactory.cs @@ -50,7 +50,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUTransformFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUTransformFilterFactory.cs index 9f216e301a..0e78cb2c36 100644 --- a/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUTransformFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.ICU/Analysis/Icu/TestICUTransformFilterFactory.cs @@ -89,7 +89,7 @@ public void TestBogusArguments() fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseBaseFormFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseBaseFormFilterFactory.cs index 61a8b2e69c..afdfc004ac 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseBaseFormFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseBaseFormFilterFactory.cs @@ -51,7 +51,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseIterationMarkCharFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseIterationMarkCharFilterFactory.cs index 88f71a9321..8310d1d781 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseIterationMarkCharFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseIterationMarkCharFilterFactory.cs @@ -99,7 +99,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseKatakanaStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseKatakanaStemFilterFactory.cs index 49ac181dd1..eda816e6c2 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseKatakanaStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseKatakanaStemFilterFactory.cs @@ -53,7 +53,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapanesePartOfSpeechStopFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapanesePartOfSpeechStopFilterFactory.cs index 617a1b8769..afe26cf8ba 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapanesePartOfSpeechStopFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapanesePartOfSpeechStopFilterFactory.cs @@ -61,7 +61,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseReadingFormFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseReadingFormFilterFactory.cs index 053652b65e..1c5f051009 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseReadingFormFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseReadingFormFilterFactory.cs @@ -50,7 +50,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizerFactory.cs index 91fbf1688d..f80a91101a 100644 --- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizerFactory.cs @@ -125,7 +125,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/SoundexTest.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/SoundexTest.cs index d05f40e5cd..c2df30d9e3 100644 --- a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/SoundexTest.cs +++ b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/SoundexTest.cs @@ -379,9 +379,7 @@ public void TestUsMappingEWithAcute() Assert.AreEqual("\u00c9000", this.StringEncoder.Encode("\u00e9")); Assert.Fail("Expected IllegalArgumentException not thrown"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -409,9 +407,7 @@ public void TestUsMappingOWithDiaeresis() Assert.AreEqual("\u00d6000", this.StringEncoder.Encode("\u00f6")); Assert.Fail("Expected IllegalArgumentException not thrown"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/TestBeiderMorseFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/TestBeiderMorseFilterFactory.cs index 5bdf1b79db..c5583b2361 100644 --- a/src/Lucene.Net.Tests.Analysis.Phonetic/TestBeiderMorseFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Phonetic/TestBeiderMorseFilterFactory.cs @@ -80,7 +80,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/TestDoubleMetaphoneFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/TestDoubleMetaphoneFilterFactory.cs index 5ba337b06e..8742066eb2 100644 --- a/src/Lucene.Net.Tests.Analysis.Phonetic/TestDoubleMetaphoneFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Phonetic/TestDoubleMetaphoneFilterFactory.cs @@ -61,7 +61,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/TestPhoneticFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/TestPhoneticFilterFactory.cs index 1baedfba5f..e5027bbf85 100644 --- a/src/Lucene.Net.Tests.Analysis.Phonetic/TestPhoneticFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Phonetic/TestPhoneticFilterFactory.cs @@ -74,7 +74,7 @@ public void TestMissingEncoder() new PhoneticFilterFactory(new Dictionary()); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Configuration Error: missing parameter 'encoder'")); } @@ -90,7 +90,7 @@ public void TestUnknownEncoder() factory.Inform(new ClasspathResourceLoader(factory.GetType())); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Error loading encoder")); } @@ -107,7 +107,7 @@ public void TestUnknownEncoderReflection() factory.Inform(new ClasspathResourceLoader(factory.GetType())); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Error loading encoder")); } @@ -206,7 +206,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.SmartCn/TestHMMChineseTokenizerFactory.cs b/src/Lucene.Net.Tests.Analysis.SmartCn/TestHMMChineseTokenizerFactory.cs index 60f24c9564..901c5a9a86 100644 --- a/src/Lucene.Net.Tests.Analysis.SmartCn/TestHMMChineseTokenizerFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.SmartCn/TestHMMChineseTokenizerFactory.cs @@ -63,7 +63,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.SmartCn/TestSmartChineseFactories.cs b/src/Lucene.Net.Tests.Analysis.SmartCn/TestSmartChineseFactories.cs index 4b23ec1513..f1168659b2 100644 --- a/src/Lucene.Net.Tests.Analysis.SmartCn/TestSmartChineseFactories.cs +++ b/src/Lucene.Net.Tests.Analysis.SmartCn/TestSmartChineseFactories.cs @@ -77,7 +77,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } @@ -89,7 +89,7 @@ public void TestBogusArguments() }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Analysis.Stempel/Stempel/TestStempelPolishStemFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Stempel/Stempel/TestStempelPolishStemFilterFactory.cs index 317dc4c591..463a467582 100644 --- a/src/Lucene.Net.Tests.Analysis.Stempel/Stempel/TestStempelPolishStemFilterFactory.cs +++ b/src/Lucene.Net.Tests.Analysis.Stempel/Stempel/TestStempelPolishStemFilterFactory.cs @@ -47,7 +47,7 @@ public void TestBogusArguments() new StempelPolishStemFilterFactory(new Dictionary() { { "bogusArg", "bogusValue" } }); fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { assertTrue(expected.Message.Contains("Unknown parameters")); } diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs b/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs index 055926d3c0..8f1aeb94a9 100644 --- a/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs +++ b/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs @@ -41,7 +41,7 @@ public virtual void TestEmpty() JavascriptCompiler.Compile("sqrt(20)", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("Unrecognized method")); } @@ -116,7 +116,7 @@ public virtual void TestWrongReturnType() JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("does not return a double")); } @@ -135,7 +135,7 @@ public virtual void TestWrongParameterType() JavascriptCompiler.Compile("foo(2)", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("must take only double parameters")); } @@ -154,7 +154,7 @@ public virtual void TestWrongNotStatic() JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("is not static")); } @@ -174,7 +174,7 @@ public virtual void TestWrongNotPublic() JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("is not public")); } @@ -196,7 +196,7 @@ public virtual void TestWrongNestedNotPublic() JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.IsTrue(e.Message.Contains("is not public")); } diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs index adbbc81228..a46ac401fa 100644 --- a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs +++ b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs @@ -193,7 +193,7 @@ public virtual void TestWrongArity() JavascriptCompiler.Compile("tan()"); Assert.Fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("arguments for method call")); } @@ -203,7 +203,7 @@ public virtual void TestWrongArity() JavascriptCompiler.Compile("tan(1, 1)"); Assert.Fail(); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("arguments for method call")); } diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionValidation.cs b/src/Lucene.Net.Tests.Expressions/TestExpressionValidation.cs index bf3330bcd4..b9cdaf144b 100644 --- a/src/Lucene.Net.Tests.Expressions/TestExpressionValidation.cs +++ b/src/Lucene.Net.Tests.Expressions/TestExpressionValidation.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Expressions.JS; +using Lucene.Net.Expressions.JS; using Lucene.Net.Search; using Lucene.Net.Util; using NUnit.Framework; @@ -55,7 +55,7 @@ public virtual void TestInvalidExternal() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Invalid reference")); } @@ -72,7 +72,7 @@ public virtual void TestInvalidExternal2() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Invalid reference")); } @@ -88,7 +88,7 @@ public virtual void TestSelfRecursion() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Cycle detected")); } @@ -105,7 +105,7 @@ public virtual void TestCoRecursion() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Cycle detected")); } @@ -123,7 +123,7 @@ public virtual void TestCoRecursion2() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Cycle detected")); } @@ -141,7 +141,7 @@ public virtual void TestCoRecursion3() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Cycle detected")); } @@ -160,7 +160,7 @@ public virtual void TestCoRecursion4() bindings.Validate(); Assert.Fail("didn't get expected exception"); } - catch (ArgumentException expected) + catch (Exception expected) when (expected.IsIllegalArgumentException()) { Assert.IsTrue(expected.Message.Contains("Cycle detected")); } diff --git a/src/Lucene.Net.Tests.Facet/Range/TestRangeFacetCounts.cs b/src/Lucene.Net.Tests.Facet/Range/TestRangeFacetCounts.cs index be755e8f0f..90d0758225 100644 --- a/src/Lucene.Net.Tests.Facet/Range/TestRangeFacetCounts.cs +++ b/src/Lucene.Net.Tests.Facet/Range/TestRangeFacetCounts.cs @@ -120,7 +120,7 @@ public virtual void TestUselessRange() _ = new Int64Range("useless", 7, true, 6, true); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -129,7 +129,7 @@ public virtual void TestUselessRange() _ = new Int64Range("useless", 7, true, 7, false); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -138,7 +138,7 @@ public virtual void TestUselessRange() _ = new DoubleRange("useless", 7.0, true, 6.0, true); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -147,7 +147,7 @@ public virtual void TestUselessRange() _ = new DoubleRange("useless", 7.0, true, 7.0, false); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs index 59960e0263..898842d7a9 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs @@ -181,7 +181,7 @@ public virtual void TestEmptyNullComponents() Assert.IsNotNull(new FacetLabel(components)); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -190,7 +190,7 @@ public virtual void TestEmptyNullComponents() _ = new FacetField("dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -199,7 +199,7 @@ public virtual void TestEmptyNullComponents() _ = new AssociationFacetField(new BytesRef(), "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -208,7 +208,7 @@ public virtual void TestEmptyNullComponents() _ = new Int32AssociationFacetField(17, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -217,7 +217,7 @@ public virtual void TestEmptyNullComponents() _ = new SingleAssociationFacetField(17.0f, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -227,7 +227,7 @@ public virtual void TestEmptyNullComponents() _ = new FacetField(null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -236,7 +236,7 @@ public virtual void TestEmptyNullComponents() _ = new FacetField("", new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -245,7 +245,7 @@ public virtual void TestEmptyNullComponents() _ = new Int32AssociationFacetField(17, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -254,7 +254,7 @@ public virtual void TestEmptyNullComponents() _ = new Int32AssociationFacetField(17, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -263,7 +263,7 @@ public virtual void TestEmptyNullComponents() _ = new SingleAssociationFacetField(17.0f, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -272,7 +272,7 @@ public virtual void TestEmptyNullComponents() _ = new SingleAssociationFacetField(17.0f, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -281,7 +281,7 @@ public virtual void TestEmptyNullComponents() _ = new AssociationFacetField(new BytesRef(), null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -290,7 +290,7 @@ public virtual void TestEmptyNullComponents() _ = new AssociationFacetField(new BytesRef(), "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -299,7 +299,7 @@ public virtual void TestEmptyNullComponents() _ = new SortedSetDocValuesFacetField(null, "abc"); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -308,7 +308,7 @@ public virtual void TestEmptyNullComponents() _ = new SortedSetDocValuesFacetField("", "abc"); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -317,7 +317,7 @@ public virtual void TestEmptyNullComponents() _ = new SortedSetDocValuesFacetField("dim", null); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -326,7 +326,7 @@ public virtual void TestEmptyNullComponents() _ = new SortedSetDocValuesFacetField("dim", ""); fail("empty or null components should not be allowed"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -352,7 +352,7 @@ public virtual void TestLongPath() Assert.IsNotNull(new FacetLabel("dim", bigComp)); fail("long paths should not be allowed; len=" + bigComp.Length); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetAssociations.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetAssociations.cs index 87913a10da..5df4b5c987 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetAssociations.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetAssociations.cs @@ -178,7 +178,7 @@ public virtual void TestWrongIndexFieldName() facets.GetSpecificValue("float"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -188,7 +188,7 @@ public virtual void TestWrongIndexFieldName() facets.GetTopChildren(10, "float"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -216,7 +216,7 @@ public virtual void TestMixedTypesInSameIndexField() writer.AddDocument(config.Build(taxoWriter, doc)); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception exc) when (exc.IsIllegalArgumentException()) { // expected } @@ -245,7 +245,7 @@ public virtual void TestNoHierarchy() writer.AddDocument(config.Build(taxoWriter, doc)); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception exc) when (exc.IsIllegalArgumentException()) { // expected } @@ -274,7 +274,7 @@ public virtual void TestRequireDimCount() writer.AddDocument(config.Build(taxoWriter, doc)); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception exc) when (exc.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts.cs index afc86a5606..72dc57c1f9 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts.cs @@ -274,7 +274,7 @@ public virtual void TestWrongIndexFieldName() facets.GetSpecificValue("a"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -284,7 +284,7 @@ public virtual void TestWrongIndexFieldName() facets.GetTopChildren(10, "a"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -371,7 +371,7 @@ public virtual void TestMultiValuedHierarchy() facets.GetSpecificValue("a"); fail("didn't hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -471,7 +471,7 @@ public virtual void TestRequireDimCount() Assert.AreEqual(1, facets.GetSpecificValue("dim")); fail("didn't hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -557,7 +557,7 @@ public virtual void TestDetectHierarchicalField() config.Build(taxoWriter, doc); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -588,7 +588,7 @@ public virtual void TestDetectMultiValuedField() config.Build(taxoWriter, doc); fail("did not hit expected exception"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetSumValueSource.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetSumValueSource.cs index 73918028ca..fbb504f326 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetSumValueSource.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetSumValueSource.cs @@ -254,7 +254,7 @@ public virtual void TestWrongIndexFieldName() facets.GetSpecificValue("a"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -264,7 +264,7 @@ public virtual void TestWrongIndexFieldName() facets.GetTopChildren(10, "a"); fail("should have hit exc"); } - catch (ArgumentException) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Highlighter/Highlight/TokenSourcesTest.cs b/src/Lucene.Net.Tests.Highlighter/Highlight/TokenSourcesTest.cs index 84e97468b4..5510eaeec5 100644 --- a/src/Lucene.Net.Tests.Highlighter/Highlight/TokenSourcesTest.cs +++ b/src/Lucene.Net.Tests.Highlighter/Highlight/TokenSourcesTest.cs @@ -315,9 +315,7 @@ public void TestTermVectorWithoutOffsetsThrowsException() false); fail("TokenSources.getTokenStream should throw IllegalArgumentException if term vector has no offsets"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs b/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs index 8228ecc345..070ddfa2a3 100644 --- a/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs +++ b/src/Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs @@ -431,9 +431,7 @@ public void TestUserFailedToIndexOffsets() highlighter.Highlight("body", query, searcher, topDocs, 2); fail("did not hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -443,9 +441,7 @@ public void TestUserFailedToIndexOffsets() highlighter.Highlight("title", new TermQuery(new Term("title", "test")), searcher, topDocs, 2); fail("did not hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleFragListBuilderTest.cs b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleFragListBuilderTest.cs index 0d5d312069..d4cc09684a 100644 --- a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleFragListBuilderTest.cs +++ b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleFragListBuilderTest.cs @@ -41,9 +41,7 @@ public void TestTooSmallFragSize() sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b c d"), sflb.minFragCharSize - 1); fail("IllegalArgumentException must be thrown"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests.Misc/Index/Sorter/SortingAtomicReaderTest.cs b/src/Lucene.Net.Tests.Misc/Index/Sorter/SortingAtomicReaderTest.cs index 8a8f80abd4..9a734de61e 100644 --- a/src/Lucene.Net.Tests.Misc/Index/Sorter/SortingAtomicReaderTest.cs +++ b/src/Lucene.Net.Tests.Misc/Index/Sorter/SortingAtomicReaderTest.cs @@ -76,7 +76,7 @@ public void TestBadSort() SortingAtomicReader.Wrap(reader, Sort.RELEVANCE); fail("Didn't get expected exception"); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { assertEquals("Cannot sort an index with a Sort that refers to the relevance score", e.Message); } diff --git a/src/Lucene.Net.Tests.Misc/Index/Sorter/TestSortingMergePolicy.cs b/src/Lucene.Net.Tests.Misc/Index/Sorter/TestSortingMergePolicy.cs index fd78e130a6..d230ee720d 100644 --- a/src/Lucene.Net.Tests.Misc/Index/Sorter/TestSortingMergePolicy.cs +++ b/src/Lucene.Net.Tests.Misc/Index/Sorter/TestSortingMergePolicy.cs @@ -179,7 +179,7 @@ public void TestBadSort() new SortingMergePolicy(NewMergePolicy(), Sort.RELEVANCE); fail("Didn't get expected exception"); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { assertEquals("Cannot sort an index with a Sort that refers to the relevance score", e.Message); } diff --git a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs index 822530ec33..bcca2972a5 100644 --- a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs +++ b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs @@ -174,9 +174,7 @@ public void TestNullTerm() query.Add(null); Assert.Fail(@"null values are not supported"); } -#pragma warning disable 168 - catch (ArgumentException ex) -#pragma warning restore 168 + catch (Exception ex) when (ex.IsIllegalArgumentException()) { } } @@ -344,9 +342,7 @@ public void TestIllegalOccur() new CommonTermsQuery(Occur.MUST_NOT, RandomOccur(random), Random.NextSingle()); Assert.Fail(@"MUST_NOT is not supproted"); } -#pragma warning disable 168 - catch (ArgumentException ex) -#pragma warning restore 168 + catch (Exception ex) when (ex.IsIllegalArgumentException()) { } @@ -355,9 +351,7 @@ public void TestIllegalOccur() new CommonTermsQuery(RandomOccur(random), Occur.MUST_NOT, Random.NextSingle()); Assert.Fail(@"MUST_NOT is not supproted"); } -#pragma warning disable 168 - catch (ArgumentException ex) -#pragma warning restore 168 + catch (Exception ex) when (ex.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs index d8cd554976..0c0e410e68 100644 --- a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs @@ -175,9 +175,7 @@ public void TestNoTerms() new TermFilter(null); Assert.Fail(@"must fail - no term!"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { } @@ -186,9 +184,7 @@ public void TestNoTerms() new TermFilter(new Term(null)); Assert.Fail(@"must fail - no field!"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests.QueryParser/Classic/TestMultiFieldQueryParser.cs b/src/Lucene.Net.Tests.QueryParser/Classic/TestMultiFieldQueryParser.cs index 8132c8bafd..4a90534562 100644 --- a/src/Lucene.Net.Tests.QueryParser/Classic/TestMultiFieldQueryParser.cs +++ b/src/Lucene.Net.Tests.QueryParser/Classic/TestMultiFieldQueryParser.cs @@ -182,7 +182,7 @@ public virtual void TestStaticMethod1() q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, queries5, fields, new MockAnalyzer(Random)); fail(); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -216,7 +216,7 @@ public virtual void TestStaticMethod2() q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, "blah", fields, flags2, new MockAnalyzer(Random)); fail(); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -241,7 +241,7 @@ public virtual void TestStaticMethod2Old() q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, "blah", fields, flags2, new MockAnalyzer(Random)); fail(); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -263,7 +263,7 @@ public virtual void TestStaticMethod3() q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, queries, fields, flags2, new MockAnalyzer(Random)); fail(); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -284,7 +284,7 @@ public virtual void TestStaticMethod3Old() q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, queries, fields, flags2, new MockAnalyzer(Random)); fail(); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs index eeee49b301..fd2573a683 100644 --- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs +++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestMultiFieldQPHelper.cs @@ -203,9 +203,7 @@ public void TestStaticMethod1() q = QueryParserUtil.Parse(queries5, fields, new MockAnalyzer(Random)); fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -245,9 +243,7 @@ public void TestStaticMethod2() q = QueryParserUtil.Parse("blah", fields, flags2, new MockAnalyzer(Random)); fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -280,9 +276,7 @@ public void TestStaticMethod2Old() q = QueryParserUtil.Parse("blah", fields, flags2, new MockAnalyzer(Random)); fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -310,9 +304,7 @@ public void TestStaticMethod3() .Parse(queries, fields, flags2, new MockAnalyzer(Random)); fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } @@ -340,9 +332,7 @@ public void TestStaticMethod3Old() .Parse(queries, fields, flags2, new MockAnalyzer(Random)); fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception, array length differs } diff --git a/src/Lucene.Net.Tests.Replicator/IndexRevisionTest.cs b/src/Lucene.Net.Tests.Replicator/IndexRevisionTest.cs index a67257fa5d..e098af7e0f 100644 --- a/src/Lucene.Net.Tests.Replicator/IndexRevisionTest.cs +++ b/src/Lucene.Net.Tests.Replicator/IndexRevisionTest.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Store; using Lucene.Net.Util; @@ -41,7 +41,7 @@ public void TestNoSnapshotDeletionPolicy() assertNotNull(new IndexRevision(writer)); fail("should have failed when IndexDeletionPolicy is not Snapshot"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Replicator/LocalReplicatorTest.cs b/src/Lucene.Net.Tests.Replicator/LocalReplicatorTest.cs index ad04a482af..07f2a03dd4 100644 --- a/src/Lucene.Net.Tests.Replicator/LocalReplicatorTest.cs +++ b/src/Lucene.Net.Tests.Replicator/LocalReplicatorTest.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Util; using NUnit.Framework; @@ -150,7 +150,7 @@ public void TestPublishOlderRev() replicator.Publish(old); fail("should have failed to publish an older revision"); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs index a0b3d85996..0c2aa97561 100644 --- a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs +++ b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Store; @@ -308,9 +308,7 @@ public void TestFuzzinessLong() query = new SlowFuzzyQuery(new Term("field", "student"), 1.1f); fail("Expected IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expecting exception } @@ -319,9 +317,7 @@ public void TestFuzzinessLong() query = new SlowFuzzyQuery(new Term("field", "student"), -0.1f); fail("Expected IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expecting exception } diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs index c869b8810f..34d1e73d46 100644 --- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs +++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs @@ -1475,7 +1475,7 @@ public void TestIllegalLookupArgument() suggester.DoLookup("а\u001E", false, 3); fail("should throw IllegalArgumentException"); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -1484,7 +1484,7 @@ public void TestIllegalLookupArgument() suggester.DoLookup("а\u001F", false, 3); fail("should throw IllegalArgumentException"); } - catch (ArgumentException /*e*/) + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } @@ -1500,5 +1500,25 @@ internal static IEnumerable Shuffle(params Input[] values) asList.Shuffle(Random); return asList; } + + // LUCENENET TODO: This is a test from Lucene 4.8.1 that currently produces a stack overflow + //// TODO: we need BaseSuggesterTestCase? + //[Test] + //public void TestTooLongSuggestion() + //{ + // Analyzer a = new MockAnalyzer(Random); + // AnalyzingSuggester suggester = new AnalyzingSuggester(a); + // String bigString = TestUtil.RandomSimpleString(Random, 60000, 60000); + // try + // { + // suggester.Build(new InputArrayEnumerator(new Input[] { + // new Input(bigString, 7)})); + // fail("did not hit expected exception"); + // } + // catch (Exception iae) when (iae.IsIllegalArgumentException()) + // { + // // expected + // } + //} } } diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs index 36b7c153be..6de5e432db 100644 --- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs +++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs @@ -101,7 +101,7 @@ public void TestIllegalByteDuringBuild() sug.Build(new InputArrayEnumerator(keys)); fail("did not hit expected exception"); } - catch (ArgumentException /*iae*/) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -123,7 +123,7 @@ public void TestIllegalByteDuringQuery() sug.DoLookup("foo\u001eb", 10); fail("did not hit expected exception"); } - catch (ArgumentException /*iae*/) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -245,7 +245,7 @@ public void TestEmptyString() sug.DoLookup("", 10); fail("did not hit exception"); } - catch (ArgumentException /*iae*/) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Analysis/TestNumericTokenStream.cs b/src/Lucene.Net.Tests/Analysis/TestNumericTokenStream.cs index d67fea30cb..7c0d8273c8 100644 --- a/src/Lucene.Net.Tests/Analysis/TestNumericTokenStream.cs +++ b/src/Lucene.Net.Tests/Analysis/TestNumericTokenStream.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Analysis.TokenAttributes; +using Lucene.Net.Analysis.TokenAttributes; using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -125,7 +125,7 @@ public virtual void TestCTA() stream.AddAttribute(); Assert.Fail("Succeeded to add CharTermAttribute."); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { Assert.IsTrue(iae.Message.StartsWith("NumericTokenStream does not support", StringComparison.Ordinal)); } @@ -134,7 +134,7 @@ public virtual void TestCTA() stream.AddAttribute(); Assert.Fail("Succeeded to add TestAttribute."); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { Assert.IsTrue(iae.Message.StartsWith("NumericTokenStream does not support", StringComparison.Ordinal)); } diff --git a/src/Lucene.Net.Tests/Document/TestDocument.cs b/src/Lucene.Net.Tests/Document/TestDocument.cs index 6b244ae1b3..7f4abad14c 100644 --- a/src/Lucene.Net.Tests/Document/TestDocument.cs +++ b/src/Lucene.Net.Tests/Document/TestDocument.cs @@ -1,4 +1,4 @@ -using J2N.Text; +using J2N.Text; using NUnit.Framework; using System; using System.IO; @@ -151,9 +151,7 @@ public virtual void TestConstructorExceptions() new Field("name", "value", new FieldType()); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -166,9 +164,7 @@ public virtual void TestConstructorExceptions() new Field("name", "value", ft2); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -366,7 +362,15 @@ public virtual void TestFieldSetValue() [Test] public virtual void TestInvalidFields() { - Assert.Throws(() => { new Field("foo", new MockTokenizer(new StreamReader(File.Open("", FileMode.Open))), StringField.TYPE_STORED); }); + try + { + new Field("foo", new MockTokenizer(new StreamReader(File.Open("", FileMode.Open))), StringField.TYPE_STORED); + fail("did not hit expected exc"); + } + catch (Exception iae) when (iae.IsIllegalArgumentException()) + { + // expected + } } // LUCENE-3682 diff --git a/src/Lucene.Net.Tests/Document/TestField.cs b/src/Lucene.Net.Tests/Document/TestField.cs index eabda5bdaf..08be5b7b1d 100644 --- a/src/Lucene.Net.Tests/Document/TestField.cs +++ b/src/Lucene.Net.Tests/Document/TestField.cs @@ -1,4 +1,4 @@ -using J2N.Globalization; +using J2N.Globalization; using J2N.Text; using Lucene.Net.Analysis; using Lucene.Net.Analysis.Standard; @@ -454,9 +454,7 @@ private void TrySetByteValue(Field f) f.SetByteValue((byte)10); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -469,9 +467,7 @@ private void TrySetBytesValue(Field f) f.SetBytesValue(new byte[] { 5, 5 }); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -484,9 +480,7 @@ private void TrySetBytesRefValue(Field f) f.SetBytesValue(new BytesRef("bogus")); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -499,9 +493,7 @@ private void TrySetDoubleValue(Field f) f.SetDoubleValue(double.MaxValue); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -514,9 +506,7 @@ private void TrySetIntValue(Field f) f.SetInt32Value(int.MaxValue); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -529,9 +519,7 @@ private void TrySetLongValue(Field f) f.SetInt64Value(long.MaxValue); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -544,9 +532,7 @@ private void TrySetFloatValue(Field f) f.SetSingleValue(float.MaxValue); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -559,9 +545,7 @@ private void TrySetReaderValue(Field f) f.SetReaderValue(new StringReader("BOO!")); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -574,9 +558,7 @@ private void TrySetShortValue(Field f) f.SetInt16Value(short.MaxValue); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -589,9 +571,7 @@ private void TrySetStringValue(Field f) f.SetStringValue("BOO!"); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -604,9 +584,7 @@ private void TrySetTokenStreamValue(Field f) f.SetTokenStream(new CannedTokenStream(new Token("foo", 0, 3))); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -619,9 +597,7 @@ private void TrySetBoost(Field f) f.Boost = 5.0f; Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/Test2BDocs.cs b/src/Lucene.Net.Tests/Index/Test2BDocs.cs index c1bcdd1b11..8b9d224fca 100644 --- a/src/Lucene.Net.Tests/Index/Test2BDocs.cs +++ b/src/Lucene.Net.Tests/Index/Test2BDocs.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Support; +using Lucene.Net.Support; using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -66,9 +66,7 @@ public virtual void TestOverflow() new MultiReader(subReaders); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestAddIndexes.cs b/src/Lucene.Net.Tests/Index/TestAddIndexes.cs index 36cb9373b2..ff2bcc0b40 100644 --- a/src/Lucene.Net.Tests/Index/TestAddIndexes.cs +++ b/src/Lucene.Net.Tests/Index/TestAddIndexes.cs @@ -310,9 +310,7 @@ public virtual void TestAddSelf() writer.AddIndexes(aux, dir); Assert.IsTrue(false); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { Assert.AreEqual(100, writer.MaxDoc); } @@ -1230,9 +1228,7 @@ public virtual void TestAddIndexMissingCodec() w.AddIndexes(toAdd); Assert.Fail("no such codec"); } -#pragma warning disable 168 - catch (ArgumentException ex) -#pragma warning restore 168 + catch (Exception ex) when (ex.IsIllegalArgumentException()) { // expected } @@ -1249,9 +1245,7 @@ public virtual void TestAddIndexMissingCodec() DirectoryReader.Open(toAdd); Assert.Fail("no such codec"); } -#pragma warning disable 168 - catch (ArgumentException ex) -#pragma warning restore 168 + catch (Exception ex) when (ex.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs b/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs index ae40bb8040..63d6e99f1f 100644 --- a/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs +++ b/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs @@ -646,9 +646,7 @@ public virtual void TestUpdateNonBinaryDocValuesField() writer.UpdateBinaryDocValue(new Term("key", "doc"), "bdv", ToBytes(17L)); Assert.Fail("should not have allowed creating new fields through update"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -658,9 +656,7 @@ public virtual void TestUpdateNonBinaryDocValuesField() writer.UpdateBinaryDocValue(new Term("key", "doc"), "foo", ToBytes(17L)); Assert.Fail("should not have allowed updating an existing field to binary-dv"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } diff --git a/src/Lucene.Net.Tests/Index/TestDirectoryReader.cs b/src/Lucene.Net.Tests/Index/TestDirectoryReader.cs index faafdf4839..f08b9f4676 100644 --- a/src/Lucene.Net.Tests/Index/TestDirectoryReader.cs +++ b/src/Lucene.Net.Tests/Index/TestDirectoryReader.cs @@ -1163,9 +1163,7 @@ public virtual void TestOOBDocID() r.Document(1); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestDocValuesIndexing.cs b/src/Lucene.Net.Tests/Index/TestDocValuesIndexing.cs index 823985c995..60a8457e04 100644 --- a/src/Lucene.Net.Tests/Index/TestDocValuesIndexing.cs +++ b/src/Lucene.Net.Tests/Index/TestDocValuesIndexing.cs @@ -128,9 +128,7 @@ public virtual void TestMultiValuedDocValuesField() w.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -166,9 +164,7 @@ public virtual void TestDifferentTypedDocValuesField() w.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -204,9 +200,7 @@ public virtual void TestDifferentTypedDocValuesField2() w.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -301,9 +295,7 @@ public virtual void TestMixedTypesSameDocument() { w.AddDocument(doc); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -327,9 +319,7 @@ public virtual void TestMixedTypesDifferentDocuments() { w.AddDocument(doc); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -355,9 +345,7 @@ public virtual void TestAddSortedTwice() iwriter.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -384,9 +372,7 @@ public virtual void TestAddBinaryTwice() iwriter.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -413,9 +399,7 @@ public virtual void TestAddNumericTwice() iwriter.AddDocument(doc); Assert.Fail("didn't hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -444,9 +428,7 @@ public virtual void TestTooLargeSortedBytes() iwriter.AddDocument(doc); Assert.Fail("did not get expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -475,9 +457,7 @@ public virtual void TestTooLargeTermSortedSetBytes() iwriter.AddDocument(doc); Assert.Fail("did not get expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } @@ -502,9 +482,7 @@ public virtual void TestMixedTypesDifferentSegments() { w.AddDocument(doc); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -620,9 +598,7 @@ public override void Run() startingGun.Wait(); w.AddDocument(doc); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected hitExc.Value = (true); @@ -656,9 +632,7 @@ public virtual void TestMixedTypesViaAddIndexes() { w.AddIndexes(dir2); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -668,9 +642,7 @@ public virtual void TestMixedTypesViaAddIndexes() { w.AddIndexes(new IndexReader[] { r }); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -697,9 +669,7 @@ public virtual void TestIllegalTypeChange() writer.AddDocument(doc); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -726,9 +696,7 @@ public virtual void TestIllegalTypeChangeAcrossSegments() writer.AddDocument(doc); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -831,9 +799,7 @@ public virtual void TestTypeChangeViaAddIndexes() writer.AddIndexes(dir); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -865,9 +831,7 @@ public virtual void TestTypeChangeViaAddIndexesIR() writer.AddIndexes(readers); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -899,9 +863,7 @@ public virtual void TestTypeChangeViaAddIndexes2() writer.AddDocument(doc); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -933,9 +895,7 @@ public virtual void TestTypeChangeViaAddIndexesIR2() writer.AddDocument(doc); Assert.Fail("did not hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -995,9 +955,7 @@ public virtual void TestSameFieldNameForPostingAndDocValue() writer.AddDocument(doc); Assert.Fail("should not have succeeded to add a field with different DV type than what already exists"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { writer.Rollback(); } diff --git a/src/Lucene.Net.Tests/Index/TestExceedMaxTermLength.cs b/src/Lucene.Net.Tests/Index/TestExceedMaxTermLength.cs index 5f9c534977..f4792ac6fb 100644 --- a/src/Lucene.Net.Tests/Index/TestExceedMaxTermLength.cs +++ b/src/Lucene.Net.Tests/Index/TestExceedMaxTermLength.cs @@ -1,6 +1,7 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using NUnit.Framework; using System; +using System.Globalization; using Assert = Lucene.Net.TestFramework.Assert; namespace Lucene.Net.Index @@ -89,9 +90,9 @@ public virtual void Test() w.AddDocument(doc); Assert.Fail("Did not get an exception from adding a monster term"); } - catch (ArgumentException e) + catch (Exception e) when (e.IsIllegalArgumentException()) { - string maxLengthMsg = Convert.ToString(IndexWriter.MAX_TERM_LENGTH); + string maxLengthMsg = Convert.ToString(IndexWriter.MAX_TERM_LENGTH, CultureInfo.InvariantCulture); string msg = e.Message; Assert.IsTrue(msg.Contains("immense term"), "IllegalArgumentException didn't mention 'immense term': " + msg); Assert.IsTrue(msg.Contains(maxLengthMsg), "IllegalArgumentException didn't mention max length (" + maxLengthMsg + "): " + msg); diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index 6870b95a79..0d4fbf1e43 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -1030,9 +1030,7 @@ public virtual void TestNegativePositions() w.AddDocument(doc); Assert.Fail("did not hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iea) -#pragma warning restore 168 + catch (Exception iea) when (iea.IsIllegalArgumentException()) { // expected } @@ -2012,9 +2010,7 @@ public virtual void TestWickedLongTerm() w.AddDocument(doc); Assert.Fail("should have hit exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs index 44652a498e..9c2b5e0d49 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs @@ -309,9 +309,7 @@ public virtual void TestInvalidValues() conf.SetIndexDeletionPolicy(null); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -325,9 +323,7 @@ public virtual void TestInvalidValues() conf.SetMergeScheduler(null); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -342,9 +338,7 @@ public virtual void TestInvalidValues() conf.SetSimilarity(null); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -358,9 +352,7 @@ public virtual void TestInvalidValues() conf.SetIndexingChain(null); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -370,9 +362,7 @@ public virtual void TestInvalidValues() conf.SetMaxBufferedDeleteTerms(0); Assert.Fail("should not have succeeded to set maxBufferedDeleteTerms to 0"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -382,9 +372,7 @@ public virtual void TestInvalidValues() conf.SetMaxBufferedDocs(1); Assert.Fail("should not have succeeded to set maxBufferedDocs to 1"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -397,9 +385,7 @@ public virtual void TestInvalidValues() conf.SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH); Assert.Fail("should not have succeeded to disable maxBufferedDocs when ramBufferSizeMB is disabled as well"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -411,9 +397,7 @@ public virtual void TestInvalidValues() conf.SetRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH); Assert.Fail("should not have succeeded to disable ramBufferSizeMB when maxBufferedDocs is disabled as well"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -424,9 +408,7 @@ public virtual void TestInvalidValues() conf.SetReaderTermsIndexDivisor(0); Assert.Fail("should not have succeeded to set termsIndexDivisor to 0"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -438,9 +420,7 @@ public virtual void TestInvalidValues() conf.SetReaderTermsIndexDivisor(-2); Assert.Fail("should not have succeeded to set termsIndexDivisor to < -1"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -450,9 +430,7 @@ public virtual void TestInvalidValues() conf.SetRAMPerThreadHardLimitMB(2048); Assert.Fail("should not have succeeded to set RAMPerThreadHardLimitMB to >= 2048"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -462,9 +440,7 @@ public virtual void TestInvalidValues() conf.SetRAMPerThreadHardLimitMB(0); Assert.Fail("should not have succeeded to set RAMPerThreadHardLimitMB to 0"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // this is expected } @@ -478,9 +454,7 @@ public virtual void TestInvalidValues() conf.SetMergePolicy(null); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs index 66fc6d5290..f598d2a746 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs @@ -1851,9 +1851,7 @@ public virtual void TestIllegalPositions() iw.AddDocument(doc); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected exception } diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterMergePolicy.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterMergePolicy.cs index c04b652a6e..205fc104e5 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriterMergePolicy.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriterMergePolicy.cs @@ -300,9 +300,7 @@ private void AssertSetters(MergePolicy lmp) lmp.MaxCFSSegmentSizeMB = -2.0; Assert.Fail("Didn't throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs b/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs index 32338ba9cd..bf579ae901 100644 --- a/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs +++ b/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs @@ -595,9 +595,7 @@ public virtual void TestUpdateNonNumericDocValuesField() writer.UpdateNumericDocValue(new Term("key", "doc"), "ndv", 17L); Assert.Fail("should not have allowed creating new fields through update"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } @@ -607,9 +605,7 @@ public virtual void TestUpdateNonNumericDocValuesField() writer.UpdateNumericDocValue(new Term("key", "doc"), "foo", 17L); Assert.Fail("should not have allowed updating an existing field to numeric-dv"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } diff --git a/src/Lucene.Net.Tests/Index/TestParallelAtomicReader.cs b/src/Lucene.Net.Tests/Index/TestParallelAtomicReader.cs index 1c0aa21833..45e2b044f4 100644 --- a/src/Lucene.Net.Tests/Index/TestParallelAtomicReader.cs +++ b/src/Lucene.Net.Tests/Index/TestParallelAtomicReader.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Search; using NUnit.Framework; using System; @@ -179,9 +179,7 @@ public virtual void TestIncompatibleIndexes() new ParallelAtomicReader(ir1, ir2); Assert.Fail("didn't get exptected exception: indexes don't have same number of documents"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -191,9 +189,7 @@ public virtual void TestIncompatibleIndexes() new ParallelAtomicReader(Random.NextBoolean(), new AtomicReader[] { ir1, ir2 }, new AtomicReader[] { ir1, ir2 }); Assert.Fail("didn't get expected exception: indexes don't have same number of documents"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -259,9 +255,7 @@ public virtual void TestIgnoreStoredFields() new ParallelAtomicReader(true, new AtomicReader[0], new AtomicReader[] { ir1 }); Assert.Fail("didn't get expected exception: need a non-empty main-reader array"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net.Tests/Index/TestParallelCompositeReader.cs b/src/Lucene.Net.Tests/Index/TestParallelCompositeReader.cs index f11c5458c6..e6d6f95f0f 100644 --- a/src/Lucene.Net.Tests/Index/TestParallelCompositeReader.cs +++ b/src/Lucene.Net.Tests/Index/TestParallelCompositeReader.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; using Lucene.Net.Search; using NUnit.Framework; @@ -294,9 +294,7 @@ public virtual void TestIncompatibleIndexes1() new ParallelCompositeReader(ir1, ir2); Assert.Fail("didn't get expected exception: indexes don't have same number of documents"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -305,9 +303,7 @@ public virtual void TestIncompatibleIndexes1() new ParallelCompositeReader(Random.NextBoolean(), ir1, ir2); Assert.Fail("didn't get expected exception: indexes don't have same number of documents"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -334,9 +330,7 @@ public virtual void TestIncompatibleIndexes2() new ParallelCompositeReader(readers); Assert.Fail("didn't get expected exception: indexes don't have same subreader structure"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -345,9 +339,7 @@ public virtual void TestIncompatibleIndexes2() new ParallelCompositeReader(Random.NextBoolean(), readers, readers); Assert.Fail("didn't get expected exception: indexes don't have same subreader structure"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -374,9 +366,7 @@ public virtual void TestIncompatibleIndexes3() new ParallelCompositeReader(readers); Assert.Fail("didn't get expected exception: indexes don't have same subreader structure"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -385,9 +375,7 @@ public virtual void TestIncompatibleIndexes3() new ParallelCompositeReader(Random.NextBoolean(), readers, readers); Assert.Fail("didn't get expected exception: indexes don't have same subreader structure"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected exception } @@ -457,9 +445,7 @@ public virtual void TestIgnoreStoredFields() new ParallelCompositeReader(true, new CompositeReader[0], new CompositeReader[] { ir1 }); Assert.Fail("didn't get expected exception: need a non-empty main-reader array"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net.Tests/Index/TestPayloadsOnVectors.cs b/src/Lucene.Net.Tests/Index/TestPayloadsOnVectors.cs index f026bf1df3..f0424313b4 100644 --- a/src/Lucene.Net.Tests/Index/TestPayloadsOnVectors.cs +++ b/src/Lucene.Net.Tests/Index/TestPayloadsOnVectors.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Analysis.TokenAttributes; +using Lucene.Net.Analysis.TokenAttributes; using Lucene.Net.Diagnostics; using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; @@ -161,9 +161,7 @@ public virtual void TestPayloadsWithoutPositions() writer.AddDocument(doc); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestPostingsOffsets.cs b/src/Lucene.Net.Tests/Index/TestPostingsOffsets.cs index b8f3622d31..9b12a24a50 100644 --- a/src/Lucene.Net.Tests/Index/TestPostingsOffsets.cs +++ b/src/Lucene.Net.Tests/Index/TestPostingsOffsets.cs @@ -1,4 +1,4 @@ -using J2N.Collections.Generic.Extensions; +using J2N.Collections.Generic.Extensions; using Lucene.Net.Diagnostics; using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; @@ -466,9 +466,7 @@ public virtual void TestNegativeOffsets() CheckTokens(new Token[] { MakeToken("foo", 1, -1, -1) }); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { //expected } @@ -482,9 +480,7 @@ public virtual void TestIllegalOffsets() CheckTokens(new Token[] { MakeToken("foo", 1, 1, 0) }); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { //expected } @@ -498,9 +494,7 @@ public virtual void TestBackwardsOffsets() CheckTokens(new Token[] { MakeToken("foo", 1, 0, 3), MakeToken("foo", 1, 4, 7), MakeToken("foo", 0, 3, 6) }); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Index/TestTermVectorsReader.cs b/src/Lucene.Net.Tests/Index/TestTermVectorsReader.cs index 3f4579ac80..b593e0f5fb 100644 --- a/src/Lucene.Net.Tests/Index/TestTermVectorsReader.cs +++ b/src/Lucene.Net.Tests/Index/TestTermVectorsReader.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Analysis; +using Lucene.Net.Analysis; using Lucene.Net.Analysis.TokenAttributes; using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; @@ -416,7 +416,7 @@ public virtual void TestIllegalIndexableField() w.AddDocument(doc); Assert.Fail("did not hit exception"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // Expected Assert.AreEqual("cannot index term vector payloads without term vector positions (field=\"field\")", iae.Message); @@ -432,7 +432,7 @@ public virtual void TestIllegalIndexableField() w.AddDocument(doc); Assert.Fail("did not hit exception"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // Expected Assert.AreEqual("cannot index term vector offsets when term vectors are not indexed (field=\"field\")", iae.Message); @@ -448,7 +448,7 @@ public virtual void TestIllegalIndexableField() w.AddDocument(doc); Assert.Fail("did not hit exception"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // Expected Assert.AreEqual("cannot index term vector positions when term vectors are not indexed (field=\"field\")", iae.Message); @@ -464,7 +464,7 @@ public virtual void TestIllegalIndexableField() w.AddDocument(doc); Assert.Fail("did not hit exception"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // Expected Assert.AreEqual("cannot index term vector payloads when term vectors are not indexed (field=\"field\")", iae.Message); diff --git a/src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs b/src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs index 224579eabd..fb105d089c 100644 --- a/src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs +++ b/src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Attributes; +using Lucene.Net.Attributes; using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; using Lucene.Net.Store; @@ -230,9 +230,7 @@ public virtual void TestSetters() tmp.MaxMergedSegmentMB = -2.0; Assert.Fail("Didn't throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } @@ -251,9 +249,7 @@ public virtual void TestSetters() tmp.FloorSegmentMB = -2.0; Assert.Fail("Didn't throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } @@ -272,9 +268,7 @@ public virtual void TestSetters() tmp.MaxCFSSegmentSizeMB = -2.0; Assert.Fail("Didn't throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net.Tests/Search/MultiCollectorTest.cs b/src/Lucene.Net.Tests/Search/MultiCollectorTest.cs index 5c5f7c939e..910271527b 100644 --- a/src/Lucene.Net.Tests/Search/MultiCollectorTest.cs +++ b/src/Lucene.Net.Tests/Search/MultiCollectorTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -68,9 +68,7 @@ public virtual void TestNullCollectors() MultiCollector.Wrap(null, null); Assert.Fail("only null collectors should not be supported"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs index 752fd423d5..0933d8665b 100644 --- a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Util; using NUnit.Framework; using System; @@ -79,9 +79,7 @@ public virtual void TestException() BooleanQuery.MaxClauseCount = 0; Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // okay } diff --git a/src/Lucene.Net.Tests/Search/TestCachingCollector.cs b/src/Lucene.Net.Tests/Search/TestCachingCollector.cs index b3476364d6..9db7c855c5 100644 --- a/src/Lucene.Net.Tests/Search/TestCachingCollector.cs +++ b/src/Lucene.Net.Tests/Search/TestCachingCollector.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -189,9 +189,7 @@ public virtual void TestIllegalCollectorOnReplay() cc.Replay(new NoOpCollector(false)); // this call should fail Assert.Fail("should have failed if an in-order Collector was given to replay(), " + "while CachingCollector was initialized with out-of-order collection"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } diff --git a/src/Lucene.Net.Tests/Search/TestFilteredQuery.cs b/src/Lucene.Net.Tests/Search/TestFilteredQuery.cs index 416733f77f..3638f47739 100644 --- a/src/Lucene.Net.Tests/Search/TestFilteredQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestFilteredQuery.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; using Lucene.Net.Util; using NUnit.Framework; @@ -417,9 +417,7 @@ public virtual void TestInvalidArguments() new FilteredQuery(null, null); Assert.Fail("Should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } @@ -428,9 +426,7 @@ public virtual void TestInvalidArguments() new FilteredQuery(new TermQuery(new Term("field", "one")), null); Assert.Fail("Should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } @@ -439,9 +435,7 @@ public virtual void TestInvalidArguments() new FilteredQuery(null, new PrefixFilter(new Term("field", "o"))); Assert.Fail("Should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs b/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs index c9601f1534..a61983b52b 100644 --- a/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using NUnit.Framework; using System; using System.Collections.Generic; @@ -398,9 +398,7 @@ public virtual void TestDistanceAsEditsSearching() q = new FuzzyQuery(new Term("field", "t"), 3); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected } diff --git a/src/Lucene.Net.Tests/Search/TestIndexSearcher.cs b/src/Lucene.Net.Tests/Search/TestIndexSearcher.cs index 4c8ab13476..03a3f5ab50 100644 --- a/src/Lucene.Net.Tests/Search/TestIndexSearcher.cs +++ b/src/Lucene.Net.Tests/Search/TestIndexSearcher.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Documents; +using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Support.Threading; using Lucene.Net.Util; @@ -138,9 +138,7 @@ public virtual void TestSearchAfterPassedMaxDoc() s.SearchAfter(new ScoreDoc(r.MaxDoc, 0.54f), new MatchAllDocsQuery(), 10); Assert.Fail("should have hit IllegalArgumentException when searchAfter exceeds maxDoc"); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // ok } diff --git a/src/Lucene.Net.Tests/Search/TestMultiPhraseQuery.cs b/src/Lucene.Net.Tests/Search/TestMultiPhraseQuery.cs index 70bc1e8f56..694bb283c3 100644 --- a/src/Lucene.Net.Tests/Search/TestMultiPhraseQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestMultiPhraseQuery.cs @@ -1,4 +1,4 @@ -using J2N.Collections.Generic.Extensions; +using J2N.Collections.Generic.Extensions; using Lucene.Net.Documents; using NUnit.Framework; using System; @@ -148,9 +148,7 @@ public virtual void TestPhrasePrefix() query4.Add(new Term("field2", "foobar")); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { // okay, all terms must belong to the same field } @@ -658,9 +656,7 @@ public virtual void TestNegativeSlop() query.Slop = -2; Assert.Fail("didn't get expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected exception } diff --git a/src/Lucene.Net.Tests/Search/TestPhraseQuery.cs b/src/Lucene.Net.Tests/Search/TestPhraseQuery.cs index 61a9c05e10..d329df874b 100644 --- a/src/Lucene.Net.Tests/Search/TestPhraseQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestPhraseQuery.cs @@ -880,9 +880,7 @@ public virtual void TestNegativeSlop() query.Slop = -2; Assert.Fail("didn't get expected exception"); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { // expected exception } diff --git a/src/Lucene.Net.Tests/Util/TestAttributeSource.cs b/src/Lucene.Net.Tests/Util/TestAttributeSource.cs index 75546dda5c..4f4f7ba18e 100644 --- a/src/Lucene.Net.Tests/Util/TestAttributeSource.cs +++ b/src/Lucene.Net.Tests/Util/TestAttributeSource.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Analysis.TokenAttributes; +using Lucene.Net.Analysis.TokenAttributes; using NUnit.Framework; using System; using System.Collections.Generic; @@ -80,9 +80,7 @@ public virtual void TestCaptureState() src3.RestoreState(state); Assert.Fail("The third instance is missing the TypeAttribute, so restoreState() should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // pass } @@ -147,9 +145,7 @@ public virtual void TestInvalidArguments() src.AddAttribute(); Assert.Fail("Should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { } @@ -159,9 +155,7 @@ public virtual void TestInvalidArguments() src.AddAttribute(); Assert.Fail("Should throw IllegalArgumentException"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { } @@ -176,7 +170,7 @@ public virtual void TestInvalidArguments() src.AddAttribute(); Assert.Fail("Should throw IllegalArgumentException"); } - catch (ArgumentException iae) + catch (Exception iae) when (iae.IsIllegalArgumentException()) { }*/ } diff --git a/src/Lucene.Net.Tests/Util/TestNamedSPILoader.cs b/src/Lucene.Net.Tests/Util/TestNamedSPILoader.cs index f6b1f51222..57a7446ce4 100644 --- a/src/Lucene.Net.Tests/Util/TestNamedSPILoader.cs +++ b/src/Lucene.Net.Tests/Util/TestNamedSPILoader.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -44,9 +44,7 @@ public virtual void TestBogusLookup() Codec.ForName("dskfdskfsdfksdfdsf"); Assert.Fail(); } -#pragma warning disable 168 - catch (ArgumentException expected) -#pragma warning restore 168 + catch (Exception expected) when (expected.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests/Util/TestPriorityQueue.cs b/src/Lucene.Net.Tests/Util/TestPriorityQueue.cs index da598ae4b8..5cb51f477e 100644 --- a/src/Lucene.Net.Tests/Util/TestPriorityQueue.cs +++ b/src/Lucene.Net.Tests/Util/TestPriorityQueue.cs @@ -1,4 +1,4 @@ -using Lucene.Net.Attributes; +using Lucene.Net.Attributes; using NUnit.Framework; using System; using System.Collections.Generic; @@ -228,7 +228,7 @@ public static void TestMaxSizeBounds() // Should had thrown an exception Assert.Fail(); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { } @@ -237,7 +237,7 @@ public static void TestMaxSizeBounds() { pq = new IntegerQueue(maxSize); } - catch (ArgumentException) + catch (Exception e) when (e.IsIllegalArgumentException()) { } } diff --git a/src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs b/src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs index b3a19d025e..5cc0a95b5a 100644 --- a/src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs +++ b/src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs @@ -1,4 +1,4 @@ -using J2N; +using J2N; using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -146,9 +146,7 @@ private static void AssertcodePointCountThrowsAssertionOn(params byte[] bytes) { UnicodeUtil.CodePointCount(new BytesRef(bytes)); } -#pragma warning disable 168 - catch (ArgumentException e) -#pragma warning restore 168 + catch (Exception e) when (e.IsIllegalArgumentException()) { threwAssertion = true; } @@ -225,9 +223,7 @@ public virtual void TestNewString() { // Ignored. } -#pragma warning disable 168 - catch (ArgumentException e2) -#pragma warning restore 168 + catch (Exception e2) when (e2.IsIllegalArgumentException()) { // Ignored. } diff --git a/src/Lucene.Net.Tests/Util/TestVirtualMethod.cs b/src/Lucene.Net.Tests/Util/TestVirtualMethod.cs index a1fe2e0fa7..310d826472 100644 --- a/src/Lucene.Net.Tests/Util/TestVirtualMethod.cs +++ b/src/Lucene.Net.Tests/Util/TestVirtualMethod.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using System; using Assert = Lucene.Net.TestFramework.Assert; @@ -109,9 +109,7 @@ public virtual void TestExceptions() publicTestMethod.GetImplementationDistance(typeof(LuceneTestCase)); Assert.Fail("LuceneTestCase is not a subclass and can never override publicTest(String)"); } -#pragma warning disable 168 - catch (ArgumentException arg) -#pragma warning restore 168 + catch (Exception arg) when (arg.IsIllegalArgumentException()) { // pass } @@ -121,9 +119,7 @@ public virtual void TestExceptions() new VirtualMethod(typeof(BaseTestVirtualMethod), "bogus"); Assert.Fail("Method bogus() does not exist, so IAE should be thrown"); } -#pragma warning disable 168 - catch (ArgumentException arg) -#pragma warning restore 168 + catch (Exception arg) when (arg.IsIllegalArgumentException()) { // pass } @@ -132,9 +128,7 @@ public virtual void TestExceptions() { new VirtualMethod(typeof(TestClass2), "PublicTest", typeof(string)); } -#pragma warning disable 168 - catch (ArgumentException arg) -#pragma warning restore 168 + catch (Exception arg) when (arg.IsIllegalArgumentException()) { Assert.Fail("Method publicTest(String) is declared in TestClass2, so IAE should not be thrown"); } @@ -145,9 +139,7 @@ public virtual void TestExceptions() new VirtualMethod(typeof(BaseTestVirtualMethod), "PublicTest", typeof(string)); Assert.Fail("Violating singleton status succeeded"); } -#pragma warning disable 168 - catch (ArgumentException arg) -#pragma warning restore 168 + catch (Exception arg) when (arg.IsIllegalArgumentException()) { // pass } diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj index 93c966f346..6260e10ac0 100644 --- a/src/Lucene.Net/Lucene.Net.csproj +++ b/src/Lucene.Net/Lucene.Net.csproj @@ -106,6 +106,8 @@ + + @@ -119,6 +121,7 @@ + diff --git a/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs b/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs index 1c15d4d70e..27415e1ad0 100644 --- a/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs +++ b/src/dotnet/Lucene.Net.Tests.ICU/Search/PostingsHighlight/TestICUPostingsHighlighter.cs @@ -430,9 +430,7 @@ public void TestUserFailedToIndexOffsets() highlighter.Highlight("body", query, searcher, topDocs, 2); fail("did not hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected } @@ -442,9 +440,7 @@ public void TestUserFailedToIndexOffsets() highlighter.Highlight("title", new TermQuery(new Term("title", "test")), searcher, topDocs, 2); fail("did not hit expected exception"); } -#pragma warning disable 168 - catch (ArgumentException iae) -#pragma warning restore 168 + catch (Exception iae) when (iae.IsIllegalArgumentException()) { // expected }