static ModuleDef CreateModuleDef(string name, Guid mvid, ClrVersion clrVersion, ModuleDef?existingModule) { var clrValues = ClrVersionValues.GetValues(clrVersion); if (clrValues is null) { throw new ArgumentNullException(nameof(clrVersion)); } ModuleDef module; if (existingModule is null) { module = new ModuleDefUser(name, mvid, clrValues.CorLibRef); } else { module = existingModule; module.Name = name; module.Mvid = mvid; OverwriteAssembly(module.CorLibTypes.AssemblyRef, clrValues.CorLibRef); } module.UpdateRowId(module); module.RuntimeVersion = clrValues.RuntimeVersion; module.Cor20HeaderRuntimeVersion = clrValues.Cor20HeaderRuntimeVersion; module.TablesHeaderVersion = clrValues.TablesHeaderVersion; module.Location = string.Empty; return(module); }
void UpdateClrVersion() { ClrVersion clrVersion = Module.ClrVersion.Unknown; if (cor20HeaderRuntimeVersion != null && !cor20HeaderRuntimeVersion.HasError && cor20HeaderRuntimeVersion.Value != null && tablesHeaderVersion != null && !tablesHeaderVersion.HasError && tablesHeaderVersion.Value != null) { var clrValues = ClrVersionValues.Find(cor20HeaderRuntimeVersion.Value.Value, tablesHeaderVersion.Value.Value, RuntimeVersion); if (clrValues != null) { clrVersion = clrValues.ClrVersion; } } if (clrVersionVM != null) { clrVersionVM.SelectedItem = clrVersion; } }
void OnClrVersionChanged() { var clrVersion = (Module.ClrVersion)clrVersionVM.SelectedItem; var clrValues = ClrVersionValues.GetValues(clrVersion); if (clrValues == null) { return; } if (cor20HeaderRuntimeVersion != null) { cor20HeaderRuntimeVersion.Value = clrValues.Cor20HeaderRuntimeVersion; } if (tablesHeaderVersion != null) { tablesHeaderVersion.Value = clrValues.TablesHeaderVersion; } RuntimeVersion = clrValues.RuntimeVersion; }