Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -47,7 +47,8 @@ net_4_5_dirs := \
mdbrebase \
ikdasm \
mono-symbolicate \
linker-analyzer
linker-analyzer \
btls
build_SUBDIRS = gacutil security culevel cil-stringreplacer commoncryptogenerator
net_4_5_SUBDIRS = gacutil

View File

@@ -13,14 +13,13 @@ using System.Globalization;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Security.Cryptography;
using System.Text;
using System.Configuration.Assemblies;
using IKVM.Reflection;
using IKVM.Reflection.Emit;
using Mono.Security.Cryptography;
using IKR = IKVM.Reflection;
namespace Mono.AssemblyLinker
{
@@ -49,6 +48,15 @@ namespace Mono.AssemblyLinker
No
}
public enum Platform {
AnyCPU,
AnyCPU32Preferred,
Arm,
X86,
X64,
IA64
}
public class AssemblyLinker {
ArrayList inputFiles = new ArrayList ();
@@ -59,24 +67,35 @@ namespace Mono.AssemblyLinker
string entryPoint;
string win32IconFile;
string win32ResFile;
string title;
string description;
string company;
string product;
string copyright;
string trademark;
string templateFile;
bool isTemplateFile = false;
Target target = Target.Dll;
Platform platform = Platform.AnyCPU;
DelaySign delaysign = DelaySign.NotSet;
string keyfile;
string keyname;
string culture;
Universe universe;
public static int Main (String[] args) {
return new AssemblyLinker ().DynMain (args);
}
private int DynMain (String[] args) {
ParseArgs (args);
using (universe = new Universe (UniverseOptions.MetadataOnly)) {
universe.LoadFile (typeof (object).Assembly.Location);
ParseArgs (args);
DoIt ();
DoIt ();
return 0;
return 0;
}
}
private void ParseArgs (string[] args)
@@ -211,7 +230,7 @@ namespace Mono.AssemblyLinker
if (realArg.StartsWith ("0x"))
realArg = realArg.Substring (2);
uint val = Convert.ToUInt32 (realArg, 16);
AddCattr (typeof (AssemblyAlgorithmIdAttribute), typeof (uint), val);
AddCattr (typeof (System.Reflection.AssemblyAlgorithmIdAttribute), typeof (uint), val);
} catch (Exception) {
ReportInvalidArgument (opt, arg);
}
@@ -233,21 +252,21 @@ namespace Mono.AssemblyLinker
case "company":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyCompanyAttribute), arg);
company = arg;
return true;
case "config":
case "configuration":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyConfigurationAttribute), arg);
AddCattr (typeof (System.Reflection.AssemblyConfigurationAttribute), arg);
return true;
case "copy":
case "copyright":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyCopyrightAttribute), arg);
copyright = arg;
return true;
case "c":
@@ -273,7 +292,7 @@ namespace Mono.AssemblyLinker
case "description":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyDescriptionAttribute), arg);
description = arg;
return true;
case "e":
@@ -292,7 +311,7 @@ namespace Mono.AssemblyLinker
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyFileVersionAttribute), arg);
AddCattr (typeof (System.Reflection.AssemblyFileVersionAttribute), arg);
return true;
case "flags":
@@ -303,7 +322,7 @@ namespace Mono.AssemblyLinker
if (realArg.StartsWith ("0x"))
realArg = realArg.Substring (2);
uint val = Convert.ToUInt32 (realArg, 16);
AddCattr (typeof (AssemblyFlagsAttribute), typeof (uint), val);
AddCattr (typeof (System.Reflection.AssemblyFlagsAttribute), typeof (uint), val);
} catch (Exception) {
ReportInvalidArgument (opt, arg);
}
@@ -342,18 +361,46 @@ namespace Mono.AssemblyLinker
outFile = arg;
return true;
case "platform":
if (arg == null)
ReportMissingText (opt);
switch (arg.ToLowerInvariant ()) {
case "arm":
platform = Platform.Arm;
break;
case "anycpu":
platform = Platform.AnyCPU;
break;
case "x86":
platform = Platform.X86;
break;
case "x64":
platform = Platform.X64;
break;
case "itanium":
platform = Platform.IA64;
break;
case "anycpu32bitpreferred":
platform = Platform.AnyCPU32Preferred;
break;
default:
ReportInvalidArgument (opt, arg);
break;
}
return true;
case "prod":
case "product":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyProductAttribute), arg);
product = arg;
return true;
case "productv":
case "productversion":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyInformationalVersionAttribute), arg);
AddCattr (typeof (System.Reflection.AssemblyInformationalVersionAttribute), arg);
return true;
case "t":
@@ -388,14 +435,14 @@ namespace Mono.AssemblyLinker
case "title":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyTitleAttribute), arg);
title = arg;
return true;
case "trade":
case "trademark":
if (arg == null)
ReportMissingText (opt);
AddCattr (typeof (AssemblyTrademarkAttribute), arg);
trademark = arg;
return true;
case "v":
@@ -405,7 +452,7 @@ namespace Mono.AssemblyLinker
Version ();
break;
}
AddCattr (typeof (AssemblyVersionAttribute), arg);
AddCattr (typeof (System.Reflection.AssemblyVersionAttribute), arg);
return true;
case "win32icon":
@@ -461,11 +508,14 @@ namespace Mono.AssemblyLinker
return command.ToLower ();
}
private void AddCattr (Type attrType, Type arg, object value) {
cattrs.Add (new CustomAttributeBuilder (attrType.GetConstructor (new Type [] { arg }), new object [] { value }));
private void AddCattr (System.Type attrType, System.Type arg, object value) {
var importedAttrType = universe.Import(attrType);
var importedArg = universe.Import(arg);
cattrs.Add (new CustomAttributeBuilder (importedAttrType.GetConstructor (new [] { importedArg }), new [] { value }));
}
private void AddCattr (Type attrType, object value) {
private void AddCattr (System.Type attrType, object value) {
AddCattr (attrType, typeof (string), value);
}
@@ -596,12 +646,25 @@ namespace Mono.AssemblyLinker
if (isTemplateFile)
aname = ReadCustomAttributesFromTemplateFile (templateFile, aname);
if (!String.IsNullOrEmpty (title))
AddCattr (typeof (System.Reflection.AssemblyTitleAttribute), title);
if (!String.IsNullOrEmpty (description))
AddCattr (typeof (System.Reflection.AssemblyDescriptionAttribute), description);
if (!String.IsNullOrEmpty (company))
AddCattr (typeof (System.Reflection.AssemblyCompanyAttribute), company);
if (!String.IsNullOrEmpty (product))
AddCattr (typeof (System.Reflection.AssemblyProductAttribute), product);
if (!String.IsNullOrEmpty (copyright))
AddCattr (typeof (System.Reflection.AssemblyCopyrightAttribute), copyright);
if (!String.IsNullOrEmpty (trademark))
AddCattr (typeof (System.Reflection.AssemblyTrademarkAttribute), trademark);
SetKeyPair (aname);
if (fileName != outFile)
ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save, Path.GetDirectoryName (outFile));
ab = universe.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save, Path.GetDirectoryName (outFile));
else
ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save);
ab = universe.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save);
foreach (CustomAttributeBuilder cb in cattrs)
ab.SetCustomAttribute (cb);
@@ -611,10 +674,6 @@ namespace Mono.AssemblyLinker
*/
foreach (ModuleInfo mod in inputFiles) {
MethodInfo mi = typeof (AssemblyBuilder).GetMethod ("AddModule", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
if (mi == null)
Report (0, "Cannot add modules on this runtime: try the Mono runtime instead.");
if (mod.target != null) {
File.Copy (mod.fileName, mod.target, true);
mod.fileName = mod.target;
@@ -631,7 +690,7 @@ namespace Mono.AssemblyLinker
if (isAssembly)
ReportWarning (1020, "Ignoring included assembly '" + mod.fileName + "'");
else
mi.Invoke (ab, new object [] { mod.fileName });
ab.__AddModule (universe.OpenRawModule(mod.fileName));
}
/*
@@ -645,7 +704,7 @@ namespace Mono.AssemblyLinker
MethodInfo mainMethodInfo = null;
try {
Type mainType = ab.GetType (mainClass);
IKVM.Reflection.Type mainType = ab.GetType (mainClass);
if (mainType != null)
mainMethodInfo = mainType.GetMethod (mainMethod);
}
@@ -666,10 +725,7 @@ namespace Mono.AssemblyLinker
if (win32IconFile != null) {
try {
MethodInfo mi = typeof (AssemblyBuilder).GetMethod ("DefineIconResource", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
if (mi == null)
Report (0, "Cannot embed win32 icons on this runtime: try the Mono runtime instead.");
mi.Invoke (ab, new object [] { win32IconFile });
ab.__DefineIconResource (File.ReadAllBytes (win32IconFile));
}
catch (Exception ex) {
Report (1031, "Error reading icon '" + win32IconFile + "' --" + ex);
@@ -685,6 +741,8 @@ namespace Mono.AssemblyLinker
}
}
ModuleBuilder mainModule = null;
foreach (ResourceInfo res in resources) {
if (res.name == null)
res.name = Path.GetFileName (res.fileName);
@@ -694,11 +752,13 @@ namespace Mono.AssemblyLinker
Report (1046, String.Format ("Resource identifier '{0}' has already been used in this assembly", res.name));
if (res.isEmbedded) {
MethodInfo mi = typeof (AssemblyBuilder).GetMethod ("EmbedResourceFile", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic,
null, CallingConventions.Any, new Type [] { typeof (string), typeof (string) }, null);
if (mi == null)
Report (0, "Cannot embed resources on this runtime: try the Mono runtime instead.");
mi.Invoke (ab, new object [] { res.name, res.fileName });
if (mainModule == null) {
mainModule = ab.DefineDynamicModule (fileName, fileName, false);
}
Stream stream = new MemoryStream (File.ReadAllBytes (res.fileName));
mainModule.DefineManifestResource (res.name, stream, res.isPrivate ? ResourceAttributes.Private : ResourceAttributes.Public);
}
else {
if (res.target != null) {
@@ -721,8 +781,36 @@ namespace Mono.AssemblyLinker
}
}
PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly;
ImageFileMachine machine;
switch (platform) {
case Platform.X86:
pekind |= PortableExecutableKinds.Required32Bit;
machine = ImageFileMachine.I386;
break;
case Platform.X64:
pekind |= PortableExecutableKinds.PE32Plus;
machine = ImageFileMachine.AMD64;
break;
case Platform.IA64:
machine = ImageFileMachine.IA64;
break;
case Platform.AnyCPU32Preferred:
pekind |= PortableExecutableKinds.Preferred32Bit;
machine = ImageFileMachine.I386;
break;
case Platform.Arm:
machine = ImageFileMachine.ARM;
break;
case Platform.AnyCPU:
default:
machine = ImageFileMachine.I386;
break;
}
try {
ab.Save (fileName);
ab.Save (fileName, pekind, machine);
}
catch (Exception ex) {
Report (1019, "Metadata failure creating assembly -- " + ex);
@@ -733,17 +821,14 @@ namespace Mono.AssemblyLinker
{
// LAMESPEC: according to MSDN, the template assembly must have a
// strong name but this is not enforced
const IKR.UniverseOptions options = IKR.UniverseOptions.MetadataOnly;
var universe = new IKR.Universe (options);
var asm = universe.LoadFile (templateFile);
// Create missing assemblies, we don't want to load them!
// Code taken from ikdasm
var names = new HashSet<string> ();
IKR.AssemblyName[] assembly_refs = asm.ManifestModule.__GetReferencedAssemblies ();
AssemblyName[] assembly_refs = asm.ManifestModule.__GetReferencedAssemblies ();
var resolved_assemblies = new IKR.Assembly [assembly_refs.Length];
var resolved_assemblies = new Assembly [assembly_refs.Length];
for (int i = 0; i < resolved_assemblies.Length; i++) {
string name = assembly_refs [i].Name;
@@ -798,6 +883,85 @@ namespace Mono.AssemblyLinker
keyname = key_name_value;
}
break;
case "System.Reflection.AssemblyTitleAttribute": {
if (title != null)
// ignore if specified on command line
continue;
// AssemblyTitleAttribute .ctor(string title)
string title_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (title_value))
title = title_value;
}
break;
case "System.Reflection.AssemblyDescriptionAttribute": {
if (description != null)
// ignore if specified on command line
continue;
// AssemblyDescriptionAttribute .ctor(string description)
string description_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (description_value))
description = description_value;
}
break;
case "System.Reflection.AssemblyProductAttribute": {
if (product != null)
// ignore if specified on command line
continue;
// AssemblyProductAttribute .ctor(string product)
string product_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (product_value))
product = product_value;
}
break;
case "System.Reflection.AssemblyCompanyAttribute": {
if (company != null)
// ignore if specified on command line
continue;
// AssemblyCompanyAttribute .ctor(string company)
string company_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (company_value))
company = company_value;
}
break;
case "System.Reflection.AssemblyCopyrightAttribute": {
if (copyright != null)
// ignore if specified on command line
continue;
// AssemblyCopyrightAttribute .ctor(string copyright)
string copyright_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (copyright_value))
copyright = copyright_value;
}
break;
case "System.Reflection.AssemblyTrademarkAttribute": {
if (trademark != null)
// ignore if specified on command line
continue;
// AssemblyTrademarkAttribute .ctor(string trademark)
string trademark_value = (string) attr_data.ConstructorArguments [0].Value;
if (!String.IsNullOrEmpty (trademark_value))
trademark = trademark_value;
}
break;
}
}
@@ -877,6 +1041,9 @@ namespace Mono.AssemblyLinker
" /main:<method> Specifies the method name of the entry point",
" /nologo Suppress the startup banner and copyright message",
" /out:<filename> Output file name for the assembly manifest",
" /platform:<text> Limit which platforms this code can run on; must be",
" one of x86, Itanium, x64, arm, anycpu32bitpreferred,",
" or anycpu (the default)",
" /prod[uct]:<text> Product name",
" /productv[ersion]:<text> Product version",
" /t[arget]:lib[rary] Create a library",

View File

@@ -0,0 +1,26 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle ("btls-cert-sync")]
[assembly: AssemblyDescription ("btls-cert-sync")]
[assembly: AssemblyDefaultAlias ("btls-cert-sync")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: SatelliteContractVersion (Consts.FxVersion)]
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
[assembly: CLSCompliant (true)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ComVisible (false)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../../class/mono.pub")]

17
mcs/tools/btls/Makefile Normal file
View File

@@ -0,0 +1,17 @@
thisdir = tools/btls
SUBDIRS =
include ../../build/rules.make
LOCAL_MCS_FLAGS =
LIB_REFS = System Mono.Security Mono.Btls.Interface
PROGRAM = btls-cert-sync.exe
ifndef HAVE_BTLS
PROGRAM_NAME = dummy-btls-cert-sync.exe
NO_INSTALL = yes
NO_SIGN_ASSEMBLY = yes
NO_TEST = yes
NO_BUILD = yes
endif
include ../../build/executable.make

View File

@@ -0,0 +1,61 @@
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using MNS = Mono.Net.Security;
namespace Mono.Btls
{
static class BtlsCertSync
{
static void Main (string[] args)
{
if (!MNS.MonoTlsProviderFactory.IsBtlsSupported ()) {
Console.Error.WriteLine ("BTLS is not supported in this runtime!");
Environment.Exit (255);
}
var configPath = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
configPath = Path.Combine (configPath, ".mono");
var oldStorePath = Path.Combine (configPath, "certs", "Trust");
var newStorePath = MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.UserTrustedRoots);
if (!Directory.Exists (oldStorePath)) {
Console.WriteLine ("Old trust store {0} does not exist.");
Environment.Exit (255);
}
if (Directory.Exists (newStorePath))
Directory.Delete (newStorePath, true);
Directory.CreateDirectory (newStorePath);
var oldfiles = Directory.GetFiles (oldStorePath, "*.cer");
Console.WriteLine ("Found {0} files in the old store.", oldfiles.Length);
foreach (var file in oldfiles) {
Console.WriteLine ("Converting {0}.", file);
var data = File.ReadAllBytes (file);
using (var x509 = MonoBtlsX509.LoadFromData (data, MonoBtlsX509Format.DER)) {
ConvertToNewFormat (newStorePath, x509);
}
}
}
static void ConvertToNewFormat (string root, MonoBtlsX509 x509)
{
long hash = x509.GetSubjectNameHash ();
string newName;
int index = 0;
do {
newName = Path.Combine (root, string.Format ("{0:x8}.{1}", hash, index++));
} while (File.Exists (newName));
Console.WriteLine (" new name: {0}", newName);
using (var stream = new FileStream (newName, FileMode.Create))
using (var bio = MonoBtlsBio.CreateMonoStream (stream))
x509.ExportAsPEM (bio, true);
}
}
}

View File

@@ -0,0 +1,4 @@
../../build/common/SR.cs
../../build/common/Consts.cs
AssemblyInfo.cs
btls-cert-sync.cs

View File

@@ -100,33 +100,34 @@ public class Program
static void RewriteAssembly (string assemblyLocation, Dictionary<string, string> resourcesStrings, CmdOptions options)
{
var readerParameters = new ReaderParameters { ReadSymbols = true };
var assembly = AssemblyDefinition.ReadAssembly (assemblyLocation, readerParameters);
foreach (var module in assembly.Modules) {
foreach (var type in module.GetTypes ()) {
foreach (var method in type.Methods) {
if (!method.HasBody)
continue;
foreach (var instr in method.Body.Instructions) {
if (instr.OpCode != OpCodes.Ldstr)
var readerParameters = new ReaderParameters { ReadSymbols = true, ReadWrite = true };
using (var assembly = AssemblyDefinition.ReadAssembly (assemblyLocation, readerParameters)) {
foreach (var module in assembly.Modules) {
foreach (var type in module.GetTypes ()) {
foreach (var method in type.Methods) {
if (!method.HasBody)
continue;
foreach (var instr in method.Body.Instructions) {
if (instr.OpCode != OpCodes.Ldstr)
continue;
string value;
if (resourcesStrings.TryGetValue ((string)instr.Operand, out value)) {
if (options.Verbose) {
Console.WriteLine ($"Replacing '{instr.Operand}' with '{value}'");
string value;
if (resourcesStrings.TryGetValue ((string)instr.Operand, out value)) {
if (options.Verbose) {
Console.WriteLine ($"Replacing '{instr.Operand}' with '{value}'");
}
instr.Operand = value;
}
instr.Operand = value;
}
}
}
}
}
var writerParameters = new WriterParameters { WriteSymbols = true };
assembly.Write (assemblyLocation, writerParameters);
var writerParameters = new WriterParameters { WriteSymbols = true };
assembly.Write (writerParameters);
}
}
static bool LoadGetResourceStrings (Dictionary<string, string> resourcesStrings, CmdOptions options)

View File

@@ -14,7 +14,7 @@ namespace Xamarin {
public static class CommonCryptor {
static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null, string decryptorInitializers = null, string encryptorInitializers = null, string properties = null)
{
string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
//
@@ -38,7 +38,9 @@ namespace %NAMESPACE% {
FeedbackSizeValue = %FEEDBACKSIZE%;
%CTOR_INIT%
}
%PROPERTIES%
public override void GenerateIV ()
{
IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
@@ -51,6 +53,8 @@ namespace %NAMESPACE% {
public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
{
%CREATEDECRYPTOR_INIT%
IntPtr decryptor = IntPtr.Zero;
switch (Mode) {
case CipherMode.CBC:
@@ -74,6 +78,8 @@ namespace %NAMESPACE% {
public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
{
%CREATEENCRYPTOR_INIT%
IntPtr encryptor = IntPtr.Zero;
switch (Mode) {
case CipherMode.CBC:
@@ -98,6 +104,9 @@ namespace %NAMESPACE% {
File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
Replace ("%CREATEDECRYPTOR_INIT%", decryptorInitializers).
Replace ("%CREATEENCRYPTOR_INIT%", encryptorInitializers).
Replace ("%PROPERTIES%", properties).
Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
}
}

View File

@@ -42,7 +42,13 @@ namespace Xamarin {
// mscorlib replacements
CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
const string checkUseSalt = "if (UseSalt) throw new NotImplementedException (\"UseSalt=true is not implemented on Mono yet\");";
CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2",
ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };",
decryptorInitializers: checkUseSalt,
encryptorInitializers: checkUseSalt,
properties: "public bool UseSalt { get; set; }");
// Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
// but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)

View File

@@ -91,7 +91,7 @@ namespace TestRunner {
}
}
#if !NET_2_1
#if !MOBILE
class ProcessTester: ITester
{
ProcessStartInfo pi;
@@ -734,7 +734,7 @@ namespace TestRunner {
bool update_verif_file;
Hashtable verif_data;
#if !NET_2_1
#if !MOBILE
ProcessStartInfo pi;
#endif
readonly string mono;
@@ -756,7 +756,7 @@ namespace TestRunner {
files_folder = Directory.GetCurrentDirectory ();
this.verif_file = verif_file;
#if !NET_2_1
#if !MOBILE
pi = new ProcessStartInfo ();
pi.CreateNoWindow = true;
pi.WindowStyle = ProcessWindowStyle.Hidden;
@@ -965,7 +965,7 @@ namespace TestRunner {
string filename = test.FileName;
AppDomain domain = null;
#if !NET_2_1
#if !MOBILE
if (safe_execution) {
// Create a new AppDomain, with the current directory as the base.
AppDomainSetup setupInfo = new AppDomainSetup ();
@@ -977,7 +977,7 @@ namespace TestRunner {
try {
DomainTester tester;
try {
#if !NET_2_1
#if !MOBILE
if (domain != null)
tester = (DomainTester) domain.CreateInstanceAndUnwrap (typeof (PositiveChecker).Assembly.FullName, typeof (DomainTester).FullName);
else
@@ -998,7 +998,7 @@ namespace TestRunner {
if (doc_output != null) {
string ref_file = filename.Replace (".cs", "-ref.xml");
try {
#if !NET_2_1
#if !MOBILE
new XmlComparer ("doc").Compare (ref_file, doc_output);
#endif
} catch (Exception e) {

View File

@@ -24,9 +24,9 @@
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
#if !NET_2_1
#if !MOBILE
using System;
using System.Collections;
@@ -137,4 +137,4 @@ public class XmlComparer
}
}
#endif
#endif

View File

@@ -55,8 +55,8 @@ namespace CorCompare {
var ifaces = new Dictionary<string, TypeReference> ();
foreach (var def in WalkHierarchy (type))
foreach (TypeReference iface in def.Interfaces)
ifaces [iface.FullName] = iface;
foreach (var iface in def.Interfaces)
ifaces [iface.InterfaceType.FullName] = iface.InterfaceType;
return ifaces.Values;
}

View File

@@ -59,6 +59,9 @@ namespace CorCompare
{ "h|?|help",
"Show this message and exit.",
v => showHelp = v != null },
{ "contract-api",
"Produces contract API with all members at each level of inheritance hierarchy",
v => FullAPISet = v != null },
};
var asms = options.Parse (args);
@@ -116,6 +119,7 @@ namespace CorCompare
internal static bool AbiMode { get; private set; }
internal static bool FollowForwarders { get; private set; }
internal static bool FullAPISet { get; set; }
}
public class Utils {
@@ -538,7 +542,7 @@ namespace CorCompare
members.Add (new ConstructorData (writer, ctors));
}
PropertyDefinition[] properties = GetProperties (type);
PropertyDefinition[] properties = GetProperties (type, Driver.FullAPISet);
if (properties.Length > 0) {
Array.Sort (properties, PropertyDefinitionComparer.Default);
members.Add (new PropertyData (writer, properties));
@@ -550,7 +554,7 @@ namespace CorCompare
members.Add (new EventData (writer, events));
}
MethodDefinition [] methods = GetMethods (type);
MethodDefinition [] methods = GetMethods (type, Driver.FullAPISet);
if (methods.Length > 0) {
Array.Sort (methods, MethodDefinitionComparer.Default);
members.Add (new MethodData (writer, methods));
@@ -693,53 +697,104 @@ namespace CorCompare
}
internal static PropertyDefinition [] GetProperties (TypeDefinition type) {
ArrayList list = new ArrayList ();
internal static PropertyDefinition [] GetProperties (TypeDefinition type, bool fullAPI) {
var list = new List<PropertyDefinition> ();
var properties = type.Properties;//type.GetProperties (flags);
foreach (PropertyDefinition property in properties) {
MethodDefinition getMethod = property.GetMethod;
MethodDefinition setMethod = property.SetMethod;
var t = type;
do {
var properties = t.Properties;//type.GetProperties (flags);
foreach (PropertyDefinition property in properties) {
MethodDefinition getMethod = property.GetMethod;
MethodDefinition setMethod = property.SetMethod;
bool hasGetter = (getMethod != null) && MustDocumentMethod (getMethod);
bool hasSetter = (setMethod != null) && MustDocumentMethod (setMethod);
bool hasGetter = (getMethod != null) && MustDocumentMethod (getMethod);
bool hasSetter = (setMethod != null) && MustDocumentMethod (setMethod);
// if neither the getter or setter should be documented, then
// skip the property
if (hasGetter || hasSetter) {
list.Add (property);
// if neither the getter or setter should be documented, then
// skip the property
if (hasGetter || hasSetter) {
if (t != type && list.Any (l => l.Name == property.Name))
continue;
list.Add (property);
}
}
}
return (PropertyDefinition []) list.ToArray (typeof (PropertyDefinition));
if (!fullAPI)
break;
if (t.IsInterface || t.IsEnum)
break;
if (t.BaseType == null || t.BaseType.FullName == "System.Object")
t = null;
else
t = t.BaseType.Resolve ();
} while (t != null);
return list.ToArray ();
}
private MethodDefinition[] GetMethods (TypeDefinition type)
private MethodDefinition[] GetMethods (TypeDefinition type, bool fullAPI)
{
ArrayList list = new ArrayList ();
var list = new List<MethodDefinition> ();
var methods = type.Methods;//type.GetMethods (flags);
foreach (MethodDefinition method in methods) {
if (method.IsSpecialName && !method.Name.StartsWith ("op_", StringComparison.Ordinal))
continue;
var t = type;
do {
var methods = t.Methods;//type.GetMethods (flags);
foreach (MethodDefinition method in methods) {
if (method.IsSpecialName && !method.Name.StartsWith ("op_", StringComparison.Ordinal))
continue;
// we're only interested in public or protected members
if (!MustDocumentMethod(method))
continue;
// we're only interested in public or protected members
if (!MustDocumentMethod (method))
continue;
if (IsFinalizer (method)) {
string name = method.DeclaringType.Name;
int arity = name.IndexOf ('`');
if (arity > 0)
name = name.Substring (0, arity);
if (t == type && IsFinalizer (method)) {
string name = method.DeclaringType.Name;
int arity = name.IndexOf ('`');
if (arity > 0)
name = name.Substring (0, arity);
method.Name = "~" + name;
method.Name = "~" + name;
}
if (t != type && list.Any (l => l.DeclaringType != method.DeclaringType && l.Name == method.Name && l.Parameters.Count == method.Parameters.Count &&
l.Parameters.SequenceEqual (method.Parameters, new ParameterComparer ())))
continue;
list.Add (method);
}
list.Add (method);
if (!fullAPI)
break;
if (t.IsInterface || t.IsEnum)
break;
if (t.BaseType == null || t.BaseType.FullName == "System.Object")
t = null;
else
t = t.BaseType.Resolve ();
} while (t != null);
return list.ToArray ();
}
sealed class ParameterComparer : IEqualityComparer<ParameterDefinition>
{
public bool Equals (ParameterDefinition x, ParameterDefinition y)
{
return x.ParameterType.Name == y.ParameterType.Name;
}
return (MethodDefinition []) list.ToArray (typeof (MethodDefinition));
public int GetHashCode (ParameterDefinition obj)
{
return obj.ParameterType.Name.GetHashCode ();
}
}
static bool IsFinalizer (MethodDefinition method)
@@ -1034,9 +1089,12 @@ namespace CorCompare
if (!(memberDefenition is MethodDefinition))
return;
MethodDefinition mbase = (MethodDefinition) memberDefenition;
MethodDefinition mbase = (MethodDefinition)memberDefenition;
ParameterData parms = new ParameterData (writer, mbase.Parameters) {
HasExtensionParameter = mbase.CustomAttributes.Any (l => l.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute")
};
ParameterData parms = new ParameterData (writer, mbase.Parameters);
parms.DoOutput ();
MemberData.OutputGenericParameters (writer, mbase);
@@ -1082,8 +1140,11 @@ namespace CorCompare
this.parameters = parameters;
}
public bool HasExtensionParameter { get; set; }
public override void DoOutput ()
{
bool first = true;
writer.WriteStartElement ("parameters");
foreach (ParameterDefinition parameter in parameters) {
writer.WriteStartElement ("parameter");
@@ -1091,13 +1152,17 @@ namespace CorCompare
AddAttribute ("position", parameter.Method.Parameters.IndexOf(parameter).ToString(CultureInfo.InvariantCulture));
AddAttribute ("attrib", ((int) parameter.Attributes).ToString());
string direction = "in";
string direction = first && HasExtensionParameter ? "this" : "in";
first = false;
if (parameter.ParameterType is ByReferenceType)
var pt = parameter.ParameterType;
var brt = pt as ByReferenceType;
if (brt != null) {
direction = parameter.IsOut ? "out" : "ref";
pt = brt.ElementType;
}
TypeReference t = parameter.ParameterType;
AddAttribute ("type", Utils.CleanupTypeName (t));
AddAttribute ("type", Utils.CleanupTypeName (pt));
if (parameter.IsOptional) {
AddAttribute ("optional", "true");
@@ -1476,13 +1541,13 @@ namespace CorCompare
ParameterDefinition info = infos [i];
string modifier;
if ((info.Attributes & ParameterAttributes.In) != 0)
modifier = "in";
else if ((info.Attributes & ParameterAttributes.Out) != 0)
modifier = "out";
else
modifier = string.Empty;
string modifier = string.Empty;
if (info.ParameterType.IsByReference) {
if ((info.Attributes & ParameterAttributes.In) != 0)
modifier = "in";
else if ((info.Attributes & ParameterAttributes.Out) != 0)
modifier = "out";
}
if (modifier.Length > 0) {
signature.Append (modifier);

View File

@@ -55,6 +55,11 @@
<type fullname="System.Diagnostics.StackFrame" />
<type fullname="System.Diagnostics.StackTrace" />
<type fullname="System.DivideByZeroException" />
<!-- debugger-agent.c: create_event_list -->
<type fullname="System.Diagnostics.DebuggerNonUserCodeAttribute"/>
<type fullname="System.Diagnostics.DebuggerHiddenAttribute"/>
<type fullname="System.Diagnostics.DebuggerStepThroughAttribute"/>
<type fullname="System.DllNotFoundException" />
<type fullname="System.Double" preserve="fields" />
<type fullname="System.Enum" preserve="fields">
@@ -111,8 +116,18 @@
<type fullname="System.String" preserve="fields">
<method name="CreateString" />
<method name="InternalAllocateStr" />
<method name="FastAllocateString" />
<method name="memcpy" />
<method name="memset" />
<method name="bzero" />
<method name="bzero_aligned_1" />
<method name="bzero_aligned_2" />
<method name="bzero_aligned_4" />
<method name="bzero_aligned_8" />
<method name="memcpy_aligned_1" />
<method name="memcpy_aligned_2" />
<method name="memcpy_aligned_4" />
<method name="memcpy_aligned_8" />
</type>
<type fullname="System.SystemException" />
<type fullname="System.Type" preserve="fields">
@@ -130,7 +145,9 @@
<type fullname="System.Variant" preserve="fields" feature="com">
<method name="Clear" />
</type>
<type fullname="System.Version" />
<type fullname="System.Version">
<method signature="System.Void .ctor(System.Int32,System.Int32,System.Int32,System.Int32)" />
</type>
<type fullname="System.Void" />
<type fullname="System.__ComObject" feature="com" />
@@ -177,7 +194,9 @@
</type>
<type fullname="System.Reflection.AssemblyName" preserve="fields" />
<type fullname="System.Reflection.ConstructorInfo" preserve="fields" />
<type fullname="System.Reflection.CustomAttributeData" preserve="fields" />
<type fullname="System.Reflection.CustomAttributeData" preserve="fields">
<method signature="System.Void .ctor(System.Reflection.ConstructorInfo,System.Reflection.Assembly,System.IntPtr,System.UInt32)" />
</type>
<type fullname="System.Reflection.CustomAttributeNamedArgument" preserve="fields" />
<type fullname="System.Reflection.CustomAttributeTypedArgument" preserve="fields" />
<type fullname="System.Reflection.EventInfo" preserve="fields">
@@ -210,6 +229,9 @@
<method name="StaticGetterAdapterFrame" />
</type>
<type fullname="System.Reflection.ParameterInfo" preserve="fields" />
<!-- reflection.c: ves_icall_get_parameter_info -->
<type fullname="System.Reflection.MonoParameterInfo" preserve="fields" />
<type fullname="System.Reflection.PropertyInfo" preserve="fields" />
<type fullname="System.Reflection.ReflectionTypeLoadException" />
<type fullname="System.Reflection.TargetException" />
@@ -262,6 +284,9 @@
-->
<type fullname="System.Runtime.CompilerServices.InternalsVisibleToAttribute" />
<type fullname="System.Runtime.CompilerServices.RuntimeWrappedException">
<method signature="System.Void .ctor(System.Object)" />
</type>
<!-- <type fullname="System.Runtime.CompilerServices.RequiredAttributeAttribute" />
<type fullname="System.Runtime.CompilerServices.RuntimeHelpers" />
<type fullname="System.Runtime.CompilerServices.TypeForwardedToAttribute" /> -->
@@ -290,12 +315,17 @@
<type fullname="System.Runtime.Remoting.Messaging.CallContext">
<method name="SetCurrentCallContext" />
</type>
<type fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" preserve="fields" />
<type fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" preserve="fields">
<method name="InitMessage" />
</type>
<type fullname="System.Runtime.Remoting.Proxies.RealProxy" preserve="fields">
<method name="PrivateInvoke" />
<method name="GetAppDomainTarget" />
</type>
<type fullname="System.Runtime.Remoting.Proxies.TransparentProxy" preserve="fields" />
<type fullname="System.Runtime.Remoting.Proxies.TransparentProxy" preserve="fields">
<method name="LoadRemoteFieldNew" />
<method name="StoreRemoteField" />
</type>
<type fullname="System.Runtime.Remoting.RemotingServices">
<method name="SerializeCallData" />
<method name="DeserializeCallData" />
@@ -317,6 +347,7 @@
<type fullname="System.Threading.Monitor">
<method name="Enter" />
<method name="Exit" />
<method name="enter_with_atomic_var" />
</type>
<!--
@@ -338,6 +369,9 @@
<type fullname="System.Threading.WaitHandle" preserve="fields">
<method name="set_Handle" />
</type>
<type fullname="System.Threading._ThreadPoolWaitCallback">
<method name="PerformWaitCallback"/>
</type>
<type fullname="System.Text.StringBuilder" preserve="fields" />
@@ -361,7 +395,12 @@
<type fullname="Mono.Interop.ComInteropProxy" feature="com" />
<type fullname="Mono.Interop.IDispatch" feature="com" />
<type fullname="Mono.Interop.IUnknown" feature="com" />
<type fullname="Mono.Interop.IUnknown" feature="com"/>
<!-- by convention (and see #34671) -->
<type fullname="Mono.Runtime" />
<type fullname="Mono.RuntimeStructs/HandleStackMark" />
<type fullname="Mono.RuntimeStructs/MonoError" />
</assembly>
</linker>

View File

@@ -69,29 +69,27 @@ namespace Mono.Linker.Steps {
protected virtual void InitializeAssembly (AssemblyDefinition assembly)
{
MarkAssembly (assembly);
foreach (TypeDefinition type in assembly.MainModule.Types) {
if (!Annotations.IsMarked (type))
continue;
foreach (TypeDefinition type in assembly.MainModule.Types)
InitializeType (type);
}
}
void InitializeType (TypeDefinition type)
{
if (type.HasNestedTypes) {
foreach (var nested in type.NestedTypes)
InitializeType (nested);
}
if (!Annotations.IsMarked (type))
return;
MarkType (type);
if (type.HasFields)
InitializeFields (type);
if (type.HasMethods)
InitializeMethods (type.Methods);
if (type.HasNestedTypes) {
foreach (var nested in type.NestedTypes) {
if (Annotations.IsMarked (nested))
InitializeType (nested);
}
}
}
void InitializeFields (TypeDefinition type)
@@ -520,8 +518,8 @@ namespace Mono.Linker.Steps {
MarkFields (type, type.IsEnum);
if (type.HasInterfaces) {
foreach (TypeReference iface in type.Interfaces)
MarkType (iface);
foreach (var iface in type.Interfaces)
MarkType (iface.InterfaceType);
}
if (type.HasMethods) {

View File

@@ -129,7 +129,7 @@ namespace Mono.Linker.Steps {
static FileInfo GetOriginalAssemblyFileInfo (AssemblyDefinition assembly)
{
return new FileInfo (assembly.MainModule.FullyQualifiedName);
return new FileInfo (assembly.MainModule.FileName);
}
static void CopyAssembly (FileInfo fi, string directory, bool symbols)

View File

@@ -174,6 +174,14 @@ namespace Mono.Linker.Steps {
Annotations.Mark (type);
if (type.IsNested) {
var parent = type;
while (parent.IsNested) {
parent = parent.DeclaringType;
Annotations.Mark (parent);
}
}
switch (preserve) {
case TypePreserve.Nothing:
if (!nav.HasChildren)

View File

@@ -152,7 +152,7 @@ namespace Mono.Linker.Steps {
// at this stage reference might include things that can't be resolved
// and if it is (resolved) it needs to be kept only if marked (#16213)
if ((td != null) && Annotations.IsMarked (td)) {
scope = assembly.MainModule.Import (td).Scope;
scope = assembly.MainModule.ImportReference (td).Scope;
if (tr.Scope != scope)
changes = true;
hash.Add (tr, scope);
@@ -163,7 +163,7 @@ namespace Mono.Linker.Steps {
var td = et.Resolve ();
IMetadataScope scope = et.Scope;
if ((td != null) && Annotations.IsMarked (td)) {
scope = assembly.MainModule.Import (td).Scope;
scope = assembly.MainModule.ImportReference (td).Scope;
hash.Add (td, scope);
}
}

View File

@@ -59,8 +59,8 @@ namespace Mono.Linker.Steps {
if (!type.HasInterfaces)
return;
foreach (TypeReference @interface in type.Interfaces) {
var iface = @interface.Resolve ();
foreach (var @interface in type.Interfaces) {
var iface = @interface.InterfaceType.Resolve ();
if (iface == null || !iface.HasMethods)
continue;
@@ -160,8 +160,8 @@ namespace Mono.Linker.Steps {
if (!type.HasInterfaces)
yield break;
foreach (TypeReference interface_ref in type.Interfaces) {
TypeDefinition @interface = interface_ref.Resolve ();
foreach (var interface_ref in type.Interfaces) {
TypeDefinition @interface = interface_ref.InterfaceType.Resolve ();
if (@interface == null)
continue;

View File

@@ -65,7 +65,7 @@ namespace Mono.Linker {
public void CacheAssembly (AssemblyDefinition assembly)
{
_assemblies [assembly.Name.Name] = assembly;
base.AddSearchDirectory (Path.GetDirectoryName (assembly.MainModule.FullyQualifiedName));
base.AddSearchDirectory (Path.GetDirectoryName (assembly.MainModule.FileName));
}
}
}

Some files were not shown because too many files have changed in this diff Show More