Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add .NET 8 framework #1123

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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 ####

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/Backtest/Backtest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/ObserveStream/ObserveStream.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/UseQuoteApi/UseQuoteApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
12 changes: 11 additions & 1 deletion src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
5 changes: 3 additions & 2 deletions src/Indicators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>

<Authors>Dave Skender</Authors>
<Product>Stock Indicators for .NET</Product>
Expand All @@ -14,7 +14,7 @@

<AssemblyName>Skender.Stock.Indicators</AssemblyName>
<RootNamespace>Skender.Stock.Indicators</RootNamespace>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>

<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand Down Expand Up @@ -54,6 +54,7 @@
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<SignAssembly>True</SignAssembly>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/_common/Generics/Pruning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static List<T> Remove<T>(

if (seriesList.Count <= removePeriods)
{
return new List<T>();
return [];
}
else
{
Expand Down
7 changes: 1 addition & 6 deletions src/_common/Generics/Transforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ internal static Collection<T> ToCollection<T>(this IEnumerable<T> source)
throw new ArgumentNullException(nameof(source));
}

Collection<T> collection = new();

foreach (T item in source)
{
collection.Add(item);
}
Collection<T> collection = [.. source];

return collection;
}
Expand Down
2 changes: 1 addition & 1 deletion src/_common/ObsoleteV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static partial class Indicator
List<IReusableResult> 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++)
{
Expand Down
8 changes: 0 additions & 8 deletions src/_common/Quotes/Quote.Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
}
4 changes: 2 additions & 2 deletions src/_common/Results/Result.Syncing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IEnumerable<TResultA> SyncIndex<TResultA, TResultB>(
// add plugs for missing values
if (prepend || append)
{
List<TResultA> toAppend = new();
List<TResultA> toAppend = [];

for (int i = 0; i < toMatchList.Count; i++)
{
Expand All @@ -81,7 +81,7 @@ public static IEnumerable<TResultA> SyncIndex<TResultA, TResultB>(
// remove unmatched results
if (remove)
{
List<TResultA> toRemove = new();
List<TResultA> toRemove = [];

for (int i = 0; i < syncMeList.Count; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/_common/Results/Result.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static IEnumerable<TResult> Condense<TResult>(
internal static List<(DateTime Date, double Value)> ToTuple(
this IEnumerable<IReusableResult> reusable)
{
List<(DateTime date, double value)> prices = new();
List<(DateTime date, double value)> prices = [];
List<IReusableResult> reList = reusable.ToList();

// find first non-nulled
Expand All @@ -59,7 +59,7 @@ public static IEnumerable<TResult> Condense<TResult>(
List<IReusableResult> 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++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/e-k/Hma/Hma.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static List<HmaResult> CalcHma(

// initialize
int shiftQty = lookbackPeriods - 1;
List<(DateTime, double)> synthHistory = new();
List<(DateTime, double)> synthHistory = [];

List<WmaResult> wmaN1 = tpList.GetWma(lookbackPeriods).ToList();
List<WmaResult> wmaN2 = tpList.GetWma(lookbackPeriods / 2).ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/m-r/Macd/Macd.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static List<MacdResult> CalcMacd(
List<EmaResult> emaSlow = tpList.CalcEma(slowPeriods);

int length = tpList.Count;
List<(DateTime, double)> emaDiff = new();
List<(DateTime, double)> emaDiff = [];
List<MacdResult> results = new(length);

// roll through quotes
Expand Down
2 changes: 1 addition & 1 deletion src/m-r/Pmo/Pmo.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static List<PmoResult> CalcPmoRocEma(
double smoothingMultiplier = 2d / timePeriods;
double? lastRocEma = null;
List<RocResult> roc = tpList.CalcRoc(1, null).ToList();
List<PmoResult> results = new();
List<PmoResult> results = [];

int startIndex = timePeriods + 1;

Expand Down
2 changes: 1 addition & 1 deletion src/m-r/Pvo/Pvo.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static List<PvoResult> CalcPvo(
List<EmaResult> emaSlow = tpList.CalcEma(slowPeriods);

int length = tpList.Count;
List<(DateTime, double)> emaDiff = new();
List<(DateTime, double)> emaDiff = [];
List<PvoResult> results = new(length);

// roll through quotes
Expand Down
2 changes: 1 addition & 1 deletion src/m-r/Renko/RenkoAtr.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static List<RenkoResult> CalcRenkoAtr<TQuote>(
decimal brickSize = (atr == null) ? 0 : (decimal)atr;

return brickSize is 0 ?
new List<RenkoResult>()
[]
: quotesList.CalcRenko(brickSize, endType);
}
}
5 changes: 5 additions & 0 deletions tests/indicators/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
4 changes: 2 additions & 2 deletions tests/indicators/Tests.Indicators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>

Expand All @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down
6 changes: 3 additions & 3 deletions tests/indicators/_common/Generics/Sort.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class Sorting : TestBase
public void ToSortedCollection()
{
// baseline for comparison
List<SmaResult> baseline = new()
{
List<SmaResult> 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 },
Expand All @@ -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<SmaResult> sortResults = baseline
Expand Down
4 changes: 2 additions & 2 deletions tests/indicators/_common/Math/Numerix.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Aggregate()
Assert.AreEqual(1396993m, r2.Volume);

// no history scenario
List<Quote> noQuotes = new();
List<Quote> noQuotes = [];
IEnumerable<Quote> noResults = noQuotes.Aggregate(PeriodSize.Day);
Assert.IsFalse(noResults.Any());
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public void AggregateTimeSpan()
Assert.AreEqual(1396993m, r2.Volume);

// no history scenario
List<Quote> noQuotes = new();
List<Quote> noQuotes = [];
IEnumerable<Quote> noResults = noQuotes.Aggregate(TimeSpan.FromDays(1));
Assert.IsFalse(noResults.Any());
}
Expand Down
Loading
Loading