The Power of Roslyn
summary
Shows how to build a real Roslyn analyzer and a code fix that finds every new zero‑length array and replaces it with Array.Empty<T>, using the IOperation array creation node plus the semantic model to get the element type. Uses the Visual Studio SDK templates, Syntax Visualizer, unit tests and F5-debugging to produce a VSIX. The fixer uses the SyntaxGenerator invocation API to synthesize language‑agnostic C# and VB code, checks for System.Array in the compilation, and installs and works in both languages.
AI-written summary · about
chapters (22)
- 0:00Start
- 0:30Agenda
- 4:12What Is an Analyzer
- 7:32Syntax Tree Api
- 8:07The Syntax Tree Api
- 9:07Properties of the Syntax Tree
- 10:07The Semantic Model
- 12:47Recap
- 13:19Syntax Generator
- 15:34Syntax Trees
- 18:57Diagnostic Descriptor
- 21:35Array Creation
- 27:06Unit Test
- 29:34Write a Fix
- 34:33Syntax Visualizer
- 36:54Debugging
- 38:37Build Our Type Expression
- 40:00Generic Expression
- 45:53Replace Node
- 46:09Create a New Document
- 46:44Spelling Mistakes
- 56:05References
related talks
49mRoslyn for the rest of us
01h 00mAutomate Yourself Out of a Job with Roslyn
50mAutomate Yourself Out Of a Job With Roslyn
01h 01mBuilding Code Analyzers with the new C# compiler platform (Roslyn)
57mRoslyn: The Craft of Static Analysis
50mThe Future of C#
01h 16mAutomate yourself out of a job with Roslyn
30mRoslyn for teamlead.If something takes more than 5 minutes -write a script.
