using System.ComponentModel.DataAnnotations;
namespace CodePlay.Core.Models;
// ==================== 核心转换模型 ====================
///
/// 转换请求
///
public class ConversionRequest
{
public string SourceLanguage { get; set; } = "";
public string TargetLanguage { get; set; } = "";
public string SourceCode { get; set; } = "";
public int ValidationRounds { get; set; }
public ConversionOptions Options { get; set; } = new();
}
///
/// 转换选项
///
public class ConversionOptions
{
public bool KeepComments { get; set; } = true;
public bool KeepDocStrings { get; set; } = true;
public bool AutoFormat { get; set; } = true;
public int MaxRetryRounds { get; set; } = 3;
public string? ProjectId { get; set; }
}
///
/// 转换结果
///
public class ConversionResult
{
public bool Success { get; set; } = true;
public string TransformedCode { get; set; } = "";
public string? ErrorMessage { get; set; }
public ConversionReport Report { get; set; } = new();
public List Warnings { get; set; } = new();
}
///
/// 转换警告
///
public class ConversionWarning
{
public string Message { get; set; } = "";
public int Line { get; set; }
public string Suggestion { get; set; } = "";
public string Type { get; set; } = "";
public string Code { get; set; } = "";
}
///
/// 转换报告
///
public class ConversionReport
{
public string Id { get; set; } = Guid.NewGuid().ToString("N")[..20];
public string? ProjectId { get; set; }
public string SourceLanguage { get; set; } = "";
public string TargetLanguage { get; set; } = "";
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public int LinesConverted { get; set; }
public int ClassesConverted { get; set; }
public int MethodsConverted { get; set; }
public int IssueCount { get; set; }
public int TodoCount { get; set; }
public string ValidationStatus { get; set; } = "";
public List TodoItems { get; set; } = new();
public List Issues { get; set; } = new();
public List TransformationLog { get; set; } = new();
}
///
/// TODO 项
///
public class TodoItem
{
public string Description { get; set; } = string.Empty;
public int LineNumber { get; set; }
public string OriginalSyntax { get; set; } = string.Empty;
public string WhyNotDirect { get; set; } = string.Empty;
public string RecommendedAlternative { get; set; } = string.Empty;
}
///
/// 问题信息
///
public class IssueInfo
{
public string Description { get; set; } = string.Empty;
public string Severity { get; set; } = "";
public int Line { get; set; }
public string Suggestion { get; set; } = string.Empty;
}
///
/// 转换日志
///
public class TransformationLogEntry
{
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string Operation { get; set; } = "";
public string Details { get; set; } = "";
public string Level { get; set; } = "Info";
public string Code { get; set; } = "";
}
///
/// 编译错误
///
public class CompilationError
{
public int Line { get; set; }
public int LineNumber { get; set; }
public int Column { get; set; }
public int ColumnNumber { get; set; }
public string Message { get; set; } = "";
public string Severity { get; set; } = "Error";
public string Id { get; set; } = "";
public string ErrorId { get; set; } = "";
public bool IsError { get; set; } = true;
}
///
/// 验证摘要
///
public class ValidationSummary
{
public bool Passed { get; set; }
public bool Success { get; set; }
public string Output { get; set; } = "";
public int ErrorCount { get; set; }
public int WarningCount { get; set; }
public int RoundsExecuted { get; set; }
public bool NeedsManualReview { get; set; }
public List Errors { get; set; } = new();
public List CompilationErrors { get; set; } = new();
public List Warnings { get; set; } = new();
public List ValidationLog { get; set; } = new();
}
///
/// 转换问题
///
public class ConversionIssue
{
public string Description { get; set; } = "";
public string Severity { get; set; } = "";
public int Line { get; set; }
public int LineNumber { get; set; }
public string Suggestion { get; set; } = "";
public string SourceSyntax { get; set; } = "";
public string OriginalCode { get; set; } = "";
public string Type { get; set; } = "";
public string Language { get; set; } = "";
public int Column { get; set; }
public bool IsError { get; set; }
public string ErrorId { get; set; } = "";
}
// ==================== 项目模型 ====================
///
/// 项目信息
///
public class ProjectInfo
{
public Guid Id { get; set; }
public string Name { get; set; } = "";
public string SourceLanguage { get; set; } = "";
public string TargetLanguage { get; set; } = "";
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
public List Files { get; set; } = new();
public int TotalConversions { get; set; }
}
///
/// 问题类型
///
public enum IssueType
{
Syntax,
Semantic,
Compatibility,
Performance,
Maintainability,
UnconvertibleSyntax
}
///
/// 日志级别
///
public enum LogLevel
{
Debug,
Info,
Warning,
Error,
Critical
}
///
/// 转换日志
///
public class TransformationLog
{
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string Operation { get; set; } = "";
public string Details { get; set; } = "";
public LogLevel Level { get; set; } = LogLevel.Info;
}
///
/// 问题严重程度
///
public enum IssueSeverity
{
Low,
Medium,
High,
Critical
}
///
/// 修复选项
///
public enum FixOption
{
Replace,
Comment,
Annotate,
Remove
}