Created
July 30, 2009 10:22
-
-
Save jbevain/158643 to your computer and use it in GitHub Desktop.
Tool to rebase System.Reactive to the .net framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Linq; | |
using Mono.Cecil; | |
class Rebase { | |
static void Main () | |
{ | |
const string file = "System.Reactive.dll"; | |
var assembly = AssemblyFactory.GetAssembly (file); | |
assembly.Name.PublicKey = null; | |
assembly.Name.HasPublicKey = false; | |
foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) { | |
switch (reference.Name) { | |
case "mscorlib": | |
case "System": | |
reference.Version = new Version (2, 0, 0, 0); | |
break; | |
case "System.Core": | |
reference.Version = new Version (3, 5, 0, 0); | |
break; | |
} | |
reference.PublicKeyToken = GetPublicKeyToken ("b77a5c561934e089"); | |
} | |
AssemblyFactory.SaveAssembly (assembly, file); | |
} | |
static byte [] GetPublicKeyToken (string str) | |
{ | |
var pktoken = new byte [str.Length / 2]; | |
for (int i = 0; i < pktoken.Length; i++) | |
pktoken [i] = Byte.Parse (str.Substring (i * 2, 2), NumberStyles.HexNumber); | |
return pktoken; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment