Fast Conversion of Objects to Dictionaries in C# February 28, 2018May 31, 2020Munir Husseini2 Comments Converting (plain old) C# objects to dictionaries is easy with Reflection (e.g., as seen here). But Reflection is rather slow,…
In-Memory Code Generation With .NET – Loading May 2, 2015September 29, 2017Munir HusseiniNo Comments This entry is part 5 of 5 in the series In-Memory Code Generation With .NETThe previous articles from this post series have discussed how to generate .NET types at runtime and how to get…
Reflection Emit: Creating Properties July 21, 2014September 27, 2017Munir Husseini1 Comment For those who need to create a dynamic type in memory using Reflection.Emit and need to add some properties, here…
Reflection Emit and Type Inheritance: Calling Base Type Constructors July 21, 2014August 2, 2019Munir Husseini2 Comments Suppose you want to use Reflection.Emit to generate a dynamic type in memory. Suppose this dynamic type should inherit a…
Roslyn: Compile C# Expressions Without Using the Scripting API May 23, 2014September 27, 2017Munir Husseini2 Comments I have an application that processes table structures. Tables have columns and some columns may contain expressions. For example, an…
Fast Named Format With Linq Expressions May 3, 2014September 29, 2017Munir Husseini7 Comments This article describes how to implement “named format” functionality with C# and Linq Expressions. The .NET Framework supports string formats…
ANTLR cannot generate ‘org.antlr.v4.codegen.CSharp_v4_5_1Target’ code as of version 4.1-SNAPSHOT February 16, 2014Munir Husseini5 Comments Today I tried to create an ANTLR 4 grammar and compile it to C#. Of course, I used Sam Harwell’s…
Add A Namespace Import Via Visual Studio Automation January 20, 2014Munir HusseiniNo Comments Suppose you had a code document represented by a FileCodeModel object. And suppose you were modifying the containing DOM. Sometimes,…
Use T4 Templates For XSLT Transformation September 20, 2013Munir HusseiniNo Comments Suppose you have XSLT style sheets that produce some code from XML files. Now suppose you want to integrate these…
Linq Expressions By Sample: Calling Generic Methods With Lambda Parameters For Unknown Types July 19, 2013Munir Husseini7 Comments Suppose you need to call a generic Method that receives a generic delegate parameter. Now suppose that you neither know…