-
Notifications
You must be signed in to change notification settings - Fork 1
feat(#4): Create new empty Mod project #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
| using BannerlordModEditor.Common.Services; | ||
| using BannerlordModEditor.Common.Models.SubModule; | ||
|
|
||
| namespace BannerlordModEditor.Common.Tests.Services | ||
| { | ||
| public class ModProjectServiceTests | ||
| { | ||
| private readonly ModProjectService _service; | ||
|
|
||
| public ModProjectServiceTests() | ||
| { | ||
| _service = new ModProjectService(new SubModuleLoader()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ValidateModName_ReturnsTrueForValidName() | ||
| { | ||
| Assert.True(_service.ValidateModName("MyMod")); | ||
| Assert.True(_service.ValidateModName("My_Cool_Mod")); | ||
| Assert.True(_service.ValidateModName("Mod123")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ValidateModName_ReturnsFalseForInvalidName() | ||
| { | ||
| Assert.False(_service.ValidateModName("")); | ||
| Assert.False(_service.ValidateModName("A")); | ||
| Assert.False(_service.ValidateModName("Mod with spaces")); | ||
| Assert.False(_service.ValidateModName("Mod@Special")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GenerateModId_ReturnsCorrectId() | ||
| { | ||
| Assert.Equal("MyMod", _service.GenerateModId("My Mod")); | ||
| Assert.Equal("MyCoolMod", _service.GenerateModId("My-Cool-Mod")); | ||
| Assert.Equal("TestMod123", _service.GenerateModId("Test Mod 123")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task CreateModProjectAsync_CreatesProjectStructure() | ||
| { | ||
| var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
| Directory.CreateDirectory(tempDir); | ||
|
|
||
| try | ||
| { | ||
| var options = new ModProjectOptions | ||
| { | ||
| ModName = "TestMod", | ||
| ModId = "TestMod", | ||
| OutputDirectory = tempDir, | ||
| UseButrTemplate = true | ||
| }; | ||
|
|
||
| var result = await _service.CreateModProjectAsync(options); | ||
|
|
||
| Assert.True(result.Success); | ||
| Assert.True(Directory.Exists(result.ProjectPath)); | ||
| Assert.True(File.Exists(Path.Combine(result.ProjectPath, "SubModule.xml"))); | ||
| Assert.True(File.Exists(Path.Combine(result.ProjectPath, "TestMod.csproj"))); | ||
| Assert.True(Directory.Exists(Path.Combine(result.ProjectPath, "ModuleData"))); | ||
| Assert.True(File.Exists(Path.Combine(result.ProjectPath, ".gitignore"))); | ||
| Assert.True(File.Exists(Path.Combine(result.ProjectPath, "README.md"))); | ||
| } | ||
| finally | ||
| { | ||
| if (Directory.Exists(tempDir)) | ||
| Directory.Delete(tempDir, true); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateModProject_ReturnsErrorForInvalidName() | ||
| { | ||
| var options = new ModProjectOptions | ||
| { | ||
| ModName = "A", | ||
| OutputDirectory = "/tmp" | ||
| }; | ||
|
|
||
| var result = _service.CreateModProject(options); | ||
|
|
||
| Assert.False(result.Success); | ||
| Assert.Contains("Invalid mod name", result.ErrorMessage); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateModProject_ReturnsErrorForExistingDirectory() | ||
| { | ||
| var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
| var modDir = Path.Combine(tempDir, "ExistingMod"); | ||
| Directory.CreateDirectory(modDir); | ||
|
|
||
| try | ||
| { | ||
| var options = new ModProjectOptions | ||
| { | ||
| ModName = "ExistingMod", | ||
| OutputDirectory = tempDir | ||
| }; | ||
|
|
||
| var result = _service.CreateModProject(options); | ||
|
|
||
| Assert.False(result.Success); | ||
| Assert.Contains("already exists", result.ErrorMessage); | ||
| } | ||
| finally | ||
| { | ||
| if (Directory.Exists(tempDir)) | ||
| Directory.Delete(tempDir, true); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateModProject_CreatesValidSubModuleXml() | ||
| { | ||
| var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
| Directory.CreateDirectory(tempDir); | ||
|
|
||
| try | ||
| { | ||
| var options = new ModProjectOptions | ||
| { | ||
| ModName = "XmlTestMod", | ||
| ModId = "XmlTestMod", | ||
| OutputDirectory = tempDir, | ||
| DependedModules = new() { "Native", "Sandbox" } | ||
| }; | ||
|
|
||
| var result = _service.CreateModProject(options); | ||
|
|
||
| Assert.True(result.Success); | ||
|
|
||
| var loader = new SubModuleLoader(); | ||
| var subModule = loader.Load(Path.Combine(result.ProjectPath, "SubModule.xml")); | ||
|
|
||
| Assert.NotNull(subModule); | ||
| Assert.Equal("XmlTestMod", subModule.Name); | ||
| Assert.Equal("XmlTestMod", subModule.Id); | ||
| Assert.Equal(2, subModule.DependedModules.Count); | ||
| } | ||
| finally | ||
| { | ||
| if (Directory.Exists(tempDir)) | ||
| Directory.Delete(tempDir, true); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,184 @@ | ||||||||||||||||||||
| using System; | ||||||||||||||||||||
| using System.Collections.Generic; | ||||||||||||||||||||
| using System.IO; | ||||||||||||||||||||
| using System.Linq; | ||||||||||||||||||||
| using System.Threading.Tasks; | ||||||||||||||||||||
| using BannerlordModEditor.Common.Models.SubModule; | ||||||||||||||||||||
|
Check failure on line 6 in BannerlordModEditor.Common/Services/ModProjectService.cs
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| namespace BannerlordModEditor.Common.Services | ||||||||||||||||||||
| { | ||||||||||||||||||||
| public class ModProjectOptions | ||||||||||||||||||||
| { | ||||||||||||||||||||
| public string ModName { get; set; } = string.Empty; | ||||||||||||||||||||
| public string ModId { get; set; } = string.Empty; | ||||||||||||||||||||
| public string OutputDirectory { get; set; } = string.Empty; | ||||||||||||||||||||
| public bool UseButrTemplate { get; set; } = true; | ||||||||||||||||||||
| public string GameVersion { get; set; } = "Latest"; | ||||||||||||||||||||
| public bool CreateSubModuleXml { get; set; } = true; | ||||||||||||||||||||
| public bool CreateCsproj { get; set; } = true; | ||||||||||||||||||||
| public bool CreateModuleDataFolder { get; set; } = true; | ||||||||||||||||||||
| public List<string> DependedModules { get; set; } = new() { "Native" }; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public class ModProjectResult | ||||||||||||||||||||
| { | ||||||||||||||||||||
| public bool Success { get; set; } | ||||||||||||||||||||
| public string ProjectPath { get; set; } = string.Empty; | ||||||||||||||||||||
| public List<string> CreatedFiles { get; set; } = new(); | ||||||||||||||||||||
|
||||||||||||||||||||
| public List<string> CreatedFiles { get; set; } = new(); | |
| public List<string> CreatedPaths { get; set; } = new(); | |
| [Obsolete("Use CreatedPaths instead. This property will be removed in a future version.")] | |
| public List<string> CreatedFiles | |
| { | |
| get => CreatedPaths; | |
| set => CreatedPaths = value ?? new(); | |
| } |
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Release)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Release)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Debug)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Debug)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / unit-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / unit-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / large-xml-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / large-xml-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / concurrency-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / concurrency-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / integration-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / integration-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / performance-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / performance-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / memory-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / memory-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / regression-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / regression-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / error-handling-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / error-handling-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 42 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / ui-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Release)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Release)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / macos-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / tmux-integration-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Debug)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / test (Debug)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / windows-tests (9.0.x)
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / unit-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / unit-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / large-xml-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / large-xml-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / concurrency-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / concurrency-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / integration-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / integration-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / performance-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / performance-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / memory-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / memory-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / regression-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / regression-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / error-handling-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / error-handling-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 44 in BannerlordModEditor.Common/Services/ModProjectService.cs
GitHub Actions / ui-tests
The type or namespace name 'ISubModuleLoader' could not be found (are you missing a using directive or an assembly reference?)
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping the synchronous, IO-heavy scaffolding in Task.Run will consume a thread-pool thread for the entire duration and doesn’t provide true async IO. Prefer either (1) making the method synchronous-only, or (2) implementing a genuinely async version that uses async file APIs (e.g., WriteAllTextAsync / async stream usage) and avoids Task.Run.
| public async Task<ModProjectResult> CreateModProjectAsync(ModProjectOptions options) | |
| { | |
| return await Task.Run(() => CreateModProject(options)); | |
| public Task<ModProjectResult> CreateModProjectAsync(ModProjectOptions options) | |
| { | |
| return Task.FromResult(CreateModProject(options)); |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation error message is inconsistent with the actual validation rules: ValidateModName currently allows -, but the message says “underscores” only (and it also doesn’t mention the length constraints). Update the message to reflect the real rules or adjust the validator to match the message.
| result.ErrorMessage = "Invalid mod name. Use only letters, numbers, and underscores."; | |
| result.ErrorMessage = "Invalid mod name. Use only letters, numbers, underscores, and hyphens, and ensure it meets the required length constraints."; |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreatedFiles is currently used to store both file paths and directory paths (e.g., ModuleData). This makes the API ambiguous for callers. Consider either (a) renaming to something like CreatedPaths, or (b) splitting into CreatedFiles and CreatedDirectories (or similar) so consumers can reliably interpret the result.
| result.CreatedFiles.Add(moduleDataPath); |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-creating bin/ and obj/ in a project template is generally undesirable because these are build output directories and can confuse tooling/users (and may create noise in scaffolding results). Prefer not creating them at scaffold time; keep the .gitignore entries and let the build generate these folders.
| var binPath = Path.Combine(projectPath, "bin"); | |
| Directory.CreateDirectory(binPath); | |
| var objPath = Path.Combine(projectPath, "obj"); | |
| Directory.CreateDirectory(objPath); |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation error message is inconsistent with the actual validation rules: ValidateModName currently allows -, but the message says “underscores” only (and it also doesn’t mention the length constraints). Update the message to reflect the real rules or adjust the validator to match the message.
| return modName.All(c => char.IsLetterOrDigit(c) || c == '_' || c == '-'); | |
| return modName.All(c => char.IsLetterOrDigit(c) || c == '_'); |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s a new behavioral branch controlled by UseButrTemplate that changes the generated .csproj content, but the tests don’t currently assert that these conditional package references are present/absent. Add a test that creates a project with UseButrTemplate = false and verifies the generated .csproj does not contain the BUTR references (and optionally one that asserts they are present when true).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test hard-codes
"/tmp"as the output directory, which will fail on Windows environments. UsePath.GetTempPath()(optionally combined with a GUID subfolder) to keep the test cross-platform and consistent with the other tests in this file.