From 46f0fac174013ae4c7de6dafea8a9e83d4758031 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Fri, 4 Nov 2022 07:49:23 +0100 Subject: [PATCH] Use string interpolation --- MoreLinq.Test/AggregateRightTest.cs | 8 ++++---- MoreLinq.Test/ScanRightTest.cs | 4 ++-- MoreLinq/AggregateRight.cs | 6 +++--- MoreLinq/Extensions.g.cs | 8 ++++---- MoreLinq/ScanRight.cs | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/MoreLinq.Test/AggregateRightTest.cs b/MoreLinq.Test/AggregateRightTest.cs index 0d3aa62af..55a8e091d 100644 --- a/MoreLinq.Test/AggregateRightTest.cs +++ b/MoreLinq.Test/AggregateRightTest.cs @@ -49,7 +49,7 @@ public void AggregateRight(SourceKind sourceKind) { var enumerable = Enumerable.Range(1, 5).Select(x => x.ToString()).ToSourceKind(sourceKind); - var result = enumerable.AggregateRight((a, b) => string.Format("({0}+{1})", a, b)); + var result = enumerable.AggregateRight((a, b) => $"({a}+{b})"); Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))")); } @@ -78,7 +78,7 @@ public void AggregateRightSeedFuncIsNotInvokedOnEmptySequence() public void AggregateRightSeed() { var result = Enumerable.Range(1, 4) - .AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .AggregateRight("5", (a, b) => $"({a}+{b})"); Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))")); } @@ -90,14 +90,14 @@ public void AggregateRightSeed() [TestCase(true)] public void AggregateRightResultorWithEmptySequence(object defaultValue) { - Assert.That(new int[0].AggregateRight(defaultValue, (a, b) => b, a => a == defaultValue), Is.EqualTo(true)); + Assert.That(new int[0].AggregateRight(defaultValue, (_, b) => b, a => a == defaultValue), Is.EqualTo(true)); } [Test] public void AggregateRightResultor() { var result = Enumerable.Range(1, 4) - .AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b), a => a.Length); + .AggregateRight("5", (a, b) => $"({a}+{b})", a => a.Length); Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))".Length)); } diff --git a/MoreLinq.Test/ScanRightTest.cs b/MoreLinq.Test/ScanRightTest.cs index 3cb334612..948dd8c70 100644 --- a/MoreLinq.Test/ScanRightTest.cs +++ b/MoreLinq.Test/ScanRightTest.cs @@ -64,7 +64,7 @@ public void ScanRight(SourceKind sourceKind) var result = Enumerable.Range(1, 5) .Select(x => x.ToString()) .ToSourceKind(sourceKind) - .ScanRight((a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight((a, b) => $"({a}+{b})"); var expectations = new[] { "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" }; @@ -101,7 +101,7 @@ public void ScanRightSeedFuncIsNotInvokedOnEmptySequence() public void ScanRightSeed() { var result = Enumerable.Range(1, 4) - .ScanRight("5", (a, b) => string.Format("({0}+{1})", a, b)); + .ScanRight("5", (a, b) => $"({a}+{b})"); var expectations = new[] { "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" }; diff --git a/MoreLinq/AggregateRight.cs b/MoreLinq/AggregateRight.cs index 162b0e412..6778c827b 100644 --- a/MoreLinq/AggregateRight.cs +++ b/MoreLinq/AggregateRight.cs @@ -34,7 +34,7 @@ static partial class MoreEnumerable /// The final accumulator value. /// /// i.ToString()).AggregateRight((a, b) => string.Format("({0}/{1})", a, b)); + /// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => $"({a}/{b})"); /// ]]> /// The result variable will contain "(1/(2/(3/(4/5))))". /// @@ -70,7 +70,7 @@ public static TSource AggregateRight(this IEnumerable source, /// /// string.Format("({0}/{1})", a, b)); + /// string result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})"); /// ]]> /// The result variable will contain "(1/(2/(3/(4/(5/6)))))". /// @@ -106,7 +106,7 @@ public static TAccumulate AggregateRight(this IEnumerable< /// /// string.Format("({0}/{1})", a, b), str => str.Length); + /// int result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})", str => str.Length); /// ]]> /// The result variable will contain 21. /// diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index af8837030..bead709d2 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -360,7 +360,7 @@ public static partial class AggregateRightExtension /// The final accumulator value. /// /// i.ToString()).AggregateRight((a, b) => string.Format("({0}/{1})", a, b)); + /// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => $"({a}/{b})"); /// ]]> /// The result variable will contain "(1/(2/(3/(4/5))))". /// @@ -386,7 +386,7 @@ public static TSource AggregateRight(this IEnumerable source, /// /// string.Format("({0}/{1})", a, b)); + /// string result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})"); /// ]]> /// The result variable will contain "(1/(2/(3/(4/(5/6)))))". /// @@ -415,7 +415,7 @@ public static TAccumulate AggregateRight(this IEnumerable< /// /// string.Format("({0}/{1})", a, b), str => str.Length); + /// int result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})", str => str.Length); /// ]]> /// The result variable will contain 21. /// @@ -5022,7 +5022,7 @@ public static IEnumerable ScanRight(this IEnumerable /// The scanned sequence. /// /// string.Format("({0}/{1})", a, b)); + /// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => $"({a}+{b})"); /// ]]> /// The result variable will contain [ "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" ]. /// diff --git a/MoreLinq/ScanRight.cs b/MoreLinq/ScanRight.cs index 131aced3c..c20d07930 100644 --- a/MoreLinq/ScanRight.cs +++ b/MoreLinq/ScanRight.cs @@ -70,7 +70,7 @@ public static IEnumerable ScanRight(this IEnumerable /// The scanned sequence. /// /// string.Format("({0}/{1})", a, b)); + /// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => $"({a}+{b})"); /// ]]> /// The result variable will contain [ "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" ]. ///