Appearance
Carrot.Data.Scaffold.Compilers.Sinks.FileSystem
net
Compiler sink that writes generated scaffold output files to the local filesystem.
Installation
xml
<ProjectReference Include="..\Carrot.Data.Scaffold.Compilers.Sinks.FileSystem\Carrot.Data.Scaffold.Compilers.Sinks.FileSystem.csproj" />Architecture
How It Works
ScaffoldCompilerSinkFileSystem extends ScaffoldCompilerSink<ScaffoldCompilerSinkFileSystemOptions> and implements Write(bundle).
For each ScaffoldCompilerManifestBundleItem in the bundle:
- Resolves the absolute file path from
FileSystem.ExecutingAssemblyDirectoryGitRoot+ the renderer output's relative path - Ensures the target directory exists (creates it if missing)
- Writes the content string to the file via
File.WriteAllText - Records the folder in the returned
ScaffoldCompilerManifestSink
When DryRun is true, Write returns null immediately - no files are touched.
Options
Enabled(defaulttrue) - master switch; when false, the sink is skipped entirely via theIfEnabledpatternDryRun(defaultfalse) - when true, the sink reports as enabled but does not write any files
Dependencies
| Dependency | Kind |
|---|---|
Carrot.Data.Scaffold.Compilers | project (compiler pipeline framework) |
Build
bash
dotnet buildUsage Guide
Sink that writes generated scaffold code to the local filesystem.
Getting Started
csharp
using Carrot.Data.Scaffold;
using Carrot.Data.Scaffold.Domain;
scaffold.Compiler(compiler =>
{
compiler
.AddModule<MyGraphRoot, MyModule>()
.SinkToFileSystem()
.Build();
});Common Patterns
1. Default (enabled, writes files)
csharp
compiler.SinkToFileSystem();2. With options
csharp
compiler.SinkToFileSystem(options =>
{
options.Enabled = true;
options.DryRun = false;
});3. Dry run mode
csharp
compiler.SinkToFileSystem(options =>
{
options.DryRun = true; // sink is enabled but writes nothing
});4. Manual registration (without extension)
csharp
compiler.SinkTo<ScaffoldCompilerSinkFileSystem, ScaffoldCompilerSinkFileSystemOptions>(options =>
{
options.Enabled = true;
});Tips / Gotchas
- Enabled by default - unlike some sinks,
Enableddefaults totrueandDryRundefaults tofalse, soSinkToFileSystem()with no options will write files. - Paths resolve from git root - all file paths are resolved relative to
FileSystem.ExecutingAssemblyDirectoryGitRoot. The renderer output'sFolderRelativedetermines the target directory. - Directories are created automatically - if the target folder doesn't exist, it is created before writing.
- DryRun still counts as enabled -
IfEnabled()returns the sink even whenDryRunis true. The bundle loop runs, butWritereturnsnullwithout touching disk. This means metadata sinks will still see the module, but no manifest sink result is recorded.