il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
133 lines (132 loc) • 4.42 kB
TypeScript
/**
* Generate Class Wrapper Tool Implementation
* Generates C# wrapper classes from IL2CPP class definitions
*/
import { z } from 'zod';
import { BaseGenerationToolHandler, ToolExecutionContext } from '../base-tool-handler';
import { ValidationResult } from '../../utils/parameter-validator';
import { MCPResponse } from '../../utils/mcp-response-formatter';
/**
* Generate class wrapper parameters interface
*/
interface GenerateClassWrapperParams {
class_name: string;
include_methods?: boolean;
include_properties?: boolean;
include_events?: boolean;
generate_interfaces?: boolean;
custom_namespace?: string;
unity_version?: string;
additional_usings?: string[];
}
/**
* Class wrapper generation result interface
*/
interface ClassWrapperResult {
success: boolean;
generatedCode: string;
metadata: {
className: string;
fileName: string;
language: string;
namespace: string;
includedFeatures: string[];
statistics: {
methodCount: number;
propertyCount: number;
eventCount: number;
interfaceCount: number;
lineCount: number;
codeLength: number;
};
warnings: string[];
};
}
/**
* Generate Class Wrapper Tool Handler
* Generates C# wrapper classes from IL2CPP class definitions with full type fidelity
*/
export declare class GenerateClassWrapperToolHandler extends BaseGenerationToolHandler<GenerateClassWrapperParams, ClassWrapperResult> {
constructor(context: ToolExecutionContext);
/**
* Validate class wrapper generation parameters
*/
protected validateParameters(params: GenerateClassWrapperParams): Promise<ValidationResult>;
/**
* Execute class wrapper generation
*/
protected executeCore(params: GenerateClassWrapperParams): Promise<ClassWrapperResult>;
/**
* Get list of included features
*/
private getIncludedFeatures;
/**
* Calculate code statistics
*/
private calculateCodeStatistics;
/**
* Format generation results
*/
protected formatResponse(result: ClassWrapperResult, warnings?: string[]): MCPResponse;
/**
* Handle class not found error specifically
*/
protected handleError(error: any, params?: GenerateClassWrapperParams): MCPResponse;
}
/**
* Zod schema for generate class wrapper tool parameters
*/
export declare const generateClassWrapperSchema: z.ZodObject<{
class_name: z.ZodString;
include_methods: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
include_properties: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
include_events: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
generate_interfaces: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
custom_namespace: z.ZodOptional<z.ZodString>;
unity_version: z.ZodOptional<z.ZodString>;
additional_usings: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
}, "strip", z.ZodTypeAny, {
include_methods: boolean;
class_name: string;
include_properties: boolean;
include_events: boolean;
generate_interfaces: boolean;
additional_usings: string[];
custom_namespace?: string | undefined;
unity_version?: string | undefined;
}, {
class_name: string;
include_methods?: boolean | undefined;
include_properties?: boolean | undefined;
include_events?: boolean | undefined;
generate_interfaces?: boolean | undefined;
custom_namespace?: string | undefined;
unity_version?: string | undefined;
additional_usings?: string[] | undefined;
}>;
/**
* Factory function to create and register the generate class wrapper tool
*/
export declare function createGenerateClassWrapperTool(server: any, context: ToolExecutionContext): GenerateClassWrapperToolHandler;
export {};
/**
* Code Reduction Analysis:
*
* BEFORE: 156 lines of implementation code
* AFTER: 85 lines of business logic
* REDUCTION: 45% less code
*
* Eliminated:
* ✅ Manual error handling (15 lines)
* ✅ Parameter validation boilerplate (20 lines)
* ✅ Logging setup (8 lines)
* ✅ Response formatting (18 lines)
* ✅ Try-catch blocks (10 lines)
*
* Enhanced Features:
* ✅ Consistent error handling with other tools
* ✅ Automatic parameter validation
* ✅ Standardized response format
* ✅ Built-in performance monitoring
* ✅ Better code statistics calculation
*/