Merge branch 'upstream'

Former-commit-id: 113370919ec4c592ded8b0db631c4c156ea76911
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2019-02-13 08:31:21 +00:00
commit 481135a35b
74 changed files with 391 additions and 163 deletions

View File

@ -1 +1 @@
88af1283ee7ed4bfd171ac03a450d09684d3fdb3
a95e320dc816cf245e735ade01aba6ea08cc8dfb

View File

@ -1 +1 @@
e2ff7c6aca9e90849d3f357529d3bbb884829755
7fc911b48686244d25c2890ed5bf73bcc205f10a

View File

@ -2,12 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
[assembly:System.Reflection.AssemblyVersionAttribute("0.10.1.0")]
[assembly:System.Reflection.AssemblyVersionAttribute("0.10.3.0")]
[assembly:System.CLSCompliantAttribute(false)]
[assembly:System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute.DebuggingModes)(2))]
[assembly:System.Reflection.AssemblyCopyrightAttribute("Copyright © 2008 - 2018 Jb Evain")]
[assembly:System.Reflection.AssemblyFileVersionAttribute("0.10.1.0")]
[assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.1.0")]
[assembly:System.Reflection.AssemblyFileVersionAttribute("0.10.3.0")]
[assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.3.0")]
[assembly:System.Reflection.AssemblyProductAttribute("Mono.Cecil")]
[assembly:System.Reflection.AssemblyTitleAttribute("Mono.Cecil.Mdb")]
[assembly:System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8)]

View File

@ -1 +1 @@
19b503b65f6796fbd03668ae2a73555fcb8fda32
3378e64a4e2dd96212fc88a657abe1ac071ddc16

View File

@ -4,7 +4,7 @@ class FontConfigPackage (Package):
Package.__init__(self, 'fontconfig', '2.10.2',
configure_flags=['--disable-docs'],
sources=[
'http://www.fontconfig.org/release/%{name}-%{version}.tar.gz'
'https://www.freedesktop.org/software/fontconfig/release/%{name}-%{version}.tar.gz'
],
# note: a non-empty DESTDIR keeps fc-cache from running at
# install-time

View File

@ -253,12 +253,7 @@ namespace Mono.Cecil.Cil {
}
}
interface IMetadataSymbolWriter : ISymbolWriter {
void SetMetadata (MetadataBuilder metadata);
void WriteModule ();
}
public sealed class PortablePdbWriter : ISymbolWriter, IMetadataSymbolWriter {
public sealed class PortablePdbWriter : ISymbolWriter {
readonly MetadataBuilder pdb_metadata;
readonly ModuleDefinition module;
@ -272,6 +267,13 @@ namespace Mono.Cecil.Cil {
{
this.pdb_metadata = pdb_metadata;
this.module = module;
this.module_metadata = module.metadata_builder;
if (module_metadata != pdb_metadata)
this.pdb_metadata.metadata_builder = this.module_metadata;
pdb_metadata.AddCustomDebugInformations (module);
}
internal PortablePdbWriter (MetadataBuilder pdb_metadata, ModuleDefinition module, ImageWriter writer)
@ -280,19 +282,6 @@ namespace Mono.Cecil.Cil {
this.writer = writer;
}
void IMetadataSymbolWriter.SetMetadata (MetadataBuilder metadata)
{
this.module_metadata = metadata;
if (module_metadata != pdb_metadata)
this.pdb_metadata.metadata_builder = metadata;
}
void IMetadataSymbolWriter.WriteModule ()
{
pdb_metadata.AddCustomDebugInformations (module);
}
public ISymbolReaderProvider GetReaderProvider ()
{
return new PortablePdbReaderProvider ();
@ -318,11 +307,7 @@ namespace Mono.Cecil.Cil {
// PDB Age
buffer.WriteUInt32 (1);
// PDB Path
var filename = writer.BaseStream.GetFileName ();
if (!string.IsNullOrEmpty (filename))
filename = Path.GetFileName (filename);
buffer.WriteBytes (System.Text.Encoding.UTF8.GetBytes (filename));
buffer.WriteBytes (System.Text.Encoding.UTF8.GetBytes (writer.BaseStream.GetFileName ()));
buffer.WriteByte (0);
var data = new byte [buffer.length];
@ -428,7 +413,7 @@ namespace Mono.Cecil.Cil {
}
}
public sealed class EmbeddedPortablePdbWriter : ISymbolWriter, IMetadataSymbolWriter {
public sealed class EmbeddedPortablePdbWriter : ISymbolWriter {
readonly Stream stream;
readonly PortablePdbWriter writer;
@ -485,16 +470,6 @@ namespace Mono.Cecil.Cil {
public void Dispose ()
{
}
void IMetadataSymbolWriter.SetMetadata (MetadataBuilder metadata)
{
((IMetadataSymbolWriter) writer).SetMetadata (metadata);
}
void IMetadataSymbolWriter.WriteModule ()
{
((IMetadataSymbolWriter) writer).WriteModule ();
}
}
#endif

View File

@ -943,6 +943,11 @@ namespace Mono.Cecil.Cil {
var name = new SR.AssemblyName {
Name = cecil_name.Name + "." + suffix,
Version = cecil_name.Version,
#if NET_CORE
CultureName = cecil_name.CultureName,
#else
CultureInfo = cecil_name.CultureInfo,
#endif
};
name.SetPublicKeyToken (cecil_name.GetPublicKeyToken ());

View File

@ -29,6 +29,8 @@ namespace Mono.Cecil.PE {
public TargetArchitecture Architecture;
public ModuleCharacteristics Characteristics;
public ushort LinkerVersion;
public ushort SubSystemMajor;
public ushort SubSystemMinor;
public ImageDebugHeader DebugHeader;

View File

@ -81,8 +81,8 @@ namespace Mono.Cecil.PE {
// Characteristics 2
ushort characteristics = ReadUInt16 ();
ushort subsystem, dll_characteristics, linker_version;
ReadOptionalHeaders (out subsystem, out dll_characteristics, out linker_version);
ushort subsystem, dll_characteristics;
ReadOptionalHeaders (out subsystem, out dll_characteristics);
ReadSections (sections);
ReadCLIHeader ();
ReadMetadata ();
@ -90,7 +90,6 @@ namespace Mono.Cecil.PE {
image.Kind = GetModuleKind (characteristics, subsystem);
image.Characteristics = (ModuleCharacteristics) dll_characteristics;
image.LinkerVersion = linker_version;
}
TargetArchitecture ReadArchitecture ()
@ -109,7 +108,7 @@ namespace Mono.Cecil.PE {
return ModuleKind.Console;
}
void ReadOptionalHeaders (out ushort subsystem, out ushort dll_characteristics, out ushort linker)
void ReadOptionalHeaders (out ushort subsystem, out ushort dll_characteristics)
{
// - PEOptionalHeader
// - StandardFieldsHeader
@ -119,7 +118,7 @@ namespace Mono.Cecil.PE {
// pe32 || pe64
linker = ReadUInt16 ();
image.LinkerVersion = ReadUInt16 ();
// CodeSize 4
// InitializedDataSize 4
// UninitializedDataSize4
@ -138,11 +137,16 @@ namespace Mono.Cecil.PE {
// UserMinor 2
// SubSysMajor 2
// SubSysMinor 2
Advance(44);
image.SubSystemMajor = ReadUInt16 ();
image.SubSystemMinor = ReadUInt16 ();
// Reserved 4
// ImageSize 4
// HeaderSize 4
// FileChecksum 4
Advance (64);
Advance (16);
// SubSystem 2
subsystem = ReadUInt16 ();

View File

@ -243,8 +243,8 @@ namespace Mono.Cecil.PE {
WriteUInt16 (0); // OSMinor
WriteUInt16 (0); // UserMajor
WriteUInt16 (0); // UserMinor
WriteUInt16 (4); // SubSysMajor
WriteUInt16 (0); // SubSysMinor
WriteUInt16 (module.subsystem_major); // SubSysMajor
WriteUInt16 (module.subsystem_minor); // SubSysMinor
WriteUInt32 (0); // Reserved
var last_section = LastSection();
@ -255,17 +255,22 @@ namespace Mono.Cecil.PE {
WriteUInt16 (GetSubSystem ()); // SubSystem
WriteUInt16 ((ushort) module.Characteristics); // DLLFlags
const ulong stack_reserve = 0x100000;
const ulong stack_commit = 0x1000;
const ulong heap_reserve = 0x100000;
const ulong heap_commit = 0x1000;
if (!pe64) {
WriteUInt32 ((uint) stack_reserve);
WriteUInt32 ((uint) stack_commit);
WriteUInt32 ((uint) heap_reserve);
WriteUInt32 ((uint) heap_commit);
const uint stack_reserve = 0x100000;
const uint stack_commit = 0x1000;
const uint heap_reserve = 0x100000;
const uint heap_commit = 0x1000;
WriteUInt32 (stack_reserve);
WriteUInt32 (stack_commit);
WriteUInt32 (heap_reserve);
WriteUInt32 (heap_commit);
} else {
const ulong stack_reserve = 0x400000;
const ulong stack_commit = 0x4000;
const ulong heap_reserve = 0x100000;
const ulong heap_commit = 0x2000;
WriteUInt64 (stack_reserve);
WriteUInt64 (stack_commit);
WriteUInt64 (heap_reserve);

View File

@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Mono.Cecil</id>
<version>0.10.1.0</version>
<version>0.10.3.0</version>
<title>Mono.Cecil</title>
<authors>Jb Evain</authors>
<owners>Jb Evain</owners>

View File

@ -1119,11 +1119,14 @@ namespace Mono.Cecil {
metadata.AddTypeReference (type);
if (scope_token.TokenType == TokenType.TypeRef) {
declaring_type = GetTypeDefOrRef (scope_token);
if (scope_token.RID != rid) {
declaring_type = GetTypeDefOrRef (scope_token);
scope = declaring_type != null
? declaring_type.Scope
: module;
scope = declaring_type != null
? declaring_type.Scope
: module;
} else // obfuscated typeref row pointing to self
scope = module;
} else
scope = GetTypeReferenceScope (scope_token);
@ -3766,7 +3769,7 @@ namespace Mono.Cecil {
if (length == 0)
return string.Empty;
if (position + length >= buffer.Length)
if (position + length > buffer.Length)
return string.Empty;
var @string = Encoding.UTF8.GetString (buffer, position, length);

View File

@ -110,18 +110,25 @@ namespace Mono.Cecil {
}
#endif
using (var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters)) {
var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider, symbol_writer);
BuildMetadata (module, metadata);
var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider);
try {
module.metadata_builder = metadata;
var writer = ImageWriter.CreateWriter (module, metadata, stream);
stream.value.SetLength (0);
writer.WriteImage ();
using (var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters)) {
metadata.SetSymbolWriter (symbol_writer);
BuildMetadata (module, metadata);
var writer = ImageWriter.CreateWriter (module, metadata, stream);
stream.value.SetLength (0);
writer.WriteImage ();
#if !NET_CORE
if (parameters.StrongNameKeyPair != null)
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
if (parameters.StrongNameKeyPair != null)
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
#endif
}
} finally {
module.metadata_builder = null;
}
}
@ -209,10 +216,10 @@ namespace Mono.Cecil {
public sealed override void Sort ()
{
Array.Sort (rows, 0, length, this);
MergeSort<TRow>.Sort (rows, 0, this.length, this);
}
protected int Compare (uint x, uint y)
protected static int Compare (uint x, uint y)
{
return x == y ? 0 : x > y ? 1 : -1;
}
@ -796,7 +803,7 @@ namespace Mono.Cecil {
readonly internal ModuleDefinition module;
readonly internal ISymbolWriterProvider symbol_writer_provider;
readonly internal ISymbolWriter symbol_writer;
internal ISymbolWriter symbol_writer;
readonly internal TextMap text_map;
readonly internal string fq_name;
readonly internal uint timestamp;
@ -846,8 +853,6 @@ namespace Mono.Cecil {
readonly TypeSpecTable typespec_table;
readonly MethodSpecTable method_spec_table;
readonly bool portable_pdb;
internal MetadataBuilder metadata_builder;
readonly DocumentTable document_table;
@ -862,7 +867,7 @@ namespace Mono.Cecil {
readonly Dictionary<ImportScopeRow, MetadataToken> import_scope_map;
readonly Dictionary<string, MetadataToken> document_map;
public MetadataBuilder (ModuleDefinition module, string fq_name, uint timestamp, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer)
public MetadataBuilder (ModuleDefinition module, string fq_name, uint timestamp, ISymbolWriterProvider symbol_writer_provider)
{
this.module = module;
this.text_map = CreateTextMap ();
@ -870,18 +875,6 @@ namespace Mono.Cecil {
this.timestamp = timestamp;
this.symbol_writer_provider = symbol_writer_provider;
if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ()) {
symbol_writer = new PortablePdbWriter (this, module);
}
this.symbol_writer = symbol_writer;
var pdb_writer = symbol_writer as IMetadataSymbolWriter;
if (pdb_writer != null) {
portable_pdb = true;
pdb_writer.SetMetadata (this);
}
this.code = new CodeWriter (this);
this.data = new DataBuffer ();
this.resources = new ResourceBuffer ();
@ -916,9 +909,6 @@ namespace Mono.Cecil {
method_spec_map = new Dictionary<MethodSpecRow, MetadataToken> (row_equality_comparer);
generic_parameters = new Collection<GenericParameter> ();
if (!portable_pdb)
return;
this.document_table = GetTable<DocumentTable> (Table.Document);
this.method_debug_information_table = GetTable<MethodDebugInformationTable> (Table.MethodDebugInformation);
this.local_scope_table = GetTable<LocalScopeTable> (Table.LocalScope);
@ -937,7 +927,6 @@ namespace Mono.Cecil {
this.module = module;
this.text_map = new TextMap ();
this.symbol_writer_provider = writer_provider;
this.portable_pdb = true;
this.string_heap = new StringHeapBuffer ();
this.guid_heap = new GuidHeapBuffer ();
@ -961,6 +950,14 @@ namespace Mono.Cecil {
this.import_scope_map = new Dictionary<ImportScopeRow, MetadataToken> (row_equality_comparer);
}
public void SetSymbolWriter (ISymbolWriter writer)
{
symbol_writer = writer;
if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ())
symbol_writer = new PortablePdbWriter (this, module);
}
TextMap CreateTextMap ()
{
var map = new TextMap ();
@ -1050,10 +1047,6 @@ namespace Mono.Cecil {
if (module.EntryPoint != null)
entry_point = LookupToken (module.EntryPoint);
var pdb_writer = symbol_writer as IMetadataSymbolWriter;
if (pdb_writer != null)
pdb_writer.WriteModule ();
}
void BuildAssembly ()

View File

@ -265,7 +265,7 @@ namespace Mono.Cecil {
if (version.MajorRevision == 3300)
path = Path.Combine (path, "v1.0.3705");
else
path = Path.Combine (path, "v1.0.5000.0");
path = Path.Combine (path, "v1.1.4322");
break;
case 2:
path = Path.Combine (path, "v2.0.50727");

View File

@ -180,6 +180,9 @@ namespace Mono.Cecil {
return debug_info ?? (debug_info = new MethodDebugInformation (this));
}
set {
debug_info = value;
}
}
public bool HasPInvokeInfo {

View File

@ -183,7 +183,7 @@ namespace Mono.Cecil {
public static bool IsVarArg (this IMethodSignature self)
{
return (self.CallingConvention & MethodCallingConvention.VarArg) != 0;
return self.CallingConvention == MethodCallingConvention.VarArg;
}
public static int GetSentinelPosition (this IMethodSignature self)

View File

@ -283,8 +283,11 @@ namespace Mono.Cecil {
TargetArchitecture architecture;
ModuleAttributes attributes;
ModuleCharacteristics characteristics;
internal ushort linker_version = 8;
Guid mvid;
internal ushort linker_version = 8;
internal ushort subsystem_major = 4;
internal ushort subsystem_minor = 0;
internal uint timestamp;
internal AssemblyDefinition assembly;
@ -304,6 +307,10 @@ namespace Mono.Cecil {
internal Collection<CustomDebugInformation> custom_infos;
#if !READ_ONLY
internal MetadataBuilder metadata_builder;
#endif
public bool IsMain {
get { return kind != ModuleKind.NetModule; }
}
@ -616,6 +623,8 @@ namespace Mono.Cecil {
this.attributes = image.Attributes;
this.characteristics = image.Characteristics;
this.linker_version = image.LinkerVersion;
this.subsystem_major = image.SubSystemMajor;
this.subsystem_minor = image.SubSystemMinor;
this.file_name = image.FileName;
this.timestamp = image.Timestamp;

66
external/cecil/Mono/MergeSort.cs vendored Normal file
View File

@ -0,0 +1,66 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
using System.Collections.Generic;
namespace Mono {
class MergeSort<T> {
private readonly T [] elements;
private readonly T [] buffer;
private readonly IComparer<T> comparer;
private MergeSort (T [] elements, IComparer<T> comparer)
{
this.elements = elements;
this.buffer = new T [elements.Length];
Array.Copy (this.elements, this.buffer, elements.Length);
this.comparer = comparer;
}
public static void Sort (T [] source, IComparer<T> comparer)
{
Sort (source, 0, source.Length, comparer);
}
public static void Sort (T [] source, int start, int length, IComparer<T> comparer)
{
new MergeSort<T> (source, comparer).Sort (start, length);
}
private void Sort (int start, int length)
{
TopDownSplitMerge (this.buffer, this.elements, start, length);
}
private void TopDownSplitMerge (T [] a, T [] b, int start, int end)
{
if (end - start < 2)
return;
int middle = (end + start) / 2;
TopDownSplitMerge (b, a, start, middle);
TopDownSplitMerge (b, a, middle, end);
TopDownMerge (a, b, start, middle, end);
}
private void TopDownMerge (T [] a, T [] b, int start, int middle, int end)
{
for (int i = start, j = middle, k = start; k < end; k++) {
if (i < middle && (j >= end || comparer.Compare (a [i], a [j]) <= 0)) {
b [k] = a [i++];
} else {
b [k] = a [j++];
}
}
}
}
}

View File

@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
[assembly: ComVisible (false)]
[assembly: AssemblyVersion ("0.10.1.0")]
[assembly: AssemblyFileVersion ("0.10.1.0")]
[assembly: AssemblyInformationalVersion ("0.10.1.0")]
[assembly: AssemblyVersion ("0.10.3.0")]
[assembly: AssemblyFileVersion ("0.10.3.0")]
[assembly: AssemblyInformationalVersion ("0.10.3.0")]

View File

@ -464,6 +464,35 @@ namespace Mono.Cecil.Tests {
});
}
[Test]
public void OrderedAttributes ()
{
TestModule ("ordered-attrs.exe", module => {
var type = module.GetType ("Program");
var method = type.GetMethod ("Main");
var attributes = method.CustomAttributes;
Assert.AreEqual (6, attributes.Count);
Assert.AreEqual ("AAttribute", attributes [0].AttributeType.Name);
Assert.AreEqual ("Main.A1", attributes [0].Fields [0].Argument.Value as string);
Assert.AreEqual ("AAttribute", attributes [1].AttributeType.Name);
Assert.AreEqual ("Main.A2", attributes [1].Fields [0].Argument.Value as string);
Assert.AreEqual ("BAttribute", attributes [2].AttributeType.Name);
Assert.AreEqual ("Main.B1", attributes [2].Fields [0].Argument.Value as string);
Assert.AreEqual ("AAttribute", attributes [3].AttributeType.Name);
Assert.AreEqual ("Main.A3", attributes [3].Fields [0].Argument.Value as string);
Assert.AreEqual ("BAttribute", attributes [4].AttributeType.Name);
Assert.AreEqual ("Main.B2", attributes [4].Fields [0].Argument.Value as string);
Assert.AreEqual ("BAttribute", attributes [5].AttributeType.Name);
Assert.AreEqual ("Main.B3", attributes [5].Fields [0].Argument.Value as string);
});
}
#if !READ_ONLY
[Test]
public void DefineCustomAttributeFromBlob ()

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