Skip to content

Commit

Permalink
various minor issues and warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rudzen committed Jun 28, 2024
1 parent 28bdad4 commit 298ae5c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="SimdLinq" />
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="xunit"/>
<PackageReference Include="xunit.analyzers"/>
<PackageReference Include="xunit.runner.visualstudio"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System.Runtime.Serialization;

namespace Rudzoft.ChessLib.Exceptions;

[Serializable]
public sealed class InvalidFenException : ArgumentException
{
public InvalidFenException()
Expand All @@ -38,7 +37,4 @@ public InvalidFenException(string message)

public InvalidFenException(string message, Exception innerException)
: base(message, innerException) { }

public InvalidFenException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System.Runtime.Serialization;

namespace Rudzoft.ChessLib.Exceptions;

public sealed class InvalidMove : InvalidOperationException
[Serializable]
public sealed class InvalidMoveException : InvalidOperationException
{
public InvalidMove()
public InvalidMoveException()
{
}

public InvalidMove(string message)
public InvalidMoveException(string message)
: base(message) { }

public InvalidMove(string message, Exception innerException)
public InvalidMoveException(string message, Exception innerException)
: base(message, innerException) { }

public InvalidMove(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System.Runtime.Serialization;

namespace Rudzoft.ChessLib.Exceptions;

public sealed class InvalidSquare : InvalidOperationException
[Serializable]
public sealed class InvalidSquareException : InvalidOperationException
{
public InvalidSquare()
public InvalidSquareException()
{
}

public InvalidSquare(string message)
public InvalidSquareException(string message)
: base(message) { }

public InvalidSquare(string message, Exception innerException)
public InvalidSquareException(string message, Exception innerException)
: base(message, innerException) { }

public InvalidSquare(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System.Runtime.Serialization;

namespace Rudzoft.ChessLib.Exceptions;

[Serializable]
Expand All @@ -42,10 +40,4 @@ public TranspositionTableFailure(string message) : base(message)
public TranspositionTableFailure(string message, Exception inner) : base(message, inner)
{
}

public TranspositionTableFailure(
SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
}
2 changes: 1 addition & 1 deletion src/chess-lib/Rudzoft.ChessLib/Notation/MoveNotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public INotation ToNotation(MoveNotations moveNotation = MoveNotations.Fan)
var notation = _notations[(int)moveNotation];

if (notation == null)
throw new InvalidMove("Invalid move notation detected.");
throw new InvalidMoveException("Invalid move notation detected.");

return notation;
}
Expand Down
7 changes: 0 additions & 7 deletions src/chess-lib/Rudzoft.ChessLib/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,6 @@ private bool IsCastleMoveLegal(Move m, Square to, Square from, Color us)
var occupied = Board.Pieces(them, PieceType.Rook, PieceType.Queen);

return (attacks & occupied).IsEmpty;

static (Square, Direction) GetRookSquareAndDirection(Square toSq, Square fromSq, Color us)
{
return toSq > fromSq
? (Square.G1.Relative(us), Direction.West)
: (Square.C1.Relative(us), Direction.East);
}
}

private bool IsEnPassantMoveLegal(Square to, Color us, Square from, Square ksq)
Expand Down
1 change: 0 additions & 1 deletion src/chess-lib/Rudzoft.ChessLib/Rudzoft.ChessLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<RepositoryType>git</RepositoryType>
<Product>Rudzoft.ChessLib</Product>
<IsPackable>true</IsPackable>
<PublishAot>true</PublishAot>
<PackageIcon>ChessLib.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand Down

0 comments on commit 298ae5c

Please sign in to comment.