Development Your First Hello World Custom Rule - rpapub/WatchfulAnvil GitHub Wiki

Caution

Content needs proof-reading.

Development: Your First Hello World Custom Rule

Welcome to the final step of the Getting Started guide! This page shows you how to generate your own baseline project using the built-in script β€” and how to safely revert your experiments to start over if needed.

πŸ“Œ Goal

You will:

  • Scaffold a brand-new custom Workflow Analyzer rules project with your organization name and rule prefix.
  • See a functional "Hello World" rule inside UiPath Studio.
  • Understand the layout and structure of your generated project.
  • Learn how to clean up and start fresh, as often as you need.

Step 1 β€” Generating Your Custom Rule Project

Run the script provided in the repo:

.\tools\New-RulesProject.ps1

What the Script Asks:

  • Organization Name: Used in your project’s namespace and folder name.
  • Rule ID Prefix: A short (2–5 uppercase letters) prefix used in your rule IDs like HWR-0001.

Example:

Enter your organization name [ACME]:
Enter the rule ID prefix (2-5 uppercase letters) [HWR]:

Step 2 β€” Reviewing What Gets Created

The script creates two projects and updates the solution file:

WatchfulAnvil/
β”œβ”€β”€ src/
β”‚   └── ACME.HelloWorld.WorkflowAnalyzerRules/
β”œβ”€β”€ tests/
β”‚   └── ACME.HelloWorld.Tests/
β”œβ”€β”€ WatchfulAnvil.sln

Files of Interest:

  • SampleRule.cs: Your "Hello World" custom rule
  • RegisterAnalyzerConfiguration.cs: Entry point that registers your rule
  • *.csproj: Project files targeting multiple .NET versions
  • A test project (xUnit + Moq) that builds in CI

Step 3 β€” Customizing Your Rule

Open SampleRule.cs under Rules/.

You can easily:

  • Change the rule ID or description
  • Tweak the rule's DefaultErrorLevel to TraceLevel.Error or TraceLevel.Warning or TraceLevel.Info
  • Edit the RecommendationMessage or DocumentationLink

Note

More substantial editing is not in scope of this Getting Started guide, and will be covered in the future. If your custom rule successfully shows up in UiPath Studio, you can consider it a success for now.

Step 4 β€” Building and Verifying the Project

  1. Open the solution (WatchfulAnvil.sln) in Visual Studio.
  2. Build the solution using Build β†’ Build Solution (or Ctrl+Shift+B). This animation guides you through an initial build of the Hello World Rule in Visual Studio The individual images of this sequence can be found here. Use the browser's back button to return to this page.
  3. Check that DLLs were created for:
    • net461 (legacy)
    • net6.0 (Windows)
    • net8.0 (Windows)

Step 5 β€” Seeing It in UiPath Studio

  1. Copy the correct DLL into the corresponding Studio Rules folder (see this page for reference, and use the browser's the back button to return to this page.).
This screenshot shows a sample local deployment for a UiPath Studio Community version 2024.10.6 This screenshot shows a sample local deployment for a UiPath Studio Community version 2024.10.6
  1. In case of an error similar to "The process cannot access the file ... because it is being used by another process", UiPath Studio is open and must be closed before copying the DLL. If an Access Denied error is returned, then the user does not have the sufficient permissions to write to the target folder and a PowerShell with elevated Admin permissions is required.

Important

The screenshot shows a UiPath Studio instelled in System Mode. That is why the Rules folder is located in a path that requires elevated permissions.

  1. Open a project in UiPath Studio (both Legacy and Windows).
  2. Run Workflow Analyzer.
  3. Confirm that your rule (HWR-SAMPLE-001) appears.
This screenshot shows that the rule HWR-SAMPLE-001 was succesfully recognized in UiPath Studio in a project with targetFramework 'Windows' This screenshot shows that the rule HWR-SAMPLE-001 was succesfully recognized in UiPath Studio in a project with targetFramework 'Windows'

Step 6 β€” Reverting Your Experiments

You can generate and regenerate projects freely. To reset:

Removing Projects from the Solution

dotnet sln WatchfulAnvil.sln remove src\ACME.HelloWorld.WorkflowAnalyzerRules\ACME.HelloWorld.WorkflowAnalyzerRules.csproj
dotnet sln WatchfulAnvil.sln remove tests\ACME.HelloWorld.Tests\ACME.HelloWorld.Tests.csproj

Deleting the Project Folders

Remove-Item -Recurse -Force .\src\ACME.HelloWorld.WorkflowAnalyzerRules
Remove-Item -Recurse -Force .\tests\ACME.HelloWorld.Tests

Now you can rerun .\tools\New-RulesProject.ps1 anytime to start fresh with a clean, functional baseline.

πŸ“š Next Steps

➑️ Continue with: Plan New Rules

⚠️ **GitHub.com Fallback** ⚠️