Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>
26 changes: 13 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<PackageVersion Include="AutoMapper" Version="14.0.0" />
<PackageVersion Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SQLite" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SQLite" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
<PackageVersion Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.MSSqlServer" Version="8.1.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.5.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.2" />
<PackageVersion Include="Serilog.Sinks.MSSqlServer" Version="8.2.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.7.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.3" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit.v3" Version="1.1.0" />
<PackageVersion Include="xunit.v3" Version="2.0.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="X.PagedList" Version="10.5.7" />
Expand Down
70 changes: 0 additions & 70 deletions Open5ETools.sln

This file was deleted.

20 changes: 20 additions & 0 deletions Open5ETools.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path=".gitignore" />
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
<File Path="docker-compose.yml" />
<File Path="LICENSE" />
<File Path="OpenGameLicense.txt" />
<File Path="README.md" />
</Folder>
<Folder Name="/src/">
<Project Path="src/Open5ETools.Core/Open5ETools.Core.csproj" />
<Project Path="src/Open5ETools.Infrastructure/Open5ETools.Infrastructure.csproj" />
<Project Path="src/Open5ETools.Resources/Open5ETools.Resources.csproj" />
<Project Path="src/Open5ETools.Web/Open5ETools.Web.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/Open5ETools.Core.Tests/Open5ETools.Core.Tests.csproj" />
</Folder>
</Solution>
1 change: 0 additions & 1 deletion src/Open5ETools.Core/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public static class Constants
"28",
"29",
"30"
,
];

public static readonly int[,] Thresholds = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.Collections.ObjectModel;

namespace Open5ETools.Core.Common.Exceptions;

public class ServiceAggregateException : Exception
{
private readonly IEnumerable<ServiceException> _innerExceptions;

public ReadOnlyCollection<ServiceException> GetInnerExceptions()
{
return new ReadOnlyCollection<ServiceException>(_innerExceptions.ToList());
return new ReadOnlyCollection<ServiceException>([.. _innerExceptions]);
}

public ServiceAggregateException(IEnumerable<ServiceException> innerExceptions)
Expand Down
15 changes: 6 additions & 9 deletions src/Open5ETools.Core/Common/Exceptions/ServiceException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public class ServiceException : Exception
{
public const string GeneralError = "GeneralError";
public const string GeneralAggregateError = "GeneralAggregateError";
public const string EntityNotFoundException = "EntityNotFoundException";
public const string RequiredValidation = "RequiredValidation";
Expand All @@ -12,30 +11,28 @@ public class ServiceException : Exception

public string? Field { get; }

public ServiceException() : base(GeneralError)
{
}

public ServiceException(string message, params string[] args) : base(message)
public ServiceException(string message, params object[] args) : base(message)
{
Field = null;
Args = args;
}


public ServiceException(string message, string field, params string[] args) : base(message)
public ServiceException(string message, string field, params object[] args) : base(message)
{
Field = field;
Args = args;
}

public ServiceException(string message, Exception innerException, params string[] args) : base(message, innerException)
public ServiceException(string message, Exception innerException, params object[] args) : base(message,
innerException)
{
Field = null;
Args = args;
}

public ServiceException(string message, string field, Exception innerException, params string[] args) : base(message, innerException)
public ServiceException(string message, string field, Exception innerException, params object[] args) : base(
message, innerException)
{
Field = field;
Args = args;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Resources;

namespace Open5ETools.Core.Common.Exceptions;

public static class ServiceExceptionExtensions
{
public static string? LocalizedMessage(this ServiceException serviceException, ResourceManager resourceManager)
private static string? LocalizedMessage(this ServiceException? serviceException, ResourceManager? resourceManager)
{
if (string.IsNullOrEmpty(serviceException?.Message))
return null;
Expand All @@ -12,8 +13,10 @@ public static class ServiceExceptionExtensions
return serviceException.Message;
try
{
return serviceException.Args != null ? string.Format(resourceManager.GetString(serviceException.Message) ?? string.Empty,
serviceException.Args) : resourceManager.GetString(serviceException.Message);
return serviceException.Args != null
? string.Format(resourceManager.GetString(serviceException.Message) ?? string.Empty,
serviceException.Args)
: resourceManager.GetString(serviceException.Message);
}
catch (Exception)
{
Expand All @@ -25,17 +28,14 @@ public static class ServiceExceptionExtensions

public static string? LocalizedMessage(this Exception exception)
{
var message = "Internal Generic Error";

switch (exception)
var message = exception switch
{
case ServiceAggregateException aex:
message = string.Join(" ", aex.GetInnerExceptions().Select(serviceException => serviceException.LocalizedMessage(Resources.Error.ResourceManager)));
break;
case ServiceException ex:
message = ex.LocalizedMessage(Resources.Error.ResourceManager);
break;
}
ServiceAggregateException aex => string.Join(" ",
aex.GetInnerExceptions()
.Select(serviceException => serviceException.LocalizedMessage(Resources.Error.ResourceManager))),
ServiceException ex => ex.LocalizedMessage(Resources.Error.ResourceManager),
_ => "Internal Generic Error"
};

return message;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Open5ETools.Core/Common/Extensions/ServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ public static class ThreadSafeRandom

public static Random ThisThreadsRandom
{
get { return _local ??= new Random(unchecked(Environment.TickCount * 31 + Environment.CurrentManagedThreadId)); }
get
{
return _local ??= new Random(unchecked(Environment.TickCount * 31 + Environment.CurrentManagedThreadId));
}
}
}

Expand All @@ -32,7 +35,7 @@ public static void Shuffle<T>(this IList<T> list)
}
}

public static string GetName(this Enum value, ResourceManager resourceManager, string? defaultValue = null)
public static string GetName(this Enum? value, ResourceManager? resourceManager, string? defaultValue = null)
{
if (value is null)
return string.Empty;
Expand Down
11 changes: 7 additions & 4 deletions src/Open5ETools.Core/Common/Helpers/AbilityHelper.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System.Globalization;

namespace Open5ETools.Core.Common.Helpers;

public static class AbilityHelper
{
public static string CalcMod(int ability)
{
var result = -5 + Math.Floor((decimal)(ability / 2));
var result = -5 + Math.Floor((decimal)(ability / 2.0));
if (result > 0)
{
return '+' + result.ToString();
return '+' + result.ToString(CultureInfo.InvariantCulture);
}
return result.ToString();

return result.ToString(CultureInfo.InvariantCulture);
}
}
}
Loading