# dotnetcore/Natasha

基于 Roslyn 的 C# 动态程序集构建库，该库允许开发者在运行时使用 C# 代码构建域 / 程序集 / 类 / 结构体 / 枚举 / 接口 / 方法等，使得程序在运行的时候可以增加新的模块及功能。Natasha 集成了域管理/插件管理，可以实现域隔离，域卸载，热拔插等功能。 该库遵循完整的编译流程，提供完整的错误提示， 可自动添加引用，完善的数据结构构建模板让开发者只专注于程序集脚本的编写，兼容 stanadard2.0 / netcoreapp3.0+, 跨平台，统一、简便的链式 API。 且我们会尽快修复您的问题及回复您的 issue.

Repository: https://github.com/dotnetcore/Natasha
Canonical: https://ross.abutalabs.com/products/natasha
Homepage: https://natasha.dotnetcore.xyz/
Language: C#
License: MIT
License Family: permissive
Topics: il, csharp, roslyn, script, dynamic, dotnetcore, hacktoberfest
Last push: 2026-03-30T04:56:36+00:00

## Health v2 (maintenance only)
Score: 67/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 74, release rhythm 40, longevity 100
- inputs: {"age_days": 3471, "days_push": 156, "days_rel": 658, "gap_med": 0.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1586, forks 232 (observed 2026-08-28T04:05:07.715224+00:00)

## What it is
Natasha is a Roslyn-based C# dynamic assembly building library that lets developers compile and load C# code at runtime, creating domains, assemblies, classes, structs, enums, interfaces, and methods on the fly. It includes domain and plugin management with domain isolation, unloading, and hot-swapping, plus a fluent chain API, automatic reference handling, and full compilation error reporting.

## Use cases
- compile and run C# code dynamically at runtime
- build a plugin system with hot-swappable C# modules
- isolate and unload dynamically loaded assemblies
- generate classes and methods from C# source strings on the fly
- implement scripting support inside a .NET application
- load new features into a running program without restarting
- manage collectible AssemblyLoadContext domains in .NET

## When to choose
- you need runtime C# compilation with a clean fluent API on .NET Core / .NET Standard 2.0+
- you want plugin management with domain isolation, unloading, and hot-swapping
- you need automatic reference resolution and detailed compiler diagnostics for generated code
- you want a cross-platform, actively maintained alternative to raw Roslyn scripting

## When to avoid
- you only need simple configuration-driven behavior that static code or dependency injection can handle
- your target is .NET Framework (pre-Core) rather than netstandard2.0 / netcoreapp3.0+
- you need dynamic compilation in a non-C# .NET language like F# or VB
- you cannot tolerate the overhead or security surface of compiling code at runtime

## Facets
- artifact type: library
- maturity: active
- function: compiler, plugin-system, interpreter, developer-tools
- domain: developer-tools, compilers, programming-languages
- platform: dotnet, cross-platform, windows
- tags: roslyn, csharp, dynamic-compilation, runtime-code-generation, scripting, assembly-building, hot-reload, assembly-unloading, domain-isolation, chain-api, plugins, linux, macos

## Member repositories
- dotnetcore/Natasha (main) score 67

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:07.715224+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:55:27.991497+00:00, confidence not recorded.
  - readme: https://github.com/dotnetcore/Natasha (fetched 2026-08-28T04:05:07.715224+00:00, sha 3e77c3f2f07e)
  - homepage: https://natasha.dotnetcore.xyz/ (fetched 2026-08-29T11:25:57.567474+00:00, sha dd671d65153c)
  - site_page: https://natasha.dotnetcore.xyz/docs (fetched 2026-08-29T11:25:57.569806+00:00, sha 347870972152)
- Data as of 2026-08-30T08:39:29.467469+00:00.
