diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Line.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Line.cs index 03511eba538..38bc13f7943 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Line.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/Line.cs @@ -668,7 +668,7 @@ internal int GetEllipsesLength() /// /// End dcp of range. /// - internal void GetGlyphRuns(System.Collections.Generic.List glyphRuns, int dcpStart, int dcpEnd) + internal void GetGlyphRuns(List glyphRuns, int dcpStart, int dcpEnd) { // NOTE: Following logic is only temporary workaround for lack // of appropriate API that should be exposed by TextLine. @@ -691,7 +691,7 @@ internal void GetGlyphRuns(System.Collections.Generic.List glyphRuns, // Copy glyph runs into separate array (for backward navigation). // And count number of chracters in the glyph runs collection. int cchGlyphRuns = 0; - ArrayList glyphRunsCollection = new ArrayList(4); + List glyphRunsCollection = new(4); AddGlyphRunRecursive(drawing, glyphRunsCollection, ref cchGlyphRuns); @@ -712,7 +712,7 @@ internal void GetGlyphRuns(System.Collections.Generic.List glyphRuns, // Remove those glyph runs from our colleciton. while (cchGlyphRuns > cchTextSpans) { - GlyphRun glyphRun = (GlyphRun)glyphRunsCollection[0]; + GlyphRun glyphRun = glyphRunsCollection[0]; cchGlyphRuns -= (glyphRun.Characters == null ? 0 : glyphRun.Characters.Count); glyphRunsCollection.RemoveAt(0); } @@ -727,7 +727,7 @@ internal void GetGlyphRuns(System.Collections.Generic.List glyphRuns, while (cchRunsInSpan < span.Length) { Invariant.Assert(runIndex < glyphRunsCollection.Count); - GlyphRun run = (GlyphRun)glyphRunsCollection[runIndex]; + GlyphRun run = glyphRunsCollection[runIndex]; int characterCount = (run.Characters == null ? 0 : run.Characters.Count); if ((dcp < curDcp + characterCount) && (dcp + cch > curDcp)) { @@ -1072,13 +1072,9 @@ private TextCollapsingProperties GetCollapsingProps(double wrappingWidth, LinePr /// /// Character length of glyph run collection /// - private void AddGlyphRunRecursive( - Drawing drawing, - IList glyphRunsCollection, - ref int cchGlyphRuns) + private static void AddGlyphRunRecursive(Drawing drawing, List glyphRunsCollection, ref int cchGlyphRuns) { - DrawingGroup group = drawing as DrawingGroup; - if (group != null) + if (drawing is DrawingGroup group) { foreach (Drawing child in group.Children) { @@ -1087,8 +1083,7 @@ private void AddGlyphRunRecursive( } else { - GlyphRunDrawing glyphRunDrawing = drawing as GlyphRunDrawing; - if (glyphRunDrawing != null) + if (drawing is GlyphRunDrawing glyphRunDrawing) { // Add a glyph run GlyphRun glyphRun = glyphRunDrawing.GlyphRun;