

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# Roslyn IDE Development Guide67## Architecture Overview89Roslyn uses a **layered service architecture** built on MEF (Managed Extensibility Framework):1011- **Workspaces** (`src/Workspaces/`): Core abstractions — `Workspace`, `Solution`, `Project`, `Document`12- **Features** (`src/Features/`): Language-agnostic IDE features (refactoring, navigation, completion)13- **Analyzers** (`src/Analyzers/`): IDE diagnostic analyzers and code fixes (IDE0xxx diagnostics)14- **CodeStyle** (`src/CodeStyle/`): Code-style analyzer packaging shared with the command-line15- **LanguageServer** (`src/LanguageServer/`): Shared LSP protocol implementation and Roslyn LSP executable (`roslyn-language-server`)16- **EditorFeatures** (`src/EditorFeatures/`): VS Editor integration and text manipulation17- **VisualStudio** (`src/VisualStudio/`): Visual Studio-specific implementations1819### Service Resolution20```csharp21// Workspace services22var service = workspace.Services.GetRequiredService<IMyWorkspaceService>();2324// Language-specific services25var csharpService = workspace.Services.GetLanguageServices(LanguageNames.CSharp)26 .GetRequiredService<IMyCSharpService>();27```2829### MEF Export Patterns30```csharp31// Workspace service (language-agnostic)32[ExportWorkspaceService(typeof(IMyService)), Shared]33internal class MyService : IMyService { }3435// Language service (per-language — never share across C#/VB)36[ExportLanguageService(typeof(IMyService), LanguageNames.CSharp), Shared]37internal class CSharpMyService : IMyService { }3839// Constructor — always include both attributes40[ImportingConstructor]41[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]42public MyService(IDependency dependency) { }43```4445## Resource & Localization4647- UI strings live in `.resx` files (e.g., `AnalyzersResources.resx`, `FeaturesResources.resx`, `WorkspacesResources.resx`)48- Reference via generated designer class: `FeaturesResources.Some_string`49- For localizable strings: `new LocalizableResourceString(nameof(FeaturesResources.Some_string), FeaturesResources.ResourceManager, typeof(FeaturesResources))`50- After modifying `.resx` files, run `dotnet msbuild <path to csproj> /t:UpdateXlf` to update `.xlf` localization files5152## Analyzers & Code Fixes (IDE0xxx)5354- IDE code-style analyzers inherit from `AbstractBuiltInCodeStyleDiagnosticAnalyzer` — not raw `DiagnosticAnalyzer`55- Always provide a `FixAllProvider` for code fixes (typically `WellKnownFixAllProviders.BatchFixer`)56- Diagnostic ID constants live in `src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs`5758## Out-of-Process (OOP) Services5960- ServiceHub components live under `src/Workspaces/Remote/` and have special deployment considerations for .NET Core vs .NET Framework — keep both targets in mind when changing remote services6162## Key Development Patterns6364### TestAccessor Pattern65Expose internal state to tests without making it public:66```csharp67internal class ProductionClass68{69 private int _privateField;7071 internal TestAccessor GetTestAccessor() => new(this);7273 internal readonly struct TestAccessor74 {75 private readonly ProductionClass _instance;76 internal TestAccessor(ProductionClass instance) => _instance = instance;77 internal ref int PrivateField => ref _instance._privateField;78 }79}80```81**TestAccessor calls are forbidden in production code** — enforced by analyzer RS0043.8283### SyntaxGenerator (Language-Agnostic Code Generation)84Use `SyntaxGenerator` to generate code without language-specific knowledge:85```csharp86var generator = SyntaxGenerator.GetGenerator(document);87var methodDecl = generator.MethodDeclaration("MyMethod", ...);88```8990## Coding Conventions9192- **Private fields**: `_camelCase`93- **Naming**: MEF exports match interface names without "I" prefix94- **Null checks**: Use `Contract.ThrowIfNull()` instead of manual null checks95- **Immutability**: All `Document`, `Solution`, `Project` instances are immutable — use `With*` methods96- **Cancellation**: Always thread `CancellationToken` through async operations97- **Performance**: Avoid LINQ in hot paths, prefer `for` loops or `.AsSpan()`, use `ObjectPool<T>`9899## Common Gotchas100101- **ImportingConstructor must be marked `[Obsolete]`** with `MefConstruction.ImportingConstructorMessage`102- **Language services must be exported with a specific language name** — don't use generic exports for both C#/VB103- **Workspace changes must use immutable updates** — `Workspace.SetCurrentSolution()`104
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dotnet/roslynAGENTS.md · 21k | AGENTS.md | buildagent-behaviour | 43/100 | 14 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | today | |
| dotnet/roslyn.github/instructions/Razor.instructions.md · 21k | Copilot instructions | buildstyletypesdo-not+1 | 67/100 | today | |
| dotnet/roslyneng/common/AGENTS.md · 21k | AGENTS.md | no sections | 4/100 | 7 days ago | |
| dotnet/roslyn.github/copilot-instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 89/100 | 8 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 14 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 65 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 14 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | today | |
| rtk-ai/rtk.github/copilot-instructions.md · 76k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 14 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 14 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 13 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 32k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 7 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/dotnet-roslyn-github-instructions-ide-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.