Skip to content

Fuse for .NET Developers

A. Shafie edited this page Jan 20, 2026 · 2 revisions

The fuse dotnet command is a specialized tool designed to prepare .NET codebases (C#, F#, ASP.NET Core) for Large Language Models (LLMs). It goes beyond simple file concatenation by understanding the structure of C# code and removing "compiler noise" that consumes tokens without adding semantic value.

Why use fuse dotnet?

Standard C# files are verbose. They contain license headers, using statements, namespace indentation, and attributes that are required for the compiler but irrelevant for an AI trying to understand your logic.

Fuse reduces token count by 20-40% on typical .NET projects by stripping this noise while preserving the core logic.

Usage

# Basic usage (smart defaults)
fuse dotnet -d ./src

# Optimize for LLM Context (Recommended)
fuse dotnet -d ./src --all

# Custom configuration
fuse dotnet -d ./src --remove-csharp-comments --remove-csharp-usings

Features

1. Smart Filtering

The .NET template automatically ignores build artifacts and high-noise files that confuse LLMs:

  • Excluded Directories: bin, obj, .vs, TestResults, node_modules, packages.
  • Excluded Files:
    • Binary resources (.resx, .resources)
    • Local config (launchSettings.json, packages.lock.json)
    • Generated code (*.g.cs, *.Designer.cs, *.generated.cs)
    • Web artifacts (*.min.js, *.map)

2. C# Minification

When using specific flags or --all, Fuse applies syntax-aware transformations:

Feature Flag Description
Namespace Flattening --remove-csharp-namespaces Removes namespace X { ... } wrappers and unindents the code by 4 spaces.
Using Removal --remove-csharp-usings Strips all using System...; statements from the top of files.
Comment Removal --remove-csharp-comments Removes //, /* */, and XML documentation ///.
Region Removal --remove-csharp-regions Removes #region and #endregion directives.

3. Aggressive Reduction (--aggressive)

Included in --all, this mode applies heuristics to maximize token density:

  • Attribute Removal: Strips non-functional attributes like [DebuggerDisplay], [Serializable], [MethodImpl]. Functional attributes like [Route] or [JsonProperty] are preserved.
  • Property Compression: Converts expanded auto-properties to single lines:
    // Before
    public int Id
    {
        get;
        set;
    }
    
    // After
    public int Id { get; set; }
  • Keyword Cleanup: Removes redundant this. qualifiers.

Example Output Comparison

Original C# File:

using System;
using System.Diagnostics;

namespace MyApp.Services
{
    /// <summary>
    /// Handles user processing.
    /// </summary>
    public class UserService
    {
        [DebuggerDisplay("User {Id}")]
        public int Id
        {
            get;
            set;
        }

        public void Process()
        {
            // Log the process
            this.Log("Processing...");
        }
    }
}

Fused Output (--all):

public class UserService
{
    public int Id { get; set; }

    public void Process()
    {
        Log("Processing...");
    }
}

Clone this wiki locally