public static SDClrVersion ToSDModel(this ClrInfo info) { var model = new SDClrVersion(); if (info != null) { model.Version = info.Version.ToString(); model.ClrFlavor = info.Flavor.ToString(); // save DAC info var dac = new SDModule(); dac.FileSize = info.DacInfo.FileSize; dac.FilePath = info.DacInfo.FileName; dac.ImageBase = info.DacInfo.ImageBase; dac.IsManaged = info.DacInfo.IsManaged; dac.TimeStamp = info.DacInfo.TimeStamp; dac.Version = info.DacInfo.Version.ToString(); // save PDB info, if avaliable if (info.DacInfo.Pdb != null) { dac.PdbInfo = new SDPdbInfo(info.DacInfo.Pdb.FileName, info.DacInfo.Pdb.Guid.ToString(), info.DacInfo.Pdb.Revision); } model.DacFile = dac; } return(model); }
public void ClrVersionsSerializationTest() { SystemAnalyzer analyzer = new SystemAnalyzer(this.context); List <SDClrVersion> versions = new List <SDClrVersion>(); foreach (SDClrVersion versionBefore in analyzer.systemInfo.ClrVersions) { string json = versionBefore.SerializeToJSON(); SDClrVersion versionAfter = JsonConvert.DeserializeObject <SDClrVersion>(json); versions.Add(versionAfter); Assert.AreEqual(versionBefore, versionAfter); // serialize again and check version string jsonAfter = versionAfter.SerializeToJSON(); StringAssert.Equals(json, jsonAfter); } Assert.IsTrue(Enumerable.SequenceEqual(analyzer.systemInfo.ClrVersions, versions)); }