Agent skill

Corvus Xplat Dynamic Compilation

by corvus-dotnet in corvus-dotnet/Corvus.JsonSchema

Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481).

Apache-2.0Auto-check passedDevelopment

Install Corvus Xplat Dynamic Compilation

skills CLI
$ npx skills add corvus-dotnet/Corvus.JsonSchema --skill corvus-xplat-dynamic-compilation -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install corvus-dotnet/Corvus.JsonSchema corvus-xplat-dynamic-compilation --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/corvus-dotnet/Corvus.JsonSchema.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/corvus-xplat-dynamic-compilation .claude/skills/corvus-xplat-dynamic-compilation && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
corvus-xplat-dynamic-compilation
GitHub stars
199
Token cost
~2.5k tokens
SKILL.md length
667 words
Files
1
Skills in repo
28
Repo updated
First seen
Licence
Apache-2.0

At a glance

Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481).

  • Works in 3 steps: DependencyContext → Always supplement (AppDomain replaces… → Directory scan + transitive resolution
  • : modifying any code that calls CSharpCompilation.Create with dynamically resolved MetadataReferences
  • SKILL.md covers Background, Affected Sites, The Three-Phase Pattern and DynamicCompiler Differences, plus 5 more sections
  • Calls dotnet

What it does

Corvus Xplat Dynamic Compilation is an agent skill from corvus-dotnet/Corvus.JsonSchema. Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481). Covers the three-phase reference resolution pattern (DependencyContext → AppDomain replacement → directory scan + transitive), the facade vs GAC mscorlib problem, all six affected sites, and local WSL testing. USE FOR: modifying any code that calls CSharpCompilation.Create with dynamically resolved MetadataReferences, adding new dynamic compilation sites, debugging CS0012 or CS1705 errors…

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Project scaffolding. The repository describes itself as: Support for Json Schema validation and entity generation. The licence is Apache-2.0.

When your agent uses it

  • : modifying any code that calls CSharpCompilation.Create with dynamically resolved MetadataReferences
  • Adding new dynamic compilation sites
  • Debugging CS0012
  • CS1705 errors in CodeGenConformanceFixture

Example prompts

  • “/corvus-xplat-dynamic-compilation”

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. DependencyContext
  2. Always supplement (AppDomain replaces facades)
  3. Directory scan + transitive resolution

What it can do on your machine

Read from SKILL.md and the folder at commit 973097f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Corvus Xplat Dynamic Compilation loads about 2.5k tokens when it runs. Until then it costs about 181 tokens; SKILL.md has 667 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~181
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from corvus-dotnet/Corvus.JsonSchema at commit 973097f, republished under its Apache-2.0 licence (© corvus-dotnet). 667 words, ~2,475 tokens.

Download SKILL.mdSave it as .claude/skills/corvus-xplat-dynamic-compilation/SKILL.md (or your agent's skills folder).
name
corvus-xplat-dynamic-compilation
description
Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481). Covers the three-phase reference resolution pattern (DependencyContext → AppDomain replacement → directory scan + transitive), the facade vs GAC mscorlib problem, all six affected sites, and local WSL testing. USE FOR: modifying any code that calls CSharpCompilation.Create with dynamically resolved MetadataReferences, adding new dynamic compilation sites, debugging CS0012 or CS1705 errors in CodeGenConformanceFixture or DynamicCompiler tests. DO NOT USE FOR: source generator development (use corvus-codegen), Roslyn analyzer authoring (use corvus-analyzers).

Cross-Platform Dynamic Roslyn Compilation

Background

The CI pipeline builds once on Ubuntu Linux, caches the build artifacts, and runs a test matrix across Ubuntu (net10.0) and Windows (net10.0 + net481). Six sites in the codebase dynamically compile C# via Roslyn at test time. On net481, these need correct metadata references to framework assemblies (mscorlib, netstandard) that live in the GAC on Windows but are not in the Linux-built output directory.

See docs/CrossPlatformDynamicCompilation.md for the full writeup including failure mode descriptions and error examples.

Affected Sites

FileContext
src/Corvus.Text.Json.Validator/.../DynamicCompiler.csProduction: runtime schema validation
tests/Corvus.Text.Json.JMESPath.CodeGeneration.Tests/CodeGenConformanceFixture.csTest fixture
tests/Corvus.Text.Json.Jsonata.CodeGeneration.Tests/CodeGenConformanceFixture.csTest fixture
tests/Corvus.Text.Json.JsonLogic.CodeGeneration.Tests/CodeGenConformanceFixture.csTest fixture
tests/Corvus.Text.Json.JsonPath.CodeGeneration.Tests/CodeGenConformanceFixture.csTest fixture
tests-v4/Corvus.Json.Specs.Tests/Drivers/JsonSchemaBuilderDriver.csV4 test driver

Three SourceGeneratorDiagnosticTests.cs files also compile dynamically but only run on net10.0 using TRUSTED_PLATFORM_ASSEMBLIES — they are not affected.

The Three-Phase Pattern

All six sites MUST follow this exact pattern. Do not deviate.

Phase 1: DependencyContext
csharp
DependencyContext? ctx = DependencyContext.Load(Assembly.GetExecutingAssembly())
    ?? DependencyContext.Default;

List<MetadataReference> references;
List<string> defines = ["DYNAMIC_BUILD"];

if (ctx is not null)
{
    references = (
        from l in ctx.CompileLibraries
        from r in TryResolveReferencePaths(l)
        select (MetadataReference)MetadataReference.CreateFromFile(r)).ToList();

    // CRITICAL: always capture defines — they include NETFRAMEWORK, NET481, etc.
    defines.AddRange(ctx.CompilationOptions.Defines.Where(d => d is not null)!);
}
else
{
    references = [];
}

Key points:

  • TryResolveReferencePaths wraps ResolveReferencePaths() in try/catch for InvalidOperationException
  • Always capture defines from ctx.CompilationOptions.Defines — they gate #if NETFRAMEWORK code
  • DependencyContext may resolve NuGet packages with newer APIs (e.g., AggressiveOptimization) — these MUST be preserved
Phase 2: Always supplement (AppDomain replaces facades)
csharp
// ALWAYS call — no conditional gate
SupplementWithDirectoryAndAppDomain(references);

CRITICAL: No hasFrameworkAssembly check. An earlier approach checked whether mscorlib/System.Runtime/netstandard was already in the refs and skipped supplementing if so. This failed because DependencyContext can resolve a facade mscorlib (version 2.0.0.0) from the NuGet reference assemblies package, which passes the name check but causes CS1705 version mismatch at compile time.

Within SupplementWithDirectoryAndAppDomain, AppDomain assemblies replace any existing ref with the same name:

csharp
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
    if (!a.IsDynamic && !string.IsNullOrEmpty(a.Location))
    {
        string name = a.GetName().Name
            ?? Path.GetFileNameWithoutExtension(a.Location);

        if (!seenNames.Add(name))
        {
            // Replace DependencyContext ref — AppDomain has the real
            // GAC assembly (mscorlib 4.0.0.0), not a facade (2.0.0.0)
            references.RemoveAll(r =>
                r is PortableExecutableReference peRef &&
                peRef.FilePath is string p &&
                Path.GetFileNameWithoutExtension(p)
                    .Equals(name, StringComparison.OrdinalIgnoreCase));
        }

        references.Add(MetadataReference.CreateFromFile(a.Location));
    }
}

The key insight: seenNames.Add(name) returns false when the name already exists from DependencyContext. In that case we remove the old ref and add the AppDomain version. For new names (framework assemblies not resolved by DependencyContext), we just add them.

Phase 3: Directory scan + transitive resolution

After AppDomain assemblies:

  1. Directory scan — enumerate *.dll in AppDomain.CurrentDomain.BaseDirectory, validate each with AssemblyName.GetAssemblyName() (skips native DLLs), add if not yet seen.

  2. Transitive resolution — iterate GetReferencedAssemblies() on all loaded assemblies, Assembly.Load() each, add if not yet seen. This catches netstandard.dll (a facade in the GAC, not loaded at startup, not in the output dir).

DynamicCompiler Differences

The production DynamicCompiler in Corvus.Text.Json.Validator has extra complexity beyond the test fixtures:

  • Takes a hostAssembly parameter (the assembly whose schema types are being validated)
  • Caches (MetadataReferences, Defines) per host assembly via ConcurrentDictionary
  • On .NET 8+, uses a collectible AssemblyLoadContext to avoid memory leaks
  • Falls back to hostAssembly.Location directory if BaseDirectory is unavailable (shadow-copy scenarios)
  • Has a separate ResolveTransitiveReferences method using a Queue<AssemblyName> BFS

Despite these differences, the three-phase pattern is identical.

Show full SKILL.md (251 more words)Show less

Common Errors and Root Causes

ErrorRoot Cause
CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard'netstandard.dll missing — transitive resolution not running or not finding it
CS1705: Assembly 'System.Text.Json' uses 'mscorlib, Version=4.0.0.0' which has a higher version than referenced assembly 'mscorlib' with identity 'mscorlib, Version=2.0.0.0'Facade mscorlib from NuGet ref assemblies; AppDomain replacement not running
CS0117: 'MethodImplOptions' does not contain a definition for 'AggressiveOptimization'NuGet package refs were replaced instead of supplemented; DependencyContext refs with newer APIs lost
CS0009: PE image doesn't contain managed metadataNative DLL added as MetadataReference; need AssemblyName.GetAssemblyName() validation

Anti-Patterns

❌ Conditional supplement gate
csharp
// DON'T DO THIS — facade mscorlib passes the check
bool hasFramework = references.Any(r => /* name == "mscorlib" */);
if (!hasFramework)
{
    SupplementWithDirectoryAndAppDomain(references);
}
❌ Replace all DependencyContext refs
csharp
// DON'T DO THIS — loses NuGet package refs with newer APIs
if (!hasFramework)
{
    references = BuildReferencesFromDirectoryAndAppDomain();
}
❌ Skip defines when supplementing
csharp
// DON'T DO THIS — loses NETFRAMEWORK, NET481 etc.
if (refs.Count > 0 && hasSystemObject)
{
    return (refs, ["DYNAMIC_BUILD"]);  // Missing ctx.CompilationOptions.Defines
}

Local Testing (WSL)

To reproduce the cross-OS CI scenario locally:

powershell
# 1. Build in WSL (Linux)
wsl -d Ubuntu-22.04 -- bash -c "
  cd /mnt/d/source/corvus-dotnet/Corvus.JsonSchema &&
  dotnet restore --force Corvus.Text.Json.slnx &&
  dotnet build Corvus.Text.Json.slnx -c Release"

# 2. Test ALL FOUR fixtures + V4 on net481 (must all pass)
dotnet test --project tests\Corvus.Text.Json.JMESPath.CodeGeneration.Tests `
  -f net481 -c Release --filter "TestCategory!=outerloop" --no-build
dotnet test --project tests\Corvus.Text.Json.Jsonata.CodeGeneration.Tests `
  -f net481 -c Release --filter "TestCategory!=outerloop" --no-build
dotnet test --project tests\Corvus.Text.Json.JsonLogic.CodeGeneration.Tests `
  -f net481 -c Release --filter "TestCategory!=outerloop" --no-build
dotnet test --project tests\Corvus.Text.Json.JsonPath.CodeGeneration.Tests `
  -f net481 -c Release --filter "TestCategory!=outerloop" --no-build
dotnet test --project tests-v4\Corvus.Json.Specs.Tests `
  -f net481 -c Release --filter "TestCategory!=outerloop" --no-build

CRITICAL: test ALL five projects, not just one. Different fixtures exercise different generated code patterns. A fix that works for JMESPath may fail for Jsonata (different API usage in generated code).

Adding a New Dynamic Compilation Site

If you need to add a new test fixture that dynamically compiles C#:

  1. Copy the BuildCompilationContext and SupplementWithDirectoryAndAppDomain methods from one of the existing fixtures (JMESPath is the simplest template)
  2. Include TryResolveReferencePaths (the try/catch wrapper)
  3. Ensure DYNAMIC_BUILD is always in the defines list
  4. Use CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview).WithPreprocessorSymbols(defines) for parsing
  5. Test with WSL build + Windows net481 execution before pushing
  6. Add the new site to the table in docs/CrossPlatformDynamicCompilation.md

Cross-References

  • Full documentation: docs/CrossPlatformDynamicCompilation.md
  • CI workflow: .github/workflows/build.yml
  • ZeroFailed config: .zf/config.ps1
  • Build and test skill: corvus-build-and-test

© corvus-dotnet, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/corvus-xplat-dynamic-compilation of corvus-dotnet/Corvus.JsonSchema.

Open the folder on GitHubat commit 973097f

Compare with similar skills

Corvus Xplat Dynamic Compilation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Corvus Xplat Dynamic Compilation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Corvus Xplat Dynamic Compilation this skillcorvus-dotnet/Corvus.JsonSchema199—~2.5kAutomated safety check: PassApache-2.0
Nx Generatenomcopter/react-mosaic4.8k7 repos~1.9kAutomated safety check: PassCustom licence
PonytailDavidObando/gsharp5648 repos~1.7kAutomated safety check: PassMIT
Run Nx Generatornrwl/nx29k2 repos~592Automated safety check: NotesMIT
Conductor Setupgemini-cli-extensions/conductor3.8k—~4.2kAutomated safety check: PassApache-2.0
Mirage VFS Adapter Authoringstrukto-ai/mirage3.7k—~2.5kAutomated safety check: PassApache-2.0

Similar skills

  • Nx Generate

    nomcopter/react-mosaic

    Generate code using nx generators. An agent skill from nomcopter/react-mosaic.

    4.8k GitHub starsUsed in 7 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Ponytail

    DavidObando/gsharp

    Forces the laziest solution that actually works, simplest, shortest, most minimal.

    564 GitHub starsUsed in 8 repos~1.7k tokens
    DevelopmentAuto-check passed
  • Run Nx generators with prioritization for workspace-plugin generators.

    29k GitHub starsUsed in 2 repos~592 tokens
    DevelopmentAuto-check: notes
  • Conductor Setup

    gemini-cli-extensions/conductor

    Scaffolds the project and sets up the Conductor environment.

    3.8k GitHub stars~4.2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Builds or extends a custom Mirage virtual filesystem adapter for an API, database, object store or app data, with a working mount configuration and filesystem tests.

    3.7k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Enforces this repository's TypeScript backend module architecture under server/: feature folders, barrel exports, and where shared types and utilities belong.

    14k GitHub stars~1.2k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from corvus-dotnet/Corvus.JsonSchema

All 28 skills in this repo
  • Corvus Analyzers

    corvus-dotnet/Corvus.JsonSchema

    Understand and work with the Roslyn analyzers shipped with Corvus.Text.Json.

    199 GitHub stars~876 tokensUpdated today
    Auto-check passed
  • Corvus Benchmarks

    corvus-dotnet/Corvus.JsonSchema

    Run, interpret, and maintain BenchmarkDotNet benchmarks for JSON Schema validation and query languages.

    199 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Corvus Bowtie Testing

    corvus-dotnet/Corvus.JsonSchema

    Test Corvus.JsonSchema against the JSON Schema Test Suite using Bowtie, the cross-implementation meta-validator.

    199 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Corvus Buffer And Pooling

    corvus-dotnet/Corvus.JsonSchema

    Write allocation-efficient buffer code in Corvus.JsonSchema using the codebase's established three-tier pooling pattern: stackalloc → ArrayPool → ThreadStatic caches.

    199 GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Corvus Bytes To Bytes

    corvus-dotnet/Corvus.JsonSchema

    Eliminate hand-rolled POCO record<-document string seams — types/paths that materialize a managed string (or List<string/Dictionary) between a bytes SOURCE (a parsed UTF-8 body, a DB column, a…

    199 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Corvus Codegen

    corvus-dotnet/Corvus.JsonSchema

    Generate strongly-typed C from JSON Schema using the Roslyn source generator or the corvusjson CLI tool.

    199 GitHub stars~2.1k tokensUpdated today
    Auto-check passed

Categories

Questions about Corvus Xplat Dynamic Compilation

What does Corvus Xplat Dynamic Compilation do?

Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481). JsonSchema. Resolve Roslyn metadata references for dynamic compilation in cross-OS CI scenarios (build on Ubuntu, test on Windows net481).

When should I use Corvus Xplat Dynamic Compilation?

Corvus Xplat Dynamic Compilation fits situations like: : modifying any code that calls CSharpCompilation.Create with dynamically resolved MetadataReferences; adding new dynamic compilation sites; debugging CS0012; CS1705 errors in CodeGenConformanceFixture.

How do I install Corvus Xplat Dynamic Compilation in Claude Code?

Run `npx skills add corvus-dotnet/Corvus.JsonSchema --skill corvus-xplat-dynamic-compilation -a claude-code`. Or copy the skill folder (.github/skills/corvus-xplat-dynamic-compilation in corvus-dotnet/Corvus.JsonSchema) into .claude/skills/corvus-xplat-dynamic-compilation in your project. Claude Code loads it when a task matches its description.

How do I install Corvus Xplat Dynamic Compilation in Codex?

Run `npx skills add corvus-dotnet/Corvus.JsonSchema --skill corvus-xplat-dynamic-compilation -a codex`. Or copy the skill folder (.github/skills/corvus-xplat-dynamic-compilation in corvus-dotnet/Corvus.JsonSchema) into .agents/skills/corvus-xplat-dynamic-compilation in your project. Codex loads it when a task matches its description.

Can I use Corvus Xplat Dynamic Compilation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add corvus-dotnet/Corvus.JsonSchema --skill corvus-xplat-dynamic-compilation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/corvus-xplat-dynamic-compilation, .gemini/skills/corvus-xplat-dynamic-compilation, .github/skills/corvus-xplat-dynamic-compilation and .opencode/skills/corvus-xplat-dynamic-compilation in your project.

What does Corvus Xplat Dynamic Compilation need to run?

Going by SKILL.md and its folder, Corvus Xplat Dynamic Compilation needs the command-line tools its instructions call (dotnet).

Does Corvus Xplat Dynamic Compilation access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Corvus Xplat Dynamic Compilation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Corvus Xplat Dynamic Compilation use?

Corvus Xplat Dynamic Compilation is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Corvus Xplat Dynamic Compilation use?

About 2.5k tokens (SKILL.md is roughly 9.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Corvus Xplat Dynamic Compilation?

Skills that share tags, products or a category with Corvus Xplat Dynamic Compilation: Nx Generate (nomcopter/react-mosaic, 4.8k stars), Ponytail (DavidObando/gsharp, 564 stars), Run Nx Generator (nrwl/nx, 29k stars) and Conductor Setup (gemini-cli-extensions/conductor, 3.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Corvus Xplat Dynamic Compilation?

corvus-dotnet (a GitHub organization) maintains it in corvus-dotnet/Corvus.JsonSchema, which has 199 GitHub stars. The repository holds 28 skills in this directory. The repository was last updated on October 9, 2026.

Source: corvus-dotnet/Corvus.JsonSchema on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.