Skip to content

For Rule Developers

Bertie2011 edited this page May 22, 2021 · 7 revisions

In order to make new rules follow the steps below.

Setup & Creating Rules

  1. Create a new .NET Core Class Library project (and solution) in Visual Studio.

    Each project will end up being a .dll file, so use multiple projects to avoid creating one big .dll file. That way users can pick their rules a little more precise and not waste time on loading rules they don't want.

  2. Download the Shared.dll and Shared.xml files and place them in the solution folder.

  3. Right click Project > Add > Reference... > Browse... and select the .dll file.

    A relative path is saved, so collaboration isn't a problem.

    The .xml file will be detected automatically if it's in the same folder as the .dll file.

  4. Create classes subclassing from CheckerRule.

    Besides required overriding of abstract members, there are also virtual members you might want to explore and override.

    Note that each rule is executed in its own thread, so your code must be thread-safe. As a rule of thumb, your rule should be stateless. This means that your rule does not save any data and one run cannot be influenced by another run.

    The identifier that users will specify in their configuration is the fully qualified class name (This.Is.The.Namespace.Rule1).

Running

  1. Create a new gitignored folder or symbolic link in the solution folder. Use this folder to store and access a download of the Data Pack Checker. This folder will later be referred to as <DPC>.

  2. Go to Project > Properties > Build Events > Post-build event command line, enter the following command and make it only run if project output is updated:

    xcopy "$(TargetDir)\$(TargetName).dll" "..\<DPC>\Rules" /Y /D /I

    Note: The $(var) syntax is supported by Visual Studio and will work as-is. Only replace the <DPC>.

  3. Create a data pack and a config file to test your rule, see For Data Pack Creators.

  4. Create a gitignored .txt file which will contain all arguments for the Data Pack Checker.

  5. Go to Project > Properties > Debug and configure as follows:

    • Select Executable in the Launch dropdown.
    • Specify ..\<DPC>\<executable> in Executable
    • Specify -f "<path_to_arguments>.txt" in Application arguments.
    • Specify ..\<DPC> in Working directory

    It is important to enter relative paths and not specify any other arguments in Application arguments, since these launch settings will end up in version control and should work for any developer.

    Prevent repeated checking with -t/--life-time await. Do not use once as it will close the window before you get a chance to read the output.

Publish & Update

  • To publish, simply share the .dll files belonging to the projects in the <DPC>/Rules folder after building on Release.
  • To update to a new version of Data Pack Checker, simply overwrite the Shared.dll and Shared.xml files with a new version, fix any warnings/errors and re-publish.