Skip to content

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.

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.

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.

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
FieldDescription
assembly_pathPath to the .dll or .exe to decompile
output_dirDirectory for decompiled output (uses temp dir if omitted)
type_nameDecompile only this type (full or short name)
language_versionTarget C# version for output syntax
create_projectGenerate a buildable .csproj project
show_il_codeOutput IL bytecode instead of C#
reference_pathsAdditional assembly paths for type resolution
remove_dead_codeStrip unreachable code from output
remove_dead_storesStrip dead variable assignments
show_il_sequence_pointsInclude source mapping markers in IL output
nested_directoriesOrganize output files by namespace hierarchy
generate_pdbGenerate a portable PDB file alongside decompiled output
use_pdb_variable_namesRecover original variable names from an existing PDB

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)

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 = False

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 into

Parameters for get_assembly_info. Just the path.

class AssemblyInfoRequest(BaseModel):
assembly_path: str

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 = None

When 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.

Returned by list_types.

class ListTypesResponse(BaseModel):
success: bool
types: list[TypeInfo] = Field(default_factory=list)
total_count: int = 0
error_message: str | None = None

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 = None

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 = None

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 = False

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.

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)
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 = None
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 = False
class EventInfo(BaseModel):
name: str
full_name: str
declaring_type: str
namespace: str | None = None
event_type: str | None = None
class ResourceInfo(BaseModel):
name: str
size: int = 0
is_public: bool = True

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)