I can’t step into a static method in a Coded Workflow file. This is my setup:
// TestQuarterHandler.cs
using StepIntoDoesntWork.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;
using StepIntoDoesntWork.Time;
namespace StepIntoDoesntWork
{
public class TestQuarterHandler : CodedWorkflow
{
[Workflow]
public void Execute()
{
string period = "24012";
int year = 2024;
Quarter quarter = Quarter.Q1;
Log(string.Format("Period: {0}. Year: {1}. Quarter: Q1.", period, year));
// ---> Breakpoint here <---
if (!QuarterHandler.IsPeriodInQuarter(period, year, quarter))
{
Log(string.Format("ERROR: Period {0} was NOT in quarter Q1.", period));
}
else
{
Log(string.Format("SUCCESS: Period {0} WAS in quarter Q1.", period));
}
}
}
}
// Time.cs
#nullable enable
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace StepIntoDoesntWork.Time
{
public enum Quarter
{
Q1 = 1,
Q2 = 2,
Q3 = 3,
Q4 = 4,
Q0 = 0, // Doesn't exist and is only used for default values.
}
public static class QuarterHandler
{
private static readonly Regex _monthRegex = new(@"(\d{2})(0[1-9]|1[0-2])", RegexOptions.Compiled);
public static bool IsPeriodInQuarter(string period, int year, Quarter quarter)
{
// ---> Breakpoint here <---
var match = _monthRegex.Match(period);
var groups = match.Groups;
if (groups.Count == 3)
{
var periodYear = int.Parse(groups[1].Value);
var month = int.Parse(groups[2].Value);
if (periodYear == (year % 100) && IsMonthInQuarter(month, quarter))
{
return true;
}
}
return false;
}
public static bool IsMonthInQuarter(int month, Quarter quarter)
{
switch (quarter)
{
case Quarter.Q1: return IsNumberInRange(month, 1, 3);
case Quarter.Q2: return IsNumberInRange(month, 4, 6);
case Quarter.Q3: return IsNumberInRange(month, 7, 9);
case Quarter.Q4: return IsNumberInRange(month, 10, 12);
default:
throw new InvalidOperationException(string.Format("Invalid quarter value: {0}.", quarter));
}
}
private static bool IsNumberInRange(int num, int min, int max) =>
min <= num && num <= max;
}
}
I then use the Invoke Workflow File
activity to start the TestQuarterHandler.cs
file. The thing is, that the breakpoints do work in this small test project, but they don’t work in my bigger, real one. I unfortunately cannot share the real project since it contains sensitive data.
I’ve tried using Slow Step
at the slowest speed but that doesn’t work either – the method call just gets stepped over anyway.