From 7405c57af534c4b9f0cdbec9af038ac2567db833 Mon Sep 17 00:00:00 2001 From: Wayfarer Date: Tue, 21 Jan 2025 20:37:36 +0100 Subject: [PATCH] format --- CommonLibraryTests/Utilities.cs | 51 ++++++++++++++++++++++++++------ ExtendedSystemObjects/Utility.cs | 6 ++-- Imaging/DirectBitmap.cs | 20 ++++++------- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/CommonLibraryTests/Utilities.cs b/CommonLibraryTests/Utilities.cs index 74f35d2..a108f28 100644 --- a/CommonLibraryTests/Utilities.cs +++ b/CommonLibraryTests/Utilities.cs @@ -116,13 +116,26 @@ public void Sequencer() } /// - /// Finds the sequences should return correct result when there are sequences. + /// Finds the sequences should return correct result when there are sequences. /// [TestMethod] public void FindSequencesShouldReturnCorrectResultWhenThereAreSequences() { // Arrange - var numbers = new List { 1, 1, 2, 4, 4, 5, 6, 6, 2, 3, 3 }; + var numbers = new List + { + 1, + 1, + 2, + 4, + 4, + 5, + 6, + 6, + 2, + 3, + 3 + }; // Act var result = Utility.FindSequences(numbers); @@ -140,7 +153,7 @@ public void FindSequencesShouldReturnCorrectResultWhenThereAreSequences() /// - /// Finds the sequences should return empty when list is empty. + /// Finds the sequences should return empty when list is empty. /// [TestMethod] public void FindSequencesShouldReturnEmptyWhenListIsEmpty() @@ -156,7 +169,7 @@ public void FindSequencesShouldReturnEmptyWhenListIsEmpty() } /// - /// Finds the sequences should return single sequence when all values are same. + /// Finds the sequences should return single sequence when all values are same. /// [TestMethod] public void FindSequencesShouldReturnSingleSequenceWhenAllValuesAreSame() @@ -173,7 +186,7 @@ public void FindSequencesShouldReturnSingleSequenceWhenAllValuesAreSame() } /// - /// Finds the sequences should handle single element list. + /// Finds the sequences should handle single element list. /// [TestMethod] public void FindSequencesShouldHandleSingleElementList() @@ -190,13 +203,20 @@ public void FindSequencesShouldHandleSingleElementList() } /// - /// Finds the sequences should return correct result when no sequences. + /// Finds the sequences should return correct result when no sequences. /// [TestMethod] public void FindSequencesShouldReturnCorrectResultWhenNoSequences() { // Arrange - var numbers = new List { 1, 2, 3, 4, 5 }; + var numbers = new List + { + 1, + 2, + 3, + 4, + 5 + }; // Act var result = Utility.FindSequences(numbers); @@ -211,13 +231,26 @@ public void FindSequencesShouldReturnCorrectResultWhenNoSequences() } /// - /// Finds the sequences should return correct result when list has mixed sequences. + /// Finds the sequences should return correct result when list has mixed sequences. /// [TestMethod] public void FindSequencesShouldReturnCorrectResultWhenListHasMixedSequences() { // Arrange - var numbers = new List { 1, 1, 2, 4, 4, 5, 5, 5, 6, 6, 7 }; + var numbers = new List + { + 1, + 1, + 2, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 7 + }; // Act var result = Utility.FindSequences(numbers); diff --git a/ExtendedSystemObjects/Utility.cs b/ExtendedSystemObjects/Utility.cs index 53f9fd5..69605a1 100644 --- a/ExtendedSystemObjects/Utility.cs +++ b/ExtendedSystemObjects/Utility.cs @@ -310,8 +310,8 @@ public static List> Sequencer(List numbers, int step } /// - /// Finds the sequences. - /// Looks for consecutive numbers in a sequence. + /// Finds the sequences. + /// Looks for consecutive numbers in a sequence. /// /// The numbers. /// Return the start, end, and the repeated value of that streak. @@ -320,7 +320,9 @@ public static List> Sequencer(List numbers, int step var result = new List<(int start, int end, int value)>(); if (numbers == null || numbers.Count == 0) + { return result; + } var start = 0; for (var i = 1; i <= numbers.Count; i++) diff --git a/Imaging/DirectBitmap.cs b/Imaging/DirectBitmap.cs index 7b621db..f852b81 100644 --- a/Imaging/DirectBitmap.cs +++ b/Imaging/DirectBitmap.cs @@ -402,18 +402,18 @@ public void SetPixelsSimd(IEnumerable<(int x, int y, Color color)> pixels) } /// - /// Draws the vertical lines. + /// Draws the vertical lines. /// /// The vertical lines. public void DrawVerticalLines(IEnumerable<(int x, int y, int finalY, Color color)> verticalLines) { - _ = Parallel.ForEach(verticalLines, (line) => - { - var (x, y, finalY, color) = line; - var colorArgb = color.ToArgb(); + _ = Parallel.ForEach(verticalLines, line => + { + var (x, y, finalY, color) = line; + var colorArgb = color.ToArgb(); // Starting position in the Bits array - var position = x + y * Width; + var position = x + (y * Width); // Calculate the number of rows in the vertical line var rowCount = finalY - y + 1; @@ -423,10 +423,10 @@ public void DrawVerticalLines(IEnumerable<(int x, int y, int finalY, Color color // Set the color for each pixel in the vertical line for (var i = 0; i < rowCount; i++) - { - bitsSpan[position + i * Width] = colorArgb; - } - }); + { + bitsSpan[position + (i * Width)] = colorArgb; + } + }); } ///