Which method should you use to get the first collection’s element that meets a certain condition – ‘First‘ or ‘FirstOrDefault‘? What should you choose to get the last element – ‘Last‘ or ‘LastOrDefault‘? At first glance, the choice may not be obvious. Hopefully, this article will answer these questions and […]
C# Code Analysis Using Roslyn Syntax Trivia
Where to start if we want to analyze all the comments in the code? Which syntax tree nodes do we need to traverse to do this? How can we figure out that the analyzed method contains preprocessor directives for conditional compilation? Such elements of the syntax tree as syntax trivia […]
C# Code Analysis Using Roslyn Semantic Model
Introduction In the previous notes, we analyzed the source files, relying entirely on the syntax tree and traversing its nodes. In many cases, traversing a single syntax tree is not enough to perform deep analysis. Here the concept ”semantic model’‘ comes in handy. A semantic model opens up new possibilities […]
C# Code Analysis With Roslyn’s Syntax Trees
Introduction In the previous article, we compared Visual Studio’s templates that one can use to build their own static analyzer. There we detailed how to write your first simple analyzer and talked about how Roslyn maps source code as syntax trees. Now we will talk about syntax tree structure in […]
Creating a Static Analyzer for C# From Project Templates in Visual Studio
”Static code analyzer” sounds a bit complicated, doesn’t it? What if after reading this small note, you will have enough knowledge to create your own static analyzer? Interested? Let’s get started! Overview and Preparation All further static analyzer development will be based on .NET Compiler Platform aka Roslyn. This platform […]
Read large text file batch wise using c#
In this article, I’ll show you how to read a large text file in c#. I will also explain how to create batches for reading a large text file using c#. To read the text file I’ll use CustomFileReader class, where i will implement IEnumerable interface to read batch wise sequential […]
Pass DataTable to Stored Procedure as Parameter in C#
In this article, I am going to explain how to pass DataTable to the stored procedure as a parameter. Here I will also explain how to create user-defined table types, stored procedures as well as reading data from notepads. I have seen, many developers get requirements for getting records from […]
C# | Read Delimited Text File
In this article, I’ll show you how to read a delimited text file in c#. To read the text file I’ll use TextReader class to read a sequential series of characters as well as texts from a text file, this class is found in the System.IO namespace or library. Here, […]






