Files
AutopilotMonitor/src/Shared/AutopilotMonitor.Shared/Models/ErrorCodeEntry.cs
T
Oliver Kieselbach db9b1995bc refactor: move the error-code generator from scripts/ to tools/ (D-225)
scripts/ at the repo root is the customer surface: everything under
Bootstrap/ and CustomerSetup/ is published to the download container by
Publish-BootstrapScripts.ps1, Authenticode-signed and version-gated. The
error-code generator is a maintainer tool no workflow runs, so it diluted
that invariant. .github/scripts/ was not the alternative -- it holds only
helpers a workflow step invokes, and unlike guardrails-in-sync and
shared-manifests-in-sync the catalog has no CI drift gate (the generator
needs IME_ENUMS_JSON from operator tooling and live MS Learn fetches).

REPO_ROOT stays ../.. at the new depth, so only the documented path moved:
the generator header and README, the C# and TypeScript comments, the test
summary, and the description header of error-codes.json together with the
generator literal that emits it (the two must stay identical or the next
regeneration diffs). The web sync re-ran clean at 607 entries with no
change to utils/error-codes.json, which drops the header.
2026-09-08 20:35:51 +02:00

101 lines
4.2 KiB
C#

#nullable enable
using System.Text.Json.Serialization;
namespace AutopilotMonitor.Shared.Models
{
/// <summary>
/// Confidence level for an error-code mapping (catalog schemaVersion 2).
/// </summary>
public enum ErrorCodeConfidence
{
/// <summary>Carried over from the v1 catalog without a primary source.</summary>
Low,
/// <summary>Paraphrase of an enum member name or of an analysis rule's text.</summary>
Medium,
/// <summary>Taken from an MS Learn page or from the IME build named in <see cref="ErrorCodeEntry.Source"/>.</summary>
High,
}
/// <summary>
/// One Windows / MSI / Intune error-code catalog entry. Mirrors the structure of
/// <c>Resources/error-codes.json</c> (generated by <c>tools/error-codes/generate.mjs</c>)
/// and the TypeScript <c>ErrorCodeEntry</c> in the web app.
/// </summary>
public sealed class ErrorCodeEntry
{
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonPropertyName("confidence")]
public ErrorCodeConfidence Confidence { get; set; }
/// <summary>
/// Provenance token: <c>msdoc:&lt;URL&gt;</c>, <c>ime:&lt;version&gt;</c>, <c>winerror.h</c>,
/// <c>rule:&lt;RULE-ID&gt;</c> or <c>legacy-catalog-v1</c>. Rendered through a formatter, never raw.
/// </summary>
[JsonPropertyName("source")]
public string Source { get; set; } = string.Empty;
/// <summary>
/// Family the code belongs to (<c>msi</c>, <c>win32</c>, <c>com</c>, <c>appx</c>, <c>windows-update</c>,
/// <c>cbs</c>, <c>intune-win32</c>, <c>intune-mobile</c>, <c>mdm-enrollment</c>, <c>autopilot</c>,
/// <c>entra-join</c>, <c>delivery-optimization</c>). Deliberately a string, not an enum: a value
/// outside the set must never turn the lazily cached catalog load into a permanent exception.
/// </summary>
[JsonPropertyName("category")]
public string Category { get; set; } = string.Empty;
/// <summary>Symbolic name (<c>ERROR_INSTALL_FAILURE</c>, <c>WU_E_ALL_UPDATES_FAILED</c>, an IME enum member). Optional.</summary>
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
/// <summary>True for the MSI return codes the IME retries automatically during the Autopilot ESP.</summary>
[JsonPropertyName("imeRetriesDuringEsp")]
public bool ImeRetriesDuringEsp { get; set; }
}
/// <summary>One IME app enforcement state (<c>enforcementStates</c> map of the catalog).</summary>
public sealed class EnforcementStateEntry
{
/// <summary>Numeric state as the catalog keys it (<c>"1000"</c>, <c>"6001"</c>).</summary>
[JsonIgnore]
public string Value { get; set; } = string.Empty;
/// <summary>IME enum member name (<c>Success</c>, <c>NotAttemptedDependencyWithFailure</c>).</summary>
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
}
/// <summary>
/// Result of <see cref="Services.ErrorCodeCatalog.TryLookupDetailed"/>: the entry plus the
/// catalog key it was found under and, when the input was a <c>HRESULT_FROM_WIN32</c> value
/// that resolved to a decimal MSI entry, the Win32 code it was derived from.
/// </summary>
public sealed class ErrorCodeLookupResult
{
public ErrorCodeLookupResult(ErrorCodeEntry entry, string key, int? derivedFromWin32)
{
Entry = entry;
Key = key;
DerivedFromWin32 = derivedFromWin32;
}
public ErrorCodeEntry Entry { get; }
/// <summary>Normalised catalog key that matched (<c>0x80070005</c>, <c>1603</c>).</summary>
public string Key { get; }
/// <summary>
/// Set when a <c>0x8007xxxx</c> input had no direct entry and resolved through its low
/// 16 bits to a decimal MSI entry (<c>0x80070643</c> → <c>1603</c>). Data for consumers,
/// never merged into the description.
/// </summary>
public int? DerivedFromWin32 { get; }
}
}