Skip to content

Commit

Permalink
Merge pull request #69 from ChrisPulman/UpdateNet9
Browse files Browse the repository at this point in the history
Update to include Net 9.0
  • Loading branch information
ChrisPulman authored Jan 15, 2025
2 parents 7d76b97 + 6cc5e70 commit 81d99bb
Show file tree
Hide file tree
Showing 15 changed files with 716 additions and 725 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/BuildDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
permissions: write-all
environment:
name: release
outputs:
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Nullable>enable</Nullable>
<PackageIcon>icon.png</PackageIcon>
<Configurations>Debug;Release;PreRelease</Configurations>
<PackageReleaseNotes>Compatability with Net 6 / 8 and netstandard2.0</PackageReleaseNotes>
<PackageReleaseNotes>Compatability with Net 8 / 9 and netstandard2.0</PackageReleaseNotes>
<PackageTags>Hashtable;rx;reactive;extensions;observable;LINQ;net;netstandard</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Chris Pulman
Copyright (c) Chris Pulman 2022 - 2025

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.2",
"version": "1.3",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/main$"
Expand Down
7 changes: 4 additions & 3 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ partial class Build : NukeBuild
AbsolutePath PackagesDirectory => RootDirectory / "output";

Target Print => _ => _
.Executes(() => Log.Information("NerdbankVersioning = {Value}", NerdbankVersioning.NuGetPackageVersion));
.Executes(() => Log.Information("NerdbankVersioning = {Value}", NerdbankVersioning.SimpleVersion));

Target Clean => _ => _
.Before(Restore)
Expand All @@ -49,7 +49,7 @@ partial class Build : NukeBuild
}

PackagesDirectory.CreateOrCleanDirectory();
await this.InstallDotNetSdk("6.x.x", "7.x.x", "8.x.x");
await this.InstallDotNetSdk("8.x.x", "9.x.x");
});

Target Restore => _ => _
Expand All @@ -60,6 +60,7 @@ partial class Build : NukeBuild
.DependsOn(Restore, Print)
.Executes(() => DotNetBuild(s => s
.SetProjectFile(Solution)
.SetVersion(NerdbankVersioning.SimpleVersion)
.SetConfiguration(Configuration)
.EnableNoRestore()));

Expand All @@ -79,7 +80,7 @@ partial class Build : NukeBuild

DotNetPack(settings => settings
.SetConfiguration(Configuration)
.SetVersion(NerdbankVersioning.NuGetPackageVersion)
.SetVersion(NerdbankVersioning.SimpleVersion)
.SetOutputDirectory(PackagesDirectory)
.CombineWith(packableProjects, (packSettings, project) =>
packSettings.SetProject(project)));
Expand Down
6 changes: 3 additions & 3 deletions build/_build.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>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;CA1822;IDE1006;IDE0051</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -14,11 +14,11 @@
<ItemGroup>
<PackageReference Include="CP.Nuke.BuildTools" Version="1.0.79" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" />
<PackageReference Include="Nuke.Common" Version="8.1.4" />
<PackageReference Include="Nuke.Common" Version="9.0.3" />
</ItemGroup>

<ItemGroup>
<PackageDownload Include="nbgv" Version="[3.6.133]" />
<PackageDownload Include="nbgv" Version="[3.7.115]" />
</ItemGroup>

</Project>
97 changes: 48 additions & 49 deletions src/HashTableRx.Tests/HashTableRxFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,67 @@

using System.Reflection;

namespace CP.Collections.Tests
namespace CP.Collections.Tests;

/// <summary>
/// HashTableRxFixture.
/// </summary>
/// <seealso cref="System.IDisposable" />
public class HashTableRxFixture : IDisposable
{
private bool _disposedValue;

/// <summary>
/// HashTableRxFixture.
/// Initializes a new instance of the <see cref="HashTableRxFixture"/> class.
/// </summary>
/// <seealso cref="System.IDisposable" />
public class HashTableRxFixture : IDisposable
public HashTableRxFixture()
{
private bool _disposedValue;
// get the current directory
var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

/// <summary>
/// Initializes a new instance of the <see cref="HashTableRxFixture"/> class.
/// </summary>
public HashTableRxFixture()
{
// get the current directory
var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// load the assembly MockLibraryWithFields.dll
var assembly = Assembly.LoadFrom(currentDirectory + "\\MockLibraryWithFields.dll");
Assert.NotNull(assembly);

// load the assembly MockLibraryWithFields.dll
var assembly = Assembly.LoadFrom(currentDirectory + "\\MockLibraryWithFields.dll");
Assert.NotNull(assembly);
// Create an instance of the MockLibraryWithFields.MockClassWithFields class
var obj = assembly.CreateInstance("TwinCATRx.RigSTRUCT");
Assert.NotNull(obj);

// Create an instance of the MockLibraryWithFields.MockClassWithFields class
var obj = assembly.CreateInstance("TwinCATRx.RigSTRUCT");
Assert.NotNull(obj);

HtRx = new(false);
HtRx.SetStucture(obj);
}
HtRx = new(false);
HtRx.SetStucture(obj);
}

/// <summary>
/// Gets the HashTable Rx.
/// </summary>
/// <value>
/// The ht rx.
/// </value>
public HashTableRx HtRx { get; }
/// <summary>
/// Gets the HashTable Rx.
/// </summary>
/// <value>
/// The ht rx.
/// </value>
public HashTableRx HtRx { get; }

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (!_disposedValue)
if (disposing)
{
if (disposing)
{
HtRx.Dispose();
}

_disposedValue = true;
HtRx.Dispose();
}

_disposedValue = true;
}
}
}
155 changes: 77 additions & 78 deletions src/HashTableRx.Tests/HashTableRxTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,97 +4,96 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;

namespace CP.Collections.Tests
namespace CP.Collections.Tests;

/// <summary>
/// UnitTest1.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="HashTableRxTest"/> class.
/// </remarks>
/// <param name="fixture">The hash table rx fixture.</param>
public class HashTableRxTest(HashTableRxFixture fixture) : IClassFixture<HashTableRxFixture>
{
/// <summary>
/// UnitTest1.
/// Test1s this instance.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="HashTableRxTest"/> class.
/// </remarks>
/// <param name="fixture">The hash table rx fixture.</param>
public class HashTableRxTest(HashTableRxFixture fixture) : IClassFixture<HashTableRxFixture>
[Fact]
public void HashTableRxCanReadValuesDirectly()
{
/// <summary>
/// Test1s this instance.
/// </summary>
[Fact]
public void HashTableRxCanReadValuesDirectly()
{
fixture.HtRx["CalibrationDataValid"] = false;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.False(t);
fixture.HtRx["CalibrationDataValid"] = false;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.False(t);

fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(0.0f, t2);
}
fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(0.0f, t2);
}

/// <summary>
/// Hashes the table rx can write values.
/// </summary>
[Fact]
public void HashTableRxCanWriteValuesDirectly()
{
fixture.HtRx["CalibrationDataValid"] = true;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.True(t);
/// <summary>
/// Hashes the table rx can write values.
/// </summary>
[Fact]
public void HashTableRxCanWriteValuesDirectly()
{
fixture.HtRx["CalibrationDataValid"] = true;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.True(t);

fixture.HtRx["Casing.Temperature.PV.Value"] = 1.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(1.0f, t2);
}
fixture.HtRx["Casing.Temperature.PV.Value"] = 1.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(1.0f, t2);
}

/// <summary>
/// Hashes the table rx can read values from observable.
/// </summary>
[Fact]
public void HashTableRxCanReadValuesFromObservable()
{
var disposables = new CompositeDisposable();
fixture.HtRx["CalibrationDataValid"] = false;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.False(t);
disposables.Add(fixture.HtRx.Observe<bool>("CalibrationDataValid").Skip(1).Subscribe(x => Assert.True(x)));
fixture.HtRx["CalibrationDataValid"] = true;
/// <summary>
/// Hashes the table rx can read values from observable.
/// </summary>
[Fact]
public void HashTableRxCanReadValuesFromObservable()
{
var disposables = new CompositeDisposable();
fixture.HtRx["CalibrationDataValid"] = false;
var t = (bool?)fixture.HtRx["CalibrationDataValid"];
Assert.False(t);
disposables.Add(fixture.HtRx.Observe<bool>("CalibrationDataValid").Skip(1).Subscribe(x => Assert.True(x)));
fixture.HtRx["CalibrationDataValid"] = true;

fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(0.0f, t2);
disposables.Add(fixture.HtRx.Observe<float>("Casing.Temperature.PV.Value").Skip(1).Subscribe(x => Assert.Equal(1.0f, x)));
fixture.HtRx["Casing.Temperature.PV.Value"] = 1.0f;
fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = (float?)fixture.HtRx["Casing.Temperature.PV.Value"];
Assert.Equal(0.0f, t2);
disposables.Add(fixture.HtRx.Observe<float>("Casing.Temperature.PV.Value").Skip(1).Subscribe(x => Assert.Equal(1.0f, x)));
fixture.HtRx["Casing.Temperature.PV.Value"] = 1.0f;

disposables.Dispose();
}
disposables.Dispose();
}

/// <summary>
/// Hashes the table rx can read values.
/// </summary>
[Fact]
public void HashTableRxCanReadValues()
{
fixture.HtRx["CalibrationDataValid"] = false;
var t = fixture.HtRx.Value<bool>("CalibrationDataValid");
Assert.False(t);
/// <summary>
/// Hashes the table rx can read values.
/// </summary>
[Fact]
public void HashTableRxCanReadValues()
{
fixture.HtRx["CalibrationDataValid"] = false;
var t = fixture.HtRx.Value<bool>("CalibrationDataValid");
Assert.False(t);

fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = fixture.HtRx.Value<float>("Casing.Temperature.PV.Value");
Assert.Equal(0.0f, t2);
}
fixture.HtRx["Casing.Temperature.PV.Value"] = 0.0f;
var t2 = fixture.HtRx.Value<float>("Casing.Temperature.PV.Value");
Assert.Equal(0.0f, t2);
}

/// <summary>
/// Hashes the table rx can write values.
/// </summary>
[Fact]
public void HashTableRxCanWriteValues()
{
fixture.HtRx.Value("CalibrationDataValid", true);
var t = fixture.HtRx.Value<bool>("CalibrationDataValid");
Assert.True(t);
/// <summary>
/// Hashes the table rx can write values.
/// </summary>
[Fact]
public void HashTableRxCanWriteValues()
{
fixture.HtRx.Value("CalibrationDataValid", true);
var t = fixture.HtRx.Value<bool>("CalibrationDataValid");
Assert.True(t);

fixture.HtRx.Value("Casing.Temperature.PV.Value", 1.0f);
var t2 = fixture.HtRx.Value<float>("Casing.Temperature.PV.Value");
Assert.Equal(1.0f, t2);
}
fixture.HtRx.Value("Casing.Temperature.PV.Value", 1.0f);
var t2 = fixture.HtRx.Value<float>("Casing.Temperature.PV.Value");
Assert.Equal(1.0f, t2);
}
}
2 changes: 0 additions & 2 deletions src/HashTableRx/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright (c) Chris Pulman. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

[assembly: CLSCompliant(true)]
2 changes: 1 addition & 1 deletion src/HashTableRx/HashTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace CP.Collections;
/// Represents a collection of key/value pairs that are organized based on the hash code of the key.
/// </summary>
[Serializable]
public class HashTable : Hashtable, IObservable<(string key, object? value)>, ICancelable
public class HashTable : Hashtable, IObservable<(string key, object? value)>, ICancelable, ICollection, IEnumerable
{
private readonly SingleAssignmentDisposable _subscription = new();
private readonly IScheduler _scheduler;
Expand Down
Loading

0 comments on commit 81d99bb

Please sign in to comment.