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
5 changes: 5 additions & 0 deletions build/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.cs]
# Nuke build fields use attribute-based reflection injection and cannot follow
# the standard private field naming convention with underscore prefix.
dotnet_naming_rule.private_fields_should_start_with_underscore.severity = none
dotnet_naming_rule.private_static_fields_should_start_with_s_underscore.severity = none
56 changes: 28 additions & 28 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;

[ShutdownDotNetAfterServerBuild]
class Build : NukeBuild
internal class Build : NukeBuild
{
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
Expand All @@ -28,30 +28,30 @@ class Build : NukeBuild
public static int Main() => Execute<Build>(x => x.Compile);

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly string Configuration = IsLocalBuild ? "Debug" : "Release";
private readonly string Configuration = IsLocalBuild ? "Debug" : "Release";

[Parameter("Enable code coverage collection")]
readonly bool CoverageEnabled = true;
private readonly bool CoverageEnabled = true;

[Parameter("Verbosity level for build output")]
readonly DotNetVerbosity BuildVerbosity = DotNetVerbosity.minimal;
private readonly DotNetVerbosity BuildVerbosity = DotNetVerbosity.minimal;

[Solution(GenerateProjects = false)]
readonly Solution Solution;
private readonly Solution Solution;

[GitVersion(NoFetch = true, Framework = "net10.0")]
[CanBeNull]
readonly GitVersion GitVersion;
private readonly GitVersion GitVersion;

AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
AbsolutePath TestResultsDirectory => ArtifactsDirectory / "test-results";
AbsolutePath CoverageDirectory => ArtifactsDirectory / "coverage";
AbsolutePath PublishDirectory => ArtifactsDirectory / "publish";
AbsolutePath PackagesDirectory => ArtifactsDirectory / "packages";
private AbsolutePath SourceDirectory => RootDirectory / "src";
private AbsolutePath TestsDirectory => RootDirectory / "tests";
private AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
private AbsolutePath TestResultsDirectory => ArtifactsDirectory / "test-results";
private AbsolutePath CoverageDirectory => ArtifactsDirectory / "coverage";
private AbsolutePath PublishDirectory => ArtifactsDirectory / "publish";
private AbsolutePath PackagesDirectory => ArtifactsDirectory / "packages";

Target Clean => _ => _
private Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
Expand All @@ -60,14 +60,14 @@ class Build : NukeBuild
ArtifactsDirectory.CreateOrCleanDirectory();
});

Target Restore => _ => _
private Target Restore => _ => _
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution));
});

Target Compile => _ => _
private Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
Expand All @@ -81,7 +81,7 @@ class Build : NukeBuild
.SetVerbosity(BuildVerbosity));
});

Target Test => _ => _
private Target Test => _ => _
.DependsOn(Compile)
.Produces(TestResultsDirectory / "*.trx")
.Produces(CoverageDirectory / "*.xml")
Expand Down Expand Up @@ -110,7 +110,7 @@ class Build : NukeBuild
DotNetTest(testSettings);
});

Target IntegrationTest => _ => _
private Target IntegrationTest => _ => _
.DependsOn(Compile)
.Produces(TestResultsDirectory / "integration-*.trx")
.Executes(() =>
Expand All @@ -129,7 +129,7 @@ class Build : NukeBuild
.SetProjectFile(project)));
});

Target Coverage => _ => _
private Target Coverage => _ => _
.DependsOn(Test)
.Produces(CoverageDirectory / "*.xml")
.Executes(() =>
Expand All @@ -143,7 +143,7 @@ class Build : NukeBuild
}
});

Target CoverageReport => _ => _
private Target CoverageReport => _ => _
.DependsOn(Coverage)
.Produces(CoverageDirectory / "report" / "**/*")
.Executes(() =>
Expand All @@ -161,7 +161,7 @@ class Build : NukeBuild
Log.Information("Coverage report generated: {Report}", CoverageDirectory / "report" / "index.html");
});

Target Pack => _ => _
private Target Pack => _ => _
.DependsOn(Compile)
.Produces(PackagesDirectory / "*.nupkg")
.Executes(() =>
Expand All @@ -176,7 +176,7 @@ class Build : NukeBuild
.SetVerbosity(BuildVerbosity));
});

Target Publish => _ => _
private Target Publish => _ => _
.DependsOn(Compile)
.Produces(PublishDirectory / "**/*")
.Executes(() =>
Expand All @@ -199,19 +199,19 @@ class Build : NukeBuild
.SetOutput(PublishDirectory / project.Name)));
});

Target Format => _ => _
private Target Format => _ => _
.Executes(() =>
{
DotNet($"format \"{Solution}\" --verbosity {Verbosity}");
});

Target FormatVerify => _ => _
private Target FormatVerify => _ => _
.Executes(() =>
{
DotNet($"format \"{Solution}\" --verify-no-changes --verbosity {Verbosity}");
});

Target Lint => _ => _
private Target Lint => _ => _
.DependsOn(Restore)
.Executes(() =>
{
Expand All @@ -224,12 +224,12 @@ class Build : NukeBuild
.SetVerbosity(BuildVerbosity));
});

Target Default => _ => _
private Target Default => _ => _
.DependsOn(Restore)
.DependsOn(Compile)
.DependsOn(Test);

Target Full => _ => _
private Target Full => _ => _
.DependsOn(Clean)
.DependsOn(Restore)
.DependsOn(Compile)
Expand All @@ -238,7 +238,7 @@ class Build : NukeBuild
.DependsOn(Pack)
.DependsOn(Publish);

Target CI => _ => _
private Target CI => _ => _
.DependsOn(Clean)
.DependsOn(Restore)
.DependsOn(Compile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static Dictionary<string, ArkConfigSetting> GetDefaults()
{ "bUseSingleplayerSettings", new ArkConfigSetting("False", "Advanced", "Use singleplayer settings multipliers") },
};
}

/// <summary>
/// Represents an ARK configuration setting with metadata.
/// </summary>
Expand All @@ -129,7 +129,7 @@ public class ArkConfigSetting
public string DefaultValue { get; }
public string Category { get; }
public string Description { get; }

public ArkConfigSetting(string defaultValue, string category, string description)
{
DefaultValue = defaultValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using FluentValidation;
using System.Reflection;
using FluentValidation;
using Microsoft.Extensions.DependencyInjection;

namespace PokManager.Application.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace PokManager.Application.UseCases.InstanceLifecycle.CreateInstance;

public class CreateInstanceRequestValidator : AbstractValidator<CreateInstanceRequest>
{
private static readonly string[] ValidMapNames = new[]
private static readonly string[] s_validMapNames = new[]
{
"TheIsland",
"TheCenter",
Expand Down Expand Up @@ -34,7 +34,7 @@ public CreateInstanceRequestValidator()

RuleFor(x => x.MapName)
.NotEmpty().WithMessage("Map name cannot be empty")
.Must(BeAValidMapName).WithMessage($"Map name must be one of: {string.Join(", ", ValidMapNames)}");
.Must(BeAValidMapName).WithMessage($"Map name must be one of: {string.Join(", ", s_validMapNames)}");

RuleFor(x => x.MaxPlayers)
.InclusiveBetween(1, 127).WithMessage("Max players must be between 1 and 127");
Expand Down Expand Up @@ -71,6 +71,6 @@ public CreateInstanceRequestValidator()

private bool BeAValidMapName(string mapName)
{
return ValidMapNames.Contains(mapName, StringComparer.OrdinalIgnoreCase);
return s_validMapNames.Contains(mapName, StringComparer.OrdinalIgnoreCase);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Diagnostics;
using PokManager.Application.Models;
using PokManager.Application.Ports;
using PokManager.Domain.Common;
using PokManager.Domain.Enumerations;
using System.Diagnostics;

namespace PokManager.Application.UseCases.InstanceManagement.SaveWorld;

Expand Down
4 changes: 2 additions & 2 deletions src/Core/PokManager.Domain/Entities/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Instance(string instanceId, string sessionName, string mapName, int
public string? ContainerId { get; set; }

// State transition rules
private static readonly Dictionary<InstanceState, HashSet<InstanceState>> AllowedTransitions = new()
private static readonly Dictionary<InstanceState, HashSet<InstanceState>> s_allowedTransitions = new()
{
[InstanceState.Created] = new() { InstanceState.Starting },
[InstanceState.Stopped] = new() { InstanceState.Starting, InstanceState.Deleted },
Expand All @@ -28,7 +28,7 @@ public class Instance(string instanceId, string sessionName, string mapName, int

public Result<Unit> TransitionTo(InstanceState newState)
{
if (!AllowedTransitions.TryGetValue(State, out var allowedStates))
if (!s_allowedTransitions.TryGetValue(State, out var allowedStates))
{
return Result.Failure<Unit>($"No transitions defined for state {State}");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/PokManager.Domain/ValueObjects/BackupId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace PokManager.Domain.ValueObjects;

public sealed class BackupId : IEquatable<BackupId>
{
private static readonly Regex ValidationPattern = new(
private static readonly Regex s_validationPattern = new(
@"^([a-zA-Z0-9_-]+)_backup_(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})$",
RegexOptions.Compiled);

Expand All @@ -29,7 +29,7 @@ public static Result<BackupId> Create(string value)
return Result<BackupId>.Failure("BackupId cannot be empty or whitespace.");
}

var match = ValidationPattern.Match(value);
var match = s_validationPattern.Match(value);
if (!match.Success)
{
return Result<BackupId>.Failure(
Expand Down
4 changes: 2 additions & 2 deletions src/Core/PokManager.Domain/ValueObjects/InstanceId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace PokManager.Domain.ValueObjects;

public sealed class InstanceId : IEquatable<InstanceId>
{
private static readonly Regex ValidationPattern = new(@"^[a-zA-Z0-9_-]+$", RegexOptions.Compiled);
private static readonly Regex s_validationPattern = new(@"^[a-zA-Z0-9_-]+$", RegexOptions.Compiled);
private const int MaxLength = 64;

public string Value { get; }
Expand All @@ -27,7 +27,7 @@ public static Result<InstanceId> Create(string value)
return Result<InstanceId>.Failure($"InstanceId cannot exceed {MaxLength} characters.");
}

if (!ValidationPattern.IsMatch(value))
if (!s_validationPattern.IsMatch(value))
{
return Result<InstanceId>.Failure("InstanceId must contain only alphanumeric characters, hyphens, and underscores.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/PokManager.Domain/ValueObjects/ServerPassword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace PokManager.Domain.ValueObjects;

public sealed class ServerPassword : IEquatable<ServerPassword>
{
private static readonly Regex ValidationPattern = new(@"^[a-zA-Z0-9]+$", RegexOptions.Compiled);
private static readonly Regex s_validationPattern = new(@"^[a-zA-Z0-9]+$", RegexOptions.Compiled);
private const int MinLength = 4;
private const int MaxLength = 64;

Expand Down Expand Up @@ -33,7 +33,7 @@ public static Result<ServerPassword> Create(string value)
return Result<ServerPassword>.Failure($"ServerPassword cannot exceed {MaxLength} characters.");
}

if (!ValidationPattern.IsMatch(value))
if (!s_validationPattern.IsMatch(value))
{
return Result<ServerPassword>.Failure("ServerPassword must contain only alphanumeric characters.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Hosting/PokManager.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Health checks are enabled in all environments for deployment verification
// In production, consider adding authentication or IP restrictions if needed

// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DockerComposeConfig
public int RestartNoticeMinutes { get; set; }
public string TimeZone { get; set; } = string.Empty;
public string MemoryLimit { get; set; } = string.Empty;

/// <summary>
/// Path to the docker-compose file
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using PokManager.Application.Ports;
using PokManager.Domain.Common;
using PokManager.Infrastructure.Docker.Models;
using Microsoft.Extensions.Logging;

namespace PokManager.Infrastructure.Docker.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ public class DockerComposeParser
.Build();

var doc = deserializer.Deserialize<Dictionary<string, object>>(yaml);

if (!doc.ContainsKey("services"))
return null;

var services = (Dictionary<object, object>)doc["services"];
var firstService = services.Values.FirstOrDefault();

if (firstService == null)
return null;

var service = (Dictionary<object, object>)firstService;

var config = new DockerComposeConfig
{
ConfigFilePath = filePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<Result<IReadOnlyList<string>>> DiscoverInstancesAsync(Cancella
try
{
var containers = await _dockerService.ListContainersAsync(cancellationToken);

// Extract instance IDs from container names (remove 'asa_' prefix)
var instanceIds = containers
.Where(c => c.Name.StartsWith("asa_", StringComparison.OrdinalIgnoreCase))
Expand Down
Loading
Loading