CSF.NET.TShock 1.4.1

dotnet add package CSF.NET.TShock --version 1.4.1
NuGet\Install-Package CSF.NET.TShock -Version 1.4.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSF.NET.TShock" Version="1.4.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSF.NET.TShock --version 1.4.1
#r "nuget: CSF.NET.TShock, 1.4.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CSF.NET.TShock as a Cake Addin
#addin nuget:?package=CSF.NET.TShock&version=1.4.1

// Install CSF.NET.TShock as a Cake Tool
#tool nuget:?package=CSF.NET.TShock&version=1.4.1

csfbanner_lighttrans_outline

πŸ—οΈ CSF.NET - Command Standardization Framework for .NET

CSF is an attribute based framework that makes creating and processing text based commands easy for any platform. It implements a modular, easy to implement pipeline for registering and executing commands, as well as a large number of extensions to make development on different platforms as easy as possible.

πŸ“ Features

πŸ—¨οΈ Automated parameter parsing:

ValueType and nullable variant types are automatically parsed by the library and populate commands as below:

[Command("handle")]
public IResult Handle(int param1, DateTime param2)
{
    return Respond("{0}, {1}", param1, param2);
}

This will automatically parse int by using the default int.TryParse implementation, and will do the same for the DateTime.

Outside of this, implementing and adding your own TypeReader's is also supported to handle implementing commands with your own types. Nullability is automatically resolved by the library.

🧾 Parameterized remainder:

RemainderAttribute defines that all remaining parameters should be concatenated into a single 'remaining' string. This ensures that you don't need to add quotation marks for longer strings such as providing reasons, passwords or directories:

[Command("handle")]
public void Handle([Remainder] string path)
{
    if (!Path.Exists(path))
        Error("Failed to find specified path!");
}

πŸ›‘ Command preconditions.

Inheriting PreconditionAttribute creates a new precondition to add in the attribute range above commands. When a command is tried to be executed, it will walk through every added precondition and abort execution if any of them fail.

[RequireSystem(PlatformID.Unix)]
[Command("copy")]
public async Task Handle()
{
    
}

πŸ“– Exposed command info & responsive errors:

CSF.NET will return results for building the command map and executing commands. If you want to run your commands asynchronously, you will have to handle the result process differently:

_csf.CommandExecuted += async (context, result) => 
{
    await Task.CompletedTask;
    if (result.IsSuccess)
        return;
    // handle failure.
}

πŸ”— Virtual base class to support freely overriding all results:

Every single method inside the CommandFramework is virtual and can be overwritten if desired to change results or rewrite certain steps inside the pipeline.

πŸ’‘ Support for overriding context, module & framework:

IContext can be implemented in your own way, as it by itself serves as just a parsing tool. You can add a number of application-unique properties that are populated at creation. Because of how context's are created, it is easy to implement your own constructors and populate values from your own codebase.

πŸ’‰ Dependency injection:

You can provide an IServiceProvider at execution to inject modules with dependencies. Modules are transient and will re-inject the expected services into the module every time a command is executed. Nullable services will not populate if the constructor parameter is declared as nullable.

πŸ—ΊοΈ Roadmap

  • Add complex parameters.

πŸ€– Samples

Samples are available to learn how to implement CSF in your own programs.

πŸ“° Extensions

CSF introduces a number of extensions for external libraries.

❓ Explaining the internals:

CSF.NET works by grabbing all available modules on the specified assembly, storing them into a command map, and running through the pipeline to enter and execute the target command method.

🏭 Build steps:

Building the command map is done in a number of steps to ensure the pipeline can run through it succesfully.

  • Find all types in the provided assembly and check if they inherit ModuleBase<>.
  • Find all methods signed with CommandAttribute, if any.
  • Create a new Module from the found module, and create a new Command for each command within.
  • Populate the information with all found TypeReaders, PreconditionAttributes, attributes and aliases.
  • Add all aliases for the command to the commandmap, sharing a reference to the same target command.

The entire build process resides here.

πŸ”— Pipeline steps:

The pipeline runs through several steps, in order, to make sure your command can safely pass through to its executing method.

  • Look up all available commands matching the provided name.
  • Find the best command match for the amount of provided parameters.
  • Check all PreconditionAttributes to see if any fail.
  • Construct the module and inject found services from the provided IServiceProvider
  • Iterate through the parameters with provided TypeReaders and create a range of parsed parameters from the result.
  • Run the BeforeExecuteAsync method.
  • Run the command method.
  • Run the AfterExecuteAsync method.
  • Return a result to the caller.

The entire pipeline process resides here.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CSF.NET.TShock:

Package Downloads
Banker

Package Description

Appointer

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.1 659 12/17/2022
1.4.0 531 11/23/2022
1.3.0 314 11/21/2022
1.2.2.1 336 11/13/2022
1.2.2 307 11/10/2022
1.2.1 334 11/9/2022
1.2.0 126 10/31/2022
1.1.0 382 10/23/2022
1.0.1 378 10/6/2022
0.1.1-beta 146 9/29/2022
0.1.0-beta 164 9/28/2022

Version 1.4.1; Made for net6+.