diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs index 3aceff72a9a..6d2df685dd0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs @@ -177,17 +177,8 @@ internal ITextPointer GetNextSpellingErrorPosition(ITextPointer position, Logica // for an error range. // This method actually runs the speller on the specified text, // re-evaluating the error from scratch. - internal IList GetSuggestionsForError(SpellingError error) + internal List GetSuggestionsForError(SpellingError error) { - ITextPointer contextStart; - ITextPointer contextEnd; - ITextPointer contentStart; - ITextPointer contentEnd; - TextMap textMap; - ArrayList suggestions; - - suggestions = new ArrayList(1); - // // IMPORTANT!! // @@ -195,18 +186,15 @@ internal IList GetSuggestionsForError(SpellingError error) // calculate the exact same error. Keep the two methods in sync! // - XmlLanguage language; - CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out language); - if (culture == null || !_spellerInterop.CanSpellCheck(culture)) - { - // Return an empty list. - } - else + List suggestions = new(4); + CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out XmlLanguage language); + + if (culture is not null && _spellerInterop.CanSpellCheck(culture)) { - ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out contentStart, out contextStart); - ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out contentEnd, out contextEnd); + ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out ITextPointer contentStart, out ITextPointer contextStart); + ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out ITextPointer contentEnd, out ITextPointer contextEnd); - textMap = new TextMap(contextStart, contextEnd, contentStart, contentEnd); + TextMap textMap = new(contextStart, contextEnd, contentStart, contentEnd); SetCulture(culture); @@ -915,7 +903,7 @@ private bool ScanErrorTextSegment(SpellerInteropBase.ISpellerSegment textSegment { if (textSegment.SubSegments.Count == 0) { - ArrayList suggestions = (ArrayList)data.Data; + List suggestions = (List)data.Data; if(textSegment.Suggestions.Count > 0) { foreach(string suggestion in textSegment.Suggestions) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/SpellerError.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/SpellerError.cs index b309aa8d32c..5761d3ff301 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/SpellerError.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/SpellerError.cs @@ -94,15 +94,7 @@ public void IgnoreAll() /// public IEnumerable Suggestions { - get - { - IList suggestions = _speller.GetSuggestionsForError(this); - - for (int i=0; i _speller.GetSuggestionsForError(this); } #endregion Public Properties