Data Models
mcilspy uses Pydantic BaseModel classes for type-safe request and response handling. All models live in src/mcilspy/models.py. The metadata reader models represent data parsed directly from PE/.NET metadata tables via dnfile.
LanguageVersion
Section titled “LanguageVersion”Controls the C# language version used for decompilation output. Maps directly to ilspycmd’s -lv flag.
class LanguageVersion(str, Enum): CSHARP1 = "CSharp1" CSHARP2 = "CSharp2" CSHARP3 = "CSharp3" CSHARP4 = "CSharp4" CSHARP5 = "CSharp5" CSHARP6 = "CSharp6" CSHARP7 = "CSharp7" CSHARP7_1 = "CSharp7_1" CSHARP7_2 = "CSharp7_2" CSHARP7_3 = "CSharp7_3" CSHARP8_0 = "CSharp8_0" CSHARP9_0 = "CSharp9_0" CSHARP10_0 = "CSharp10_0" CSHARP11_0 = "CSharp11_0" CSHARP12_0 = "CSharp12_0" PREVIEW = "Preview" LATEST = "Latest"Default is LATEST. Use specific versions when you need output compatible with a particular C# compiler.
EntityType
Section titled “EntityType”Filters which kinds of types to return from list_types. Accepts both full names and single-letter shorthand.
class EntityType(str, Enum): CLASS = "c" # class INTERFACE = "i" # interface STRUCT = "s" # struct DELEGATE = "d" # delegate ENUM = "e" # enum
@classmethod def from_string(cls, value: str) -> "EntityType": """Convert 'class' or 'c' to EntityType.CLASS, etc."""The from_string() class method handles conversion from either format, so "class" and "c" both resolve to EntityType.CLASS.
Request Models
Section titled “Request Models”DecompileRequest
Section titled “DecompileRequest”Parameters for decompile_assembly. Only assembly_path is required — everything else has sensible defaults.
class DecompileRequest(BaseModel): assembly_path: str output_dir: str | None = None type_name: str | None = None language_version: LanguageVersion = LanguageVersion.LATEST create_project: bool = False show_il_code: bool = False reference_paths: list[str] = Field(default_factory=list) remove_dead_code: bool = False remove_dead_stores: bool = False show_il_sequence_points: bool = False nested_directories: bool = False generate_pdb: bool = False use_pdb_variable_names: bool = False| Field | Description |
|---|---|
assembly_path | Path to the .dll or .exe to decompile |
output_dir | Directory for decompiled output (uses temp dir if omitted) |
type_name | Decompile only this type (full or short name) |
language_version | Target C# version for output syntax |
create_project | Generate a buildable .csproj project |
show_il_code | Output IL bytecode instead of C# |
reference_paths | Additional assembly paths for type resolution |
remove_dead_code | Strip unreachable code from output |
remove_dead_stores | Strip dead variable assignments |
show_il_sequence_points | Include source mapping markers in IL output |
nested_directories | Organize output files by namespace hierarchy |
generate_pdb | Generate a portable PDB file alongside decompiled output |
use_pdb_variable_names | Recover original variable names from an existing PDB |
ListTypesRequest
Section titled “ListTypesRequest”Parameters for list_types. Defaults to listing classes only.
class ListTypesRequest(BaseModel): assembly_path: str entity_types: list[EntityType] = Field( default_factory=lambda: [EntityType.CLASS] ) reference_paths: list[str] = Field(default_factory=list)GenerateDiagrammerRequest
Section titled “GenerateDiagrammerRequest”Parameters for generate_diagrammer. Supports include/exclude patterns to control which types appear in the diagram.
class GenerateDiagrammerRequest(BaseModel): assembly_path: str output_dir: str | None = None include_pattern: str | None = None exclude_pattern: str | None = None docs_path: str | None = None strip_namespaces: list[str] = Field(default_factory=list) report_excluded: bool = FalseDumpPackageRequest
Section titled “DumpPackageRequest”Parameters for dump_package. Both fields are required.
class DumpPackageRequest(BaseModel): assembly_path: str # Path to assembly or NuGet package folder output_dir: str # Directory to extract assemblies intoAssemblyInfoRequest
Section titled “AssemblyInfoRequest”Parameters for get_assembly_info. Just the path.
class AssemblyInfoRequest(BaseModel): assembly_path: strResponse Models
Section titled “Response Models”DecompileResponse
Section titled “DecompileResponse”Returned by decompile_assembly and decompile_method.
class DecompileResponse(BaseModel): success: bool source_code: str | None = None output_path: str | None = None error_message: str | None = None assembly_name: str type_name: str | None = NoneWhen output_dir is provided, source_code may be None and output_path points to the directory containing the files. When decompiling to stdout (no output_dir), source_code contains the decompiled text.
ListTypesResponse
Section titled “ListTypesResponse”Returned by list_types.
class ListTypesResponse(BaseModel): success: bool types: list[TypeInfo] = Field(default_factory=list) total_count: int = 0 error_message: str | None = NoneDumpPackageResponse
Section titled “DumpPackageResponse”Returned by dump_package.
class DumpPackageResponse(BaseModel): success: bool output_path: str | None = None assemblies_dumped: list[str] = Field(default_factory=list) error_message: str | None = NoneTypeInfo
Section titled “TypeInfo”Represents a single type discovered by list_types.
class TypeInfo(BaseModel): name: str full_name: str kind: str # "class", "interface", "struct", etc. namespace: str | None = NoneAssemblyInfo
Section titled “AssemblyInfo”Returned by get_assembly_info.
class AssemblyInfo(BaseModel): name: str version: str full_name: str location: str target_framework: str | None = None runtime_version: str | None = None is_signed: bool = False has_debug_info: bool = FalseMetadata Models (dnfile-based)
Section titled “Metadata Models (dnfile-based)”These models represent data parsed directly from .NET PE metadata tables. They are used by the metadata tools (search_methods, search_fields, search_properties, list_events, list_resources, get_metadata_summary) which work without ilspycmd.
MethodInfo
Section titled “MethodInfo”class MethodInfo(BaseModel): name: str full_name: str declaring_type: str namespace: str | None = None return_type: str | None = None is_public: bool = False is_static: bool = False is_virtual: bool = False is_abstract: bool = False parameters: list[str] = Field(default_factory=list)FieldInfo
Section titled “FieldInfo”class FieldInfo(BaseModel): name: str full_name: str declaring_type: str namespace: str | None = None field_type: str | None = None is_public: bool = False is_static: bool = False is_literal: bool = False # True for constants (const/enum values) default_value: str | None = NonePropertyInfo
Section titled “PropertyInfo”class PropertyInfo(BaseModel): name: str full_name: str declaring_type: str namespace: str | None = None property_type: str | None = None has_getter: bool = False has_setter: bool = FalseEventInfo
Section titled “EventInfo”class EventInfo(BaseModel): name: str full_name: str declaring_type: str namespace: str | None = None event_type: str | None = NoneResourceInfo
Section titled “ResourceInfo”class ResourceInfo(BaseModel): name: str size: int = 0 is_public: bool = TrueAssemblyMetadata
Section titled “AssemblyMetadata”The complete metadata summary returned by get_metadata_summary.
class AssemblyMetadata(BaseModel): name: str version: str culture: str | None = None public_key_token: str | None = None target_framework: str | None = None type_count: int = 0 method_count: int = 0 field_count: int = 0 property_count: int = 0 event_count: int = 0 resource_count: int = 0 referenced_assemblies: list[str] = Field(default_factory=list)