ROTOR

ROTOR

The simple compile-time resource linker for C#.

Read Me

Rotor is a Roslyn based linker tool that allows you to embed and access arbitrary resource files in your C# project as strongly typed references.

This makes it easy to bundle files directly into your assemblies and access them from code via a simple syntax like Resources.MyFile.


✨ Features

  • Embed arbitrary files (e.g., .json, .bin, .png, .zip, etc.).
  • Automatically generate code to access files.
  • Zero runtime dependencies, all files are statically linked in at compile-time.
  • Easy access from your C# code: Resources.MyFile.

🔧 Setup

1. Reference the Analyzer Project

Add the following to your .csproj to reference the Resource Linker as an analyzer:

<ProjectReference Include="..\Rotor.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

This ensures the analyzer runs at build time without being included in your app’s output.

2. Include Your Resource Files

Add an <ItemGroup> to your .csproj to include resource files:

<ItemGroup>
  <AdditionalFiles Include="Resources\*.*" />
</ItemGroup>

This allows the analyzer to detect and generate code for all files placed in the Resources folder.

3. Create a Resources Folder

In your project, create a Resources directory and add any files you want to access:

MyProject/
├── Resources/
│   ├── Config.json
│   ├── Help.md
│   └── Logo.png

Source Code