Project.Analyze#
Computes analytics over dates without scheduling them. It reads either a supplied ProjectData or the current dates of a Project, including unsolved edits. It never installs data and never changes the solved status.
Signature#
public ScheduleResult Analyze(ProjectData? data, AnalyzeOptions options)
Synchronous and CPU-only. Doesn't change the project's state, and works on an unsolved project.
Parameters#
| Name | Type | Description |
|---|---|---|
data |
ProjectData? |
Dates to analyze, or null for the project's current dates |
options |
AnalyzeOptions |
Which analytics to compute |
Behavior#
- A non-null
datais validated and analyzed as given, but never installed. WithValidation.Repair, repairs run on a copy and leave the caller's object unchanged. Each repair appears as aNote.Repaired. nullanalyzes the project's current dates, including edits made byApplysince the last solve.
Returns#
A ScheduleResult with Cycles, Notes, Analytics and Overallocations filled. Updates and Conflicts are empty. BaselineId is set only when data is null and the project is solved with no unsolved edits.
Errors#
| Error | When |
|---|---|
InputException |
Supplied data fails validation |
ArgumentNullException |
options is null |
Example#
Get the critical path of dates stored elsewhere, without scheduling them.
using Plen;
Moment Day(int d) => Moment.FromYmdHm(2026, 1, d, 0, 0) ?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Tasks =
[
new TaskData("design") { StartDate = Day(5), Duration = 2.0 },
new TaskData("build") { StartDate = Day(7), Duration = 3.0 },
],
Links = [new LinkData { Id = "l1", Source = "design", Target = "build" }],
};
var project = new Project();
var options = new AnalyzeOptions
{
Analytics = new AnalyticsOptions { CriticalPath = true },
};
var result = project.Analyze(data, options);
if (result.Analytics?.CriticalPath is { } critical)
Console.WriteLine($"critical tasks: {string.Join(", ", critical.Tasks)}");
Related#
AnalyzeOptions- the optionsScheduleResult- the returned resultAnalytics- the critical path and slack data- Critical path and slack - requesting and reading analytics