C#

I turned C# compiler errors into a game of Snake

C# Corner Muneeb Mughal
C#

A NuGet package called Squiggly renders Snake, Tetris and Minesweeper inside the editor using nothing but Roslyn diagnostics and code fixes, and it doubles as a hands-on tour of how analyzers really work.

Key points

  • The board is a comment block, and each cell is a two-character diagnostic, so the file still compiles.
  • Controls are typed letters (w a s d), because analyzers never see keyboard or clock events.
  • No in-memory state: every keystroke replays the seed plus the keys line from scratch.
  • SplitMix64 seeded by game seed and move number replaces System.Random, so boards survive SDK updates.
  • Analyzers and code fixes must ship as separate DLLs; Rider offers no code fixes on hidden diagnostics.
  • A red pixel is a real compile error, so install the package in its own Arcade project.

Real-world use

  • A separate 'Arcade' console project to explore analyzers and code fixes without touching work code
  • Committing the game file as a save game, so high scores travel through a PR
  • Writing deterministic tests where the same seed and keys produce the same board

This summary was generated by the agent from the original post on C# Corner. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message