Skip to content

Commit

Permalink
#636 - Change TargetFramework to .NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sys27 committed Jun 5, 2023
1 parent ff9359a commit 383acbc
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CI/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- task: PublishPipelineArtifact@1
inputs:
path: xFunc.Maths/bin/Release/netstandard2.1
path: xFunc.Maths/bin/Release/net6.0
artifact: xFunc.Maths

- task: PublishPipelineArtifact@1
Expand Down
24 changes: 20 additions & 4 deletions xFunc.Maths/Expressions/Units/AngleUnits/AngleUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,28 @@ private AngleUnit(double factor, params string[] unitNames)
=> !left.Equals(right);

/// <inheritdoc />
public bool Equals(AngleUnit other)
=> Factor.Equals(other.Factor) && UnitNames.SequenceEqual(other.UnitNames);
public bool Equals(AngleUnit? other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;

return Factor.Equals(other.Factor) && UnitNames.Equals(other.UnitNames);
}

/// <inheritdoc />
public override bool Equals(object? obj)
=> obj is AngleUnit other && Equals(other);
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != GetType())
return false;

return Equals((AngleUnit)obj);
}

/// <inheritdoc />
[ExcludeFromCodeCoverage]
Expand Down Expand Up @@ -116,7 +132,7 @@ static void AddUnits(IDictionary<string, AngleUnit> dictionary, AngleUnit unit)
/// <param name="unit">When this method returns, the value associated with the specified name, if the unit is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.</param>
/// <returns><c>true</c> if area units contain an unit with the specified <paramref name="name"/>; otherwise, <c>false</c>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
public static bool FromName(string name, out AngleUnit unit)
public static bool FromName(string name, [NotNullWhen(true)] out AngleUnit? unit)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
Expand Down
30 changes: 25 additions & 5 deletions xFunc.Maths/Expressions/Units/AreaUnits/AreaUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,37 @@ private AreaUnit(double factor, string unitName)
=> !left.Equals(right);

/// <inheritdoc />
public bool Equals(AreaUnit other)
=> Factor.Equals(other.Factor) && UnitName == other.UnitName;
public bool Equals(AreaUnit? other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;

return Factor.Equals(other.Factor) && UnitName == other.UnitName;
}

/// <inheritdoc />
public override bool Equals(object? obj)
=> obj is AreaUnit other && Equals(other);
{
if (ReferenceEquals(null, obj))
return false;

if (ReferenceEquals(this, obj))
return true;

if (obj.GetType() != GetType())
return false;

return Equals((AreaUnit)obj);
}

/// <inheritdoc />
[ExcludeFromCodeCoverage]
public override int GetHashCode()
=> HashCode.Combine(Factor, UnitName);
{
return HashCode.Combine(Factor, UnitName);
}

/// <inheritdoc />
public override string ToString()
Expand Down Expand Up @@ -173,7 +193,7 @@ private static IDictionary<string, AreaUnit> GetUnits()
/// <param name="unit">When this method returns, the value associated with the specified name, if the unit is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.</param>
/// <returns><c>true</c> if area units contain an unit with the specified <paramref name="name"/>; otherwise, <c>false</c>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
public static bool FromName(string name, out AreaUnit unit)
public static bool FromName(string name, [NotNullWhen(true)] out AreaUnit? unit)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/AreaUnits/AreaValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public int CompareTo(AreaValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/LengthUnits/LengthValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public int CompareTo(LengthValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/MassUnits/MassValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public int CompareTo(MassValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/PowerUnits/PowerValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public int CompareTo(PowerValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/TimeUnits/TimeValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public int CompareTo(TimeValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
28 changes: 23 additions & 5 deletions xFunc.Maths/Expressions/Units/VolumeUnits/VolumeUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,35 @@ private VolumeUnit(double factor, string unitName)
=> !left.Equals(right);

/// <inheritdoc />
public bool Equals(VolumeUnit other)
=> Factor.Equals(other.Factor) && UnitName == other.UnitName;
public bool Equals(VolumeUnit? other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;

return Factor.Equals(other.Factor) && UnitName == other.UnitName;
}

/// <inheritdoc />
public override bool Equals(object? obj)
=> obj is VolumeUnit other && Equals(other);
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != GetType())
return false;

return Equals((VolumeUnit)obj);
}

/// <inheritdoc />
[ExcludeFromCodeCoverage]
public override int GetHashCode()
=> HashCode.Combine(Factor, UnitName);
{
return HashCode.Combine(Factor, UnitName);
}

/// <inheritdoc />
public override string ToString()
Expand Down Expand Up @@ -129,7 +147,7 @@ private static IDictionary<string, VolumeUnit> GetUnits()
/// <param name="unit">When this method returns, the value associated with the specified name, if the unit is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.</param>
/// <returns><c>true</c> if volume units contain an unit with the specified <paramref name="name"/>; otherwise, <c>false</c>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
public static bool FromName(string name, out VolumeUnit unit)
public static bool FromName(string name, [NotNullWhen(true)] out VolumeUnit? unit)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Expressions/Units/VolumeUnits/VolumeValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public int CompareTo(VolumeValue other)
}

/// <inheritdoc />
public int CompareTo(object obj)
public int CompareTo(object? obj)
=> obj switch
{
null => 1,
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/Results/ExpressionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ExpressionResult(IExpression exp)
=> Result = exp ?? throw new ArgumentNullException(nameof(exp));

/// <inheritdoc />
public override string ToString() => Result.ToString();
public override string ToString() => Result.ToString()!;

/// <inheritdoc cref="IResult.Result" />
public IExpression Result { get; }
Expand Down
2 changes: 1 addition & 1 deletion xFunc.Maths/xFunc.Maths.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<RootNamespace>xFunc.Maths</RootNamespace>
<PackageId>xFunc.Maths</PackageId>
Expand Down

0 comments on commit 383acbc

Please sign in to comment.