Make toolshed's CommandImplementationAttribute optional (#6218)

This commit is contained in:
Leon Friedrich
2025-09-23 15:47:21 +12:00
committed by GitHub
parent 585e847818
commit ddeb78accd
6 changed files with 38 additions and 8 deletions

View File

@@ -215,3 +215,18 @@ public sealed class TestNestedEnumerableCommand : ToolshedCommand
[CommandImplementation]
public IEnumerable<ProtoId<EntityCategoryPrototype>> Impl() => _arr.OrderByDescending(x => x.Id);
}
[ToolshedCommand]
public sealed class TestImplicitImplCommand : ToolshedCommand
{
public int Impl() => 1;
}
[ToolshedCommand]
public sealed class TestExplicitImplCommand : ToolshedCommand
{
public int Impl() => 1;
[CommandImplementation]
public int Impl2() => 2;
}

View File

@@ -60,6 +60,10 @@ public sealed class ToolshedTests : ToolshedTest
Assert.Throws<AssertionException>(() => ParseError<OutOfInputError>("i 2"));
Assert.That(ExpectedErrors.Count, Is.EqualTo(1));
ExpectedErrors.Clear();
// Check that the CommandImplementationAttibute is optional when the type only defines one method.
AssertResult("testimplicitimpl", 1);
AssertResult("testexplicitimpl", 2);
});
}