From e879c891927ec78e6ec7e86d416e11d12c62eb32 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:26:35 -0500 Subject: [PATCH 1/4] update dotnet build actions --- .github/workflows/build-codeql.yml | 2 +- .github/workflows/build-indicators.yml | 2 +- .github/workflows/deploy-package.yml | 2 +- .github/workflows/test-performance.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-codeql.yml b/.github/workflows/build-codeql.yml index ad76c4c16..cdcc8bf97 100644 --- a/.github/workflows/build-codeql.yml +++ b/.github/workflows/build-codeql.yml @@ -39,7 +39,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.x' - name: Initialize uses: github/codeql-action/init@v2 diff --git a/.github/workflows/build-indicators.yml b/.github/workflows/build-indicators.yml index 0579fdc65..f33ae1c78 100644 --- a/.github/workflows/build-indicators.yml +++ b/.github/workflows/build-indicators.yml @@ -28,7 +28,7 @@ jobs: - name: Install .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: "7.x" + dotnet-version: "8.x" dotnet-quality: "ga" - name: Build solution diff --git a/.github/workflows/deploy-package.yml b/.github/workflows/deploy-package.yml index f0367e12b..3b4929453 100644 --- a/.github/workflows/deploy-package.yml +++ b/.github/workflows/deploy-package.yml @@ -50,7 +50,7 @@ jobs: - name: Install .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: "7.x" + dotnet-version: "8.x" dotnet-quality: "ga" - name: Build library diff --git a/.github/workflows/test-performance.yml b/.github/workflows/test-performance.yml index 53e1dd780..d323c0a1a 100644 --- a/.github/workflows/test-performance.yml +++ b/.github/workflows/test-performance.yml @@ -17,7 +17,7 @@ jobs: - name: Install .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: "7.x" + dotnet-version: "8.x" dotnet-quality: "ga" - name: Build library From acd5064e5e08743c3cc925e2036c434208a20232 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:27:48 -0500 Subject: [PATCH 2/4] update project targets --- .editorconfig | 11 ++++++----- docs/examples/Backtest/Backtest.csproj | 2 +- docs/examples/ConsoleApp/ConsoleApp.csproj | 2 +- .../CustomIndicators/CustomIndicatorsLibrary.csproj | 2 +- .../CustomIndicatorsUsage.csproj | 2 +- docs/examples/ObserveStream/ObserveStream.csproj | 2 +- docs/examples/UseQuoteApi/UseQuoteApi.csproj | 2 +- src/GlobalSuppressions.cs | 12 +++++++++++- src/Indicators.csproj | 5 +++-- src/_common/ObsoleteV2.cs | 2 +- tests/indicators/GlobalSuppressions.cs | 5 +++++ tests/indicators/Tests.Indicators.csproj | 4 ++-- tests/other/Tests.Other.csproj | 4 ++-- tests/performance/Tests.Performance.csproj | 2 +- 14 files changed, 37 insertions(+), 20 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3d751d715..a8b773fed 100644 --- a/.editorconfig +++ b/.editorconfig @@ -133,14 +133,14 @@ csharp_indent_case_contents = true csharp_style_prefer_top_level_statements = false:silent csharp_style_prefer_utf8_string_literals = true:suggestion csharp_preserve_single_line_statements = false +csharp_style_prefer_primary_constructors = true:suggestion # IDE0058: Expression value is never used dotnet_diagnostic.IDE0058.severity = none [*.{cs,vb}] -dotnet_style_namespace_match_folder= false:silent -dotnet_style_allow_multiple_blank_lines_experimental= false:silent -dotnet_style_allow_statement_immediately_after_block_experimental= false:silent +tab_width = 4 +end_of_line = crlf #### Naming styles #### @@ -189,8 +189,6 @@ dotnet_naming_style.pascal_case.required_suffix = dotnet_naming_style.pascal_case.word_separator = dotnet_naming_style.pascal_case.capitalization = pascal_case dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -end_of_line = crlf dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning @@ -218,3 +216,6 @@ dotnet_style_qualification_for_field = false:silent dotnet_style_qualification_for_property = false:silent dotnet_style_qualification_for_method = false:silent dotnet_style_qualification_for_event = false:silent +dotnet_style_namespace_match_folder= false:silent +dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion +dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion diff --git a/docs/examples/Backtest/Backtest.csproj b/docs/examples/Backtest/Backtest.csproj index ddc5383e3..65af421c0 100644 --- a/docs/examples/Backtest/Backtest.csproj +++ b/docs/examples/Backtest/Backtest.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable diff --git a/docs/examples/ConsoleApp/ConsoleApp.csproj b/docs/examples/ConsoleApp/ConsoleApp.csproj index ddc5383e3..65af421c0 100644 --- a/docs/examples/ConsoleApp/ConsoleApp.csproj +++ b/docs/examples/ConsoleApp/ConsoleApp.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable diff --git a/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj b/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj index 5b4ff71c4..3bcf14387 100644 --- a/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj +++ b/docs/examples/CustomIndicators/CustomIndicatorsLibrary.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable diff --git a/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj b/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj index d39f50045..3c1fd397b 100644 --- a/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj +++ b/docs/examples/CustomIndicatorsUsage/CustomIndicatorsUsage.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable disable diff --git a/docs/examples/ObserveStream/ObserveStream.csproj b/docs/examples/ObserveStream/ObserveStream.csproj index 925465ae9..c4c176fc3 100644 --- a/docs/examples/ObserveStream/ObserveStream.csproj +++ b/docs/examples/ObserveStream/ObserveStream.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable diff --git a/docs/examples/UseQuoteApi/UseQuoteApi.csproj b/docs/examples/UseQuoteApi/UseQuoteApi.csproj index 170190659..a1e4f8a38 100644 --- a/docs/examples/UseQuoteApi/UseQuoteApi.csproj +++ b/docs/examples/UseQuoteApi/UseQuoteApi.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable diff --git a/src/GlobalSuppressions.cs b/src/GlobalSuppressions.cs index c085362d6..b475b80d0 100644 --- a/src/GlobalSuppressions.cs +++ b/src/GlobalSuppressions.cs @@ -36,6 +36,16 @@ [assembly: SuppressMessage( "StyleCop.CSharp.SpacingRules", "SA1008:Opening parenthesis should be spaced correctly", - Justification = "Not compatible with `or` statement (Microsoft bug)", + Justification = "Not compatible with `or` statement (analyzer bug)", Scope = "member", Target = "~M:Skender.Stock.Indicators.ResultUtility.Condense``1(System.Collections.Generic.IEnumerable{``0})~System.Collections.Generic.IEnumerable{``0}")] + +[assembly: SuppressMessage( + "Maintainability", + "CA1510:Use ArgumentNullException throw helper", + Justification = "Can only use with .NET 6 or later. We support .NET Framework and .NET Standard.")] + +[assembly: SuppressMessage( + "StyleCop.CSharp.SpacingRules", + "SA1010:Opening square brackets should be spaced correctly", + Justification = "Invalid for new C# 12 [ collection ] syntax.")] diff --git a/src/Indicators.csproj b/src/Indicators.csproj index 823c96297..e0a63f23f 100644 --- a/src/Indicators.csproj +++ b/src/Indicators.csproj @@ -1,7 +1,7 @@ - net7.0;net6.0;netstandard2.1;netstandard2.0 + net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0 Dave Skender Stock Indicators for .NET @@ -14,7 +14,7 @@ Skender.Stock.Indicators Skender.Stock.Indicators - 10.0 + 12.0 en-US false @@ -54,6 +54,7 @@ true true true + True diff --git a/src/_common/ObsoleteV2.cs b/src/_common/ObsoleteV2.cs index 540e097b4..15a6dca2f 100644 --- a/src/_common/ObsoleteV2.cs +++ b/src/_common/ObsoleteV2.cs @@ -39,7 +39,7 @@ public static partial class Indicator List reList = reusable.ToSortedList(); int length = reList.Count; - Collection<(DateTime Date, double? Value)> results = new(); + Collection<(DateTime Date, double? Value)> results = []; for (int i = 0; i < length; i++) { diff --git a/tests/indicators/GlobalSuppressions.cs b/tests/indicators/GlobalSuppressions.cs index 26c9d7ecb..b63914909 100644 --- a/tests/indicators/GlobalSuppressions.cs +++ b/tests/indicators/GlobalSuppressions.cs @@ -24,3 +24,8 @@ "Security", "CA5394:Do not use insecure randomness", Justification = "Okay for test rig, non-production code.")] + +[assembly: SuppressMessage( + "StyleCop.CSharp.SpacingRules", + "SA1010:Opening square brackets should be spaced correctly", + Justification = "Invalid for new C# 12 [ collection ] syntax.")] diff --git a/tests/indicators/Tests.Indicators.csproj b/tests/indicators/Tests.Indicators.csproj index b4946ef6c..849fdbc73 100644 --- a/tests/indicators/Tests.Indicators.csproj +++ b/tests/indicators/Tests.Indicators.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable false @@ -14,7 +14,7 @@ - + diff --git a/tests/other/Tests.Other.csproj b/tests/other/Tests.Other.csproj index 94356be6b..0a90d5f6d 100644 --- a/tests/other/Tests.Other.csproj +++ b/tests/other/Tests.Other.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable false @@ -14,7 +14,7 @@ - + diff --git a/tests/performance/Tests.Performance.csproj b/tests/performance/Tests.Performance.csproj index 052dada6e..bb68eb478 100644 --- a/tests/performance/Tests.Performance.csproj +++ b/tests/performance/Tests.Performance.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable Exe From 286402f72cb91561ab9a77cbe1ced746f6a52aa9 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:28:06 -0500 Subject: [PATCH 3/4] update recommended syntax --- src/_common/Generics/Pruning.cs | 2 +- src/_common/Generics/Transforms.cs | 7 +------ src/_common/Quotes/Quote.Exceptions.cs | 8 -------- src/_common/Results/Result.Syncing.cs | 4 ++-- src/_common/Results/Result.Utilities.cs | 4 ++-- src/e-k/Hma/Hma.Series.cs | 2 +- src/m-r/Macd/Macd.Series.cs | 2 +- src/m-r/Pmo/Pmo.Series.cs | 2 +- src/m-r/Pvo/Pvo.Series.cs | 2 +- src/m-r/Renko/RenkoAtr.Series.cs | 2 +- tests/indicators/_common/Generics/Sort.Tests.cs | 6 +++--- tests/indicators/_common/Math/Numerix.Tests.cs | 4 ++-- .../_common/Quotes/Quote.Aggregates.Tests.cs | 4 ++-- .../_common/Quotes/Quote.Validation.Tests.cs | 6 +++--- .../_common/Results/Result.Syncing.Tests.cs | 16 ++++++++-------- .../_common/Results/Result.Utilities.Tests.cs | 6 +++--- tests/indicators/a-d/Beta/Beta.Tests.cs | 12 ++++++------ tests/indicators/a-d/Dpo/Dpo.Tests.cs | 4 ++-- tests/other/Convergence.Tests.cs | 5 +---- 19 files changed, 41 insertions(+), 57 deletions(-) diff --git a/src/_common/Generics/Pruning.cs b/src/_common/Generics/Pruning.cs index d7ecba760..1cdc85e16 100644 --- a/src/_common/Generics/Pruning.cs +++ b/src/_common/Generics/Pruning.cs @@ -23,7 +23,7 @@ internal static List Remove( if (seriesList.Count <= removePeriods) { - return new List(); + return []; } else { diff --git a/src/_common/Generics/Transforms.cs b/src/_common/Generics/Transforms.cs index 56e9af7c8..2e7385dc9 100644 --- a/src/_common/Generics/Transforms.cs +++ b/src/_common/Generics/Transforms.cs @@ -14,12 +14,7 @@ internal static Collection ToCollection(this IEnumerable source) throw new ArgumentNullException(nameof(source)); } - Collection collection = new(); - - foreach (T item in source) - { - collection.Add(item); - } + Collection collection = [.. source]; return collection; } diff --git a/src/_common/Quotes/Quote.Exceptions.cs b/src/_common/Quotes/Quote.Exceptions.cs index ecab17d15..07f3a7a08 100644 --- a/src/_common/Quotes/Quote.Exceptions.cs +++ b/src/_common/Quotes/Quote.Exceptions.cs @@ -28,12 +28,4 @@ public InvalidQuotesException(string? paramName, object? actualValue, string? me : base(paramName, actualValue, message) { } - - // A constructor is needed for serialization when an - // exception propagates from a remoting server to the client. - [ExcludeFromCodeCoverage] - protected InvalidQuotesException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } diff --git a/src/_common/Results/Result.Syncing.cs b/src/_common/Results/Result.Syncing.cs index fbee8b4db..a39b0c9f9 100644 --- a/src/_common/Results/Result.Syncing.cs +++ b/src/_common/Results/Result.Syncing.cs @@ -54,7 +54,7 @@ public static IEnumerable SyncIndex( // add plugs for missing values if (prepend || append) { - List toAppend = new(); + List toAppend = []; for (int i = 0; i < toMatchList.Count; i++) { @@ -81,7 +81,7 @@ public static IEnumerable SyncIndex( // remove unmatched results if (remove) { - List toRemove = new(); + List toRemove = []; for (int i = 0; i < syncMeList.Count; i++) { diff --git a/src/_common/Results/Result.Utilities.cs b/src/_common/Results/Result.Utilities.cs index 06fd4e49c..a166aadff 100644 --- a/src/_common/Results/Result.Utilities.cs +++ b/src/_common/Results/Result.Utilities.cs @@ -35,7 +35,7 @@ public static IEnumerable Condense( internal static List<(DateTime Date, double Value)> ToTuple( this IEnumerable reusable) { - List<(DateTime date, double value)> prices = new(); + List<(DateTime date, double value)> prices = []; List reList = reusable.ToList(); // find first non-nulled @@ -59,7 +59,7 @@ public static IEnumerable Condense( List reList = reusable.ToSortedList(); int length = reList.Count; - Collection<(DateTime Date, double Value)> results = new(); + Collection<(DateTime Date, double Value)> results = []; for (int i = 0; i < length; i++) { diff --git a/src/e-k/Hma/Hma.Series.cs b/src/e-k/Hma/Hma.Series.cs index 2ee0d38ff..c308c10f7 100644 --- a/src/e-k/Hma/Hma.Series.cs +++ b/src/e-k/Hma/Hma.Series.cs @@ -13,7 +13,7 @@ internal static List CalcHma( // initialize int shiftQty = lookbackPeriods - 1; - List<(DateTime, double)> synthHistory = new(); + List<(DateTime, double)> synthHistory = []; List wmaN1 = tpList.GetWma(lookbackPeriods).ToList(); List wmaN2 = tpList.GetWma(lookbackPeriods / 2).ToList(); diff --git a/src/m-r/Macd/Macd.Series.cs b/src/m-r/Macd/Macd.Series.cs index 10957af80..b8c0b7550 100644 --- a/src/m-r/Macd/Macd.Series.cs +++ b/src/m-r/Macd/Macd.Series.cs @@ -17,7 +17,7 @@ internal static List CalcMacd( List emaSlow = tpList.CalcEma(slowPeriods); int length = tpList.Count; - List<(DateTime, double)> emaDiff = new(); + List<(DateTime, double)> emaDiff = []; List results = new(length); // roll through quotes diff --git a/src/m-r/Pmo/Pmo.Series.cs b/src/m-r/Pmo/Pmo.Series.cs index 0323e96a1..f2fdc94bf 100644 --- a/src/m-r/Pmo/Pmo.Series.cs +++ b/src/m-r/Pmo/Pmo.Series.cs @@ -58,7 +58,7 @@ private static List CalcPmoRocEma( double smoothingMultiplier = 2d / timePeriods; double? lastRocEma = null; List roc = tpList.CalcRoc(1, null).ToList(); - List results = new(); + List results = []; int startIndex = timePeriods + 1; diff --git a/src/m-r/Pvo/Pvo.Series.cs b/src/m-r/Pvo/Pvo.Series.cs index 93931b342..29f831dce 100644 --- a/src/m-r/Pvo/Pvo.Series.cs +++ b/src/m-r/Pvo/Pvo.Series.cs @@ -17,7 +17,7 @@ internal static List CalcPvo( List emaSlow = tpList.CalcEma(slowPeriods); int length = tpList.Count; - List<(DateTime, double)> emaDiff = new(); + List<(DateTime, double)> emaDiff = []; List results = new(length); // roll through quotes diff --git a/src/m-r/Renko/RenkoAtr.Series.cs b/src/m-r/Renko/RenkoAtr.Series.cs index 1d77bcc9b..73323db2f 100644 --- a/src/m-r/Renko/RenkoAtr.Series.cs +++ b/src/m-r/Renko/RenkoAtr.Series.cs @@ -18,7 +18,7 @@ internal static List CalcRenkoAtr( decimal brickSize = (atr == null) ? 0 : (decimal)atr; return brickSize is 0 ? - new List() + [] : quotesList.CalcRenko(brickSize, endType); } } diff --git a/tests/indicators/_common/Generics/Sort.Tests.cs b/tests/indicators/_common/Generics/Sort.Tests.cs index 24e5e1766..6463ec7dc 100644 --- a/tests/indicators/_common/Generics/Sort.Tests.cs +++ b/tests/indicators/_common/Generics/Sort.Tests.cs @@ -11,8 +11,8 @@ public class Sorting : TestBase public void ToSortedCollection() { // baseline for comparison - List baseline = new() - { + List baseline = + [ new SmaResult(DateTime.Parse("1/1/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/2/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/9/2000", EnglishCulture)) { Sma = null }, @@ -22,7 +22,7 @@ public void ToSortedCollection() new SmaResult(DateTime.Parse("1/6/2000", EnglishCulture)) { Sma = 6 }, new SmaResult(DateTime.Parse("1/7/2000", EnglishCulture)) { Sma = 7 }, new SmaResult(DateTime.Parse("1/8/2000", EnglishCulture)) { Sma = double.NaN }, - }; + ]; // PUBLIC VARIANT, generic sorted Collection Collection sortResults = baseline diff --git a/tests/indicators/_common/Math/Numerix.Tests.cs b/tests/indicators/_common/Math/Numerix.Tests.cs index 8362576c0..931ff8c67 100644 --- a/tests/indicators/_common/Math/Numerix.Tests.cs +++ b/tests/indicators/_common/Math/Numerix.Tests.cs @@ -10,8 +10,8 @@ public class NumerixTests : TestBase .Select(x => (double)x.Close) .ToArray(); - private readonly double[] x = { 1, 2, 3, 4, 5 }; - private readonly double[] y = { 0, 0, 0, 0 }; + private readonly double[] x = [1, 2, 3, 4, 5]; + private readonly double[] y = [0, 0, 0, 0]; [TestMethod] public void StdDev() diff --git a/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs b/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs index 34b23a1ed..1f8a5204c 100644 --- a/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs @@ -45,7 +45,7 @@ public void Aggregate() Assert.AreEqual(1396993m, r2.Volume); // no history scenario - List noQuotes = new(); + List noQuotes = []; IEnumerable noResults = noQuotes.Aggregate(PeriodSize.Day); Assert.IsFalse(noResults.Any()); } @@ -89,7 +89,7 @@ public void AggregateTimeSpan() Assert.AreEqual(1396993m, r2.Volume); // no history scenario - List noQuotes = new(); + List noQuotes = []; IEnumerable noResults = noQuotes.Aggregate(TimeSpan.FromDays(1)); Assert.IsFalse(noResults.Any()); } diff --git a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs index 35d088693..a20b604da 100644 --- a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs @@ -80,14 +80,14 @@ public void ValidateCut() [ExpectedException(typeof(InvalidQuotesException), "Duplicate date found.")] public void DuplicateHistory() { - List badHistory = new() - { + List badHistory = + [ new Quote { Date = DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", EnglishCulture), Open = 214.86m, High = 220.33m, Low = 210.96m, Close = 216.99m, Volume = 5923254 }, new Quote { Date = DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", EnglishCulture), Open = 214.75m, High = 228.00m, Low = 214.31m, Close = 226.99m, Volume = 11213471 }, new Quote { Date = DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", EnglishCulture), Open = 226.42m, High = 227.48m, Low = 221.95m, Close = 226.75m, Volume = 5911695 }, new Quote { Date = DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", EnglishCulture), Open = 226.93m, High = 230.31m, Low = 225.45m, Close = 229.01m, Volume = 5527893 }, new Quote { Date = DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", EnglishCulture), Open = 228.97m, High = 231.92m, Low = 228.00m, Close = 231.28m, Volume = 3979484 } - }; + ]; badHistory.Validate(); } diff --git a/tests/indicators/_common/Results/Result.Syncing.Tests.cs b/tests/indicators/_common/Results/Result.Syncing.Tests.cs index 4142c71f5..294648b7b 100644 --- a/tests/indicators/_common/Results/Result.Syncing.Tests.cs +++ b/tests/indicators/_common/Results/Result.Syncing.Tests.cs @@ -10,8 +10,8 @@ public class Syncing : TestBase public void SyncIndex() { // baseline for comparison - List baseline = new() - { + List baseline = + [ new SmaResult(DateTime.Parse("1/1/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/2/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/3/2000", EnglishCulture)) { Sma = 3 }, @@ -21,11 +21,11 @@ public void SyncIndex() new SmaResult(DateTime.Parse("1/7/2000", EnglishCulture)) { Sma = 7 }, new SmaResult(DateTime.Parse("1/8/2000", EnglishCulture)) { Sma = double.NaN }, new SmaResult(DateTime.Parse("1/9/2000", EnglishCulture)) { Sma = null }, - }; + ]; // to be synced - List eval = new() - { + List eval = + [ new EmaResult(DateTime.Parse("1/3/2000", EnglishCulture)) { Ema = 3 }, new EmaResult(DateTime.Parse("1/4/2000", EnglishCulture)) { Ema = 4 }, new EmaResult(DateTime.Parse("1/5/2000", EnglishCulture)) { Ema = 5 }, @@ -33,7 +33,7 @@ public void SyncIndex() new EmaResult(DateTime.Parse("1/7/2000", EnglishCulture)) { Ema = 7 }, new EmaResult(DateTime.Parse("1/9/2000", EnglishCulture)) { Ema = double.NaN }, new EmaResult(DateTime.Parse("1/10/2000", EnglishCulture)) { Ema = null }, - }; + ]; // prepend option List prepend = eval.SyncIndex(baseline, SyncType.Prepend).ToList(); @@ -88,8 +88,8 @@ public void SyncIndex() } // no results - List noBaseline = new(); - List noEval = new(); + List noBaseline = []; + List noEval = []; IEnumerable noBaseResults = eval.SyncIndex(noBaseline); IEnumerable noEvalResults = noEval.SyncIndex(baseline); diff --git a/tests/indicators/_common/Results/Result.Utilities.Tests.cs b/tests/indicators/_common/Results/Result.Utilities.Tests.cs index b70742d48..d50914f62 100644 --- a/tests/indicators/_common/Results/Result.Utilities.Tests.cs +++ b/tests/indicators/_common/Results/Result.Utilities.Tests.cs @@ -34,8 +34,8 @@ public void Condense() public void ToTuple() { // baseline for comparison - List baseline = new() - { + List baseline = + [ new SmaResult(DateTime.Parse("1/1/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/2/2000", EnglishCulture)) { Sma = null }, new SmaResult(DateTime.Parse("1/3/2000", EnglishCulture)) { Sma = 3 }, @@ -45,7 +45,7 @@ public void ToTuple() new SmaResult(DateTime.Parse("1/7/2000", EnglishCulture)) { Sma = 7 }, new SmaResult(DateTime.Parse("1/8/2000", EnglishCulture)) { Sma = double.NaN }, new SmaResult(DateTime.Parse("1/9/2000", EnglishCulture)) { Sma = null }, - }; + ]; // default chainable NaN with pruning (internal) List<(DateTime Date, double Value)> chainableTuple = baseline diff --git a/tests/indicators/a-d/Beta/Beta.Tests.cs b/tests/indicators/a-d/Beta/Beta.Tests.cs index f01f985ea..d749bd124 100644 --- a/tests/indicators/a-d/Beta/Beta.Tests.cs +++ b/tests/indicators/a-d/Beta/Beta.Tests.cs @@ -255,8 +255,8 @@ public void NoQuotes() [TestMethod] public void NoMatch() { - List quoteA = new() - { + List quoteA = + [ new Quote { Date = DateTime.Parse("1/1/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/2/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/3/2020", EnglishCulture), Close = 1234 }, @@ -266,10 +266,10 @@ public void NoMatch() new Quote { Date = DateTime.Parse("1/7/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/8/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/9/2020", EnglishCulture), Close = 1234 } - }; + ]; - List quoteB = new() - { + List quoteB = + [ new Quote { Date = DateTime.Parse("1/1/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/2/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/3/2020", EnglishCulture), Close = 1234 }, @@ -279,7 +279,7 @@ public void NoMatch() new Quote { Date = DateTime.Parse("1/7/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/8/2020", EnglishCulture), Close = 1234 }, new Quote { Date = DateTime.Parse("1/9/2020", EnglishCulture), Close = 1234 } - }; + ]; Assert.ThrowsException(() => quoteA.GetBeta(quoteB, 3)); diff --git a/tests/indicators/a-d/Dpo/Dpo.Tests.cs b/tests/indicators/a-d/Dpo/Dpo.Tests.cs index c1764f2a1..c89117e1f 100644 --- a/tests/indicators/a-d/Dpo/Dpo.Tests.cs +++ b/tests/indicators/a-d/Dpo/Dpo.Tests.cs @@ -11,8 +11,8 @@ public class DpoTests : TestBase public void Standard() { // get expected data - List qot = new(); - List exp = new(); + List qot = []; + List exp = []; List csvData = File.ReadAllLines("a-d/Dpo/Dpo.Data.csv") .Skip(1) diff --git a/tests/other/Convergence.Tests.cs b/tests/other/Convergence.Tests.cs index a4e4c1600..79a61e490 100644 --- a/tests/other/Convergence.Tests.cs +++ b/tests/other/Convergence.Tests.cs @@ -8,10 +8,7 @@ namespace Tests.Convergence; public class ConvergenceTests : TestBase { private static readonly int[] QuotesQuantities = - { - 5, 14, 28, 40, 50, 75, 100, 110, 120, 130, 140, 150, - 160, 175, 200, 250, 350, 500, 600, 700, 800, 900, 1000 - }; + [5, 14, 28, 40, 50, 75, 100, 110, 120, 130, 140, 150, 160, 175, 200, 250, 350, 500, 600, 700, 800, 900, 1000]; [TestMethod] public void Adx() From 9af21229e59db11891bf278a6e2ba4766d7ecd50 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:38:58 -0500 Subject: [PATCH 4/4] install .NET SDK for examples build --- .github/workflows/build-examples.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-examples.yml b/.github/workflows/build-examples.yml index d01b8fa18..aa273a92f 100644 --- a/.github/workflows/build-examples.yml +++ b/.github/workflows/build-examples.yml @@ -18,9 +18,16 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository uses: actions/checkout@v4 + - name: Install .NET SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: "8.x" + dotnet-quality: "ga" + - name: Build examples run: > dotnet build docs/examples/Examples.sln