private static InstructionArgumentEditorViewModel CreateViewModel() { var reader = new OpCodeDescriptionReader(); IOpCodeDescriptionDefinition data = null; if (File.Exists("OpCodeDescriptions.xml")) { data = reader.Read("OpCodeDescriptions.xml"); } else if (File.Exists(@"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml")) { data = reader.Read(@"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } else { data = reader.Read(@"D:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } var desc = data.GetDesc(PapyrusOpCodes.Cast); if (desc.Arguments == null || desc.Arguments.Count == 0) { desc.Arguments = new List <OpCodeArgumentDescription>(); var fallbackDesc = PapyrusInstructionOpCodeDescription.FromOpCode(desc.OpCode); for (var i = 0; i < fallbackDesc.ArgumentCount; i++) { desc.Arguments.Add(new OpCodeArgumentDescription { Index = i, Alias = "Value" + (i + 1), Ref = OpCodeRef.None, Description = "", ValueType = OpCodeValueTypes.ReferenceOrConstant }); } } return(new InstructionArgumentEditorViewModel(null, null, null, null, null, null, desc)); }
public void Read_XmlFile_ReturnsOpCodeDefinition() { var reader = new OpCodeDescriptionReader(); var def = reader.Read(@"D:\Git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); var nopDef = def.GetDesc(PapyrusOpCodes.Nop); Assert.IsNotNull(nopDef); Assert.IsNotNull(def); }