Mono.Cecil – Generics

Till now we saw an overview on Cecil and two simple examples. Today I want to show how you can handle generics in Cecil.

For the example I’m going to use EqualityComparer<> Continue reading

Posted in .NET, c# | Tagged , , , | Leave a comment

Value type methods – call, callvirt, constrained and hidden boxing

Long time ago I wrote a post here on  call vs callvirt and the needed of the this null check. Here I want to wrote about this topic but on value types.

Look on these three ToString() calls: Continue reading

Posted in .NET, c#, Roslyn | Tagged , , , , , , , | 4 Comments

Make method static with Roslyn

Before Roslyn days, this was not easy to do that, like others re factoring.

Fortunately we have R# for this.

But now it’s not so hard to re factor an instance method into static method.

I wrote a rewriter that convert any Continue reading

Posted in .NET, c#, Roslyn | Tagged , , , , , | Leave a comment

What is the @ sign before a variable name

You probably saw this at least once

var @delegate = ...

Or especially in generated code (like if you let R# to do some rewriting for you) you can see

var @t = ...

So, what is it? the simple answer is the ‘@’ sign can be added to a reserved word and then you can define for example variable that with the name “@delegate” but you can not define “delegate” variable.

But what special with ‘@’ ? you can add any other characters like “_delegate”?

It’s indeed different because when you add the ‘@’ sign, in the assembly the variable name is Continue reading

Posted in .NET, c# | Tagged , , , , | Leave a comment