Add XML documentation across gateway, worker, and .NET client
This commit is contained in:
@@ -2,8 +2,13 @@ using MxGateway.Contracts.Proto;
|
||||
|
||||
namespace MxGateway.Worker.Conversion;
|
||||
|
||||
/// <summary>Result of converting an HResult to a protocol status and diagnostic message.</summary>
|
||||
public sealed class HResultConversion
|
||||
{
|
||||
/// <summary>Initializes the conversion result.</summary>
|
||||
/// <param name="hresult">The original HResult value.</param>
|
||||
/// <param name="protocolStatus">The converted protocol status.</param>
|
||||
/// <param name="diagnosticMessage">Diagnostic message describing the HResult.</param>
|
||||
public HResultConversion(
|
||||
int hresult,
|
||||
ProtocolStatus protocolStatus,
|
||||
@@ -14,9 +19,12 @@ public sealed class HResultConversion
|
||||
DiagnosticMessage = diagnosticMessage;
|
||||
}
|
||||
|
||||
/// <summary>The original HResult value.</summary>
|
||||
public int HResult { get; }
|
||||
|
||||
/// <summary>The converted protocol status.</summary>
|
||||
public ProtocolStatus ProtocolStatus { get; }
|
||||
|
||||
/// <summary>Diagnostic message describing the HResult.</summary>
|
||||
public string DiagnosticMessage { get; }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace MxGateway.Worker.Conversion;
|
||||
|
||||
public sealed class HResultConverter
|
||||
{
|
||||
/// <summary>Converts an exception to an HResult conversion with protocol status and diagnostic message.</summary>
|
||||
/// <param name="exception">Exception to convert.</param>
|
||||
/// <returns>Conversion result with HResult, protocol status, and diagnostics.</returns>
|
||||
public HResultConversion Convert(Exception exception)
|
||||
{
|
||||
if (exception is null)
|
||||
@@ -23,6 +26,10 @@ public sealed class HResultConverter
|
||||
CreateSafeDiagnosticMessage(exception));
|
||||
}
|
||||
|
||||
/// <summary>Creates a protocol status from an HResult code and optional exception.</summary>
|
||||
/// <param name="hresult">HResult error code.</param>
|
||||
/// <param name="exception">Exception providing additional context.</param>
|
||||
/// <returns>Protocol status with mapped code and message.</returns>
|
||||
public ProtocolStatus CreateProtocolStatus(
|
||||
int hresult,
|
||||
Exception? exception = null)
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace MxGateway.Worker.Conversion;
|
||||
|
||||
public sealed class MxStatusConversionException : Exception
|
||||
{
|
||||
/// <summary>Initializes a new instance of the <see cref="MxStatusConversionException"/> class.</summary>
|
||||
/// <param name="message">The exception message.</param>
|
||||
public MxStatusConversionException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,9 @@ internal static class MxStatusDetailText
|
||||
[8017] = "Object must be offscan to modify attributes that have an MxSecurityConfigure security classification",
|
||||
};
|
||||
|
||||
/// <summary>Looks up the text description for an MXAccess status detail code.</summary>
|
||||
/// <param name="detail">Status detail code.</param>
|
||||
/// <returns>Description text if found; otherwise empty string.</returns>
|
||||
public static string Lookup(int detail)
|
||||
{
|
||||
return KnownDetails.TryGetValue(detail, out string text) ? text : string.Empty;
|
||||
|
||||
@@ -6,8 +6,11 @@ using MxGateway.Contracts.Proto;
|
||||
|
||||
namespace MxGateway.Worker.Conversion;
|
||||
|
||||
/// <summary>Converts MXAccess MXSTATUS_PROXY COM objects to protobuf MxStatusProxy messages.</summary>
|
||||
public sealed class MxStatusProxyConverter
|
||||
{
|
||||
/// <summary>Converts a single status object to a protobuf message, reflecting all fields and diagnostics.</summary>
|
||||
/// <param name="status">COM status object to convert.</param>
|
||||
public MxStatusProxy Convert(object status)
|
||||
{
|
||||
if (status is null)
|
||||
@@ -33,6 +36,8 @@ public sealed class MxStatusProxyConverter
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Converts an array of status objects, handling nulls gracefully.</summary>
|
||||
/// <param name="statuses">Array of COM status objects; null returns empty list.</param>
|
||||
public IReadOnlyList<MxStatusProxy> ConvertMany(Array? statuses)
|
||||
{
|
||||
if (statuses is null)
|
||||
@@ -60,6 +65,8 @@ public sealed class MxStatusProxyConverter
|
||||
return converted;
|
||||
}
|
||||
|
||||
/// <summary>Preserves completion-only status bytes as a diagnostic hex string since they cannot be unpacked.</summary>
|
||||
/// <param name="statusBytes">Status bytes to encode as hex string.</param>
|
||||
public string PreserveCompletionOnlyStatusBytes(byte[] statusBytes)
|
||||
{
|
||||
if (statusBytes is null)
|
||||
|
||||
@@ -8,11 +8,22 @@ namespace MxGateway.Worker.Conversion;
|
||||
|
||||
public sealed class VariantConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts an object value to an MxValue without a specified data type.
|
||||
/// </summary>
|
||||
/// <param name="value">Value to convert.</param>
|
||||
/// <returns>Converted MxValue.</returns>
|
||||
public MxValue Convert(object? value)
|
||||
{
|
||||
return Convert(value, MxDataType.Unspecified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an object value to an MxValue with an expected data type.
|
||||
/// </summary>
|
||||
/// <param name="value">Value to convert.</param>
|
||||
/// <param name="expectedDataType">Expected MXAccess data type.</param>
|
||||
/// <returns>Converted MxValue.</returns>
|
||||
public MxValue Convert(
|
||||
object? value,
|
||||
MxDataType expectedDataType)
|
||||
@@ -35,6 +46,12 @@ public sealed class VariantConverter
|
||||
return ConvertScalar(value, expectedDataType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a .NET array to an MxArray.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to convert.</param>
|
||||
/// <param name="expectedElementDataType">Expected data type for array elements.</param>
|
||||
/// <returns>Converted MxArray.</returns>
|
||||
public MxArray ConvertArray(
|
||||
Array array,
|
||||
MxDataType expectedElementDataType = MxDataType.Unspecified)
|
||||
|
||||
Reference in New Issue
Block a user