public void Process (LinkContext context) { AssemblyDefinition assembly; if (!context.TryGetLinkedAssembly ("mscorlib", out assembly)) return; var resources = assembly.MainModule.Resources; for (int i = 0; i < resources.Count; i++) { var resource = resources [i] as EmbeddedResource; if (resource == null) continue; switch (resource.Name) { case "collation.core.bin": case "collation.tailoring.bin": continue; default: if (!resource.Name.Contains ("cjk")) continue; if (IncludeCJK ()) continue; resources.RemoveAt (i--); break; } } }
public virtual void Process (LinkContext context) { AssemblyDefinition assembly; if (!context.TryGetLinkedAssembly ("mscorlib", out assembly)) return; // skip this if we're not linking mscorlib, e.g. --linkskip=mscorlib if (context.Annotations.GetAction (assembly) != AssemblyAction.Link) return; var resources = assembly.MainModule.Resources; for (int i = 0; i < resources.Count; i++) { var resource = resources [i] as EmbeddedResource; if (resource == null) continue; switch (resource.Name) { case "collation.core.bin": case "collation.tailoring.bin": continue; default: if (!resource.Name.Contains ("cjk")) continue; if (IncludeCJK ()) continue; resources.RemoveAt (i--); break; } } }
void ProcessCorlib (LinkContext context) { AssemblyDefinition corlib; if (!context.TryGetLinkedAssembly ("mscorlib", out corlib)) return; AddPreserveInfo (corlib, "DES", "DESCryptoServiceProvider"); AddPreserveInfo (corlib, "DSA", "DSACryptoServiceProvider"); AddPreserveInfo (corlib, "RandomNumberGenerator", "RNGCryptoServiceProvider"); AddPreserveInfo (corlib, "SHA1", "SHA1CryptoServiceProvider"); AddPreserveInfo (corlib, "SHA1", "SHA1Managed"); AddPreserveInfo (corlib, "MD5", "MD5CryptoServiceProvider"); AddPreserveInfo (corlib, "RC2", "RC2CryptoServiceProvider"); AddPreserveInfo (corlib, "TripleDES", "TripleDESCryptoServiceProvider"); AddPreserveInfo (corlib, "Rijndael", "RijndaelManaged"); AddPreserveInfo (corlib, "RIPEMD160", "RIPEMD160Managed"); AddPreserveInfo (corlib, "SHA256", "SHA256Managed"); AddPreserveInfo (corlib, "SHA384", "SHA384Managed"); AddPreserveInfo (corlib, "SHA512", "SHA512Managed"); AddPreserveInfo (corlib, "HMAC", "HMACMD5"); AddPreserveInfo (corlib, "HMAC", "HMACRIPEMD160"); AddPreserveInfo (corlib, "HMAC", "HMACSHA1"); AddPreserveInfo (corlib, "HMAC", "HMACSHA256"); AddPreserveInfo (corlib, "HMAC", "HMACSHA384"); AddPreserveInfo (corlib, "HMAC", "HMACSHA512"); AddPreserveInfo (corlib, "HMACMD5", "MD5CryptoServiceProvider"); AddPreserveInfo (corlib, "HMACRIPEMD160", "RIPEMD160Managed"); AddPreserveInfo (corlib, "HMACSHA1", "SHA1CryptoServiceProvider"); AddPreserveInfo (corlib, "HMACSHA1", "SHA1Managed"); AddPreserveInfo (corlib, "HMACSHA256", "SHA256Managed"); AddPreserveInfo (corlib, "HMACSHA384", "SHA384Managed"); AddPreserveInfo (corlib, "HMACSHA512", "SHA512Managed"); TryAddPreserveInfo (corlib, "Aes", "AesManaged"); var corlibAes = GetCryptoType (corlib, "Aes"); Preserve (corlibAes, GetCryptoType (corlib, "AesManaged")); AssemblyDefinition syscore; if (context.TryGetLinkedAssembly ("System.Core", out syscore)) Preserve (corlibAes, GetCryptoType (syscore, "AesCryptoServiceProvider")); }
void ProcessSystemCore (LinkContext context) { AssemblyDefinition syscore; if (!context.TryGetLinkedAssembly ("System.Core", out syscore)) return; // AddPreserveInfo (syscore, "Aes", "AesCryptoServiceProvider"); TryAddPreserveInfo (syscore, "Aes", "AesManaged"); }
public void Process (LinkContext context) { AssemblyDefinition monomac; if (!context.TryGetLinkedAssembly ("MonoMac", out monomac)) return; foreach (TypeDefinition type in monomac.MainModule.Types) { if (!type.IsNSObject ()) continue; ProcessNSObject (type); } }
public void Process(LinkContext context) { var profile = (Profile.Current as BaseProfile); AssemblyDefinition assembly; if (!context.TryGetLinkedAssembly (profile.ProductAssembly, out assembly)) return; // skip this if we're not linking monotouch, e.g. --linkskip=monotouch if (context.Annotations.GetAction (assembly) != AssemblyAction.Link) return; foreach (TypeDefinition type in assembly.MainModule.Types) { ProcessType (type); } }
public void Process(LinkContext context) { var profile = (Profile.Current as BaseProfile); AssemblyDefinition assembly; if (!context.TryGetLinkedAssembly (profile.ProductAssembly, out assembly)) return; HashSet<string> namespaces = new HashSet<string> (); foreach (TypeDefinition type in assembly.MainModule.Types) { namespaces.Add (type.Namespace); } // clean NSObject from loading them var nsobject = assembly.MainModule.GetType (Namespaces.Foundation + ".NSObject"); var nsobject_cctor = nsobject.GetTypeConstructor (); var instructions = nsobject_cctor.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { Instruction ins = instructions [i]; if (ins.OpCode.Code != Code.Ldstr) continue; // To be safe we only remove the ones we know about *and* // only when we know the namespace is not being used by the app // Based on the list from xamcore/src/Foundation/NSObjectMac.cs bool remove_dlopen = false; switch (ins.Operand as string) { case Constants.FoundationLibrary: // note: every app has Foundation - even if I could not find a sample that required it pre-loaded remove_dlopen = !namespaces.Contains (Namespaces.Foundation); break; case Constants.AppKitLibrary: // note: every app has AppKit - even if I could not find a sample that required it pre-loaded remove_dlopen = !namespaces.Contains (Namespaces.AppKit); break; case Constants.AddressBookLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.AddressBook); break; case Constants.CoreTextLibrary: // FIXME: CoreTextArcMonoMac does not need it (i.e. maybe we could always remove it) remove_dlopen = !namespaces.Contains (Namespaces.CoreText); break; case Constants.WebKitLibrary: // WhereIsMyMac sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.WebKit); break; case Constants.QuartzLibrary: // FIXME: AnimatedClock does not need it (i.e. maybe we could always remove it) remove_dlopen = !namespaces.Contains (Namespaces.CoreAnimation); break; case Constants.QTKitLibrary: // QTRecorder sample won't work without it // StillMotion sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.QTKit); break; case Constants.CoreLocationLibrary: // WhereIsMyMac sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.CoreLocation); break; case Constants.SecurityLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.Security); break; case Constants.QuartzComposerLibrary: // CAQuartzComposition sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.QuartzComposer); break; case Constants.CoreWlanLibrary: // CoreWLANWirelessManager sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.CoreWlan); break; case Constants.PdfKitLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.PdfKit); break; case Constants.ImageKitLibrary: // ImageKitDemo sample won't work without it remove_dlopen = !namespaces.Contains (Namespaces.ImageKit); break; case Constants.ScriptingBridgeLibrary: // no working (attic) sample remove_dlopen = !namespaces.Contains (Namespaces.ScriptingBridge); break; case Constants.AVFoundationLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.AVFoundation); break; case Constants.CoreBluetoothLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.CoreBluetooth); break; case Constants.GameKitLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.GameKit); break; case Constants.SceneKitLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.SceneKit); break; case Constants.StoreKitLibrary: // no sample remove_dlopen = !namespaces.Contains (Namespaces.StoreKit); break; #if DEBUG default: string libname = ins.Operand as string; if (libname.StartsWith ("/", StringComparison.Ordinal)) Console.WriteLine ("Unprocessed library / namespace {0}", libname); break; #endif } if (remove_dlopen) { FieldDefinition f = Nop (ins); if (f != null) { i += 3; nsobject.Fields.Remove (f); } } } }