Skip to content

Commit

Permalink
fix: IQuote equatable, remove .NET Standard 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender committed Feb 4, 2024
1 parent 024bdab commit 35bd585
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ See the [guide]({{site.baseurl}}/guide/#content) and the [full list of indicator
Our [NuGet library](https://www.nuget.org/packages/Skender.Stock.Indicators) directly targets all current frameworks for peak performance, including the .NET Standard for older framework compatibility.

- .NET 8.0, 7.0, 6.0
- .NET Standard 2.1, 2.0
- .NET Standard 2.1

The compiled library package is [Common Language Specification (CLS) compliant](https://docs.microsoft.com/en-us/dotnet/standard/common-type-system) and can be used in other programming languages, including Python and everything in the .NET universe.

Expand Down
2 changes: 1 addition & 1 deletion src/Indicators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<Authors>Dave Skender</Authors>
<Product>Stock Indicators for .NET</Product>
Expand Down
2 changes: 2 additions & 0 deletions src/_common/ObsoleteV3.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Items marked with &#128681; require special attention since they will not produc

- all backwards compatible v1 accomodations removed.

- no longer supporting .NET Standard 2.0 for older .NET Framework compatibility.

- &#128681; `IReusableResult.Value` property was changed to non-nullable and returns `double.NaN` instead of `null`
for incalculable periods. The standard results (e.g. `EmaResult.Ema`) continue to return `null` for incalculable periods.

Expand Down
16 changes: 8 additions & 8 deletions src/_common/Quotes/Quote.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public record class Quote : IQuote
public decimal Volume { get; set; }

public bool Equals(IQuote? other)
=> base.Equals(other);
=> base.Equals(other);
}

public abstract class EquatableQuote<TQuote>()
Expand Down Expand Up @@ -78,8 +78,8 @@ public bool Equals(TQuote? other)
&& (Volume == other.Volume);
}

public static bool operator ==(this, other)
// ==(EquatableQuote<TQuote> lhs, EquatableQuote<TQuote> rhs)
public static bool operator
==(EquatableQuote<TQuote> lhs, EquatableQuote<TQuote> rhs)
{
if (lhs is null)
{
Expand All @@ -96,13 +96,13 @@ public bool Equals(TQuote? other)
return lhs.Equals(rhs);
}

public static bool operator !=(this, other)
// !=(EquatableQuote<TQuote> lhs, EquatableQuote<TQuote> rhs)
=> !(lhs == rhs);
public static bool operator
!=(EquatableQuote<TQuote> lhs, EquatableQuote<TQuote> rhs)
=> !(lhs == rhs);

public override int GetHashCode()
=> throw new ApplicationException("this class does not support GetHashCode");
//=> (TickDate, Open, High, Low, Close, Volume).GetHashCode();
=> HashCode.Combine(
TickDate, Open, High, Low, Close, Volume);
}

internal class QuoteD
Expand Down
2 changes: 2 additions & 0 deletions tests/indicators/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public abstract class SeriesTestBase : TestQuoteBase
internal readonly DateTime evalDate
= DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", EnglishCulture);

// TODO: once caught up, make these abstract instead of virtual

[TestMethod]
public virtual void Standard()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/other/PublicApi.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ internal sealed class MyEma : IResult
public double? Ema { get; set; }
}

internal sealed class MyCustomQuote : EquatableQuote<MyCustomQuote>, IQuote
internal sealed class MyCustomQuote
: EquatableQuote<MyCustomQuote>, IQuote
{
// redirect inherited base properties
DateTime ISeries.TickDate => CloseDate;
Expand Down

0 comments on commit 35bd585

Please sign in to comment.