Questions tagged [il]

CIL (Common Intermediate Language) is a low-level language used by Microsoft .NET Framework and Mono.

477 questions
14
votes
4 answers

Visual Studio/RAD support for coding directly in IL?

For the longest time I've been curious to code directly in Intermediate Language as an academic endeavour, to gain a better understanding of what's happening "under the hood". Does anybody provide Visual Studio support for *IL in the form of:…
John K
  • 28,441
  • 31
  • 139
  • 229
14
votes
7 answers

Is an in depth knowledge of IL important for .net development

When I did mostly c++ I though it was critical to know assembly and wrote some non trial asm code just so that I could truly understand what was going on. I now do mostly .net and while I have some understanding of IL I am by no means proficient. …
rerun
  • 25,014
  • 6
  • 48
  • 78
14
votes
15 answers

Should .NET developers *really* be spending time learning C for low-level exposure?

When Joel Spolsky and Jeff Atwood began the disagreement in their podcast over whether programmers should learn C, regardless of their industry and platform of delivery, it sparkled quite an explosive debate within the developer community that…
icelava
  • 9,787
  • 7
  • 52
  • 74
13
votes
2 answers

What OpCodes were introduced in CLR 4.0?

Are there any IL opcodes that are new in .NET 4.0 as compared to 3.5, and if so, where can I find a list of them?
Timwi
  • 65,159
  • 33
  • 165
  • 230
13
votes
6 answers

Can "this" be null in C# virtual methods? What happens with the rest of instance methods?

I was curious if there is a way for this to be null in a virtual method in C#. I assume it is not possible. I saw that in existing code, during a code review and I would like to be 100% sure to comment for its removal, but I would like some…
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
13
votes
2 answers

IL optimization for JIT compilers

I am developing a compiler that emits IL code. It is important that the resulting IL is JIT'ted to the fastest possible machine codes by Mono and Microsoft .NET JIT compilers. My questions are: Does it make sense to optimize patterns…
Denis Yarkovoy
  • 1,277
  • 8
  • 16
13
votes
2 answers

Why does LambdaExpression.Compile() work on iOS (Xamarin)?

Since Xamarin.iOS doesn't support code generation at runtime, why do Compile() and DynamicInvoke() work as expected? For example, the following code works fine: var lambda = Expression.Lambda( Expression.Add( …
Philippe Leybaert
  • 168,566
  • 31
  • 210
  • 223
13
votes
3 answers

When I use is operator why there is only a null-check in IL code?

I was wondering how is is operator implemented in C#.And I have written a simple test program (nothing special, just for demonstration purposes): class Base { public void Display() { Console.WriteLine("Base"); } } class Derived : Base {…
Selman Genç
  • 100,147
  • 13
  • 119
  • 184
13
votes
4 answers

What is the difference between ldc.i4.s and ldc.i4?

I was studying about the Intermediate Language for C#(IL) and came across the following piece of code:- //Add.il //Add Two Numbers .assembly extern mscorlib {} .assembly Add { .ver 1:0:1:0 } .module add.exe .method static void main() cil…
Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97
13
votes
2 answers

Are there other ways of calling an interface method of a struct without boxing except in generic classes?

see code snippet public interface I0 { void f0(); } public struct S0:I0 { void I0.f0() { } } public class A where E :I0 { public E e; public void call() { e.f0(); } } here is IL code for call() .maxstack…
Vince
  • 896
  • 5
  • 18
12
votes
2 answers

Value Type Conversion in Dynamically Generated IL

Update Over a year later, and I finally realized the cause of this behavior. Essentially, an object can't be unboxed to a different type than it was boxed as (even if that type casts or converts to the destination type), and if you don't…
Tim M.
  • 53,671
  • 14
  • 120
  • 163
12
votes
3 answers

How does the Conditional attribute work?

I have some helper methods marked with [Conditional("XXX")]. The intent is to make the methods conditionally compile when only the XXX conditional compilation symbol is present. We're using this for debugging and tracing functionality and it works…
DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233
12
votes
2 answers

Why is 'box' instruction emitted for generic?

Here is fairly simple generic class. Generic parameter is constrained to be reference type. IRepository and DbSet also contain the same constraint. public class Repository : IRepository where TEntity : class, IEntity { …
mikalai
  • 1,746
  • 13
  • 23
12
votes
8 answers

How to pass ctor args in Activator.CreateInstance or use IL?

I need a performance enhanced Activator.CreateInstance() and came across this article by Miron Abramson that uses a factory to create the instance in IL and then cache it. (I've included code below from Miron Abramson's site in case it somehow…
thames
  • 5,833
  • 6
  • 38
  • 45
12
votes
3 answers

Why does C# compiler produce method call to call BaseClass method in IL

Lets say we have following sample code in C#: class BaseClass { public virtual void HelloWorld() { Console.WriteLine("Hello Tarik"); } } class DerivedClass : BaseClass { public override void HelloWorld() { …
Tarik
  • 79,711
  • 83
  • 236
  • 349
1 2
3
31 32