mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Massive improvements to UIX decompiler
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Microsoft.Iris.Debug.Data
|
|||||||
{
|
{
|
||||||
OpCode = opCode;
|
OpCode = opCode;
|
||||||
|
|
||||||
if (args != null)
|
if (args != null && args.Length > 0)
|
||||||
Arguments = args;
|
Arguments = args;
|
||||||
else
|
else
|
||||||
Arguments = new List<OpCodeArgument>();
|
Arguments = new List<OpCodeArgument>();
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Xml;
|
||||||
|
|
||||||
#if NET40_OR_GREATER || NET6_0_OR_GREATER
|
#if NET40_OR_GREATER || NET6_0_OR_GREATER
|
||||||
using DataMappingModelsList = System.Collections.ObjectModel.ObservableCollection<Microsoft.Iris.Debug.DataMappingModel>;
|
using DataMappingModelsList = System.Collections.ObjectModel.ObservableCollection<Microsoft.Iris.Debug.DataMappingModel>;
|
||||||
|
using DecompileResultList = System.Collections.ObjectModel.ObservableCollection<Microsoft.Iris.Debug.DecompilationResult>;
|
||||||
#else
|
#else
|
||||||
using DataMappingModelsList = System.Collections.Generic.List<Microsoft.Iris.Debug.DataMappingModel>;
|
using DataMappingModelsList = System.Collections.Generic.List<Microsoft.Iris.Debug.DataMappingModel>;
|
||||||
|
using DecompileResultList = System.Collections.Generic.List<Microsoft.Iris.Debug.DecompilationResult>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Microsoft.Iris.Debug
|
namespace Microsoft.Iris.Debug
|
||||||
@@ -12,7 +14,7 @@ namespace Microsoft.Iris.Debug
|
|||||||
{
|
{
|
||||||
public bool UseDecompiler { get; set; } = false;
|
public bool UseDecompiler { get; set; } = false;
|
||||||
public bool OpenDebugPipe { get; set; } = false;
|
public bool OpenDebugPipe { get; set; } = false;
|
||||||
public List<System.Xml.XmlDocument> DecompileResults { get; } = new List<System.Xml.XmlDocument>();
|
public DecompileResultList DecompileResults { get; } = new DecompileResultList();
|
||||||
public TraceSettings TraceSettings { get; } = TraceSettings.Current;
|
public TraceSettings TraceSettings { get; } = TraceSettings.Current;
|
||||||
|
|
||||||
public bool GenerateDataMappingModels { get; set; } = false;
|
public bool GenerateDataMappingModels { get; set; } = false;
|
||||||
@@ -26,6 +28,18 @@ namespace Microsoft.Iris.Debug
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DecompilationResult
|
||||||
|
{
|
||||||
|
internal DecompilationResult(string context, XmlDocument doc)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
Doc = doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Context { get; private set; }
|
||||||
|
public XmlDocument Doc { get; private set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class DataMappingModel
|
public class DataMappingModel
|
||||||
{
|
{
|
||||||
internal DataMappingModel(string provider, string type, string generatedCode)
|
internal DataMappingModel(string provider, string type, string generatedCode)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.Iris.Debug;
|
using Microsoft.Iris.Debug;
|
||||||
@@ -758,7 +759,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
|
|
||||||
// Token: 0x04000949 RID: 2377
|
// Token: 0x04000949 RID: 2377
|
||||||
private static Stack _stack = new Stack();
|
private static Stack _stack = new Stack();
|
||||||
private static Stack _xmlStack = new Stack();
|
private static Stack<XmlNode> _xmlStack = new Stack<XmlNode>();
|
||||||
|
|
||||||
// Token: 0x0400094A RID: 2378
|
// Token: 0x0400094A RID: 2378
|
||||||
public static object ScriptError = new Interpreter.ScriptErrorObject();
|
public static object ScriptError = new Interpreter.ScriptErrorObject();
|
||||||
@@ -852,7 +853,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
SymbolReference[] symbolReferenceTable = context.MarkupType.SymbolReferenceTable;
|
SymbolReference[] symbolReferenceTable = context.MarkupType.SymbolReferenceTable;
|
||||||
Trace.IsCategoryEnabled(TraceCategory.Markup);
|
Trace.IsCategoryEnabled(TraceCategory.Markup);
|
||||||
Stack stack = _stack;
|
Stack stack = _stack;
|
||||||
Stack xmlStack = _xmlStack;
|
Stack<XmlNode> xmlStack = _xmlStack;
|
||||||
int count = stack.Count;
|
int count = stack.Count;
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
@@ -913,7 +914,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
int num2 = reader.ReadUInt16();
|
int num2 = reader.ReadUInt16();
|
||||||
TypeSchema typeSchema2 = importTables.TypeImports[num2];
|
TypeSchema typeSchema2 = importTables.TypeImports[num2];
|
||||||
TypeSchema typeSchema3 = (TypeSchema)stack.Pop();
|
TypeSchema typeSchema3 = (TypeSchema)stack.Pop();
|
||||||
TypeSchema typeSchemaXml3 = (TypeSchema)xmlStack.Pop();
|
xmlStack.Pop();
|
||||||
if (!typeSchema2.IsAssignableFrom(typeSchema3))
|
if (!typeSchema2.IsAssignableFrom(typeSchema3))
|
||||||
{
|
{
|
||||||
ErrorManager.ReportError("Script runtime failure: Dynamic construction type override failed. Attempting to construct '{0}' in place of '{1}'", (typeSchema3 != null) ? typeSchema3.Name : "null", typeSchema2.Name);
|
ErrorManager.ReportError("Script runtime failure: Dynamic construction type override failed. Attempting to construct '{0}' in place of '{1}'", (typeSchema3 != null) ? typeSchema3.Name : "null", typeSchema2.Name);
|
||||||
@@ -1039,7 +1040,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
"symbolRef", typeof(SymbolReference), symbolRef));
|
"symbolRef", typeof(SymbolReference), symbolRef));
|
||||||
|
|
||||||
object obj8 = context.ReadSymbol(symbolRef);
|
object obj8 = context.ReadSymbol(symbolRef);
|
||||||
var objXml8 = XmlDoc.CreateElement(obj8.GetType().Name);
|
var objXml8 = GenerateXmlRepresentation(obj8);
|
||||||
|
|
||||||
stack.Push(obj8);
|
stack.Push(obj8);
|
||||||
xmlStack.Push(objXml8);
|
xmlStack.Push(objXml8);
|
||||||
@@ -1092,7 +1093,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
PropertySchema propertySchema = importTables.PropertyImports[num11];
|
PropertySchema propertySchema = importTables.PropertyImports[num11];
|
||||||
object propValue = stack.Pop();
|
object propValue = stack.Pop();
|
||||||
object destObj = stack.Pop();
|
object destObj = stack.Pop();
|
||||||
object propValueXml = xmlStack.Pop();
|
XmlNode propValueXml = xmlStack.Pop();
|
||||||
var destObjXml = (XmlElement)xmlStack.Pop();
|
var destObjXml = (XmlElement)xmlStack.Pop();
|
||||||
ReportErrorOnNull(destObj, "Property Set", propertySchema.Name);
|
ReportErrorOnNull(destObj, "Property Set", propertySchema.Name);
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
@@ -1115,17 +1116,11 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
propertySchema.SetValue(ref destObj, propValue);
|
propertySchema.SetValue(ref destObj, propValue);
|
||||||
if (propValueXml is XmlElement propValueXmlElem)
|
if (!IsDefaultValue(propValue))
|
||||||
{
|
SetXmlPropValue(destObjXml, propertySchema.Name, propValueXml);
|
||||||
var propXmlElem = XmlDoc.CreateElement(propertySchema.Name);
|
|
||||||
propXmlElem.AppendChild(propValueXmlElem);
|
|
||||||
destObjXml.AppendChild(propXmlElem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
destObjXml.SetAttribute(propertySchema.Name, propValueXml.ToString());
|
|
||||||
}
|
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
stack.Push(destObj);
|
stack.Push(destObj);
|
||||||
@@ -1138,7 +1133,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
int propertyIndex = reader.ReadUInt16();
|
int propertyIndex = reader.ReadUInt16();
|
||||||
object value2 = stack.Pop();
|
object value2 = stack.Pop();
|
||||||
XmlElement valueXml2 = (XmlElement)xmlStack.Pop();
|
XmlNode valueXml2 = xmlStack.Pop();
|
||||||
object collection = GetCollectionDecompile(stack.Peek(), importTables, propertyIndex, out var propertySchema);
|
object collection = GetCollectionDecompile(stack.Peek(), importTables, propertyIndex, out var propertySchema);
|
||||||
ReportErrorOnNull(collection, "List Add");
|
ReportErrorOnNull(collection, "List Add");
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
@@ -1149,14 +1144,17 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add value to list
|
// Add value to list
|
||||||
var destObjXml = (XmlElement)xmlStack.Peek();
|
var destObjXml = xmlStack.Peek();
|
||||||
// Create element if needed
|
if (!IsDefaultValue(value2) && valueXml2 != null)
|
||||||
if (!(destObjXml.SelectSingleNode(propertySchema.Name) is XmlElement propXmlElem2))
|
|
||||||
{
|
{
|
||||||
propXmlElem2 = XmlDoc.CreateElement(propertySchema.Name);
|
// Create element if needed
|
||||||
destObjXml.AppendChild(propXmlElem2);
|
if (destObjXml.SelectSingleNode(propertySchema.Name) is not XmlElement propXmlElem2)
|
||||||
|
{
|
||||||
|
propXmlElem2 = XmlDoc.CreateElement(propertySchema.Name);
|
||||||
|
destObjXml.AppendChild(propXmlElem2);
|
||||||
|
}
|
||||||
|
propXmlElem2.AppendChild(valueXml2);
|
||||||
}
|
}
|
||||||
propXmlElem2.AppendChild(valueXml2);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1164,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
int index2 = reader.ReadUInt16();
|
int index2 = reader.ReadUInt16();
|
||||||
string key = (string)constantsTable.Get(index2);
|
string key = (string)constantsTable.Get(index2);
|
||||||
object value3 = stack.Pop();
|
object value3 = stack.Pop();
|
||||||
XmlElement valueXml3 = (XmlElement)xmlStack.Pop();
|
XmlNode valueXml3 = xmlStack.Pop();
|
||||||
object collection2 = GetCollectionDecompile(stack.Peek(), importTables, propertyIndex2, out var propertySchema2);
|
object collection2 = GetCollectionDecompile(stack.Peek(), importTables, propertyIndex2, out var propertySchema2);
|
||||||
ReportErrorOnNull(collection2, "Dictionary Add");
|
ReportErrorOnNull(collection2, "Dictionary Add");
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
@@ -1176,20 +1174,30 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add value to dictionary
|
if (!IsDefaultValue(value3) && valueXml3 != null)
|
||||||
var destObjXml2 = (XmlElement)xmlStack.Peek();
|
|
||||||
// Create element if needed
|
|
||||||
if (propertySchema2 != null)
|
|
||||||
{
|
{
|
||||||
XmlElement propXmlElem2 = destObjXml2.SelectSingleNode(propertySchema2.Name) as XmlElement;
|
// Prepare value XML element
|
||||||
if (propXmlElem2 == null)
|
if (valueXml3 is not XmlElement valueXmlElem3)
|
||||||
{
|
{
|
||||||
propXmlElem2 = XmlDoc.CreateElement(propertySchema2.Name);
|
// Need to create an XML element from the node
|
||||||
destObjXml2.AppendChild(propXmlElem2);
|
valueXmlElem3 = XmlDoc.CreateElement(value3.GetType().Name);
|
||||||
|
valueXmlElem3.AppendChild(valueXml3);
|
||||||
}
|
}
|
||||||
propXmlElem2.AppendChild(valueXml3);
|
|
||||||
|
// Add value to dictionary
|
||||||
|
var destObjXml2 = xmlStack.Peek();
|
||||||
|
// Create element if needed
|
||||||
|
if (propertySchema2 != null)
|
||||||
|
{
|
||||||
|
if (destObjXml2.SelectSingleNode(propertySchema2.Name) is not XmlElement propXmlElem2)
|
||||||
|
{
|
||||||
|
propXmlElem2 = XmlDoc.CreateElement(propertySchema2.Name);
|
||||||
|
destObjXml2.AppendChild(propXmlElem2);
|
||||||
|
}
|
||||||
|
propXmlElem2.AppendChild(valueXmlElem3);
|
||||||
|
}
|
||||||
|
valueXmlElem3.SetAttribute("Name", key);
|
||||||
}
|
}
|
||||||
valueXml3.SetAttribute("Name", key);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1210,6 +1218,13 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
object value4 = stack.Peek();
|
object value4 = stack.Peek();
|
||||||
propertySchema3.SetValue(ref instance2, value4);
|
propertySchema3.SetValue(ref instance2, value4);
|
||||||
|
|
||||||
|
if (opCode == OpCode.PropertyAssign)
|
||||||
|
{
|
||||||
|
var xmlInstance2 = (XmlElement)xmlStack.Pop();
|
||||||
|
SetXmlPropValue(xmlInstance2, propertySchema3.Name, value4);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag) && Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (!ErrorsDetected(watermark, ref result, ref flag) && Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1221,10 +1236,15 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
int num13 = reader.ReadUInt16();
|
int num13 = reader.ReadUInt16();
|
||||||
PropertySchema propertySchema4 = importTables.PropertyImports[num13];
|
PropertySchema propertySchema4 = importTables.PropertyImports[num13];
|
||||||
|
|
||||||
object instance3 = null;
|
object instance3 = null;
|
||||||
|
XmlElement xmlInstance3 = null;
|
||||||
|
|
||||||
if (opCode != OpCode.PropertyGetStatic)
|
if (opCode != OpCode.PropertyGetStatic)
|
||||||
{
|
{
|
||||||
instance3 = ((opCode == OpCode.PropertyGet) ? stack.Pop() : stack.Peek());
|
bool pop = opCode == OpCode.PropertyGet;
|
||||||
|
instance3 = pop ? stack.Pop() : stack.Peek();
|
||||||
|
xmlInstance3 = (XmlElement)(pop ? xmlStack.Pop() : xmlStack.Peek());
|
||||||
ReportErrorOnNullOrDisposed(instance3, "Property Get", propertySchema4.Name, propertySchema4.Owner);
|
ReportErrorOnNullOrDisposed(instance3, "Property Get", propertySchema4.Name, propertySchema4.Owner);
|
||||||
if (ErrorsDetected(watermark, ref result, ref flag))
|
if (ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
@@ -1255,6 +1275,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
for (j--; j >= 0; j--)
|
for (j--; j >= 0; j--)
|
||||||
{
|
{
|
||||||
array2[j] = stack.Pop();
|
array2[j] = stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
}
|
}
|
||||||
object instance4 = null;
|
object instance4 = null;
|
||||||
bool flag3 = opCode != OpCode.MethodInvokeStatic && opCode != OpCode.MethodInvokeStaticPushLastParam;
|
bool flag3 = opCode != OpCode.MethodInvokeStatic && opCode != OpCode.MethodInvokeStaticPushLastParam;
|
||||||
@@ -1265,6 +1286,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
if (!flag4)
|
if (!flag4)
|
||||||
{
|
{
|
||||||
instance4 = stack.Pop();
|
instance4 = stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1284,11 +1306,14 @@ namespace Microsoft.Iris.Markup
|
|||||||
if (methodSchema.ReturnType != VoidSchema.Type)
|
if (methodSchema.ReturnType != VoidSchema.Type)
|
||||||
{
|
{
|
||||||
stack.Push(obj11);
|
stack.Push(obj11);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(obj11));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.Push(array2[array2.Length - 1]);
|
var lastParam = array2[array2.Length - 1];
|
||||||
|
stack.Push(lastParam);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(lastParam));
|
||||||
}
|
}
|
||||||
ParameterListAllocator.Free(array2);
|
ParameterListAllocator.Free(array2);
|
||||||
}
|
}
|
||||||
@@ -1328,6 +1353,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
int num17 = reader.ReadUInt16();
|
int num17 = reader.ReadUInt16();
|
||||||
TypeSchema fromType = importTables.TypeImports[num17];
|
TypeSchema fromType = importTables.TypeImports[num17];
|
||||||
object obj13 = stack.Pop();
|
object obj13 = stack.Pop();
|
||||||
|
var xmlObj13 = xmlStack.Pop();
|
||||||
ReportErrorOnNull(obj13, "Type Conversion", typeSchema11.Name);
|
ReportErrorOnNull(obj13, "Type Conversion", typeSchema11.Name);
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
@@ -1340,6 +1366,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
stack.Push(obj14);
|
stack.Push(obj14);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(obj14));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1353,12 +1380,15 @@ namespace Microsoft.Iris.Markup
|
|||||||
if (!TypeSchema.IsUnaryOperation(op))
|
if (!TypeSchema.IsUnaryOperation(op))
|
||||||
{
|
{
|
||||||
right = stack.Pop();
|
right = stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
}
|
}
|
||||||
object left = stack.Pop();
|
object left = stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
object obj15 = typeSchema12.PerformOperationDeep(left, right, op);
|
object obj15 = typeSchema12.PerformOperationDeep(left, right, op);
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
stack.Push(obj15);
|
stack.Push(obj15);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(obj15));
|
||||||
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1370,12 +1400,14 @@ namespace Microsoft.Iris.Markup
|
|||||||
int num19 = reader.ReadUInt16();
|
int num19 = reader.ReadUInt16();
|
||||||
TypeSchema typeSchema13 = importTables.TypeImports[num19];
|
TypeSchema typeSchema13 = importTables.TypeImports[num19];
|
||||||
object obj16 = stack.Pop();
|
object obj16 = stack.Pop();
|
||||||
|
var xmlObj16 = xmlStack.Pop();
|
||||||
bool value6 = false;
|
bool value6 = false;
|
||||||
if (obj16 != null)
|
if (obj16 != null)
|
||||||
{
|
{
|
||||||
value6 = typeSchema13.IsAssignableFrom(obj16);
|
value6 = typeSchema13.IsAssignableFrom(obj16);
|
||||||
}
|
}
|
||||||
stack.Push(BooleanBoxes.Box(value6));
|
stack.Push(BooleanBoxes.Box(value6));
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(value6));
|
||||||
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1390,6 +1422,8 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
stack.Pop();
|
stack.Pop();
|
||||||
stack.Push(null);
|
stack.Push(null);
|
||||||
|
xmlStack.Pop();
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(null));
|
||||||
}
|
}
|
||||||
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
@@ -1401,10 +1435,12 @@ namespace Microsoft.Iris.Markup
|
|||||||
int num21 = reader.ReadUInt16();
|
int num21 = reader.ReadUInt16();
|
||||||
TypeSchema obj18 = importTables.TypeImports[num21];
|
TypeSchema obj18 = importTables.TypeImports[num21];
|
||||||
stack.Push(obj18);
|
stack.Push(obj18);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(obj18));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OpCode.PushNull:
|
case OpCode.PushNull:
|
||||||
stack.Push(null);
|
stack.Push(null);
|
||||||
|
xmlStack.Push(GenerateXmlRepresentation(null));
|
||||||
break;
|
break;
|
||||||
case OpCode.PushConstant:
|
case OpCode.PushConstant:
|
||||||
{
|
{
|
||||||
@@ -1420,10 +1456,12 @@ namespace Microsoft.Iris.Markup
|
|||||||
break;
|
break;
|
||||||
case OpCode.DiscardValue:
|
case OpCode.DiscardValue:
|
||||||
stack.Pop();
|
stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
break;
|
break;
|
||||||
case OpCode.ReturnValue:
|
case OpCode.ReturnValue:
|
||||||
{
|
{
|
||||||
object obj20 = stack.Pop();
|
object obj20 = stack.Pop();
|
||||||
|
xmlStack.Pop();
|
||||||
result = obj20;
|
result = obj20;
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
@@ -1438,6 +1476,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
uint currentOffset = reader.ReadUInt32();
|
uint currentOffset = reader.ReadUInt32();
|
||||||
object obj21 = (opCode == OpCode.JumpIfFalse) ? stack.Pop() : stack.Peek();
|
object obj21 = (opCode == OpCode.JumpIfFalse) ? stack.Pop() : stack.Peek();
|
||||||
|
if (opCode == OpCode.JumpIfFalse) xmlStack.Pop();
|
||||||
bool flag6 = (bool)obj21;
|
bool flag6 = (bool)obj21;
|
||||||
bool flag7 = opCode == OpCode.JumpIfTruePeek;
|
bool flag7 = opCode == OpCode.JumpIfTruePeek;
|
||||||
Trace.IsCategoryEnabled(TraceCategory.Markup);
|
Trace.IsCategoryEnabled(TraceCategory.Markup);
|
||||||
@@ -1577,7 +1616,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
|
|
||||||
CleanUpXmlDoc();
|
CleanUpXmlDoc();
|
||||||
Application.DebugSettings.DecompileResults.Add(XmlDoc);
|
Application.DebugSettings.DecompileResults.Add(new(loadResult.Uri, XmlDoc));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1603,46 +1642,93 @@ namespace Microsoft.Iris.Markup
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static object GenerateXmlRepresentation(object obj)
|
private static XmlNode GenerateXmlRepresentation(object obj, int recursionLevel = 5)
|
||||||
{
|
{
|
||||||
var objType = obj.GetType();
|
if (obj == null || recursionLevel < 0)
|
||||||
if (objType.IsPrimitive || objType.IsEnum || objType == typeof(string))
|
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
var objXml = XmlDoc.CreateElement(objType.Name);
|
return null;
|
||||||
// Use reflection to recursively generate XML representations for each property
|
}
|
||||||
foreach (System.Reflection.PropertyInfo prop in objType.GetProperties())
|
|
||||||
|
var objType = obj.GetType();
|
||||||
|
|
||||||
|
if (objType.IsPrimitive || objType.IsEnum || objType == typeof(string))
|
||||||
|
{
|
||||||
|
return XmlDoc.CreateTextNode(obj.ToString());
|
||||||
|
}
|
||||||
|
else if (obj is AssemblyObjectProxyHelper.IAssemblyProxyObject objProxy
|
||||||
|
&& obj != objProxy.AssemblyObject)
|
||||||
|
{
|
||||||
|
// This is a proxy object, meaning it doesn't actually hold any values itself.
|
||||||
|
return GenerateXmlRepresentation(objProxy.AssemblyObject, recursionLevel);
|
||||||
|
}
|
||||||
|
else if (typeof(IEnumerable).IsAssignableFrom(objType))
|
||||||
|
{
|
||||||
|
// This is a list or array
|
||||||
|
var objXml = XmlDoc.CreateElement("List");
|
||||||
|
foreach (object item in obj as IEnumerable)
|
||||||
{
|
{
|
||||||
if (!prop.CanWrite)
|
var itemXml = GenerateXmlRepresentation(item, recursionLevel);
|
||||||
continue;
|
if (itemXml != null)
|
||||||
|
objXml.AppendChild(itemXml);
|
||||||
object value = prop.GetValue(obj, null);
|
|
||||||
object defaultValue = prop.PropertyType.IsValueType ? Activator.CreateInstance(prop.PropertyType) : null;
|
|
||||||
if (value.Equals(defaultValue))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var propValue = GenerateXmlRepresentation(value);
|
|
||||||
if (propValue is XmlElement propValueXml)
|
|
||||||
{
|
|
||||||
var propXml = XmlDoc.CreateElement(prop.Name);
|
|
||||||
propXml.AppendChild(propValueXml);
|
|
||||||
objXml.AppendChild(propXml);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Primitive type, set as attribute
|
|
||||||
objXml.SetAttribute(prop.Name, propValue.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return objXml;
|
return objXml;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var objXml = XmlDoc.CreateElement(objType.Name);
|
||||||
|
|
||||||
|
// Use reflection to recursively generate XML representations for each property
|
||||||
|
foreach (System.Reflection.PropertyInfo prop in objType.GetProperties())
|
||||||
|
{
|
||||||
|
if (!prop.CanWrite || !prop.CanRead)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
object value = prop.GetValue(obj, null);
|
||||||
|
if (IsDefaultValue(value))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SetXmlPropValue(objXml, prop.Name, value, recursionLevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objXml;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetXmlPropValue(XmlElement objXml, string propName, object value, int recursionLevel = 10)
|
||||||
|
{
|
||||||
|
var valueXml = GenerateXmlRepresentation(value, recursionLevel);
|
||||||
|
SetXmlPropValue(objXml, propName, valueXml);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetXmlPropValue(XmlElement objXml, string propName, XmlNode valueXml)
|
||||||
|
{
|
||||||
|
if (valueXml is XmlElement propValueXml)
|
||||||
|
{
|
||||||
|
var propXml = XmlDoc.CreateElement(propName);
|
||||||
|
propXml.AppendChild(propValueXml);
|
||||||
|
objXml.AppendChild(propXml);
|
||||||
|
}
|
||||||
|
else if (valueXml != null)
|
||||||
|
{
|
||||||
|
// Primitive type, set as attribute
|
||||||
|
objXml.SetAttribute(propName, valueXml.InnerText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsDefaultValue(object value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
var type = value.GetType();
|
||||||
|
object defaultValue = type.IsValueType ? Activator.CreateInstance(type) : null;
|
||||||
|
return value?.Equals(defaultValue) ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CleanUpXmlDoc()
|
private static void CleanUpXmlDoc()
|
||||||
{
|
{
|
||||||
XmlNamespaceManager nsManager = new XmlNamespaceManager(XmlDoc.NameTable);
|
XmlNamespaceManager nsManager = new XmlNamespaceManager(XmlDoc.NameTable);
|
||||||
var hosts = XmlDoc.DocumentElement.SelectNodes("*//Host", nsManager);
|
var hosts = XmlDoc.DocumentElement.SelectNodes("*//Host", nsManager);
|
||||||
foreach (XmlNode node in hosts)
|
foreach (XmlNode node in hosts)
|
||||||
{
|
{
|
||||||
if (!(node is XmlElement host))
|
if (!(node is XmlElement host))
|
||||||
|
|||||||
Reference in New Issue
Block a user