cil

A .net disassembler/decompiler [closed]

送分小仙女□ 提交于 2019-11-26 20:08:44
I am looking for a disassembler or better, a decompiler for .net. The situation is that the source code for an assembly written by one of my predecessors is lost and I'd like to take a look to see what it's doing. I know that ildasm comes with the Visual Studio installation so I can get at the MSIL, but I was hoping there was a program clever enough to work back to the C# code (or best approximation). Are there any tools for this out there? (If not, I suppose it'll be a good excuse for me to sit down and start to learn MSIL) Have you looked at Reflector? http://www.red-gate.com/products

What does beforefieldinit flag do?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 18:23:51
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? See my article on this very issue. Basically, beforefieldinit means "the type can be initialized at any point before any static fields are referenced." In theory that means it can be very lazily initialized - if you call a static method which doesn't touch any fields, the JIT doesn't need to initialize the type. In practice it means that the class is initialized earlier than it would be otherwise - it's okay for it to be initialized at the start of the first

A .net disassembler/decompiler [closed]

谁说我不能喝 提交于 2019-11-26 12:17:10
问题 I am looking for a disassembler or better, a decompiler for .net. The situation is that the source code for an assembly written by one of my predecessors is lost and I\'d like to take a look to see what it\'s doing. I know that ildasm comes with the Visual Studio installation so I can get at the MSIL, but I was hoping there was a program clever enough to work back to the C# code (or best approximation). Are there any tools for this out there? (If not, I suppose it\'ll be a good excuse for me

Java's Virtual Machine and CLR

大憨熊 提交于 2019-11-26 11:44:58
问题 As a sort of follow up to the question called Differences between MSIL and Java bytecode?, what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framework Common Language Runtime (CLR) works? Also, is the .NET framework CLR a \"virtual machine\" or does it not have the attributes of a virtual machine? 回答1: There are a lot of similarities between both implementations (and in my opinion: yes, they're both "virtual machines"). For one thing, they

General purpose FromEvent method

冷暖自知 提交于 2019-11-26 10:28:40
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 Action OnCompletion; } public static Task FromEvent(MyClass obj) { TaskCompletionSource<object> tcs = new TaskCompletionSource<object>(); obj.OnCompletion += () => { tcs.SetResult(null); }; return tcs.Task; } This then allows: await FromEvent(new MyClass()); The problem is that you need to create a new FromEvent method for every event in every class that you would like to await on. That could get really

Call and Callvirt

杀马特。学长 韩版系。学妹 提交于 2019-11-26 08:05:32
问题 What is the difference between the CIL instructions \"Call\" and \"Callvirt\"? 回答1: call is for calling non-virtual, static, or superclass methods, i.e., the target of the call is not subject to overriding. callvirt is for calling virtual methods (so that if this is a subclass that overrides the method, the subclass version is called instead). 回答2: When the runtime executes a call instruction it's making a call to an exact piece of code (method). There's no question about where it exists.

What does beforefieldinit flag do?

不想你离开。 提交于 2019-11-26 07:01:03
问题 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? 回答1: See my article on this very issue. Basically, beforefieldinit means "the type can be initialized at any point before any static fields are referenced." In theory that means it can be very lazily initialized - if you call a static method which doesn't touch any fields, the JIT doesn't need to initialize the type. In practice it means that the class is

Dynamically replace the contents of a C# method?

血红的双手。 提交于 2019-11-26 02:49:14
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) { for (int m = 2; m < n - 1; m += 1) if (m % n == 0) return false; return true; } At run-time, I need to be able to analyse methods that have the Distributed attribute (which I already can do) and then insert code before the body of the function executes and after the function returns. More importantly, I need to be able to do it without modifying code where Solve is called or at the start of the function (at

General purpose FromEvent method

戏子无情 提交于 2019-11-26 02:09:14
问题 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 Action OnCompletion; } public static Task FromEvent(MyClass obj) { TaskCompletionSource<object> tcs = new TaskCompletionSource<object>(); obj.OnCompletion += () => { tcs.SetResult(null); }; return tcs.Task; } This then allows: await FromEvent(new MyClass()); The problem is that you need to create a new

Dynamically replace the contents of a C# method?

拜拜、爱过 提交于 2019-11-26 01:41:15
问题 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) { for (int m = 2; m < n - 1; m += 1) if (m % n == 0) return false; return true; } At run-time, I need to be able to analyse methods that have the Distributed attribute (which I already can do) and then insert code before the body of the function executes and after the function returns. More importantly, I need to