using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Unity.Pipeline.Models
{
///
/// Response from code evaluation commands containing results, output, and diagnostics.
///
[Serializable]
public class EvalResponse :CommandExecutionResponse
{
///
/// Console output captured during execution.
///
[JsonProperty("output")]
public string Output { get; set; }
///
/// Compilation diagnostics (errors, warnings) from Roslyn.
///
[JsonProperty("diagnostics")]
public List Diagnostics { get; set; } = new List();
///
/// Create a successful evaluation response.
///
public static EvalResponse EvalSuccess(object result, string output = null, long executionTimeMs = 0, List diagnostics = null)
{
return new EvalResponse
{
Success = true,
Result = result,
Output = output,
ExecutionTimeMs = executionTimeMs,
Diagnostics = diagnostics ?? new List()
};
}
///
/// Create a failed evaluation response.
///
public static EvalResponse EvalFailure(string error, string errorDetails = null, long executionTimeMs = 0, List diagnostics = null)
{
return new EvalResponse
{
Success = false,
Error = error,
ErrorDetails = errorDetails,
ExecutionTimeMs = executionTimeMs,
Diagnostics = diagnostics ?? new List()
};
}
}
///
/// Compilation diagnostic information from Roslyn.
///
[Serializable]
public class DiagnosticInfo
{
///
/// Severity level: "error", "warning", "info".
///
[JsonProperty("severity")]
public string Severity { get; set; }
///
/// Diagnostic message text.
///
[JsonProperty("message")]
public string Message { get; set; }
///
/// Line number (0-based).
///
[JsonProperty("line")]
public int Line { get; set; }
///
/// Column number (0-based).
///
[JsonProperty("column")]
public int Column { get; set; }
///
/// Diagnostic identifier (e.g., "CS1002").
///
[JsonProperty("id")]
public string Id { get; set; }
}
}