fe2a6db786
rust / build / test / clippy / fmt (push) Has been cancelled
Layout:
- src/ .NET 10 x64 reference: MxNativeCodec, MxNativeClient,
MxAsbClient, probes, tests, harnesses. Executable spec.
- design/ Architectural plan for the Rust port (M0–M6), error
model, protocol invariants, risks (R1–R16), adversarial
review log (review.md).
- rust/ Rust workspace. M0 skeleton + M1 codec parity.
mxaccess-codec: 215 unit tests + 2 cross-implementation
parity tests (byte-identical against .NET reference).
Other crates are M0 stubs awaiting M2+.
- captures/ Frida + netsh + pcap evidence per CLAUDE.md
("captures are evidence, not throwaway logs").
- analysis/ Decompiled C# (frida/proxy/decompiled-*),
Ghidra exports for native DLLs (`exports/` only —
working state at `projects/` and AVEVA's input
binaries at `input/` are gitignored).
- docs/ Reverse-engineering reference docs.
- tools/ Setup-LiveProbeEnv.ps1 (Infisical credential fetcher),
Compute-Crc.ps1 (.NET parity helper).
- .github/workflows/ Rust CI: fmt + build + test + clippy on Windows.
- LICENSE MIT (Joseph Doherty, 2026).
Verified:
- cargo test --workspace → 217 passed (215 unit + 2 .NET parity), 0 failed
- cargo clippy --workspace -- -D warnings → clean
- cargo fmt --all -- --check → clean
- cargo publish --dry-run -p mxaccess-codec → packages cleanly
Excluded from history (see .gitignore):
- **/bin, **/obj, **/target — build artifacts
- analysis/ghidra/projects/ — Ghidra working state (regenerable)
- analysis/ghidra/input/ — AVEVA proprietary DLLs (vendor IP)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
259 lines
6.1 KiB
C#
259 lines
6.1 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Asb.Base.V2;
|
|
|
|
public static class ArchestrAResultExtensions
|
|
{
|
|
public static ArchestrAResult AddSuccessMessage(this ArchestrAResult result, [Localizable(false)] string message, params object[] arguments)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
result.AddSuccessMessage(FormatMessage(message, arguments));
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddSuccessMessage(this ArchestrAResult result, [Localizable(false)] string message)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (string.IsNullOrEmpty(message))
|
|
{
|
|
return result;
|
|
}
|
|
if (result.SuccessMessages == null)
|
|
{
|
|
result.SuccessMessages = new string[0];
|
|
}
|
|
List<string> list = result.SuccessMessages.ToList();
|
|
list.Add(message);
|
|
result.SuccessMessages = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddInformationMessage(this ArchestrAResult result, [Localizable(false)] string message, params object[] arguments)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
result.AddInformationMessage(FormatMessage(message, arguments));
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddInformationMessage(this ArchestrAResult result, [Localizable(false)] string message)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (string.IsNullOrEmpty(message))
|
|
{
|
|
return result;
|
|
}
|
|
if (result.InformationMessages == null)
|
|
{
|
|
result.InformationMessages = new string[0];
|
|
}
|
|
List<string> list = result.InformationMessages.ToList();
|
|
list.Add(message);
|
|
result.InformationMessages = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddErrorMessage(this ArchestrAResult result, [Localizable(false)] string message, params object[] arguments)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
result.AddErrorMessage(FormatMessage(message, arguments));
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddErrorMessage(this ArchestrAResult result, [Localizable(false)] string message)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (string.IsNullOrEmpty(message))
|
|
{
|
|
return result;
|
|
}
|
|
if (result.ErrorMessages == null)
|
|
{
|
|
result.ErrorMessages = new string[0];
|
|
}
|
|
List<string> list = result.ErrorMessages.ToList();
|
|
list.Add(message);
|
|
result.ErrorMessages = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddErrorMessages(this ArchestrAResult result, IEnumerable<string> messages)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (messages == null)
|
|
{
|
|
return result;
|
|
}
|
|
if (result.ErrorMessages == null)
|
|
{
|
|
result.ErrorMessages = new string[0];
|
|
}
|
|
List<string> list = result.ErrorMessages.ToList();
|
|
list.AddRange(messages);
|
|
result.ErrorMessages = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddExtension(this ArchestrAResult result, NamedValue extension)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (extension == null)
|
|
{
|
|
return result;
|
|
}
|
|
if (result.Extensions == null)
|
|
{
|
|
result.Extensions = new NamedValue[0];
|
|
}
|
|
List<NamedValue> list = result.Extensions.ToList();
|
|
list.Add(extension);
|
|
result.Extensions = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult AddExtension(this ArchestrAResult result, [Localizable(false)] string name, object value)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (result.Extensions == null)
|
|
{
|
|
result.Extensions = new NamedValue[0];
|
|
}
|
|
List<NamedValue> list = result.Extensions.ToList();
|
|
list.Add(new NamedValue
|
|
{
|
|
Name = name,
|
|
Value = Value.Create(value)
|
|
});
|
|
result.Extensions = list.ToArray();
|
|
return result;
|
|
}
|
|
|
|
public static ArchestrAResult Concatenate(this ArchestrAResult thisResult, ArchestrAResult result)
|
|
{
|
|
if (thisResult == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (result != null)
|
|
{
|
|
if (!result.Success)
|
|
{
|
|
thisResult.Success = false;
|
|
}
|
|
if (result.ErrorMessages != null)
|
|
{
|
|
if (thisResult.ErrorMessages == null)
|
|
{
|
|
thisResult.ErrorMessages = new string[0];
|
|
}
|
|
List<string> list = thisResult.ErrorMessages.ToList();
|
|
list.AddRange(result.ErrorMessages);
|
|
thisResult.ErrorMessages = list.ToArray();
|
|
}
|
|
if (result.InformationMessages != null)
|
|
{
|
|
if (thisResult.InformationMessages == null)
|
|
{
|
|
thisResult.InformationMessages = new string[0];
|
|
}
|
|
List<string> list2 = thisResult.InformationMessages.ToList();
|
|
list2.AddRange(result.InformationMessages);
|
|
thisResult.ErrorMessages = list2.ToArray();
|
|
}
|
|
if (result.SuccessMessages != null)
|
|
{
|
|
if (thisResult.SuccessMessages == null)
|
|
{
|
|
thisResult.SuccessMessages = new string[0];
|
|
}
|
|
List<string> list3 = thisResult.SuccessMessages.ToList();
|
|
list3.AddRange(result.SuccessMessages);
|
|
thisResult.SuccessMessages = list3.ToArray();
|
|
}
|
|
if (result.Extensions != null)
|
|
{
|
|
if (thisResult.Extensions == null)
|
|
{
|
|
thisResult.Extensions = new NamedValue[0];
|
|
}
|
|
List<NamedValue> list4 = thisResult.Extensions.ToList();
|
|
list4.AddRange(result.Extensions);
|
|
thisResult.Extensions = list4.ToArray();
|
|
}
|
|
if (thisResult.ResultCode == 0)
|
|
{
|
|
thisResult.ResultCode = result.ResultCode;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static string ToFormattedString(this ArchestrAResult result)
|
|
{
|
|
if (result == null)
|
|
{
|
|
return null;
|
|
}
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (result.Success)
|
|
{
|
|
stringBuilder.Append("Success");
|
|
if (result.SuccessMessages != null && result.SuccessMessages.Length != 0)
|
|
{
|
|
stringBuilder.Append(": ");
|
|
stringBuilder.Append(string.Join("| ", result.SuccessMessages));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.Append("Failure");
|
|
if (result.ErrorMessages != null && result.ErrorMessages.Length != 0)
|
|
{
|
|
stringBuilder.Append(": ");
|
|
stringBuilder.Append(string.Join("| ", result.ErrorMessages));
|
|
}
|
|
}
|
|
return stringBuilder.ToString();
|
|
}
|
|
|
|
private static string FormatMessage([Localizable(false)] string message, params object[] arguments)
|
|
{
|
|
string result = message;
|
|
if (arguments != null && arguments.Length != 0)
|
|
{
|
|
result = string.Format(CultureInfo.CurrentCulture, message, arguments);
|
|
}
|
|
return result;
|
|
}
|
|
}
|