-
Notifications
You must be signed in to change notification settings - Fork 0
For Rule Developers
In order to make new rules follow the steps below.
-
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.
-
Download the Shared.dll and Shared.xml files and place them in the solution folder.
-
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.
-
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
).
-
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>
. -
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>
. -
Create a data pack and a config file to test your rule, see For Data Pack Creators.
-
Create a gitignored
.txt
file which will contain all arguments for the Data Pack Checker. -
Go to
Project
>Properties
>Debug
and configure as follows:- Select
Executable
in theLaunch
dropdown. - Specify
..\<DPC>\<executable>
inExecutable
- Specify
-f "<path_to_arguments>.txt"
inApplication arguments
. - Specify
..\<DPC>
inWorking 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 useonce
as it will close the window before you get a chance to read the output. - Select
- 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.