cil Questions

2

Solved

Does the .NET's Virtual Machine compiles the CIL bytecode (and then execute the code at the lowest level - CPU assembler), or it is an interpreter (that reads the following instructions and execute...
Schlesien asked 18/7, 2010 at 11:42

2

Solved

Let's say I have code like: if (someEnumerable.Count() < 2) { // Do something } Would this result in someEnumerable being iterated over fully, or would evaluation complete if Count() reaches a...
Moriahmoriarty asked 25/8, 2023 at 11:51

4

Solved

The following IL code creates a Type instance named (fnptr)* (token 0x2000000 - invalid, module mscorlib.dll). ldtoken method void* ()* call class [mscorlib]System.Type [mscorlib]System.Type::GetT...
Ism asked 28/11, 2014 at 20:28

2

Solved

I'm having a hard time trying to (Dis)assemble a dll using the Visual Studio command prompt, don't look that simple as I see in the microsoft page. I'm using the ildasm for these way: ildasm myLi...
Florinda asked 26/8, 2018 at 5:8

1

I need to create a dynamic .NET delegate with specially marshalled parameters (e.g. [MarshalAs(UnamangedType.LPWStr)]) at runtime using System.Reflection.Emit. This requires me to create a type inh...
Brogle asked 29/7, 2020 at 17:27

3

I'm trying to call the following MSIL method: .method public hidebysig static bool IsRuntimeType(class [mscorlib]System.Type 'type') cil managed { .maxstack 2 ldarg.0 isinst [mscorlib]System.Ru...
Squashy asked 26/4, 2016 at 19:22

4

Solved

What does beforefieldinit flag do? When I look into the IL of my class I see this flag but I don't know what this flag is actually doing?
Fabianfabianism asked 4/3, 2009 at 14:29

3

Solved

Updated with a solution that works for me. See the bottom of this question. Context: I needed a way to evaluate the size of a generic type for the purpose of calculating array lengths to fit withi...
Riddance asked 31/10, 2017 at 0:49

3

Solved

I have reviewed ECMA 335 and I have only found a reference to the .export keyword which seems promising but has very little documentation. I have found similar questions on StackOverflow with respe...
Symploce asked 22/1, 2012 at 0:25

11

What I want to do is change how a C# method executes when it is called, so that I can write something like this: [Distributed] public DTask<bool> Solve(int n, DEvent<bool> callback) { ...
Condescending asked 4/9, 2011 at 12:7

3

Solved

in cil code, ldftn is used to get the function pointer address to call the delegate constructor(i.e. .ctor(object, native int)). How to get the function pointer used to construct delegate in C#?
Culex asked 12/10, 2010 at 14:39

3

Solved

I have a question that I'm very confused about. The way I understand .NET is like this: C# Application (source code) -> csc.exe (compiler) -> .NET application (which is in MSIL) If so, why is...
Ras asked 5/6, 2020 at 22:11

7

Solved

So I am learning MSIL right now to learn to debug my C# .NET applications. I've always wondered: what is the purpose of the stack? Just to put my question in context: Why is there a transfer fro...
Studding asked 24/10, 2011 at 11:58

4

Solved

Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)] attribute. This indicates that the "method is implemented within the common language runtime itself". What ...
Eugene asked 22/6, 2012 at 17:19

1

I'm working on an ILGenerator extension to help emit IL fragments using Expression. Everything was fine, until I worked on the integer conversion part. There are something really counter-intuitive ...
Kyoko asked 27/3, 2020 at 7:26

4

Solved

Using the new async/await model it's fairly straightforward to generate a Task that is completed when an event fires; you just need to follow this pattern: public class MyClass { public event Act...
Witchcraft asked 12/10, 2012 at 19:31

2

Solved

At the bottom of pg 86 in Pro .NET Performance - Optimize Your C# Applications, it talks about the implementaton of ValueType.Equals() and says this: The definition of CanCompareBits and FastEqu...
Solipsism asked 15/12, 2019 at 1:55

1

Solved

I'm trying to pass a readonly struct to a method with in modifier. When I look at generated IL code, it seems that defensive copy of the readonly struct is made. The readonly struct is defined as ...
Pitiful asked 20/7, 2019 at 15:30

2

Solved

In 8.8.4 of the C# specification, it provides this example: A foreach statement of the form foreach (V v in x) embedded-statement is then expanded to: { E e = ((C)(x)).GetEnumerator(); ...
Nugatory asked 15/9, 2019 at 3:38

0

Let's consider some very simple C# code: static void Main(string[] args)         {             int i = 5;             string s = "ABC";             bool b = false;         } Jeffrey Richter's "C...
Periderm asked 5/6, 2019 at 21:32

2

Solved

The question is about C# language specification and CIL language specification, as well as Microsoft's and Mono's C# compiler behavior. I'm building some code analysis tools (no matter what), whi...
Lindsaylindsey asked 23/4, 2019 at 14:33

1

Solved

Some preliminary info Given the following C# function: public static void func<T>(T t) { System.Console.WriteLine(t); } It is compiled into the following CIL: .method public hidebysig s...
Violence asked 26/2, 2019 at 15:3

1

Solved

I am creating a .NET method based on raw IL. I would like to wrap the stand-alone newly created method into a .NET assembly and write this assembly to disk as a foo.dll file in order to then feed t...
Slim asked 4/2, 2019 at 11:6

7

Solved

What is the explanation for the result from the following operation? k += c += k += c; I was trying to understand the output result from the following code: int k = 10; int c = 30; k += c += k ...
Colporteur asked 13/2, 2019 at 16:14

2

Solved

I have this sequence of CIL codes which I injected through the use of Mono.Cecil. However, the modified .NET C# application will not run. Objective: Manually load and pop values from stack to dis...
Chattel asked 17/10, 2012 at 3:3

© 2022 - 2024 — McMap. All rights reserved.