Skip to content

Commit

Permalink
revert: Restore .NET Standard 2.0 (#1312)
Browse files Browse the repository at this point in the history
We'd prematurely removed .NET Standard 2.0
We do plan on removing it for version 3 since it will limit use of newer SDK features with better overall performance.
  • Loading branch information
DaveSkender authored Jan 5, 2025
1 parent afb4300 commit 49d6ddd
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 26 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/test-indicators.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Indicators
name: Test Indicators

on:
push:
branches: ["main"]

pull_request:
branches: ["*"]
workflow_dispatch:

jobs:
test:
Expand All @@ -20,38 +20,29 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
dotnet-version: ["9.x"]
# TODO: restore when runners have 9.x on all
# ["2.1.x", "6.x", "9.x"]
dotnet-version: ["6.0.x", "9.0.x"]

env:

# identifying primary configuration so only one reports coverage
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.x' }}
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.0.x' }}

# .NET SDK versions in the matrix that support `ga` quality spec
# versions before 5.x do not support it
SUPPORT_GA: ${{ contains(fromJson('["6.x", "9.x"]'), matrix.dotnet-version) }}
# Identifies the current target framework
TARGET_FRAMEWORK: >
${{ matrix.dotnet-version == '6.0.x' && 'net6.0' ||
matrix.dotnet-version == '9.0.x' && 'net9.0' }}
steps:

- name: Checkout source
uses: actions/checkout@v4

- name: Setup .NET
id: dotnet-new
uses: actions/setup-dotnet@v4
if: env.SUPPORT_GA == 'true'
with:
dotnet-version: ${{ matrix.dotnet-version }}
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Setup .NET (older)
uses: actions/setup-dotnet@v4
if: env.SUPPORT_GA == 'false'
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Build library
run: >
dotnet build
Expand All @@ -66,6 +57,7 @@ jobs:
run: >
dotnet test tests/indicators/Tests.Indicators.csproj
--configuration Release
--property:TestFramework="${{ env.TARGET_FRAMEWORK }}"
--no-build
--verbosity normal
--logger trx
Expand All @@ -84,8 +76,8 @@ jobs:
--logger trx
--results-directory ./test-other
- name: Post test summary
uses: dorny/test-reporter@v1
- name: Post test results
uses: dorny/test-reporter@v1.9.1
if: env.IS_PRIMARY == 'true' && always()
with:
name: Test results
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ _TeamCity*
*.coverage
*.coveragexml

# Visual Studio live unit testing
*.lutconfig

# NCrunch
_NCrunch_*
.*crunch*.local.xml
Expand Down Expand Up @@ -218,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -314,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -323,11 +326,11 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Jekyll site
_site/

# zip artifacts
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion docs/pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 9.0, 8.0, 6.0
- .NET Standard 2.1
- .NET Standard 2.1, 2.0

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>net9.0;net8.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>

<Authors>Dave Skender</Authors>
<Product>Stock Indicators for .NET</Product>
Expand Down
39 changes: 39 additions & 0 deletions tests/indicators/_Initialize.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;

// GLOBALS & INITIALIZATION OF TEST DATA

Expand All @@ -8,6 +10,9 @@
[assembly: InternalsVisibleTo("Tests.Performance")]
namespace Tests.Common;

/// <summary>
/// Base class for all test classes, providing common test data and utilities.
/// </summary>
[TestClass]
public abstract class TestBase
{
Expand All @@ -27,3 +32,37 @@ public abstract class TestBase
internal static readonly IEnumerable<Quote> zeroesQuotes = TestData.GetZeros();
internal static readonly IEnumerable<(DateTime, double)> tupleNanny = TestData.GetTupleNaN();
}

/// <summary>
/// Test class for the startup of the test project.
/// </summary>
[TestClass]
public class Startup
{
/// <summary>
/// Displays the assembly location, name, version, and target framework
/// as a sanity check for test runner targeting.
/// </summary>
[TestMethod]
[TestCategory("ShowMe")]
public void ShowFramework()
{
// Get the assembly of any type from your Indicators project
Assembly assembly = typeof(Indicator).Assembly;

Console.WriteLine($"Assembly Location: {assembly.Location}");
Console.WriteLine($"Assembly Name: {assembly.GetName().Name}");
Console.WriteLine($"Assembly Version: {assembly.GetName().Version}");

// Get the target framework the assembly was built for
TargetFrameworkAttribute targetFrameworkAttribute = assembly
.GetCustomAttribute<TargetFrameworkAttribute>();

string frameworkName
= targetFrameworkAttribute?.FrameworkName ?? "Unknown";

Console.WriteLine($"Target Framework: {frameworkName}");

frameworkName.Should().NotBe("Unknown");
}
}

0 comments on commit 49d6ddd

Please sign in to comment.