Skip to content

Commit

Permalink
feature: Update to rx 5.0.0 and .net 5 and nullability (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson authored Nov 26, 2020
1 parent 809e700 commit 36d18e0
Show file tree
Hide file tree
Showing 485 changed files with 26,270 additions and 27,875 deletions.
50 changes: 30 additions & 20 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ jobs:
with:
dotnet-version: 3.1.x

- name: Install .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2

- name: Update VS2019
shell: powershell
run: Start-Process -Wait -PassThru -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "update --passive --norestart --installpath ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"""

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
Expand All @@ -37,29 +49,28 @@ jobs:
run: dotnet restore
working-directory: src

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2

- name: Build
run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
run: msbuild /t:build,pack /nowarn:MSB4011 /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
working-directory: src

- name: Install Report Generator
run: dotnet tool install --global dotnet-reportgenerator-globaltool

- name: Run Unit Tests
run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput="../../artifacts/coverage/coverage.xml" /p:Include="[${{ env.productNamespacePrefix}}*]*" /p:Exclude="[${{ env.productNamespacePrefix}}*Tests.*]*"
working-directory: src

- name: Generate Coverage Report
run: reportgenerator -reports:"coverage.*.xml" -targetdir:report-output
working-directory: artifacts/coverage
- name: Run Unit Tests and Generate Coverage
uses: glennawatson/coverlet-msbuild@v1
with:
project-files: '**/*Tests*.csproj'
no-build: true
exclude-filter: '[${{env.productNamespacePrefix}}.*.Tests.*]*'
include-filter: '[${{env.productNamespacePrefix}}*]*'
output-format: cobertura
output: '../../artifacts/'
configuration: ${{ env.configuration }}

- name: Upload Code Coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
directory: artifacts/coverage
shell: bash
run: |
echo $PWD
bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -t ${{ env.CODECOV_TOKEN }} -s '$PWD/artifacts' -f '*.xml'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Create NuGet Artifacts
uses: actions/upload-artifact@master
Expand All @@ -80,7 +91,7 @@ jobs:
- name: Download NuGet Packages
uses: actions/download-artifact@v2
with:
name: nuget
name: nuget

- name: Changelog
uses: glennawatson/ChangeLog@v1
Expand All @@ -102,4 +113,3 @@ jobs:
SOURCE_URL: https://api.nuget.org/v3/index.json
run: |
dotnet nuget push -s ${{ env.SOURCE_URL }} -k ${{ env.NUGET_AUTH_TOKEN }} **/*.nupkg
8 changes: 6 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<WarningsAsErrors>CS8600;CS8602;CS8603;CS8604;CS8605;CS8606;CS8607;CS8608;CS8609;CS8610;CS8611;CS8612;CS8613;CS8614;CS8615;CS8616;CS8617;CS8618;CS8619;CS8620;CS8621;CS8622;CS8623;CS8624;CS8625;CS8626;CS8627;CS8628;CS8629;CS8630;CS8634;CS8766;CS8767</WarningsAsErrors>
</PropertyGroup>

<!-- MonoAndroid doesn't seem to want to allow debugging for maintainers -->
Expand Down Expand Up @@ -54,9 +55,12 @@
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="!$(IsTestProject) AND !$(IsBenchmarkProject)">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.261" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="3.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="all" />
</ItemGroup>
<ItemGroup Condition="!$(IsTestProject) AND !$(IsBenchmarkProject)">
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions src/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">
<DefineConstants>$(DefineConstants);NETCOREAPP;P_LINQ;SUPPORTS_BINDINGLIST</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.StartsWith('net5'))">
<DefineConstants>$(DefineConstants);NETSTANDARD;PORTABLE;P_LINQ;SUPPORTS_BINDINGLIST</DefineConstants>
</PropertyGroup>

</Project>
5 changes: 3 additions & 2 deletions src/DynamicData.Benchmarks/Cache/SourceCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for full license information.

using System.Linq;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

Expand All @@ -24,12 +25,12 @@ public BenchmarkItem(int id)
public class SourceCache
{
private SourceCache<BenchmarkItem, int> _cache;
private BenchmarkItem[] _items = Enumerable.Range(1,100).Select(i=> new BenchmarkItem(i)).ToArray();
private BenchmarkItem[] _items = Enumerable.Range(1, 100).Select(i => new BenchmarkItem(i)).ToArray();

[GlobalSetup]
public void Setup()
{
_cache = new SourceCache<BenchmarkItem, int>(i=> i.Id);
_cache = new SourceCache<BenchmarkItem, int>(i => i.Id);
}

[Params(1, 100, 1_000, 10_000, 100_000)]
Expand Down
3 changes: 2 additions & 1 deletion src/DynamicData.Benchmarks/List/GroupAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Linq;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

Expand All @@ -16,7 +17,7 @@ public class GroupAdd
{
private IDisposable _groupSubscription;
private SourceList<int> _sourceList;
private int[] _items = Enumerable.Range(1,100).ToArray();
private int[] _items = Enumerable.Range(1, 100).ToArray();

[Params(1, 100, 1_000, 10_000, 100_000)]
public int N;
Expand Down
3 changes: 2 additions & 1 deletion src/DynamicData.Benchmarks/List/GroupRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Linq;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

Expand Down Expand Up @@ -47,7 +48,7 @@ public void Teardown()
public void Remove() => _sourceList.RemoveAt(_items[0]);

[Benchmark]
public void RemoveRange() => _sourceList.RemoveRange(40,20);
public void RemoveRange() => _sourceList.RemoveRange(40, 20);

[Benchmark]
public void Clear() => _sourceList.Clear();
Expand Down
5 changes: 3 additions & 2 deletions src/DynamicData.Benchmarks/List/SourceList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for full license information.

using System.Linq;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

Expand All @@ -13,7 +14,7 @@ namespace DynamicData.Benchmarks.List
[MarkdownExporterAttribute.GitHub]
public class SourceList
{
private SourceList<string> _sourceList;
private SourceList<string> _sourceList;
private string[] _items;

[Params(1, 100, 1_000, 10_000, 100_000)]
Expand All @@ -36,6 +37,6 @@ public void SetupIteration()
public void AddRange() => _sourceList.AddRange(_items);

[Benchmark]
public void Insert() => _sourceList.InsertRange(_items,0);
public void Insert() => _sourceList.InsertRange(_items, 0);
}
}
78 changes: 42 additions & 36 deletions src/DynamicData.Tests/AggregationTests/AggregationFixture.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
using System;
using System.Reactive.Linq;

using DynamicData.Aggregation;
using DynamicData.Kernel;
using DynamicData.Tests.Domain;

using FluentAssertions;

using Xunit;

namespace DynamicData.Tests.AggregationTests
{

public class AggregationFixture: IDisposable
public class AggregationFixture : IDisposable
{
private readonly SourceCache<Person, string> _source;
private readonly IObservable<int> _accumulator;

private readonly SourceCache<Person, string> _source;

/// <summary>
/// Initialises this instance.
/// </summary>
public AggregationFixture()
{
_source = new SourceCache<Person, string>(p => p.Name);

_accumulator = _source.Connect()
.ForAggregation()
.Scan(0, (current, items) =>
{
items.ForEach(x =>
{
if (x.Type == AggregateType.Add)
{
current = current + x.Item.Age;
}
else
{
current = current - x.Item.Age;
}
});
return current;
});
}

public void Dispose()
{
_source.Dispose();
_accumulator = _source.Connect().ForAggregation().Scan(
0,
(current, items) =>
{
items.ForEach(
x =>
{
if (x.Type == AggregateType.Add)
{
current += x.Item.Age;
}
else
{
current -= x.Item.Age;
}
});
return current;
});
}

[Fact]
Expand All @@ -51,11 +50,12 @@ public void CanAccumulate()
int latest = 0;
int counter = 0;

var accumulator = _accumulator.Subscribe(value =>
{
latest = value;
counter++;
});
var accumulator = _accumulator.Subscribe(
value =>
{
latest = value;
counter++;
});

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
Expand All @@ -74,11 +74,12 @@ public void CanHandleUpdatedItem()
int latest = 0;
int counter = 0;

var accumulator = _accumulator.Subscribe(value =>
{
latest = value;
counter++;
});
var accumulator = _accumulator.Subscribe(
value =>
{
latest = value;
counter++;
});

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("A", 15));
Expand All @@ -87,5 +88,10 @@ public void CanHandleUpdatedItem()
latest.Should().Be(15, "Accumulated value should be 60");
accumulator.Dispose();
}

public void Dispose()
{
_source.Dispose();
}
}
}
}
Loading

0 comments on commit 36d18e0

Please sign in to comment.