All posts with Tag Roslyn

Write your own Code Analyzer with Roslyn

We are all familiar with diagnostics that are provided from the compiler when we develop an application, they could be in form of warnings, errors or code suggestions. A diagnostic or code analyzer, inspects our open files for various metrics, like style, maintainability, design, etc. However, sometimes we need to write a tailor-made analysis for our specific situation, tool, or project.

Read the whole article

Preview image blogpost

Changing Syntax Tree uing Roslyn API

A syntax tree has knowledge about the textual content of what it represents and that content relates to C#. There are scenarios that we need to change the code, such as code fixes, refactorings, or advanced source generation, and it could be done through changing the syntax tree; since this is a bidirectional relationship. There are two approaches, Replacement Methods and SyntaxRewriter classes

Read the whole article

Preview image blogpost

Create Syntax Trees using Roslyn APIs

Sometimes when we want to generate code whether it is source generators or code fixes for a code analyzer, it is required to know how a syntax tree could be created using the Roslyn Compiler API. There are two ways, that we will discuss them in this post.

Read the whole article

Creating Code with Code - Introduction to Roslyn

Compilers used to be a black box, they were accepting a bunch of source files as input and were producing an artifact as an output! There were no means of interaction with any of the phases inside the compiler pipeline. However, with Roslyn, The .NET Compiler Platform SDK, it is not the case anymore!

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload x