OllamaCodeFix 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package OllamaCodeFix --version 1.0.5
                    
NuGet\Install-Package OllamaCodeFix -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OllamaCodeFix" Version="1.0.5">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OllamaCodeFix" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="OllamaCodeFix">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OllamaCodeFix --version 1.0.5
                    
#r "nuget: OllamaCodeFix, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OllamaCodeFix@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OllamaCodeFix&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=OllamaCodeFix&version=1.0.5
                    
Install as a Cake Tool

OllamaCodeFix

Roslyn analyzer that detects magic numbers in C# code and suggests meaningful constant names using Ollama (local LLaMA AI).

Features

  • Detects magic numbers (numeric literals other than 0 and 1)
  • Suggests PascalCase constant names based on code context (class, method, parameters, surrounding code)
  • Works in Visual Studio (lightbulb) and via dotnet format (batch mode)
  • Uses local AI — no data sent to external services

Prerequisites

  • Ollama running locally on port 11434
  • Model llama3.1:8b pulled:
ollama pull llama3.1:8b

Or via Docker:

docker run -d -p 11434:11434 --name ollama ollama/ollama
docker exec ollama ollama pull llama3.1:8b

Installation

dotnet add package OllamaCodeFix

Usage

Visual Studio

Magic numbers will show a warning (MAGIC_NUMBER_ISSUE). Click the lightbulb to extract to a named constant with an AI-suggested name.

Command Line (batch)

dotnet format analyzers --diagnostics MAGIC_NUMBER_ISSUE --severity warn

Example

Before:

public decimal CalculateTotal(decimal subtotal, string customerType)
{
    decimal discount = 0;
    if (customerType == "VIP")
        discount = subtotal * 0.15m;
    var tax = subtotal * 0.21m;
    return subtotal - discount + tax;
}

After:

public decimal CalculateTotal(decimal subtotal, string customerType)
{
    const decimal VipDiscountRate = 0.15m;
    const decimal TaxRate = 0.21m;
    decimal discount = 0;
    if (customerType == "VIP")
        discount = subtotal * VipDiscountRate;
    var tax = subtotal * TaxRate;
    return subtotal - discount + tax;
}

Logs

Logs are written to %LOCALAPPDATA%\OllamaCodeFix\:

  • ollama.log — requests/responses to Ollama
  • codefix.log — CodeFix provider activity
  • fixall.log — batch fix activity
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 137 5/2/2026
1.0.6 110 5/1/2026
1.0.5 102 5/1/2026
1.0.4 103 5/1/2026
1.0.3 108 5/1/2026
1.0.2 104 5/1/2026
1.0.1 109 4/30/2026
1.0.0 113 4/29/2026