Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>C# X-RayNew to Visual Studio Code? Get it now.
C# X-Ray

C# X-Ray

Mladen Mihajlovic

| (0) | Free
See what the C# compiler produces: browse source generator output in the Explorer.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

C# X-Ray

See the code your source generators write, right in VS Code.

Install from the Visual Studio Marketplace, or search for "C# X-Ray" in VS Code's Extensions view.

[GeneratedRegex], System.Text.Json, [LibraryImport], CommunityToolkit.Mvvm and your own generators all add code to your project that you never see in the Explorer. Visual Studio shows it under Dependencies → Analyzers; VS Code doesn't (microsoft/vscode-dotnettools#362). C# X-Ray adds a Generated Files view that does.

The Generated Files view next to a generated file open in the editor

Features

  • Every generated file, by project and generator. Find what a generator produced without building or digging through obj/.
  • Live code. Files open straight from the C# language server, with colors, hover and Go to Definition. What you see is what the compiler sees right now.
  • One entry per file, even with several target frameworks. A project that targets net8.0 and net9.0 appears once. If a file's code differs between frameworks, it expands so you can open each version.
  • Stays up to date. The view refreshes after you save, build or change files.
  • Lightweight. No extra .NET process, no files written into your project, no settings changed.

Getting started

  1. Install C# X-Ray from the Marketplace. It installs the C# extension too if you don't have it. C# Dev Kit is optional.
  2. Open a folder with a C# project.
  3. In the Explorer sidebar, expand Generated Files. (Drag it higher if you like.)

The files appear once the C# extension has loaded your projects. On a big solution that can take a minute.

Using the view

Click a file Opens the generated code. For a project with several frameworks, it opens the newest framework's version.
"differs by framework" Expand the file to open the version for a specific framework.
A framework next to a file The file is only generated for that framework.
↻ Refresh Reloads the list.
▷ Rerun Source Generators Asks the C# extension to run the generators again, then reloads the list.

When a change doesn't show up

By default, the C# extension reruns generators when you save, build or press Rerun Source Generators, not while you type. A file you just deleted or renamed stays in the list until one of those happens.

If a change is missing, press Rerun Source Generators (▷) in the view's title bar. To have generators run as you type instead, set this, then restart VS Code (it uses more CPU):

"dotnet.server.sourceGeneratorExecution": "Automatic"

Settings

Setting Default
csharpXray.autoRefresh true Refresh the view after saves, file changes and builds. When off, use the Refresh button.

Troubleshooting

  • "Looking for generated files…" doesn't go away. The C# extension is still loading your projects. If it can't load them, C# X-Ray says so at the top of the view after 30 seconds. Check the C# extension's output or status bar.
  • A file is missing. Files that contain no types or members (for example only [assembly: …] attributes) can't be found yet; see Known limitations.
  • Something else looks wrong. The C# X-Ray output panel shows when and why the view refreshed, and how long each lookup took.

Known limitations

  • The C# extension has no way to list generated files, so C# X-Ray finds them through symbol search. A generated file that declares no types or members won't show up.
  • If the C# extension finds nothing, the view falls back to files written to obj/ by <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>. Those come from your last build and can be out of date; the view says so at the top.
  • In a project with several target frameworks, a save may update only one framework's version, so a file can show "differs by framework" until you build or press Rerun Source Generators.
  • Breakpoints in generated files probably don't work yet.

Coming later

Ideas for more C# X-Ray views, such as a syntax tree viewer and an IL / lowered C# viewer, are in ROADMAP.md.

Development

npm install
npm test                                # unit tests
npm run test:integration                # opens VS Code on sample/ with your installed C# extension
WITH_DEVKIT=1 npm run test:integration  # the same, with C# Dev Kit
npm run package                         # builds csharp-xray-<version>.vsix

Press F5 in VS Code to try the extension on the sample/ project.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft