diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProvider.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProvider.cs
new file mode 100644
index 00000000..116847eb
--- /dev/null
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProvider.cs
@@ -0,0 +1,451 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
+{
+ public abstract class CodeProvider
+ {
+ ///
+ /// Gets the
+ ///
+ /// The CS harp.
+ public static CodeProviders.CSharpCodeProvider CSharp { get; } = new CodeProviders.CSharpCodeProvider();
+
+ public abstract string Title { get; }
+ public abstract string CodeFileExtension { get; }
+
+ protected abstract string GetAccessModifiersInternal(bool isPublic, bool isFamily, bool isAssembly, bool isPrivate, bool isAbstract, bool isSealed);
+
+ public string GetAccessModifiers(EventInfo ei)
+ {
+ MethodInfo miAdd = ei.GetAddMethod();
+ MethodInfo miRemove = ei.GetRemoveMethod();
+ MethodInfo miRaise = ei.GetRaiseMethod();
+
+ bool IsPublic = false;
+ bool IsFamily = false;
+ bool IsAssembly = false;
+ bool IsPrivate = false;
+
+ if (miAdd != null)
+ {
+ IsPublic = miAdd.IsPublic;
+ IsFamily = miAdd.IsFamily;
+ IsAssembly = miAdd.IsAssembly;
+ IsPrivate = miAdd.IsPrivate;
+ }
+ else if (miRemove != null)
+ {
+ IsPublic = miRemove.IsPublic;
+ IsFamily = miRemove.IsFamily;
+ IsAssembly = miRemove.IsAssembly;
+ IsPrivate = miRemove.IsPrivate;
+ }
+ else if (miRaise != null)
+ {
+ IsPublic = miRaise.IsPublic;
+ IsFamily = miRaise.IsFamily;
+ IsAssembly = miRaise.IsAssembly;
+ IsPrivate = miRaise.IsPrivate;
+ }
+ else
+ {
+ }
+
+ return GetAccessModifiersInternal(IsPublic, IsFamily, IsAssembly, IsPrivate, false, false);
+ }
+ public string GetAccessModifiers(MethodInfo mi)
+ {
+ bool IsPublic = mi.IsPublic;
+ bool IsFamily = mi.IsFamily;
+ bool IsAssembly = mi.IsAssembly;
+ bool IsPrivate = mi.IsPrivate;
+ return GetAccessModifiersInternal(IsPublic, IsFamily, IsAssembly, IsPrivate, mi.IsAbstract, false);
+ }
+ public string GetAccessModifiers(FieldInfo mi)
+ {
+ bool IsPublic = mi.IsPublic;
+ bool IsFamily = mi.IsFamily;
+ bool IsAssembly = mi.IsAssembly;
+ bool IsPrivate = mi.IsPrivate;
+ return GetAccessModifiersInternal(IsPublic, IsFamily, IsAssembly, IsPrivate, false, false);
+ }
+ public string GetAccessModifiers(PropertyInfo mi)
+ {
+ bool IsPublic = (mi.GetGetMethod()?.IsPublic).GetValueOrDefault() || (mi.GetSetMethod()?.IsPublic).GetValueOrDefault();
+ bool IsFamily = (mi.GetGetMethod()?.IsFamily).GetValueOrDefault() && (mi.GetSetMethod()?.IsFamily).GetValueOrDefault();
+ bool IsAssembly = (mi.GetGetMethod()?.IsAssembly).GetValueOrDefault() && (mi.GetSetMethod()?.IsAssembly).GetValueOrDefault();
+ bool IsPrivate = (mi.GetGetMethod()?.IsPrivate).GetValueOrDefault() && (mi.GetSetMethod()?.IsPrivate).GetValueOrDefault();
+ return GetAccessModifiersInternal(IsPublic, IsFamily, IsAssembly, IsPrivate, false, false);
+ }
+ public string GetAccessModifiers(Type mi)
+ {
+ bool IsPublic = mi.IsPublic;
+ bool IsAbstract = mi.IsAbstract;
+ bool IsSealed = mi.IsSealed;
+ return GetAccessModifiersInternal(IsPublic, false, false, false, IsAbstract, IsSealed);
+ }
+
+ protected abstract string GetBeginBlockInternal(int indentLevel);
+ public string GetBeginBlock(int indentLevel)
+ {
+ return GetBeginBlockInternal(indentLevel);
+ }
+ protected abstract string GetBeginBlockInternal(Type type, int indentLevel);
+ public string GetBeginBlock(Type type, int indentLevel)
+ {
+ return GetBeginBlockInternal(type, indentLevel);
+ }
+ protected abstract string GetEndBlockInternal(string elementName, int indentLevel);
+ public string GetEndBlock(Type type, int indentLevel)
+ {
+ return GetEndBlockInternal(GetElementName(type), indentLevel);
+ }
+
+ protected abstract string GetBeginBlockInternal(System.Reflection.MethodInfo mi, int indentLevel);
+ public string GetBeginBlock(System.Reflection.MethodInfo mi, int indentLevel)
+ {
+ return GetBeginBlockInternal(mi, indentLevel);
+ }
+ protected abstract string GetEndBlockInternal(System.Reflection.MethodInfo mi, int indentLevel);
+ public string GetEndBlock(System.Reflection.MethodInfo mi, int indentLevel)
+ {
+ return GetEndBlockInternal(GetElementName(mi), indentLevel);
+ }
+
+ protected abstract string GetElementNameInternal(System.Reflection.MethodInfo mi);
+ public string GetElementName(System.Reflection.MethodInfo mi)
+ {
+ return GetElementNameInternal(mi);
+ }
+ protected abstract string GetElementNameInternal(Type type);
+ public string GetElementName(Type type)
+ {
+ return GetElementNameInternal(type);
+ }
+
+ protected abstract string GetSourceCodeInternal(Type mi, int indentLevel);
+ public string GetSourceCode(Type mi, int indentLevel)
+ {
+ return GetSourceCodeInternal(mi, indentLevel);
+ }
+ protected abstract string GetSourceCodeInternal(System.Reflection.EventInfo item, int indentLevel);
+ public string GetSourceCode(System.Reflection.EventInfo item, int indentLevel)
+ {
+ return GetSourceCodeInternal(item, indentLevel);
+ }
+ protected abstract string GetSourceCodeInternal(System.Reflection.FieldInfo mi, int indentLevel);
+ public string GetSourceCode(System.Reflection.FieldInfo mi, int indentLevel)
+ {
+ return GetSourceCodeInternal(mi, indentLevel);
+ }
+ protected abstract string GetSourceCodeInternal(System.Reflection.MethodInfo mi, int indentLevel);
+ public string GetSourceCode(System.Reflection.MethodInfo mi, int indentLevel)
+ {
+ return GetSourceCodeInternal(mi, indentLevel);
+ }
+ protected abstract string GetSourceCodeInternal(System.Reflection.PropertyInfo item, bool autoProperty, int indentLevel);
+ public string GetSourceCode(System.Reflection.PropertyInfo item, bool autoProperty, int indentLevel)
+ {
+ return GetSourceCodeInternal(item, autoProperty, indentLevel);
+ }
+
+ protected abstract string GetTypeNameInternal(Type type);
+ public string GetTypeName(Type type)
+ {
+ return GetTypeNameInternal(type);
+ }
+
+ protected abstract string GetMethodSignatureInternal(System.Reflection.MethodInfo mi);
+ public string GetMethodSignature(System.Reflection.MethodInfo mi)
+ {
+ return GetMethodSignatureInternal(mi);
+ }
+
+ private static BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+
+ public MethodInfo[] GetMethods(Type type)
+ {
+ MethodInfo[] meths = type.GetMethods(bindingFlags);
+ List list = new List();
+ for (int j = 0; j < meths.Length; j++)
+ {
+ if (meths[j].IsSpecialName && (meths[j].Name.StartsWith("set_", StringComparison.OrdinalIgnoreCase) || meths[j].Name.StartsWith("get_", StringComparison.OrdinalIgnoreCase)) && (type.GetProperty(meths[j].Name.Substring(4), bindingFlags) != null))
+ {
+ // we can be REASONABLY sure that this is a property setter / getter,
+ // and as we've already gotten all the properties, ignore it
+ continue;
+ }
+ list.Add(meths[j]);
+ }
+ return list.ToArray();
+ }
+ public FieldInfo[] GetFields(Type type, out List AutoPropertyNames)
+ {
+ List list = new List();
+ AutoPropertyNames = new List();
+
+ FieldInfo[] fields = type.GetFields(bindingFlags);
+ for (int j = 0; j < fields.Length; j++)
+ {
+ if (fields[j].Name.StartsWith("<", StringComparison.OrdinalIgnoreCase) && fields[j].Name.Contains(">"))
+ {
+ // might be a backing field
+ int k__backingfield_name_start = fields[j].Name.IndexOf('<');
+ int k__backingfield_name_end = fields[j].Name.IndexOf('>', k__backingfield_name_start);
+
+ string k__backingfield_name = fields[j].Name.Substring(k__backingfield_name_start + 1, k__backingfield_name_end - k__backingfield_name_start - 1);
+ PropertyInfo pi = type.GetProperty(k__backingfield_name, bindingFlags);
+ if (pi != null)
+ {
+ AutoPropertyNames.Add(pi.Name);
+ continue;
+ }
+ }
+ else
+ {
+ list.Add(fields[j]);
+ }
+ }
+ return list.ToArray();
+ }
+
+ public string GetILOpcodeStr(short opcode)
+ {
+ return GetILOpcodeStr((ILOpcode)opcode);
+ }
+ public string GetILOpcodeStr(ILOpcode opcode)
+ {
+ switch (opcode)
+ {
+ case ILOpcode.Add: return "add";
+ case ILOpcode.AddOvf: return "add.ovf";
+ case ILOpcode.AddOvfUn: return "add.ovf.un";
+ case ILOpcode.And: return "and";
+ case ILOpcode.ArgList: return "arglist";
+ case ILOpcode.Beq: return "beq ";
+ case ILOpcode.BeqS: return "beq ";
+ case ILOpcode.Bge: return "bge ";
+ case ILOpcode.BgeS: return "bge.s ";
+ case ILOpcode.BgeUn: return "bge.un ";
+ case ILOpcode.BgeUnS: return "bge.un.s ";
+ case ILOpcode.Bgt: return "bgt ";
+ case ILOpcode.BgtS: return "bgt.s ";
+ case ILOpcode.BgtUn: return "bgt.un ";
+ case ILOpcode.BgtUnS: return "bgt.un.s ";
+ case ILOpcode.Ble: return "ble ";
+ case ILOpcode.BleS: return "ble.s ";
+ case ILOpcode.BleUn: return "ble.un ";
+ case ILOpcode.BleUnS: return "ble.un.s ";
+ case ILOpcode.Blt: return "blt ";
+ case ILOpcode.BltS: return "blt.s ";
+ case ILOpcode.BltUn: return "blt.un ";
+ case ILOpcode.BltUnS: return "blt.un.s ";
+ case ILOpcode.BneUn: return "bne.un ";
+ case ILOpcode.BneUnS: return "bne.un.s ";
+ case ILOpcode.Box: return "box ";
+ case ILOpcode.Br: return "br ";
+ case ILOpcode.BrS: return "br.s ";
+ case ILOpcode.Break: return "break";
+ case ILOpcode.BrFalse: return "brfalse ";
+ case ILOpcode.BrFalseS: return "brfalse.s ";
+ case ILOpcode.BrTrue: return "brtrue ";
+ case ILOpcode.BrTrueS: return "brtrue.s ";
+ case ILOpcode.Call: return "call ";
+ case ILOpcode.CallI: return "calli ";
+ case ILOpcode.CallVirt: return "callvirt ";
+ case ILOpcode.CastClass: return "castclass ";
+ case ILOpcode.Ceq: return "ceq";
+ case ILOpcode.Cgt: return "cgt";
+ case ILOpcode.CgtUn: return "cgt.un";
+ case ILOpcode.CkFinite: return "ckfinite";
+ case ILOpcode.Clt: return "clt";
+ case ILOpcode.CltUn: return "clt.un";
+ case ILOpcode.Constrained: return "constrained ";
+ case ILOpcode.ConvI: return "conv.i";
+ case ILOpcode.ConvI1: return "conv.i1";
+ case ILOpcode.ConvI2: return "conv.i2";
+ case ILOpcode.ConvI4: return "conv.i4";
+ case ILOpcode.ConvI8: return "conv.i8";
+ case ILOpcode.ConvOvfI: return "conv.ovf.i";
+ case ILOpcode.ConvOvfIUn: return "conv.ovf.i.un";
+ case ILOpcode.ConvOvfI1: return "conv.ovf.i1";
+ case ILOpcode.ConvOvfI1Un: return "conv.ovf.i1.un";
+ case ILOpcode.ConvOvfI2: return "conv.ovf.i2";
+ case ILOpcode.ConvOvfI2Un: return "conv.ovf.i2.un";
+ case ILOpcode.ConvOvfI4: return "conv.ovf.i4";
+ case ILOpcode.ConvOvfI4Un: return "conv.ovf.i4.un";
+ case ILOpcode.ConvOvfI8: return "conv.ovf.i8";
+ case ILOpcode.ConvOvfI8Un: return "conv.ovf.i8.un";
+ case ILOpcode.ConvOvfU: return "conv.ovf.u";
+ case ILOpcode.ConvOvfUUn: return "conv.ovf.u.un";
+ case ILOpcode.ConvOvfU1: return "conv.ovf.u1";
+ case ILOpcode.ConvOvfU1Un: return "conv.ovf.u1.un";
+ case ILOpcode.ConvOvfU2: return "conv.ovf.u2";
+ case ILOpcode.ConvOvfU2Un: return "conv.ovf.u2.un";
+ case ILOpcode.ConvOvfU4: return "conv.ovf.u4";
+ case ILOpcode.ConvOvfU4Un: return "conv.ovf.u4.un";
+ case ILOpcode.ConvOvfU8: return "conv.ovf.u8";
+ case ILOpcode.ConvOvfU8Un: return "conv.ovf.u8.un";
+ case ILOpcode.ConvRUn: return "conv.r.un";
+ case ILOpcode.ConvR4: return "conv.r4";
+ case ILOpcode.ConvR8: return "conv.r8";
+ case ILOpcode.ConvU: return "conv.u";
+ case ILOpcode.ConvU1: return "conv.u1";
+ case ILOpcode.ConvU2: return "conv.u2";
+ case ILOpcode.ConvU4: return "conv.u4";
+ case ILOpcode.ConvU8: return "conv.u8";
+ case ILOpcode.CpBlk: return "cpblk";
+ case ILOpcode.CpObj: return "cpobj ";
+ case ILOpcode.Div: return "div";
+ case ILOpcode.DivUn: return "div.un";
+ case ILOpcode.Dup: return "dup";
+ case ILOpcode.EndFault: return "endfault";
+ case ILOpcode.EndFilter: return "endfilter";
+ // case ILOpcode.EndFinally: return "endfinally"; // same as endfault?
+ case ILOpcode.InitBlk: return "initblk";
+ case ILOpcode.InitObj: return "initobj ";
+ case ILOpcode.IsInst: return "isinst ";
+ case ILOpcode.Jmp: return "jmp";
+ case ILOpcode.LdArg: return "ldarg ";
+ case ILOpcode.LdArg0: return "ldarg.0";
+ case ILOpcode.LdArg1: return "ldarg.1";
+ case ILOpcode.LdArg2: return "ldarg.2";
+ case ILOpcode.LdArg3: return "ldarg.3";
+ case ILOpcode.LdArgS: return "ldarg.s ";
+ case ILOpcode.LdArgA: return "ldarg.a ";
+ case ILOpcode.LdArgAS: return "ldarg.a.s ";
+ case ILOpcode.LdCI4: return "ldc.i4 ";
+ case ILOpcode.LdCI4_M1: return "ldc.i4.m1";
+ case ILOpcode.LdCI4_0: return "ldc.i4.0";
+ case ILOpcode.LdCI4_1: return "ldc.i4.1";
+ case ILOpcode.LdCI4_2: return "ldc.i4.2";
+ case ILOpcode.LdCI4_3: return "ldc.i4.3";
+ case ILOpcode.LdCI4_4: return "ldc.i4.4";
+ case ILOpcode.LdCI4_5: return "ldc.i4.5";
+ case ILOpcode.LdCI4_6: return "ldc.i4.6";
+ case ILOpcode.LdCI4_7: return "ldc.i4.7";
+ case ILOpcode.LdCI4_8: return "ldc.i4.8";
+ case ILOpcode.LdCI4S: return "ldc.i4.s ";
+ case ILOpcode.LdCI8: return "ldc.i8 ";
+ case ILOpcode.LdCR4: return "ldc.r4 ";
+ case ILOpcode.LdCR8: return "ldc.r8 ";
+ case ILOpcode.LdElem: return "ldelem ";
+ case ILOpcode.LdElemI: return "ldelem.i";
+ case ILOpcode.LdElemI1: return "ldelem.i1";
+ case ILOpcode.LdElemU1: return "ldelem.u1";
+ case ILOpcode.LdElemI2: return "ldelem.i2";
+ case ILOpcode.LdElemU2: return "ldelem.u2";
+ case ILOpcode.LdElemI4: return "ldelem.i4";
+ case ILOpcode.LdElemU4: return "ldelem.u4";
+ case ILOpcode.LdElemI8: return "ldelem.i8";
+ case ILOpcode.LdElemR4: return "ldelem.r4";
+ case ILOpcode.LdElemR8: return "ldelem.r8";
+ case ILOpcode.LdElemRef: return "ldelem.ref";
+ case ILOpcode.LdElemA: return "ldelema ";
+ case ILOpcode.LdFld: return "ldfld ";
+ case ILOpcode.LdFldA: return "ldflda ";
+ case ILOpcode.LdFtn: return "ldftn ";
+ case ILOpcode.LdIndI: return "ldind.i";
+ case ILOpcode.LdIndI1: return "ldind.i1";
+ case ILOpcode.LdIndU1: return "ldind.u1";
+ case ILOpcode.LdIndI2: return "ldind.i2";
+ case ILOpcode.LdIndU2: return "ldind.u2";
+ case ILOpcode.LdIndI4: return "ldind.i4";
+ case ILOpcode.LdIndU4: return "ldind.u4";
+ case ILOpcode.LdIndI8: return "ldind.i8";
+ case ILOpcode.LdIndR4: return "ldind.r4";
+ case ILOpcode.LdIndR8: return "ldind.r8";
+ case ILOpcode.LdLen: return "ldlen";
+ case ILOpcode.LdLoc: return "ldloc ";
+ case ILOpcode.LdLoc0: return "ldloc.0";
+ case ILOpcode.LdLoc1: return "ldloc.1";
+ case ILOpcode.LdLoc2: return "ldloc.2";
+ case ILOpcode.LdLoc3: return "ldloc.3";
+ case ILOpcode.LdLocS: return "ldloc.s ";
+ case ILOpcode.LdLocA: return "ldloca ";
+ case ILOpcode.LdLocAS: return "ldloca.s ";
+ case ILOpcode.LdNull: return "ldnull";
+ case ILOpcode.LdObj: return "ldobj ";
+ case ILOpcode.LdSFld: return "ldsfld ";
+ case ILOpcode.LdSFldA: return "ldsflda ";
+ case ILOpcode.LdStr: return "ldstr ";
+ case ILOpcode.LdToken: return "ldtoken ";
+ case ILOpcode.LdVirtFtn: return "ldvirtftn ";
+ case ILOpcode.Leave: return "leave ";
+ case ILOpcode.LeaveS: return "leave ";
+ case ILOpcode.LocAlloc: return "localloc";
+ case ILOpcode.MkRefAny: return "mkrefany ";
+ case ILOpcode.Mul: return "mul";
+ case ILOpcode.MulOvf: return "mul.ovf";
+ case ILOpcode.MulOvfUn: return "mul.ovf.un";
+ case ILOpcode.Neg: return "neg";
+ case ILOpcode.NewArr: return "newarr ";
+ case ILOpcode.NewObj: return "newobj ";
+ case ILOpcode.No: return "no.{typecheck, rangecheck, nullcheck}";
+ case ILOpcode.Nop: return "nop";
+ case ILOpcode.Not: return "not";
+ case ILOpcode.Or: return "or";
+ case ILOpcode.Pop: return "pop";
+ case ILOpcode.Readonly: return "readonly.";
+ case ILOpcode.RefAnyType: return "refanytype";
+ case ILOpcode.RefAnyVal: return "refanyval ";
+ case ILOpcode.Rem: return "rem";
+ case ILOpcode.RemUn: return "rem.un";
+ case ILOpcode.Ret: return "ret";
+ case ILOpcode.Rethrow: return "rethrow";
+ case ILOpcode.Shl: return "shl";
+ case ILOpcode.Shr: return "shl";
+ case ILOpcode.ShrUn: return "shl";
+ case ILOpcode.SizeOf: return "sizeof ";
+ case ILOpcode.StArg: return "starg ";
+ case ILOpcode.StArgS: return "starg.s ";
+ case ILOpcode.StElem: return "stelem ";
+ case ILOpcode.StElemI: return "stelem.i";
+ case ILOpcode.StElemI1: return "stelem.i1";
+ case ILOpcode.StElemI2: return "stelem.i2";
+ case ILOpcode.StElemI4: return "stelem.i4";
+ case ILOpcode.StElemI8: return "stelem.i8";
+ case ILOpcode.StElemR4: return "stelem.r4";
+ case ILOpcode.StElemR8: return "stelem.r8";
+ case ILOpcode.StElemRef: return "stelem.ref";
+ case ILOpcode.StFld: return "stfld ";
+ case ILOpcode.StIndI: return "stind.i";
+ case ILOpcode.StIndI1: return "stind.i1";
+ case ILOpcode.StIndI2: return "stind.i2";
+ case ILOpcode.StIndI4: return "stind.i4";
+ case ILOpcode.StIndI8: return "stind.i8";
+ case ILOpcode.StIndR4: return "stind.r4";
+ case ILOpcode.StIndR8: return "stind.r8";
+ case ILOpcode.StIndRef: return "stind.ref";
+ case ILOpcode.StLoc: return "stloc ";
+ case ILOpcode.StLoc0: return "stloc.0";
+ case ILOpcode.StLoc1: return "stloc.1";
+ case ILOpcode.StLoc2: return "stloc.2";
+ case ILOpcode.StLoc3: return "stloc.3";
+ case ILOpcode.StLocS: return "stloc.s ";
+ case ILOpcode.StObj: return "stobj ";
+ case ILOpcode.StSFld: return "stsfld ";
+ case ILOpcode.Sub: return "sub";
+ case ILOpcode.SubOvf: return "sub.ovf";
+ case ILOpcode.SubOvfUn: return "sub.ovf.un";
+ case ILOpcode.Switch: return "switch ";
+ case ILOpcode.Tail: return "tail.";
+ case ILOpcode.Throw: return "throw";
+ case ILOpcode.Unaligned: return "unaligned.(alignment)";
+ case ILOpcode.Unbox: return "unbox ";
+ case ILOpcode.UnboxAny: return "unbox.any ";
+ case ILOpcode.Volatile: return "volatile.";
+ case ILOpcode.Xor: return "xor";
+ }
+ return "";
+ }
+
+ public string GetVariableName(MethodInfo mi, LocalVariableInfo localVariableInfo)
+ {
+ // TODO: read the PDB file (if exists) to get the local variable info
+ return "local_" + localVariableInfo.LocalIndex.ToString();
+ }
+ }
+}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/CSharpCodeProvider.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/CSharpCodeProvider.cs
new file mode 100644
index 00000000..51e5ecf8
--- /dev/null
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/CSharpCodeProvider.cs
@@ -0,0 +1,427 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using UniversalEditor.Accessors;
+using UniversalEditor.IO;
+
+namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable.CodeProviders
+{
+ public class CSharpCodeProvider : CodeProvider
+ {
+ public override string Title => "C#";
+ public override string CodeFileExtension => ".cs";
+
+ protected override string GetAccessModifiersInternal(bool isPublic, bool isFamily, bool isAssembly, bool isPrivate, bool isAbstract, bool isSealed)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (isPublic) sb.Append("public ");
+ if (isFamily) sb.Append("protected ");
+ if (isAssembly) sb.Append("internal ");
+ if (isPrivate) sb.Append("private ");
+ if (isAbstract) sb.Append("abstract ");
+ if (isSealed) sb.Append("sealed ");
+ return sb.ToString().Trim();
+ }
+ protected override string GetBeginBlockInternal(Type type, int indentLevel)
+ {
+ return GetBeginBlockInternal(indentLevel);
+ }
+ protected override string GetBeginBlockInternal(int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ sb.Append('{');
+ return sb.ToString();
+ }
+ protected override string GetEndBlockInternal(string elementName, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ sb.Append('}');
+ return sb.ToString();
+ }
+
+ protected override string GetBeginBlockInternal(MethodInfo mi, int indentLevel)
+ {
+ return GetBeginBlockInternal(indentLevel);
+ }
+ protected override string GetEndBlockInternal(MethodInfo mi, int indentLevel)
+ {
+ return GetEndBlockInternal(GetElementName(mi), indentLevel);
+ }
+
+ protected override string GetElementNameInternal(Type type)
+ {
+ if (type.IsClass)
+ {
+ return "class";
+ }
+ else if (type.IsInterface)
+ {
+ return "interface";
+ }
+ else if (type.IsEnum)
+ {
+ return "enum";
+ }
+ else if (type.IsValueType)
+ {
+ return "struct";
+ }
+ throw new NotSupportedException();
+ }
+ protected override string GetElementNameInternal(MethodInfo mi)
+ {
+ return String.Empty;
+ }
+
+ protected override string GetMethodSignatureInternal(MethodInfo mi)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(GetAccessModifiers(mi));
+ sb.Append(' ');
+ sb.Append(GetTypeName(mi.ReturnType));
+ sb.Append(' ');
+ sb.Append(mi.Name);
+ sb.Append('(');
+ ParameterInfo[] pis = mi.GetParameters();
+ for (int i = 0; i < pis.Length; i++)
+ {
+ if (pis[i].ParameterType.IsByRef && pis[i].IsOut)
+ {
+ sb.Append("out ");
+ }
+ else if (pis[i].ParameterType.IsByRef)
+ {
+ sb.Append("ref ");
+ }
+
+ sb.Append(GetTypeName(pis[i].ParameterType));
+ sb.Append(' ');
+ sb.Append(pis[i].Name);
+
+ if (i < pis.Length - 1)
+ sb.Append(", ");
+ }
+ sb.Append(')');
+ return sb.ToString();
+ }
+
+ protected override string GetSourceCodeInternal(MethodInfo mi, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ string indentStr = new string('\t', indentLevel);
+ sb.Append(indentStr);
+ sb.Append(GetMethodSignature(mi));
+
+ MethodBody mb = mi.GetMethodBody();
+ if (mb != null)
+ {
+ sb.AppendLine();
+ sb.Append(GetBeginBlock(mi, indentLevel));
+ sb.AppendLine();
+
+ for (int i = 0; i < mb.LocalVariables.Count; i++)
+ {
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.Append(GetTypeName(mb.LocalVariables[i].LocalType));
+ sb.Append(' ');
+ sb.Append(GetVariableName(mi, mb.LocalVariables[i]));
+ sb.AppendLine(";");
+ }
+
+ if (mb.LocalVariables.Count > 0)
+ sb.AppendLine();
+
+ byte[] bytecode = mb.GetILAsByteArray();
+ MemoryAccessor ma = new MemoryAccessor(bytecode);
+ Reader r = new Reader(ma);
+ while (!r.EndOfStream)
+ {
+ int sz = 0;
+ ILOpcode opcode = ReadOpcode(r, out sz);
+ ILOpcode opcode2 = PeekOpcode(r);
+
+ sb.Append(new string('\t', indentLevel + 1));
+
+
+ if (opcode2 == ILOpcode.NewArr)
+ {
+ int? lit = OpcodeToLiteralInt(opcode);
+ sb.Append(String.Format("X[] = new X[{0}]", lit.GetValueOrDefault(0)));
+ }
+ else
+ {
+ sb.AppendLine(GetILOpcodeStr(opcode));
+ continue;
+ }
+ }
+
+ sb.Append(GetEndBlock(mi, indentLevel));
+ }
+ else
+ {
+ sb.Append(';');
+ }
+ return sb.ToString();
+ }
+
+ private int? OpcodeToLiteralInt(ILOpcode opcode)
+ {
+ switch (opcode)
+ {
+ case ILOpcode.LdCI4_0:
+ {
+ return 0;
+ }
+ case ILOpcode.LdCI4_1:
+ {
+ return 1;
+ }
+ case ILOpcode.LdCI4_2:
+ {
+ return 2;
+ }
+ case ILOpcode.LdCI4_3:
+ {
+ return 3;
+ }
+ case ILOpcode.LdCI4_4:
+ {
+ return 4;
+ }
+ case ILOpcode.LdCI4_5:
+ {
+ return 5;
+ }
+ case ILOpcode.LdCI4_6:
+ {
+ return 6;
+ }
+ case ILOpcode.LdCI4_7:
+ {
+ return 7;
+ }
+ case ILOpcode.LdCI4_8:
+ {
+ return 8;
+ }
+ case ILOpcode.LdCI4_M1:
+ {
+ return -1;
+ }
+ }
+ return null;
+ }
+
+ private ILOpcode PeekOpcode(Reader r)
+ {
+ int sz = 0;
+ ILOpcode opcode = ReadOpcode(r, out sz);
+ if (sz == 0)
+ return opcode;
+
+ r.Seek(-sz, SeekOrigin.Current);
+ return opcode;
+ }
+ private ILOpcode ReadOpcode(Reader r, out int size)
+ {
+ if (r.EndOfStream)
+ {
+ size = 0;
+ return ILOpcode.Nop;
+ }
+
+ byte bytecode_b = r.ReadByte();
+ short bytecode_s = bytecode_b;
+ size = 1;
+
+ if (bytecode_s == 0xFE)
+ {
+ bytecode_s = BitConverter.ToInt16(new byte[] { bytecode_b, r.ReadByte() }, 0);
+ size = 2;
+ }
+ return (ILOpcode)bytecode_s;
+ }
+
+ protected override string GetSourceCodeInternal(FieldInfo fi, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ sb.Append(GetAccessModifiers(fi));
+ sb.Append(' ');
+ sb.Append(fi.FieldType.FullName);
+ sb.Append(' ');
+ sb.Append(fi.Name);
+ sb.Append(';');
+ return sb.ToString();
+ }
+
+ protected override string GetTypeNameInternal(Type type)
+ {
+ string fullyQualifiedTypeName = type.FullName ?? type.Name;
+ if (fullyQualifiedTypeName.Equals("System.Void")) return "void";
+ if (fullyQualifiedTypeName.Equals("System.Byte")) return "byte";
+ if (fullyQualifiedTypeName.Equals("System.SByte")) return "sbyte";
+ if (fullyQualifiedTypeName.Equals("System.Char")) return "char";
+ if (fullyQualifiedTypeName.Equals("System.Int16")) return "short";
+ if (fullyQualifiedTypeName.Equals("System.UInt16")) return "ushort";
+ if (fullyQualifiedTypeName.Equals("System.Int32")) return "int";
+ if (fullyQualifiedTypeName.Equals("System.UInt32")) return "uint";
+ if (fullyQualifiedTypeName.Equals("System.Int64")) return "long";
+ if (fullyQualifiedTypeName.Equals("System.UInt64")) return "ulong";
+ if (fullyQualifiedTypeName.Equals("System.String")) return "string";
+ if (fullyQualifiedTypeName.Equals("System.Single")) return "float";
+ if (fullyQualifiedTypeName.Equals("System.Double")) return "double";
+ if (fullyQualifiedTypeName.Equals("System.Decimal")) return "decimal";
+ if (fullyQualifiedTypeName.Equals("System.Boolean")) return "bool";
+ if (fullyQualifiedTypeName.Equals("System.Object")) return "object";
+ return fullyQualifiedTypeName;
+ }
+
+ protected override string GetSourceCodeInternal(Type item, int indentLevel)
+ {
+ string indentStr = new string('\t', indentLevel);
+ StringBuilder sb = new StringBuilder();
+
+ sb.Append(indentStr);
+ sb.Append(GetAccessModifiers(item));
+ sb.Append(' ');
+ sb.Append(GetElementName(item));
+ sb.Append(' ');
+ sb.Append(item.Name);
+
+ if (!item.IsValueType && (item.BaseType != null && item.BaseType != typeof(object) && item.BaseType != typeof(Enum)))
+ {
+ sb.Append(" : ");
+ sb.Append(GetTypeName(item.BaseType));
+ }
+ sb.AppendLine();
+
+ sb.Append(GetBeginBlock(indentLevel));
+ sb.AppendLine();
+
+ BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+ if (item.IsEnum)
+ {
+ FieldInfo[] fields = item.GetFields(bindingFlags);
+ for (int j = 0; j < fields.Length; j++)
+ {
+ if (fields[j].FieldType == item)
+ {
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.Append(fields[j].Name);
+ if (j < fields.Length - 1)
+ sb.Append(',');
+
+ sb.AppendLine();
+ }
+ }
+ }
+ else
+ {
+ List AutoPropertyNames;
+ FieldInfo[] fields = GetFields(item, out AutoPropertyNames);
+ for (int j = 0; j < fields.Length; j++)
+ {
+ sb.AppendLine(GetSourceCode(fields[j], indentLevel + 1));
+ sb.AppendLine();
+ }
+
+ EventInfo[] events = item.GetEvents(bindingFlags);
+ for (int j = 0; j < events.Length; j++)
+ {
+ sb.AppendLine(GetSourceCode(events[j], indentLevel + 1));
+ sb.AppendLine();
+ }
+
+ PropertyInfo[] props = item.GetProperties(bindingFlags);
+ for (int j = 0; j < props.Length; j++)
+ {
+ sb.AppendLine(GetSourceCode(props[j], AutoPropertyNames.Contains(props[j].Name), indentLevel + 1));
+ sb.AppendLine();
+ }
+
+ MethodInfo[] meths = GetMethods(item);
+ for (int j = 0; j < meths.Length; j++)
+ {
+ sb.AppendLine(GetSourceCode(meths[j], indentLevel + 1));
+ sb.AppendLine();
+ }
+ }
+ sb.Append(GetEndBlock(item, indentLevel));
+ return sb.ToString();
+ }
+
+ protected override string GetSourceCodeInternal(EventInfo item, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ sb.Append(GetAccessModifiers(item));
+ sb.Append(" event ");
+ sb.Append(GetTypeName(item.EventHandlerType));
+ sb.Append(' ');
+ sb.Append(item.Name);
+ return sb.ToString();
+ }
+
+ protected override string GetSourceCodeInternal(PropertyInfo item, bool autoProperty, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ string amProp = GetAccessModifiers(item);
+ sb.Append(amProp);
+ sb.Append(' ');
+ sb.Append(GetTypeName(item.PropertyType));
+ sb.Append(' ');
+ sb.Append(item.Name);
+ sb.Append(' ');
+ sb.Append("{ ");
+ MethodInfo miGet = item.GetGetMethod();
+ if (miGet != null)
+ {
+ string am = GetAccessModifiers(miGet);
+ if (!String.IsNullOrEmpty(am) && amProp != am)
+ {
+ sb.Append(am);
+ sb.Append(' ');
+ }
+
+ sb.Append("get");
+
+ if (autoProperty)
+ {
+ sb.Append("; ");
+ }
+ else
+ {
+ sb.Append(" { ");
+ sb.Append(" } ");
+ }
+ }
+ MethodInfo miSet = item.GetSetMethod();
+ if (miSet != null)
+ {
+ string am = GetAccessModifiers(miSet);
+ if (!String.IsNullOrEmpty(am) && amProp != am)
+ sb.Append(am);
+
+ sb.Append(" set");
+
+ if (autoProperty)
+ {
+ sb.Append("; ");
+ }
+ else
+ {
+ sb.Append(" { ");
+ sb.Append(" }");
+ }
+ }
+
+ sb.Append('}');
+ return sb.ToString();
+ }
+ }
+}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/VisualBasicCodeProvider.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/VisualBasicCodeProvider.cs
new file mode 100644
index 00000000..9667ff74
--- /dev/null
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/CodeProviders/VisualBasicCodeProvider.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Reflection;
+using System.Text;
+
+namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable.CodeProviders
+{
+ public class VisualBasicCodeProvider : CodeProvider
+ {
+ public override string Title => "VB.NET";
+ public override string CodeFileExtension => ".vb";
+
+ protected override string GetAccessModifiersInternal(bool isPublic, bool isFamily, bool isAssembly, bool isPrivate, bool isAbstract, bool isSealed)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (isPublic) sb.Append("Public ");
+ if (isFamily) sb.Append("Protected ");
+ if (isAssembly) sb.Append("Friend ");
+ if (isPrivate) sb.Append("Private ");
+ if (isAbstract) sb.Append("Abstract ");
+ if (isSealed) sb.Append("Sealed ");
+ return sb.ToString().Trim();
+ }
+ protected override string GetBeginBlockInternal(int indentLevel)
+ {
+ return new string('\t', indentLevel);
+ }
+ protected override string GetEndBlockInternal(string elementName, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ sb.Append("End ");
+ sb.Append(elementName);
+ return sb.ToString();
+ }
+ protected override string GetBeginBlockInternal(MethodInfo mi, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+
+ string am = GetAccessModifiers(mi);
+ if (!String.IsNullOrEmpty(am))
+ {
+ sb.Append(am);
+ sb.Append(' ');
+ }
+ sb.Append(GetElementName(mi));
+ sb.Append(' ');
+
+ sb.Append(GetMethodSignature(mi));
+
+ if (mi.ReturnType != typeof(void))
+ {
+ sb.Append(" As ");
+ sb.Append(GetTypeName(mi.ReturnType));
+ }
+ return sb.ToString();
+ }
+ protected override string GetBeginBlockInternal(Type type, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ string am = GetAccessModifiers(type);
+ sb.Append(' ');
+ sb.Append(GetElementName(type));
+ sb.Append(' ');
+ sb.Append(type.Name);
+ return sb.ToString();
+ }
+ protected override string GetEndBlockInternal(MethodInfo mi, int indentLevel)
+ {
+ return GetEndBlockInternal(GetElementName(mi), indentLevel);
+ }
+
+ protected override string GetElementNameInternal(Type type)
+ {
+ if (type.IsClass)
+ {
+ return "Class";
+ }
+ else if (type.IsInterface)
+ {
+ return "Interface";
+ }
+ else if (type.IsEnum)
+ {
+ return "Enum";
+ }
+ else if (type.IsValueType)
+ {
+ return "Structure";
+ }
+ throw new NotSupportedException();
+ }
+ protected override string GetElementNameInternal(MethodInfo mi)
+ {
+ if (mi.ReturnType == typeof(void))
+ {
+ return "Sub";
+ }
+ return "Function";
+ }
+
+ protected override string GetSourceCodeInternal(EventInfo item, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ /*
+ sb.Append(new string('\t', indentLevel));
+ string am = GetAccessModifiers(fi);
+ if (String.IsNullOrEmpty(am.Trim()))
+ {
+ sb.Append("Dim");
+ }
+ else
+ {
+ sb.Append(am);
+ }
+ sb.Append(' ');
+ sb.Append(fi.Name);
+ sb.Append(" As ");
+ sb.Append(fi.FieldType.FullName);
+ */
+ return sb.ToString();
+ }
+ protected override string GetSourceCodeInternal(FieldInfo item, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(new string('\t', indentLevel));
+ string am = GetAccessModifiers(item);
+ if (String.IsNullOrEmpty(am.Trim()))
+ {
+ sb.Append("Dim");
+ }
+ else
+ {
+ sb.Append(am);
+ }
+ sb.Append(' ');
+ sb.Append(item.Name);
+ sb.Append(" As ");
+ sb.Append(item.FieldType.FullName);
+ return sb.ToString();
+ }
+ protected override string GetSourceCodeInternal(Type mi, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(GetBeginBlock(mi, indentLevel));
+ sb.AppendLine();
+
+ MethodInfo[] mis = mi.GetMethods();
+ for (int i = 0; i < mis.Length; i++)
+ {
+ sb.AppendLine(GetBeginBlock(mis[i], indentLevel + 1));
+ sb.AppendLine();
+ sb.AppendLine(GetEndBlock(mis[i], indentLevel + 1));
+ sb.AppendLine();
+ }
+
+ sb.AppendLine();
+ sb.Append(GetEndBlock(mi, indentLevel));
+ return sb.ToString();
+ }
+ protected override string GetSourceCodeInternal(MethodInfo mi, int indentLevel)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override string GetMethodSignatureInternal(MethodInfo mi)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(mi.Name);
+ sb.Append('(');
+
+ ParameterInfo[] pis = mi.GetParameters();
+ for (int i = 0; i < pis.Length; i++)
+ {
+ if (pis[i].ParameterType.IsByRef)
+ {
+ sb.Append("ByRef ");
+ }
+ else
+ {
+ sb.Append("ByVal ");
+ }
+
+ sb.Append(pis[i].Name);
+ sb.Append(" As ");
+ sb.Append(GetTypeName(pis[i].ParameterType));
+
+ if (i < pis.Length - 1)
+ sb.Append(", ");
+ }
+
+ sb.Append(')');
+ return sb.ToString();
+ }
+
+ protected override string GetTypeNameInternal(Type type)
+ {
+ string fullyQualifiedTypeName = type.FullName ?? type.Name;
+ if (fullyQualifiedTypeName.Equals("System.Byte")) return "Byte";
+ if (fullyQualifiedTypeName.Equals("System.SByte")) return "SByte";
+ if (fullyQualifiedTypeName.Equals("System.Char")) return "Char";
+ if (fullyQualifiedTypeName.Equals("System.Int16")) return "Short";
+ if (fullyQualifiedTypeName.Equals("System.UInt16")) return "UShort";
+ if (fullyQualifiedTypeName.Equals("System.Int32")) return "Int";
+ if (fullyQualifiedTypeName.Equals("System.UInt32")) return "UInt";
+ if (fullyQualifiedTypeName.Equals("System.Int64")) return "Long";
+ if (fullyQualifiedTypeName.Equals("System.UInt64")) return "ULong";
+ if (fullyQualifiedTypeName.Equals("System.String")) return "String";
+ if (fullyQualifiedTypeName.Equals("System.Single")) return "Single";
+ if (fullyQualifiedTypeName.Equals("System.Double")) return "Double";
+ if (fullyQualifiedTypeName.Equals("System.Decimal")) return "Decimal";
+ if (fullyQualifiedTypeName.Equals("System.Boolean")) return "Boolean";
+ if (fullyQualifiedTypeName.Equals("System.Object")) return "Object";
+ return fullyQualifiedTypeName;
+ }
+ protected override string GetSourceCodeInternal(PropertyInfo item, bool autoProperty, int indentLevel)
+ {
+ StringBuilder sb = new StringBuilder();
+ string indentStr = new string('\t', indentLevel);
+ sb.Append(indentStr);
+ sb.Append(GetAccessModifiers(item));
+ sb.Append(' ');
+ sb.Append("Property ");
+ sb.Append(item.Name);
+ sb.Append(" As ");
+ sb.Append(GetTypeName(item.PropertyType));
+ sb.AppendLine();
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.AppendLine("Get");
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.AppendLine("End Get");
+
+
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.AppendLine("Set");
+ sb.Append(new string('\t', indentLevel + 1));
+ sb.AppendLine("End Set");
+
+ sb.Append(new string('\t', indentLevel));
+ sb.Append("End Property");
+ return sb.ToString();
+ }
+ }
+}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ExecutableEditor.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ExecutableEditor.cs
index 0fac490b..2cd384b3 100644
--- a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ExecutableEditor.cs
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ExecutableEditor.cs
@@ -61,6 +61,7 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
private TextBox txtAssemblyVersion = null;
private DefaultTreeModel tmOtherInformation = null;
+ private ManagedAssemblyPanel pnlManagedAssembly = null;
public ExecutableEditor()
{
@@ -142,11 +143,14 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
pnlMetadata.Layout = new GridLayout();
pnlMetadata.Controls.Add(lblAssemblyName, new GridLayout.Constraints(0, 0));
- pnlMetadata.Controls.Add(txtAssemblyName, new GridLayout.Constraints(0, 1));
+ pnlMetadata.Controls.Add(txtAssemblyName, new GridLayout.Constraints(0, 1, 1, 1, ExpandMode.Horizontal));
pnlMetadata.Controls.Add(lblAssemblyVersion, new GridLayout.Constraints(1, 0));
- pnlMetadata.Controls.Add(txtAssemblyVersion, new GridLayout.Constraints(1, 1));
+ pnlMetadata.Controls.Add(txtAssemblyVersion, new GridLayout.Constraints(1, 1, 1, 1, ExpandMode.Horizontal));
- tabManagedAssembly.Controls.Add(pnlMetadata);
+ tabManagedAssembly.Controls.Add(pnlMetadata, new BoxLayout.Constraints(false, true));
+
+ pnlManagedAssembly = new ManagedAssemblyPanel();
+ tabManagedAssembly.Controls.Add(pnlManagedAssembly, new BoxLayout.Constraints(true, true));
tbs.TabPages.Add(tabManagedAssembly);
@@ -241,6 +245,8 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
txtAssemblyName.Text = executable.ManagedAssembly.GetName().Name;
txtAssemblyVersion.Text = executable.ManagedAssembly.GetName().Version.ToString();
+
+ pnlManagedAssembly.Assembly = executable.ManagedAssembly;
}
}
}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ILOpcode.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ILOpcode.cs
new file mode 100644
index 00000000..a0bfd840
--- /dev/null
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ILOpcode.cs
@@ -0,0 +1,925 @@
+using System;
+namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
+{
+ public enum ILOpcode : short
+ {
+ ///
+ /// add - Add two values, returning a new value.
+ ///
+ Add = 0x58,
+ ///
+ /// add.ovf - Add signed integer values with overflow check.
+ ///
+ AddOvf = 0xD6,
+ ///
+ /// add.ovf.un - Add unsigned integer values with overflow check.
+ ///
+ AddOvfUn = 0xD7,
+ ///
+ /// and - Bitwise AND of two integral values, returns an integral value.
+ ///
+ And = 0x5F,
+ ///
+ /// arglist - Return argument list handle for the current method.
+ ///
+ ArgList = 0x00FE,
+ ///
+ /// beq <int32 (target)> - Branch to target if equal.
+ ///
+ Beq = 0x3B,
+ ///
+ /// beq.s <int8 (target)> - Branch to target if equal, short form.
+ ///
+ BeqS = 0x2E,
+
+ ///
+ /// bge <int32 (target)> - Branch to target if greater than or equal to.
+ ///
+ Bge = 0x3C,
+ ///
+ /// bge.s <int8 (target)> - Branch to target if greater than or equal to, short form.
+ ///
+ BgeS = 0x2F,
+ ///
+ /// bge.un <int32 (target)> - Branch to target if greater than or equal to (unsigned or unordered).
+ ///
+ BgeUn = 0x41,
+ ///
+ /// bge.un.s <int8 (target)> - Branch to target if greater than or equal to (unsigned or unordered), short form
+ ///
+ BgeUnS = 0x34,
+
+ ///
+ /// bgt <int32 (target)> Branch to target if greater than.
+ ///
+ Bgt = 0x3D,
+ ///
+ /// bgt.s <int8 (target)> Branch to target if greater than, short form.
+ ///
+ BgtS = 0x30,
+ ///
+ /// bgt.un <int32 (target)> Branch to target if greater than (unsigned or unordered).
+ ///
+ BgtUn = 0x42,
+ ///
+ /// bgt.un.s <int8 (target)> Branch to target if greater than (unsigned or unordered), short form.
+ ///
+ BgtUnS = 0x35,
+
+ ///
+ /// ble <int32 (target)> Branch to target if less than or equal to.
+ ///
+ Ble = 0x3E,
+ ///
+ /// ble.s <int8 (target)> Branch to target if less than or equal to, short form.
+ ///
+ BleS = 0x31,
+ ///
+ /// ble.un <int32 (target)> Branch to target if less than or equal to (unsigned or unordered).
+ ///
+ BleUn = 0x43,
+ ///
+ /// ble.un.s <int8 (target)> Branch to target if less than or equal to (unsigned or unordered), short form.
+ ///
+ BleUnS = 0x36,
+
+ ///
+ /// blt <int32 (target)> Branch to target if less than.
+ ///
+ Blt = 0x3F,
+ ///
+ /// blt.s <int8 (target)> Branch to target if less than, short form.
+ ///
+ BltS = 0x32,
+ ///
+ /// blt.un <int32 (target)> Branch to target if less than (unsigned or unordered).
+ ///
+ BltUn = 0x44,
+ ///
+ /// blt.un.s <int8 (target)> Branch to target if less than (unsigned or unordered), short form.
+ ///
+ BltUnS = 0x37,
+
+ ///
+ /// bne.un <int32 (target)> Branch to target if unequal or unordered.
+ ///
+ BneUn = 0x40,
+ ///
+ /// bne.un.s <int8 (target)> Branch to target if unequal or unordered, short form.
+ ///
+ BneUnS = 0x33,
+
+ ///
+ /// Convert a boxable value to its boxed form
+ ///
+ Box = 0x8C,
+
+ ///
+ /// br <int32 (target)> Branch to target.
+ ///
+ Br = 0x38,
+ ///
+ /// br.s <int8 (target)> Branch to target, short form.
+ ///
+ BrS = 0x2B,
+
+ ///
+ /// break - Inform a debugger that a breakpoint has been reached.
+ ///
+ Break = 0x01,
+
+ ///
+ /// brfalse <int32 (target)> - Branch to target if value is zero (false).
+ ///
+ BrFalse = 0x39,
+ ///
+ /// brfalse.s <int8 (target)> - Branch to target if value is zero (false), short form.
+ ///
+ BrFalseS = 0x2C,
+ ///
+ /// brinst <int32 (target)> - Branch to target if value is a non-null object reference (alias for brtrue).
+ ///
+ BrInst = 0x3A,
+ ///
+ /// brinst.s <int8 (target)> - Branch to target if value is a non-null object reference, short form (alias for brtrue.s).
+ ///
+ BrInstS = 0x2D,
+ ///
+ /// brnull <int32 (target)> - Branch to target if value is null (alias for brfalse).
+ ///
+ BrNull = 0x39,
+ ///
+ /// brnull.s <int8 (target)> - Branch to target if value is null (alias for brfalse.s), short form.
+ ///
+ BrNullS = 0x2C,
+ ///
+ /// brtrue <int32 (target)> - Branch to target if value is non-zero (true).
+ ///
+ BrTrue = 0x3A,
+ ///
+ /// brtrue.s <int8 (target)> - Branch to target if value is non-zero (true), short form.
+ ///
+ BrTrueS = 0x2D,
+ ///
+ /// brzero <int32 (target)> - Branch to target if value is zero (alias for brfalse).
+ ///
+ BrZero = 0x39,
+ ///
+ /// brzero.s <int8 (target)> - Branch to target if value is zero (alias for brfalse.s), short form.
+ ///
+ BrZeroS = 0x2C,
+ ///
+ /// call <method> - Call method described by method.
+ ///
+ Call = 0x28,
+ ///
+ /// calli <callsitedescr> - Call method indicated on the stack with arguments described by callsitedescr.
+ ///
+ CallI = 0x29,
+ ///
+ /// callvirt <method> - Call a method associated with an object.
+ ///
+ CallVirt = 0x6F,
+ ///
+ /// castclass <class> - Cast obj to class.
+ ///
+ CastClass = 0x74,
+ ///
+ /// ceq - Push 1 (of type int32) if value1 equals value2, else push 0.
+ ///
+ Ceq = 0x01FE,
+ ///
+ /// cgt - Push 1 (of type int32) if value1 greater that value2, else push 0.
+ ///
+ Cgt = 0x02FE,
+ ///
+ /// cgt.un - Push 1 (of type int32) if value1 greater that value2, unsigned or unordered, else push 0.
+ ///
+ CgtUn = 0x03FE,
+ ///
+ /// Throw ArithmeticException if value is not a finite number.
+ ///
+ CkFinite = 0xC3,
+ ///
+ /// clt - Push 1 (of type int32) if value1 lower than value2, else push 0.
+ ///
+ Clt = 0x04FE,
+ ///
+ /// clt.un - Push 1 (of type int32) if value1 lower than value2, unsigned or unordered, else push 0.
+ ///
+ CltUn = 0x05FE,
+ ///
+ /// constrained <thisType> - Call a virtual method on a type constrained to be type T
+ ///
+ Constrained = 0x16FE,
+ ///
+ /// Convert to native int, pushing native int on stack.
+ ///
+ ConvI = 0xD3,
+ ///
+ /// conv.i1 - Convert to int8, pushing int32 on stack.
+ ///
+ ConvI1 = 0x67,
+ ///
+ /// conv.i2 - Convert to int16, pushing int32 on stack.
+ ///
+ ConvI2 = 0x68,
+ ///
+ /// conv.i4 - Convert to int32, pushing int32 on stack.
+ ///
+ ConvI4 = 0x69,
+ ///
+ /// conv.i8 - Convert to int64, pushing int64 on stack.
+ ///
+ ConvI8 = 0x6A,
+ ///
+ /// conv.ovf.i - Convert to a native int (on the stack as native int) and throw an exception on overflow.
+ ///
+ ConvOvfI = 0xD4,
+ ///
+ /// conv.ovf.i.un - Convert unsigned to a native int (on the stack as native int) and throw an exception on overflow.
+ ///
+ ConvOvfIUn = 0x8A,
+ ///
+ /// conv.ovf.i1 - Convert to an int8 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI1 = 0xB3,
+ ///
+ /// conv.ovf.i1.un - Convert unsigned to an int8 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI1Un = 0x82,
+ ///
+ /// conv.ovf.i2 - Convert to an int16 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI2 = 0xB5,
+ ///
+ /// conv.ovf.i2.un - Convert unsigned to an int16 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI2Un = 0x83,
+ ///
+ /// conv.ovf.i4 - Convert to an int32 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI4 = 0xB7,
+ ///
+ /// conv.ovf.i4.un - Convert unsigned to an int32 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfI4Un = 0x84,
+ ///
+ /// conv.ovf.i8 - Convert to an int64 (on the stack as int64) and throw an exception on overflow.
+ ///
+ ConvOvfI8 = 0xB9,
+ ///
+ /// conv.ovf.i8.un - Convert unsigned to an int64 (on the stack as int64) and throw an exception on overflow.
+ ///
+ ConvOvfI8Un = 0x85,
+ ///
+ /// conv.ovf.u - Convert to a native unsigned int (on the stack as native int) and throw an exception on overflow.
+ ///
+ ConvOvfU = 0xD5,
+ ///
+ /// conv.ovf.u.un - Convert unsigned to a native unsigned int (on the stack as native int) and throw an exception on overflow.
+ ///
+ ConvOvfUUn = 0x8B,
+ ///
+ /// conv.ovf.u1 - Convert to an unsigned int8 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU1 = 0xB4,
+ ///
+ /// conv.ovf.u1.un - Convert unsigned to an unsigned int8 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU1Un = 0x86,
+ ///
+ /// conv.ovf.u2 - Convert to an unsigned int16 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU2 = 0xB6,
+ ///
+ /// conv.ovf.u2.un - Convert unsigned to an unsigned int16 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU2Un = 0x87,
+ ///
+ /// conv.ovf.u4 - Convert to an unsigned int32 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU4 = 0xB8,
+ ///
+ /// conv.ovf.u4.un - Convert unsigned to an unsigned int32 (on the stack as int32) and throw an exception on overflow.
+ ///
+ ConvOvfU4Un = 0x88,
+ ///
+ /// conv.ovf.u8 - Convert to an unsigned int64 (on the stack as int64) and throw an exception on overflow.
+ ///
+ ConvOvfU8 = 0xBA,
+ ///
+ /// conv.ovf.u8.un - Convert unsigned to an unsigned int64 (on the stack as int64) and throw an exception on overflow.
+ ///
+ ConvOvfU8Un = 0x89,
+
+ ///
+ /// conv.r.un - Convert unsigned integer to floating-point, pushing F on stack.
+ ///
+ ConvRUn = 0x76,
+ ///
+ /// conv.r4 - Convert to float32, pushing F on stack.
+ ///
+ ConvR4 = 0x6B,
+ ///
+ /// conv.r8 - Convert to float64, pushing F on stack.
+ ///
+ ConvR8 = 0x6C,
+ ///
+ /// conv.u - Convert to native unsigned int, pushing native int on stack.
+ ///
+ ConvU = 0xE0,
+ ///
+ /// conv.u1 - Convert to unsigned int8, pushing int32 on stack.
+ ///
+ ConvU1 = 0xD2,
+ ///
+ /// conv.u2 - Convert to unsigned int16, pushing int32 on stack.
+ ///
+ ConvU2 = 0xD1,
+ ///
+ /// conv.u4 - Convert to unsigned int32, pushing int32 on stack.
+ ///
+ ConvU4 = 0x6D,
+ ///
+ /// conv.u8 - Convert to unsigned int64, pushing int64 on stack.
+ ///
+ ConvU8 = 0x6E,
+ ///
+ /// cpblk - Copy data from memory to memory.
+ ///
+ CpBlk = 0x17FE,
+ ///
+ /// cpobj <typeTok> - Copy a value type from src to dest.
+ ///
+ CpObj = 0x70,
+ ///
+ /// div - Divide two values to return a quotient or floating-point result.
+ ///
+ Div = 0x5B,
+ ///
+ /// div.un - Divide two values, unsigned, returning a quotient.
+ ///
+ DivUn = 0x5C,
+ ///
+ /// dup - Duplicate the value on the top of the stack.
+ ///
+ Dup = 0x25,
+ ///
+ /// endfault - End fault clause of an exception block.
+ ///
+ EndFault = 0xDC,
+ ///
+ /// endfilter - End an exception handling filter clause.
+ ///
+ EndFilter = 0x11FE,
+ ///
+ /// endfinally - End finally clause of an exception block.
+ ///
+ EndFinally = 0xDC,
+ ///
+ /// initblk - Set all bytes in a block of memory to a given byte value.
+ ///
+ InitBlk = 0x18FE,
+ ///
+ /// initobj <typeTok> - initialize the value at address dest.
+ ///
+ InitObj = 0x15FE,
+ ///
+ /// isinst <class> - Test if obj is an instance of class, returning null or an instance of that class or interface.
+ ///
+ IsInst = 0x75,
+ ///
+ /// jmp <method> - Exit current method and jump to the specified method.
+ ///
+ Jmp = 0x27,
+ ///
+ /// ldarg <uint16 (num)> - Load argument numbered num onto the stack.
+ ///
+ LdArg = 0x09FE,
+ ///
+ /// ldarg.0 - Load argument 0 onto the stack.
+ ///
+ LdArg0 = 0x02,
+ ///
+ /// ldarg.1 - Load argument 1 onto the stack.
+ ///
+ LdArg1 = 0x03,
+ ///
+ /// ldarg.2 - Load argument 2 onto the stack.
+ ///
+ LdArg2 = 0x04,
+ ///
+ /// ldarg.3 - Load argument 3 onto the stack.
+ ///
+ LdArg3 = 0x05,
+ ///
+ /// ldarg.s <uint8 (num)> Load argument numbered num onto the stack, short form.
+ ///
+ LdArgS = 0x0E,
+ ///
+ /// ldarga <uint16 (argNum)> - Fetch the address of argument argNum.
+ ///
+ LdArgA = 0x0AFE,
+ ///
+ /// ldarga.s <uint8 (argNum)> - Fetch the address of argument argNum, short form.
+ ///
+ LdArgAS = 0x0F,
+ ///
+ /// Push num of type int32 onto the stack as int32.
+ ///
+ LdCI4 = 0x20,
+ ///
+ /// ldc.i4.m1 - Push the constant value -1 onto the stack as int32.
+ ///
+ LdCI4_M1 = 0x15,
+ ///
+ /// ldc.i4.0 - Push the constant value 0 onto the stack as int32.
+ ///
+ LdCI4_0 = 0x16,
+ ///
+ /// ldc.i4.1 - Push the constant value 1 onto the stack as int32.
+ ///
+ LdCI4_1 = 0x17,
+ ///
+ /// ldc.i4.2 - Push the constant value 2 onto the stack as int32.
+ ///
+ LdCI4_2 = 0x18,
+ ///
+ /// ldc.i4.3 - Push the constant value 3 onto the stack as int32.
+ ///
+ LdCI4_3 = 0x19,
+ ///
+ /// ldc.i4.4 - Push the constant value 4 onto the stack as int32.
+ ///
+ LdCI4_4 = 0x1A,
+ ///
+ /// ldc.i4.5 - Push the constant value 5 onto the stack as int32.
+ ///
+ LdCI4_5 = 0x1B,
+ ///
+ /// ldc.i4.6 - Push the constant value 6 onto the stack as int32.
+ ///
+ LdCI4_6 = 0x1C,
+ ///
+ /// ldc.i4.7 - Push the constant value 7 onto the stack as int32.
+ ///
+ LdCI4_7 = 0x1D,
+ ///
+ /// ldc.i4.8 - Push the constant value 8 onto the stack as int32.
+ ///
+ LdCI4_8 = 0x1E,
+ ///
+ /// ldc.i4.s <int8 (num)> - Push num onto the stack as int32, short form.
+ ///
+ LdCI4S = 0x1F,
+
+ ///
+ /// ldc.i8 <int64 (num)> - Push num of type int64 onto the stack as int64.
+ ///
+ LdCI8 = 0x21,
+ ///
+ /// ldc.r4 <float32 (num)> - Push num of type float32 onto the stack as F.
+ ///
+ LdCR4 = 0x22,
+ ///
+ /// ldc.r8 <float64 (num)> - Push num of type float64 onto the stack as F.
+ ///
+ LdCR8 = 0x23,
+ ///
+ /// ldelem <typeTok> - Load the element at index onto the top of the stack.
+ ///
+ LdElem = 0xA3,
+ ///
+ /// ldelem.i - Load the element with type native int at index onto the top of the stack as a native int.
+ ///
+ LdElemI = 0x97,
+ ///
+ /// ldelem.i1 - Load the element with type int8 at index onto the top of the stack as an int32.
+ ///
+ LdElemI1 = 0x90,
+ ///
+ /// ldelem.u1 - Load the element with type unsigned int8 at index onto the top of the stack as an int32.
+ ///
+ LdElemU1 = 0x91,
+ ///
+ /// ldelem.i2 - Load the element with type int16 at index onto the top of the stack as an int32.
+ ///
+ LdElemI2 = 0x92,
+ ///
+ /// ldelem.u1 - Load the element with type unsigned int8 at index onto the top of the stack as an int32.
+ ///
+ LdElemU2 = 0x93,
+ ///
+ /// ldelem.i4 - Load the element with type int32 at index onto the top of the stack as an int32.
+ ///
+ LdElemI4 = 0x94,
+ ///
+ /// ldelem.u1 - Load the element with type unsigned int8 at index onto the top of the stack as an int32.
+ ///
+ LdElemU4 = 0x95,
+ ///
+ /// ldelem.i8 / ldelem.u8 - Load the element with type (unsigned) int64 at index onto the top of the stack as an int64.
+ ///
+ LdElemI8 = 0x96,
+ ///
+ /// ldelem.i4 - Load the element with type float32 at index onto the top of the stack as an F.
+ ///
+ LdElemR4 = 0x98,
+ ///
+ /// ldelem.i8 - Load the element with type float64 at index onto the top of the stack as an F.
+ ///
+ LdElemR8 = 0x99,
+ ///
+ /// ldelem.ref - Load the element at index onto the top of the stack as an O. The type of the O is the same as the element type of the array pushed on the CIL stack.
+ ///
+ LdElemRef = 0x9A,
+ ///
+ /// ldelema <class> - Load the address of element at index onto the top of the stack.
+ ///
+ LdElemA = 0x8F,
+ ///
+ /// ldfld <field> - Push the value of field of object (or value type) obj, onto the stack.
+ ///
+ LdFld = 0x7B,
+ ///
+ /// ldflda <field> - Push the address of field of object obj on the stack.
+ ///
+ LdFldA = 0x7C,
+ ///
+ /// ldftn <method> - Push a pointer to a method referenced by method, on the stack.
+ ///
+ LdFtn = 0x06FE,
+ ///
+ /// ldind.i - Indirect load value of type native int as native int on the stack
+ ///
+ LdIndI = 0x4D,
+ ///
+ /// ldind.i1 - Indirect load value of type int8 as int32 on the stack
+ ///
+ LdIndI1 = 0x46,
+ ///
+ /// ldind.u1 - Indirect load value of type unsigned int8 as int32 on the stack
+ ///
+ LdIndU1 = 0x47,
+ ///
+ /// ldind.i2 - Indirect load value of type int16 as int32 on the stack
+ ///
+ LdIndI2 = 0x48,
+ ///
+ /// ldind.u2 - Indirect load value of type unsigned int16 as int32 on the stack
+ ///
+ LdIndU2 = 0x49,
+ ///
+ /// ldind.i4 - Indirect load value of type int32 as int32 on the stack
+ ///
+ LdIndI4 = 0x4A,
+ ///
+ /// ldind.u4 - Indirect load value of type unsigned int32 as int32 on the stack
+ ///
+ LdIndU4 = 0x4B,
+ ///
+ /// ldind.i8 / ldind.u8 - Indirect load value of type (unsigned) int64 as int64 on the stack
+ ///
+ LdIndI8 = 0x4C,
+ ///
+ /// ldind.r8 - Indirect load value of type float32 as F on the stack
+ ///
+ LdIndR4 = 0x4E,
+ ///
+ /// ldind.r8 - Indirect load value of type float64 as F on the stack
+ ///
+ LdIndR8 = 0x4F,
+ ///
+ /// ldind.ref - Indirect load value of type object ref as O on the stack.
+ ///
+ LdIndRef = 0x50,
+
+ ///
+ /// ldlen - Push the length (of type native unsigned int) of array on the stack.
+ ///
+ LdLen = 0x8E,
+
+ ///
+ /// ldloc <uint16 (indx)> - Load local variable of index indx onto stack.
+ ///
+ LdLoc = 0x0CFE,
+ ///
+ /// ldloc.0 - Load local variable 0 onto stack.
+ ///
+ LdLoc0 = 0x06,
+ ///
+ /// ldloc.1 - Load local variable 1 onto stack.
+ ///
+ LdLoc1 = 0x07,
+ ///
+ /// ldloc.2 - Load local variable 2 onto stack.
+ ///
+ LdLoc2 = 0x08,
+ ///
+ /// ldloc.3 - Load local variable 3 onto stack.
+ ///
+ LdLoc3 = 0x09,
+ ///
+ /// ldloc.s <uint8 (indx)> - Load local variable of index indx onto stack, short form.
+ ///
+ LdLocS = 0x11,
+ ///
+ /// ldloca <uint16 (indx)> - Load address of local variable with index indx.
+ ///
+ LdLocA = 0x0DFE,
+ ///
+ /// ldloca.s <uint16 (indx)> - Load address of local variable with index indx, short form.
+ ///
+ LdLocAS = 0x12,
+ ///
+ /// ldnull - Push a null reference on the stack.
+ ///
+ LdNull = 0x14,
+ ///
+ /// ldobj <typeTok> - Copy the value stored at address src to the stack.
+ ///
+ LdObj = 0x71,
+ ///
+ /// ldsfld <field> - Push the value of the static field on the stack.
+ ///
+ LdSFld = 0x7E,
+ ///
+ /// ldsflda <field> - Push the address of the static field, field, on the stack.
+ ///
+ LdSFldA = 0x7F,
+ ///
+ /// ldstr <string> - Push a string object for the literal string.
+ ///
+ LdStr = 0x72,
+ ///
+ /// ldtoken <token> - Convert metadata token to its runtime representation.
+ ///
+ LdToken = 0xD0,
+ ///
+ /// ldvirtftn <method> - Push address of virtual method on the stack.
+ ///
+ LdVirtFtn = 0x07FE,
+ ///
+ /// leave <int32 (target)> - Exit a protected region of code.
+ ///
+ Leave = 0xDD,
+ ///
+ /// leave <int8 (target)> - Exit a protected region of code, short form.
+ ///
+ LeaveS = 0xDE,
+ ///
+ /// localloc - Allocate space from the local memory pool.
+ ///
+ LocAlloc = 0x0FFE,
+ ///
+ /// mkrefany <class> - Push a typed reference to ptr of type class onto the stack.
+ ///
+ MkRefAny = 0xC6,
+ ///
+ /// mul - Multiply values.
+ ///
+ Mul = 0x5A,
+ ///
+ /// mul.ovf - Multiply signed integer values. Signed result shall fit in same size.
+ ///
+ MulOvf = 0xD8,
+ ///
+ /// mul.ovf.un - Multiply unsigned integer values. Unsigned result shall fit in same size.
+ ///
+ MulOvfUn = 0xD9,
+ ///
+ /// neg - Negate value.
+ ///
+ Neg = 0x65,
+ ///
+ /// newarr <etype> - Create a new array with elements of type etype.
+ ///
+ NewArr = 0x8D,
+ ///
+ /// newobj <ctor> - Allocate an uninitialized object or value type and call ctor.
+ ///
+ NewObj = 0x73,
+ ///
+ /// no.{typecheck, rangecheck, nullcheck} - The specified fault check(s) normally performed as part of the execution of the subsequent instruction can/shall be skipped.
+ ///
+ No = 0x19FE,
+ ///
+ /// nop - Do nothing (No operation).
+ ///
+ Nop = 0x00,
+ ///
+ /// not - Bitwise complement (logical not).
+ ///
+ Not = 0x66,
+ ///
+ /// or - Bitwise OR of two integer values, returns an integer.
+ ///
+ Or = 0x60,
+ ///
+ /// pop - Pop value from the stack.
+ ///
+ Pop = 0x26,
+ ///
+ /// readonly. - Specify that the subsequent array address operation performs no type check at runtime, and that it returns a controlled-mutability managed pointer.
+ ///
+ Readonly = 0x1EFE,
+ ///
+ /// refanytype - Push the type token stored in a typed reference.
+ ///
+ RefAnyType = 0x1DFE,
+ ///
+ /// refanyval <type> - Push the address stored in a typed reference.
+ ///
+ RefAnyVal = 0xC2,
+ ///
+ /// rem - Remainder when dividing one value by another.
+ ///
+ Rem = 0x5D,
+ ///
+ /// rem.un - Remainder when dividing one unsigned value by another.
+ ///
+ RemUn = 0x5E,
+ ///
+ /// ret - Return from method, possibly with a value.
+ ///
+ Ret = 0x2A,
+ ///
+ /// rethrow - Rethrow the current exception.
+ ///
+ Rethrow = 0x1AFE,
+ ///
+ /// shl - Shift an integer left (shifting in zeros), return an integer.
+ ///
+ Shl = 0x62,
+ ///
+ /// shr - Shift an integer right (shift in sign), return an integer.
+ ///
+ Shr = 0x63,
+ ///
+ /// shr.un - Shift an integer right (shift in zero), return an integer.
+ ///
+ ShrUn = 0x64,
+ ///
+ /// sizeof <typeTok> - Push the size, in bytes, of a type as an unsigned int32.
+ ///
+ SizeOf = 0x1CFE,
+ ///
+ /// starg <uint16 (num)> - Store value to the argument numbered num.
+ ///
+ StArg = 0x0BFE,
+ ///
+ /// starg.s <uint8 (num)> - Store value to the argument numbered num, short form.
+ ///
+ StArgS = 0x10,
+ ///
+ /// stelem <typeTok> - Replace array element at index with the value on the stack
+ ///
+ StElem = 0xA4,
+ ///
+ /// stelem.i - Replace array element at index with the i value on the stack.
+ ///
+ StElemI = 0x9B,
+ ///
+ /// stelem.i1 - Replace array element at index with the int8 value on the stack.
+ ///
+ StElemI1 = 0x9C,
+ ///
+ /// stelem.i2 - Replace array element at index with the int16 value on the stack.
+ ///
+ StElemI2 = 0x9D,
+ ///
+ /// stelem.i1 - Replace array element at index with the int32 value on the stack.
+ ///
+ StElemI4 = 0x9E,
+ ///
+ /// stelem.i2 - Replace array element at index with the int64 value on the stack.
+ ///
+ StElemI8 = 0x9F,
+ ///
+ /// stelem.r4 - Replace array element at index with the float32 value on the stack.
+ ///
+ StElemR4 = 0xA0,
+ ///
+ /// stelem.r8 - Replace array element at index with the float64 value on the stack.
+ ///
+ StElemR8 = 0xA1,
+ ///
+ /// stelem.ref - Replace array element at index with the ref value on the stack.
+ ///
+ StElemRef = 0xA2,
+ ///
+ /// stfld <field> - Replace the value of field of the object obj with value.
+ ///
+ StFld = 0x7D,
+ ///
+ /// stind.i - Store value of type native int into memory at address
+ ///
+ StIndI = 0xDF,
+ ///
+ /// stind.i1 - Store value of type int8 into memory at address
+ ///
+ StIndI1 = 0x52,
+ ///
+ /// stind.i2 - Store value of type int16 into memory at address
+ ///
+ StIndI2 = 0x53,
+ ///
+ /// stind.i4 - Store value of type int32 into memory at address
+ ///
+ StIndI4 = 0x54,
+ ///
+ /// stind.i8 - Store value of type int64 into memory at address
+ ///
+ StIndI8 = 0x55,
+ ///
+ /// stind.r4 - Store value of type float32 into memory at address
+ ///
+ StIndR4 = 0x56,
+ ///
+ /// stind.r8 - Store value of type float64 into memory at address
+ ///
+ StIndR8 = 0x57,
+ ///
+ /// stind.ref - Store value of type object ref (type O) into memory at address
+ ///
+ StIndRef = 0x51,
+ ///
+ /// stloc <uint16 (indx)> - Pop a value from stack into local variable indx.
+ ///
+ StLoc = 0x0EFE,
+ ///
+ /// stloc.0 - Pop a value from stack into local variable 0.
+ ///
+ StLoc0 = 0x0A,
+ ///
+ /// stloc.1 - Pop a value from stack into local variable 1.
+ ///
+ StLoc1 = 0x0B,
+ ///
+ /// stloc.2 - Pop a value from stack into local variable 2.
+ ///
+ StLoc2 = 0x0C,
+ ///
+ /// stloc.3 - Pop a value from stack into local variable 3.
+ ///
+ StLoc3 = 0x0D,
+ ///
+ /// stloc.s <uint8 (indx)> - Pop a value from stack into local variable indx, short form.
+ ///
+ StLocS = 0x13,
+ ///
+ /// stobj <typeTok> - Store a value of type typeTok at an address.
+ ///
+ StObj = 0x81,
+ ///
+ /// stsfld <field> - Replace the value of the static field with val.
+ ///
+ StSFld = 0x80,
+ ///
+ /// sub - Subtract value2 from value1, returning a new value.
+ ///
+ Sub = 0x59,
+ ///
+ /// sub.ovf - Subtract native int from a native int. Signed result shall fit in same size.
+ ///
+ SubOvf = 0xDA,
+ ///
+ /// sub.ovf.un - Subtract native unsigned int from a native unsigned int. Unsigned result shall fit in same size.
+ ///
+ SubOvfUn = 0xDB,
+ ///
+ /// switch <uint32, int32, int32 (t1..tN)> - Jump to one of n values.
+ ///
+ Switch = 0x45,
+ ///
+ /// tail. - Subsequent call terminates current method.
+ ///
+ Tail = 0x14FE,
+ ///
+ /// throw - Throw an exception.
+ ///
+ Throw = 0x7A,
+
+ ///
+ /// unaligned.(alignment) - Subsequent pointer instruction might be unaligned.
+ ///
+ Unaligned = 0x12FE,
+ ///
+ /// unbox <valuetype> - Extract a value-type from obj, its boxed representation, and push a controlled-mutability managed pointer to it to the top of the stack.
+ ///
+ Unbox = 0x79,
+ ///
+ /// unbox.any <typeTok> - Extract a value-type from obj, its boxed representation, and copy to the top of the stack
+ ///
+ UnboxAny = 0xA5,
+ ///
+ /// Subsequent pointer reference is volatile.
+ ///
+ Volatile = 0x13FE,
+ ///
+ /// xor - Bitwise XOR of integer values, returns an integer.
+ ///
+ Xor = 0x61
+ }
+}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ManagedAssemblyPanel.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ManagedAssemblyPanel.cs
new file mode 100644
index 00000000..14363e63
--- /dev/null
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/Editors/Executable/ManagedAssemblyPanel.cs
@@ -0,0 +1,314 @@
+using System;
+using System.Reflection;
+using System.Text;
+using MBS.Framework.UserInterface;
+using MBS.Framework.UserInterface.Controls;
+using MBS.Framework.UserInterface.Dialogs;
+using MBS.Framework.UserInterface.Layouts;
+
+namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
+{
+ public class ManagedAssemblyPanel : Container
+ {
+ private TextBox txtSearch = null;
+ private ListView tvTypes = null;
+ private DefaultTreeModel tmTypes = null;
+ private TextBox txtSource = null;
+
+ private ComboBox cboLanguage = null;
+
+ private System.Reflection.Assembly _Assembly = null;
+ public System.Reflection.Assembly Assembly
+ {
+ get { return _Assembly; }
+ set
+ {
+ _Assembly = value;
+ UpdateTypeList();
+ }
+ }
+
+ private void UpdateTypeList()
+ {
+ tmTypes.Rows.Clear();
+
+ Type[] types = null;
+ try
+ {
+ types = _Assembly.GetTypes();
+ }
+ catch (System.Reflection.ReflectionTypeLoadException ex)
+ {
+ types = ex.Types;
+ }
+
+ for (int i = 0; i < types.Length; i++)
+ {
+ if (types[i] == null)
+ continue;
+
+ string[] nameParts = types[i].FullName.Split(new char[] { '.' });
+ bool nestedClass = false;
+ while (nameParts[nameParts.Length - 1].Contains("+"))
+ {
+ // handle the case of nested classes
+ nestedClass = true;
+ Array.Resize(ref nameParts, nameParts.Length + 1);
+ string[] p = nameParts[nameParts.Length - 2].Split(new char[] { '+' });
+ nameParts[nameParts.Length - 2] = p[0];
+ nameParts[nameParts.Length - 1] = p[1];
+ }
+
+ TreeModelRow row = tmTypes.RecursiveCreateTreeModelRow(tmTypes.Columns[0], nameParts, new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[1], "Namespace")
+ });
+
+ if (nestedClass)
+ row.ParentRow.RowColumns[1].Value = "Class";
+
+ row.RowColumns.Add(new TreeModelRowColumn(tmTypes.Columns[1], "Class"));
+
+ SetupTypeTreeModelRow(row, types[i]);
+ }
+ }
+
+ private void SetupTypeTreeModelRow(TreeModelRow row, Type type)
+ {
+ row.SetExtraData("item", type);
+
+ System.Reflection.BindingFlags bindingFlags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | BindingFlags.DeclaredOnly;
+
+ TreeModelRow rowBaseTypes = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], "Base Types")
+ });
+
+ if (type.BaseType != null)
+ {
+ TreeModelRow rowBaseType = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], type.BaseType.FullName)
+ });
+ SetupTypeTreeModelRow(rowBaseType, type.BaseType);
+ rowBaseTypes.Rows.Add(rowBaseType);
+ }
+
+ row.Rows.Add(rowBaseTypes);
+
+ TreeModelRow rowDerivedTypes = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], "Derived Types")
+ });
+ row.Rows.Add(rowDerivedTypes);
+
+ System.Reflection.FieldInfo[] fields = type.GetFields(bindingFlags);
+ for (int j = 0; j < fields.Length; j++)
+ {
+ TreeModelRow row2 = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], fields[j]),
+ new TreeModelRowColumn(tmTypes.Columns[1], "Field")
+ });
+ row2.SetExtraData("item", fields[j]);
+ row.Rows.Add(row2);
+ }
+
+ System.Reflection.EventInfo[] events = type.GetEvents(bindingFlags);
+ for (int j = 0; j < events.Length; j++)
+ {
+ TreeModelRow row2 = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], events[j]),
+ new TreeModelRowColumn(tmTypes.Columns[1], "Event")
+ });
+ row2.SetExtraData("item", events[j]);
+ row.Rows.Add(row2);
+ }
+
+ System.Reflection.PropertyInfo[] props = type.GetProperties(bindingFlags);
+ for (int j = 0; j < props.Length; j++)
+ {
+ TreeModelRow row2 = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], props[j]),
+ new TreeModelRowColumn(tmTypes.Columns[1], "Property")
+ });
+ row2.SetExtraData("item", props[j]);
+ row.Rows.Add(row2);
+ }
+
+ System.Reflection.MethodInfo[] meths = type.GetMethods(bindingFlags);
+ for (int j = 0; j < meths.Length; j++)
+ {
+ if (meths[j].IsSpecialName && (meths[j].Name.StartsWith("set_", StringComparison.OrdinalIgnoreCase) || meths[j].Name.StartsWith("get_", StringComparison.OrdinalIgnoreCase)))
+ {
+ // we can be REASONABLY sure that this is a property setter / getter,
+ // and as we've already gotten all the properties, ignore it
+ continue;
+ }
+
+ TreeModelRow row2 = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmTypes.Columns[0], GetMethodTitle(meths[j])),
+ new TreeModelRowColumn(tmTypes.Columns[1], "Method")
+ });
+ row2.SetExtraData("item", meths[j]);
+ row.Rows.Add(row2);
+ }
+ }
+
+ private void tsbILSave_Click(object sender, EventArgs e)
+ {
+ MemberInfo t = tvTypes.SelectedRows[0].GetExtraData("item");
+ if (t == null)
+ return;
+
+ FileDialog dlg = new FileDialog();
+ dlg.Text = "Save Code File";
+
+ dlg.SelectedFileNames.Clear();
+
+ dlg.SelectedFileNames.Add(t.Name + Language.CodeFileExtension);
+
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+
+ }
+ }
+
+ public ManagedAssemblyPanel()
+ {
+ Layout = new BoxLayout(Orientation.Vertical);
+
+ Container ctToolbarAndOthers = new Container();
+ ctToolbarAndOthers.Layout = new BoxLayout(Orientation.Horizontal);
+
+ Toolbar tb = new Toolbar();
+ tb.Items.Add(new ToolbarItemButton("tsbILSave", StockType.Save, tsbILSave_Click));
+ ctToolbarAndOthers.Controls.Add(tb, new BoxLayout.Constraints(false, true));
+
+ cboLanguage = new ComboBox();
+ cboLanguage.Changed += cboLanguage_Changed;
+ Type[] codeProviders = MBS.Framework.Reflection.GetAvailableTypes(new Type[] { typeof(CodeProvider) });
+ DefaultTreeModel tmLanguage = new DefaultTreeModel(new Type[] { typeof(string) });
+
+ /*
+ tmLanguage.Rows.Add(new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmLanguage.Columns[0], "Raw Bytes")
+ }));
+ */
+
+ for (int i = 0; i < codeProviders.Length; i++)
+ {
+ CodeProvider codeProvider = (codeProviders[i].Assembly.CreateInstance(codeProviders[i].FullName) as CodeProvider);
+ TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[]
+ {
+ new TreeModelRowColumn(tmLanguage.Columns[0], codeProvider.Title)
+ });
+ row.SetExtraData("provider", codeProvider);
+ tmLanguage.Rows.Add(row);
+ }
+ if (tmLanguage.Rows.Count > 0)
+ {
+ cboLanguage.SelectedItem = tmLanguage.Rows[0];
+ }
+ cboLanguage.ReadOnly = true;
+ cboLanguage.Model = tmLanguage;
+ ctToolbarAndOthers.Controls.Add(cboLanguage, new BoxLayout.Constraints(false, false));
+
+ Controls.Add(ctToolbarAndOthers, new BoxLayout.Constraints(false, true));
+
+ SplitContainer scLeftRight = new SplitContainer(Orientation.Vertical);
+ scLeftRight.SplitterPosition = 250;
+
+ txtSearch = new TextBox();
+
+ scLeftRight.Panel1.Layout = new BoxLayout(Orientation.Vertical);
+ scLeftRight.Panel1.Controls.Add(txtSearch, new BoxLayout.Constraints(false, true));
+
+ tvTypes = new ListView();
+ tvTypes.SelectionChanged += tvTypes_SelectionChanged;
+
+ tmTypes = new DefaultTreeModel(new Type[] { typeof(string), typeof(string) });
+ tvTypes.Model = tmTypes;
+
+ tvTypes.Columns.Add(new ListViewColumnText(tmTypes.Columns[0], "Name"));
+ tvTypes.Columns.Add(new ListViewColumnText(tmTypes.Columns[1], "Type"));
+ scLeftRight.Panel1.Controls.Add(tvTypes, new BoxLayout.Constraints(true, true));
+
+ scLeftRight.Panel2.Layout = new BoxLayout(Orientation.Vertical);
+ txtSource = new TextBox();
+ txtSource.Multiline = true;
+ scLeftRight.Panel2.Controls.Add(txtSource, new BoxLayout.Constraints(true, true));
+
+ Controls.Add(scLeftRight, new BoxLayout.Constraints(true, true));
+ }
+
+ void cboLanguage_Changed(object sender, EventArgs e)
+ {
+ CodeProvider provider = cboLanguage.SelectedItem.GetExtraData("provider");
+ Language = provider;
+ }
+
+
+ private CodeProvider _Language = CodeProvider.CSharp;
+ public CodeProvider Language
+ {
+ get { return _Language; }
+ set
+ {
+ _Language = value;
+ tvTypes_SelectionChanged(this, EventArgs.Empty);
+ }
+ }
+
+ private string GetAccessModifiersSourceCode(System.Reflection.PropertyInfo mi)
+ {
+ return Language.GetAccessModifiers(mi);
+ }
+ private string GetAccessModifiersSourceCode(System.Reflection.MethodInfo mi)
+ {
+ return Language.GetAccessModifiers(mi);
+ }
+ private string GetAccessModifiersSourceCode(System.Reflection.FieldInfo mi)
+ {
+ return Language.GetAccessModifiers(mi);
+ }
+ private string GetAccessModifiersSourceCode(Type mi)
+ {
+ return Language.GetAccessModifiers(mi);
+ }
+
+ private string GetMethodTitle(System.Reflection.MethodInfo mi)
+ {
+ StringBuilder sb = new StringBuilder();
+ string typeName = Language.GetTypeName(mi.ReturnType);
+ sb.Append(mi.Name);
+ sb.Append('(');
+ sb.Append(')');
+ sb.Append(" : ");
+ sb.Append(typeName);
+ return sb.ToString();
+ }
+
+ private void tvTypes_SelectionChanged(object sender, EventArgs e)
+ {
+ if (tvTypes.SelectedRows.Count == 0)
+ return;
+
+ object item = tvTypes.SelectedRows[0].GetExtraData("item");
+ if (item is Type)
+ {
+ Type typ = (item as Type);
+ txtSource.Text = Language.GetSourceCode(typ, 0);
+ }
+ else if (item is System.Reflection.MethodInfo)
+ {
+ txtSource.Text = Language.GetSourceCode(item as System.Reflection.MethodInfo, 0);
+ }
+ }
+
+ }
+}
diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/UniversalEditor.Plugins.Executable.UserInterface.csproj b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/UniversalEditor.Plugins.Executable.UserInterface.csproj
index d2f0474d..57d3d5e7 100644
--- a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/UniversalEditor.Plugins.Executable.UserInterface.csproj
+++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Executable.UserInterface/UniversalEditor.Plugins.Executable.UserInterface.csproj
@@ -32,10 +32,16 @@
+
+
+
+
+
+