Skip to content

Commit e0a5d0a

Browse files
committed
Fix some of the SonarQube issues and update publish.yml
1 parent 00cc80e commit e0a5d0a

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
run: dotnet pack ./src/${{ env.ProjectName }}/${{ env.ProjectName }}.csproj --configuration Release --output ./nupkg
2929

3030
- name: 🚀 Publish to NuGet.org
31-
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source https://apiint.nugettest.org/v3/index.json --api-key ${{ secrets.NuGet_Test_API_Key }} # https://api.nuget.org/v3/index.json
31+
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NuGet_Test_API_Key }} #
3232

src/AStar.Dev.Functional.Extensions/AStar.Dev.Functional.Extensions.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<IncludeSymbols>true</IncludeSymbols>
1010
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1111
<PackageId>AStar.Dev.Functional.Extensions</PackageId>
12-
<Version>0.2.2-alpha</Version>
12+
<Version>0.3.0-alpha</Version>
1313
<PackageReadmeFile>Readme.md</PackageReadmeFile>
1414
<Authors>Jason</Authors>
1515
<Company>AStar Development</Company>
@@ -25,17 +25,20 @@
2525
<IsPackable>true</IsPackable>
2626
<Title>AStar.Dev.Functional.Extensions</Title>
2727
<Copyright>AStar Development 2025</Copyright>
28-
<PackageReleaseNotes>No changes in this version, just extending the documentation</PackageReleaseNotes>
28+
<PackageReleaseNotes>A complete rewrite of Result etc., and additional extensions / objects.</PackageReleaseNotes>
29+
<PackageIcon>astar.png</PackageIcon>
2930
</PropertyGroup>
3031

3132
<ItemGroup>
3233
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
3334
</ItemGroup>
3435

3536
<ItemGroup>
37+
<None Include="blog-post.md" Pack="true" PackagePath="\"/>
3638
<None Include="Readme.md" Pack="true" PackagePath="\"/>
3739
<None Include="Readme-result.md" Pack="true" PackagePath="\"/>
3840
<None Include="Readme-option.md" Pack="true" PackagePath="\"/>
41+
<None Update="astar.png" Pack="true" PackagePath="\"/>
3942
</ItemGroup>
4043

4144
</Project>

src/AStar.Dev.Functional.Extensions/Option{T}.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public TResult Match<TResult>(Func<T, TResult> onSome, Func<TResult> onNone) =>
3636
_ => throw new InvalidOperationException("It should not be possible to reach this point.")
3737
};
3838

39+
/// <summary>
40+
/// Determines whether the specified object is equal to the current <see cref="Option{T}" />.
41+
/// </summary>
42+
/// <param name="obj">The object to compare with the current instance.</param>
43+
/// <returns>
44+
/// <c>true</c> if the specified object is equal to the current instance; otherwise, <c>false</c>.
45+
/// </returns>
3946
public override bool Equals(object? obj)
4047
{
4148
if(obj is Option<T> other)
@@ -51,6 +58,14 @@ public override bool Equals(object? obj)
5158
return false;
5259
}
5360

61+
/// <summary>
62+
/// Returns a hash code for the current instance of the <see cref="Option{T}" />.
63+
/// For <see cref="Option{T}.Some" />, the hash code is computed based on its type and value.
64+
/// For <see cref="Option{T}.None" />, the hash code is derived from its type.
65+
/// </summary>
66+
/// <returns>
67+
/// An integer representing the hash code of the current instance.
68+
/// </returns>
5469
public override int GetHashCode() =>
5570
this switch
5671
{
@@ -59,8 +74,24 @@ public override int GetHashCode() =>
5974
_ => 0
6075
};
6176

62-
// Add equality operators
77+
/// <summary>
78+
/// Determines whether two <see cref="Option{T}" /> instances are equal at a value level.
79+
/// </summary>
80+
/// <param name="left">The first <see cref="Option{T}" /> instance to compare.</param>
81+
/// <param name="right">The second <see cref="Option{T}" /> instance to compare.</param>
82+
/// <returns>
83+
/// True if the two <see cref="Option{T}" /> instances are considered equal; otherwise, false.
84+
/// </returns>
6385
public static bool operator ==(Option<T> left, Option<T> right) => left.Equals(right);
86+
87+
/// <summary>
88+
/// Determines whether two <see cref="Option{T}" /> instances are not equal at a value level.
89+
/// </summary>
90+
/// <param name="left">The first <see cref="Option{T}" /> instance to compare.</param>
91+
/// <param name="right">The second <see cref="Option{T}" /> instance to compare.</param>
92+
/// <returns>
93+
/// <c>true</c> if the two instances are not equal; otherwise, <c>false</c>.
94+
/// </returns>
6495
public static bool operator !=(Option<T> left, Option<T> right) => !left.Equals(right);
6596

6697
/// <summary>
15.6 KB
Loading

test/AStar.Dev.Functional.Extensions.Tests.Unit/OptionShould.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ namespace AStar.Dev.Functional.Extensions.Tests.Unit;
22

33
public class OptionShould
44
{
5+
private static readonly int[] ExpectedArrayOfInts = [1, 2, 3];
6+
private static readonly int[] ExpectedArrayOfInts2 = [20, 40];
7+
58
[Fact]
69
public void MatchToSomeHandlerWhenOptionIsSome()
710
{
@@ -649,7 +652,7 @@ public void ExtractValuesFromCollectionOfOptions()
649652
var result = options.Values().ToList();
650653

651654
result.Count.ShouldBe(3);
652-
result.ShouldBe(new[] { 1, 2, 3 });
655+
result.ShouldBe(ExpectedArrayOfInts);
653656
}
654657

655658
[Fact]
@@ -675,7 +678,7 @@ public void TransformCollectionWithChooser()
675678
: Option.None<int>()).ToList();
676679

677680
result.Count.ShouldBe(2);
678-
result.ShouldBe(new[] { 20, 40 });
681+
result.ShouldBe(ExpectedArrayOfInts2);
679682
}
680683

681684
[Fact]

0 commit comments

Comments
 (0)