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

Feature : Add Net 8.0, update code to c#12, Fix decimal StdDev #756

Merged
merged 15 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
36 changes: 9 additions & 27 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -16,53 +14,37 @@ jobs:
outputs:
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
steps:
- name: Get Current Visual Studio Information
shell: bash
run: |
dotnet tool update -g dotnet-vs
echo "## About RELEASE ##"
vs where release

- name: Update Visual Studio Latest Release
shell: bash
run: |
echo "## Update RELEASE ##"
vs update release Enterprise
vs modify release Enterprise +mobile +desktop +uwp +web
echo "## About RELEASE Updated ##"
vs where release
echo "##vso[task.prependpath]$(vs where release --prop=InstallationPath)\MSBuild\Current\Bin"


- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true

- name: Install .NET 6 & .NET 7
- name: Setup .NET 6/7
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true

- name: Add MSBuild to PATH
uses: microsoft/[email protected]
with:
vs-prerelease: true

- name: NuGet Restore
run: msbuild /t:restore /v:minimal /m
run: dotnet restore DynamicData.sln
working-directory: src

- name: Build
run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
run: dotnet build --no-restore --configuration Release DynamicData.sln
working-directory: src

- name: Pack
run: dotnet pack --no-restore --configuration Release DynamicData.sln
working-directory: src

- name: Run Unit Tests and Generate Coverage
Expand Down
31 changes: 4 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,34 @@ jobs:
outputs:
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
steps:
- name: Get Current Visual Studio Information
shell: bash
run: |
dotnet tool update -g dotnet-vs
echo "## About RELEASE ##"
vs where release

- name: Update Visual Studio Latest Release
shell: bash
run: |
echo "## Update RELEASE ##"
vs update release Enterprise
vs modify release Enterprise +mobile +desktop +uwp +web
echo "## About RELEASE Updated ##"
vs where release
echo "##vso[task.prependpath]$(vs where release --prop=InstallationPath)\MSBuild\Current\Bin"

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET 6 & .NET 7
- name: Setup .NET 6/7
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true

- name: Add MSBuild to PATH
uses: microsoft/[email protected]
with:
vs-prerelease: true

- name: NuGet Restore
run: msbuild /t:restore /v:minimal /m
run: dotnet restore DynamicData.sln
working-directory: src

- name: Build
run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
run: dotnet pack --no-restore --configuration Release DynamicData.sln
working-directory: src

- uses: nuget/setup-nuget@v1
name: Setup NuGet

- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000</NoWarn>
<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000;SA1010</NoWarn>
<Platform>AnyCPU</Platform>
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
<IsBenchmarkProject>$(MSBuildProjectName.Contains('Benchmarks'))</IsBenchmarkProject>
Expand Down Expand Up @@ -65,7 +65,7 @@
</ItemGroup>
<ItemGroup Condition="!$(IsTestProject) AND !$(IsBenchmarkProject)">
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="!$(IsTestProject) AND !$(IsBenchmarkProject)">
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('net7'))">
<DefineConstants>$(DefineConstants);NETSTANDARD;PORTABLE;P_LINQ;SUPPORTS_BINDINGLIST</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.StartsWith('net8'))">
<DefineConstants>$(DefineConstants);NETSTANDARD;PORTABLE;P_LINQ;SUPPORTS_BINDINGLIST</DefineConstants>
</PropertyGroup>
</Project>
144 changes: 144 additions & 0 deletions src/DynamicData.Tests/AggregationTests/AverageFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,150 @@ public void AddedItemsContributeToSum()
accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumLong()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => Convert.ToInt64(p.Age)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumFloat()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => Convert.ToSingle(p.Age)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumDouble()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => Convert.ToDouble(p.Age)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumDecimal()
{
decimal avg = 0;

var accumulator = _source.Connect().Avg(p => Convert.ToDecimal(p.Age)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumNullable()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => p.AgeNullable).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", new int?(10), "F", null));
_source.AddOrUpdate(new Person("B", new int?(20), "F", null));
_source.AddOrUpdate(new Person("C", new int?(30), "F", null));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumNullableLong()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => (long?)(p.AgeNullable.HasValue ? Convert.ToInt64(p.AgeNullable) : default)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", new int?(10), "F", null));
_source.AddOrUpdate(new Person("B", new int?(20), "F", null));
_source.AddOrUpdate(new Person("C", new int?(30), "F", null));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumNullableFloat()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => (float?)(p.AgeNullable.HasValue ? Convert.ToSingle(p.AgeNullable) : default)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", new int?(10), "F", null));
_source.AddOrUpdate(new Person("B", new int?(20), "F", null));
_source.AddOrUpdate(new Person("C", new int?(30), "F", null));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumNullableDouble()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => (double?)(p.AgeNullable.HasValue ? Convert.ToDouble(p.AgeNullable) : default)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", new int?(10), "F", null));
_source.AddOrUpdate(new Person("B", new int?(20), "F", null));
_source.AddOrUpdate(new Person("C", new int?(30), "F", null));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

[Fact]
public void AddedItemsContributeToSumNullableDecimal()
{
decimal avg = 0;

var accumulator = _source.Connect().Avg(p => (decimal?)(p.AgeNullable.HasValue ? Convert.ToDecimal(p.AgeNullable) : default)).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", new int?(10), "F", null));
_source.AddOrUpdate(new Person("B", new int?(20), "F", null));
_source.AddOrUpdate(new Person("C", new int?(30), "F", null));

avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}

public void Dispose()
{
_source.Dispose();
Expand Down
Loading