cil

NEO区块链-DAPP开发直通车-第零篇

大城市里の小女人 提交于 2019-12-05 13:49:30
什么是DAPP DAPP 是以太坊发明的词汇 Decentralized Application. 目前基于区块链技术开发的应用程序广泛的接受使用了这一名称。 NEL将为开发DAPP提供全面的服务 什么是NEL NEL是 “NewEconoLab新经济实验室”的简称,成立于2017.11.9日,是一个年轻的社区型组织。 致力于 培养社区开发人才,推动项目落地,发展NEO社区生态 主要活动区域是:https://github.com/NewEconoLab/ NEL会为NEO的DAPP开发提供全面的支持,欢迎学习、交流、参与。 DAPP开发的几种模式 目前DAPP开发有几种模式 之前做了一次基于全节2点开发DAPP的培训,效果不太好。去的人都太帅了,颜值超越了程序员太多。 所以这里补上说明,退一步,更加系统的来说一下DAPP的开发。 很多时候,很多事情,并不是只差一个程序员的状态。往往,你差好几个程序员。 我们将分这几种模式来讨论一下。下文列出的需要程序员都可以一人身兼N职。 模式一、基于全节点客户端开发DAPP 基于全节点客户端开发DAPP是工作量最少的模式,你只需要修改NEO GUI 源码,加上你的DAPP专属的代码. 如果你是要测试一个DAPP的概念,这种方式比较适合,快。 需要程序员: 1.winform 程序员,会c#的程序员多半可以用几个小时掌握winform开发。 2

Where can I find a list of escaped characters in MSIL string constants?

故事扮演 提交于 2019-12-05 12:47:59
问题 I've written a program (in C#) that reads and manipulates MSIL programs that have been generated from C# programs. I had mistakenly assumed that the syntax rules for MSIL string constants are the same as for C#, but then I ran into the following situation: This C# statement string s = "Do you wish to send anyway?"; gets compiled into (among other MSIL statements) this IL_0128: ldstr "Do you wish to send anyway\?" I wasn't expecting the backslash that is used to escape the question mark. Now I

Why the compiler adds an extra parameter for delegates when there is no closure?

人盡茶涼 提交于 2019-12-05 12:05:37
问题 I was playing with delegates and noticed that when I create a Func<int,int,int> like the example below: Func<int, int, int> func1 = (x, y) => x * y; The signature of the compiler generated method is not what I expected: As you can see it takes an object for it's first parameter. But when there is a closure: int z = 10; Func<int, int, int> func1 = (x, y) => x * y * z; Everything works as expected: This is the IL code for the method with extra parameter: .method private hidebysig static int32 '

Is there a generic CIL code to convert any type instance to string?

北战南征 提交于 2019-12-05 10:56:39
Is it possible to write generic CIL instructions which will convert instances of any type (both value and reference) to System.String? In particular, I'm interested in Mono.Cecil code which will inject those instructions into a method. Analyzing a generic method I came up with these Mono.Cecil calls: (it's supposed to convert the i-th method parameter to string) System.Reflection.MethodInfo to_string_method_info = typeof( System.Object ).GetMethod( "ToString" ); Mono.Cecil.MethodReference to_string_reference = injectible_assembly.MainModule.Import( to_string_method_info ); Mono.Cecil

.NET CIL manipulation of evaluation stack

£可爱£侵袭症+ 提交于 2019-12-05 10:51:37
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 display in Console.WriteLine for (int i = 0; i < 3; i++) { int z = some value popped manually from stack; Console.WriteLine(z); } This is the simple main() program I modified: .method private hidebysig static void Main(string[] args) cil managed { .entrypoint .maxstack 5 .locals init ( [0] int32 num, [1] int32 num2) L_0000: ldc.i4.6 //manually push value 6 to stack L_0001: ldc.i4.5 //manually push value

IDE for MSIL

て烟熏妆下的殇ゞ 提交于 2019-12-05 07:23:25
There's any number of questions about MSIL on SO but none that directly answer this. I've been using Textpad which does have a syntax definition file for MSIL and then using ILASM in a command prompt window. I did find a reference to ILIDE but the link is broken. Is there an IDE or add-on / plugin to Visual Studio / Eclipse for MSIL that allows syntax highlighting, intellisense, code completion, debugging etc.? Use MonoDevelop You can build specially MSIL projects. It's very useful for these issues, also you can use it in both Windows and Linux. What is better than this? :) I made an extension

Why does the IL set this value twice?

淺唱寂寞╮ 提交于 2019-12-05 05:38:13
I was trying around a bit with Try Roslyn when I entered this piece of code: using System; using System.Linq; using System.Collections.Generic; using Microsoft.CSharp; public class C { public C() { x = 4; } public int x { get; } = 5; } And it gave me back this code: using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; [assembly: AssemblyVersion("0.0.0.0")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations |

Array of pointers in C++/CLI MSIL assembly

我只是一个虾纸丫 提交于 2019-12-05 03:43:44
I'm trying to wrap some legacy C code for use with C# running on .NET Core. I'm using the approach given here to create a C++ wrapper that compiles to pure MSIL. It's working well for simple functions, but I've found that if my code ever uses pointers-to-pointers or arrays of pointers it will crash with a memory violation. Often it crashes Visual Studio and I have to restart everything, which is tedious. For example, the following code will cause the crashes: public ref class example { public: static void test() { Console::WriteLine("\nTesting pointers."); double a[5] = {5,6,7,8,9}; //Array.

Performance penalty when Generic.List<T>.Add is the the last statement in a function and tailcall optimization is on

旧时模样 提交于 2019-12-05 03:22:21
I've run into a strange performance penalty that I've boiled down to this code: [<Struct>] type Vector3(x: float32, y: float32, z: float32) = member this.X = x member this.Y = y member this.Z = z type Data(n: int) = let positions = System.Collections.Generic.List<Vector3>() let add j = positions.Add (Vector3(j, j, j)) let add1 j = positions.Add (Vector3(j, j, j)); () member this.UseAdd () = for i = 1 to n do add (float32 i) member this.UseAdd1 () = for i = 1 to n do add1 (float32 i) let timeIt name (f: unit -> unit) = let timer = System.Diagnostics.Stopwatch.StartNew() f () printfn "%s: %ims"

How to pin a generic Span<T> instance to work on it with Parallel.For?

梦想与她 提交于 2019-12-05 03:04:35
I'm rewriting some of my extension methods using the new Span<T> type and I'm having trouble finding a way to properly pin a generic instance to be able to use parallel code to work on it. As an example, consider this extension method: public static unsafe void Fill<T>(this Span<T> span, [NotNull] Func<T> provider) where T : struct { int cores = Environment.ProcessorCount, batch = span.Length / cores, mod = span.Length % cores, sizeT = Unsafe.SizeOf<T>(); //fixed (void* p0 = &span.DangerousGetPinnableReference()) // This doesn't work, can't pin a T object void* p0 = Unsafe.AsPointer(ref span