Imported Upstream version 5.14.0.106

Former-commit-id: 03fab0f68b93e237c47a03f7d3793d7f5d7c276d
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2018-05-26 08:37:10 +00:00
parent c34b058d3e
commit fee6ab6a16
60 changed files with 271 additions and 93 deletions

View File

@ -1 +1 @@
a716110cdcded6f6c9a459907b56b1f4d6eeadbe fe749f40b031bea9c317a0fdd447b7463c1fa428

View File

@ -1 +1 @@
1b47868002d8f5b8e4c85708dc50e855d259353b 7dc767be05a654f669f5fcb931c96a68bb03fc6c

View File

@ -5,9 +5,9 @@
[assembly:System.Reflection.AssemblyVersionAttribute("0.10.0.0")] [assembly:System.Reflection.AssemblyVersionAttribute("0.10.0.0")]
[assembly:System.CLSCompliantAttribute(false)] [assembly:System.CLSCompliantAttribute(false)]
[assembly:System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute.DebuggingModes)(2))] [assembly:System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute.DebuggingModes)(2))]
[assembly:System.Reflection.AssemblyCopyrightAttribute("Copyright © 2008 - 2015 Jb Evain")] [assembly:System.Reflection.AssemblyCopyrightAttribute("Copyright © 2008 - 2018 Jb Evain")]
[assembly:System.Reflection.AssemblyFileVersionAttribute("0.10.0.0")] [assembly:System.Reflection.AssemblyFileVersionAttribute("0.10.0.0")]
[assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.0.0-beta7")] [assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.0.0")]
[assembly:System.Reflection.AssemblyProductAttribute("Mono.Cecil")] [assembly:System.Reflection.AssemblyProductAttribute("Mono.Cecil")]
[assembly:System.Reflection.AssemblyTitleAttribute("Mono.Cecil.Mdb")] [assembly:System.Reflection.AssemblyTitleAttribute("Mono.Cecil.Mdb")]
[assembly:System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8)] [assembly:System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8)]

View File

@ -1 +1 @@
ab7d67e411350069bbfbb253ebf85aaea01ddab9 8d89b5ff7f8c0d7a260c7d6ec5d1b9baf4b22fd2

View File

@ -49,12 +49,13 @@ namespace Mono.Cecil.Cil {
string url; string url;
byte type; Guid type;
byte hash_algorithm; Guid hash_algorithm;
byte language; Guid language;
byte language_vendor; Guid language_vendor;
byte [] hash; byte [] hash;
byte [] embedded_source;
public string Url { public string Url {
get { return url; } get { return url; }
@ -62,23 +63,43 @@ namespace Mono.Cecil.Cil {
} }
public DocumentType Type { public DocumentType Type {
get { return (DocumentType) type; } get { return type.ToType (); }
set { type = (byte) value; } set { type = value.ToGuid (); }
}
public Guid TypeGuid {
get { return type; }
set { type = value; }
} }
public DocumentHashAlgorithm HashAlgorithm { public DocumentHashAlgorithm HashAlgorithm {
get { return (DocumentHashAlgorithm) hash_algorithm; } get { return hash_algorithm.ToHashAlgorithm (); }
set { hash_algorithm = (byte) value; } set { hash_algorithm = value.ToGuid (); }
}
public Guid HashAlgorithmGuid {
get { return hash_algorithm; }
set { hash_algorithm = value; }
} }
public DocumentLanguage Language { public DocumentLanguage Language {
get { return (DocumentLanguage) language; } get { return language.ToLanguage (); }
set { language = (byte) value; } set { language = value.ToGuid (); }
}
public Guid LanguageGuid {
get { return language; }
set { language = value; }
} }
public DocumentLanguageVendor LanguageVendor { public DocumentLanguageVendor LanguageVendor {
get { return (DocumentLanguageVendor) language_vendor; } get { return language_vendor.ToVendor (); }
set { language_vendor = (byte) value; } set { language_vendor = value.ToGuid (); }
}
public Guid LanguageVendorGuid {
get { return language_vendor; }
set { language_vendor = value; }
} }
public byte [] Hash { public byte [] Hash {
@ -86,10 +107,16 @@ namespace Mono.Cecil.Cil {
set { hash = value; } set { hash = value; }
} }
public byte[] EmbeddedSource {
get { return embedded_source; }
set { embedded_source = value; }
}
public Document (string url) public Document (string url)
{ {
this.url = url; this.url = url;
this.hash = Empty<byte>.Array; this.hash = Empty<byte>.Array;
this.embedded_source = Empty<byte>.Array;
this.token = new MetadataToken (TokenType.Document); this.token = new MetadataToken (TokenType.Document);
} }
} }

View File

@ -761,6 +761,44 @@ namespace Mono.Cecil.Cil {
ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream); ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream);
} }
#if !NET_CORE
[Serializable]
#endif
public sealed class SymbolsNotFoundException : FileNotFoundException {
public SymbolsNotFoundException (string message) : base (message)
{
}
#if !NET_CORE
SymbolsNotFoundException (
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base (info, context)
{
}
#endif
}
#if !NET_CORE
[Serializable]
#endif
public sealed class SymbolsNotMatchingException : InvalidOperationException {
public SymbolsNotMatchingException (string message) : base (message)
{
}
#if !NET_CORE
SymbolsNotMatchingException (
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base (info, context)
{
}
#endif
}
public class DefaultSymbolReaderProvider : ISymbolReaderProvider { public class DefaultSymbolReaderProvider : ISymbolReaderProvider {
readonly bool throw_if_no_symbol; readonly bool throw_if_no_symbol;
@ -810,7 +848,7 @@ namespace Mono.Cecil.Cil {
} }
if (throw_if_no_symbol) if (throw_if_no_symbol)
throw new FileNotFoundException (string.Format ("No symbol found for file: {0}", fileName)); throw new SymbolsNotFoundException (string.Format ("No symbol found for file: {0}", fileName));
return null; return null;
} }

View File

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

View File

@ -105,7 +105,7 @@ namespace Mono.Cecil {
: symbol_reader_provider.GetSymbolReader (module, module.FileName); : symbol_reader_provider.GetSymbolReader (module, module.FileName);
if (reader != null) if (reader != null)
module.ReadSymbols (reader); module.ReadSymbols (reader, parameters.ThrowIfSymbolsAreNotMatching);
} }
if (module.Image.HasDebugTables ()) if (module.Image.HasDebugTables ())
@ -834,6 +834,12 @@ namespace Mono.Cecil {
types [i] = ReadType (i + 1); types [i] = ReadType (i + 1);
} }
if (module.IsWindowsMetadata ()) {
for (uint i = 0; i < length; i++) {
WindowsRuntimeProjections.Project (types [i]);
}
}
} }
static bool IsNested (TypeAttributes attributes) static bool IsNested (TypeAttributes attributes)
@ -945,9 +951,6 @@ namespace Mono.Cecil {
if (IsNested (attributes)) if (IsNested (attributes))
type.DeclaringType = GetNestedTypeDeclaringType (type); type.DeclaringType = GetNestedTypeDeclaringType (type);
if (module.IsWindowsMetadata ())
WindowsRuntimeProjections.Project (type);
return type; return type;
} }
@ -1035,7 +1038,12 @@ namespace Mono.Cecil {
if (type != null) if (type != null)
return type; return type;
return ReadTypeDefinition (rid); type = ReadTypeDefinition (rid);
if (module.IsWindowsMetadata ())
WindowsRuntimeProjections.Project (type);
return type;
} }
TypeDefinition ReadTypeDefinition (uint rid) TypeDefinition ReadTypeDefinition (uint rid)
@ -2812,9 +2820,9 @@ namespace Mono.Cecil {
var name = signature.ReadDocumentName (); var name = signature.ReadDocumentName ();
documents [i - 1] = new Document (name) { documents [i - 1] = new Document (name) {
HashAlgorithm = hash_algorithm.ToHashAlgorithm (), HashAlgorithmGuid = hash_algorithm,
Hash = hash, Hash = hash,
Language = language.ToLanguage (), LanguageGuid = language,
token = new MetadataToken (TokenType.Document, i), token = new MetadataToken (TokenType.Document, i),
}; };
} }

View File

@ -282,6 +282,12 @@ namespace Mono.Cecil {
if (File.Exists (file)) if (File.Exists (file))
return GetAssembly (file, parameters); return GetAssembly (file, parameters);
if (on_mono && Directory.Exists (path + "-api")) {
file = Path.Combine (path + "-api", "mscorlib.dll");
if (File.Exists (file))
return GetAssembly (file, parameters);
}
return null; return null;
} }

View File

@ -177,7 +177,7 @@ namespace Mono.Cecil {
string.Empty, string.Empty,
type.Name, type.Name,
module, module,
ImportScope (type.Assembly ()), ImportScope (type),
type.IsValueType ()); type.IsValueType ());
reference.etype = ImportElementType (type); reference.etype = ImportElementType (type);
@ -193,6 +193,11 @@ namespace Mono.Cecil {
return reference; return reference;
} }
protected virtual IMetadataScope ImportScope (Type type)
{
return ImportScope (type.Assembly ());
}
static bool ImportOpenGenericType (Type type, ImportGenericKind import_kind) static bool ImportOpenGenericType (Type type, ImportGenericKind import_kind)
{ {
return type.IsGenericType () && type.IsGenericTypeDefinition () && import_kind == ImportGenericKind.Open; return type.IsGenericType () && type.IsGenericTypeDefinition () && import_kind == ImportGenericKind.Open;
@ -294,7 +299,7 @@ namespace Mono.Cecil {
return etype; return etype;
} }
AssemblyNameReference ImportScope (SR.Assembly assembly) protected AssemblyNameReference ImportScope (SR.Assembly assembly)
{ {
return ImportReference (assembly.GetName ()); return ImportReference (assembly.GetName ());
} }
@ -504,7 +509,7 @@ namespace Mono.Cecil {
type.Namespace, type.Namespace,
type.Name, type.Name,
module, module,
ImportScope (type.Scope), ImportScope (type),
type.IsValueType); type.IsValueType);
MetadataSystem.TryProcessPrimitiveTypeReference (reference); MetadataSystem.TryProcessPrimitiveTypeReference (reference);
@ -518,7 +523,12 @@ namespace Mono.Cecil {
return reference; return reference;
} }
IMetadataScope ImportScope (IMetadataScope scope) protected virtual IMetadataScope ImportScope (TypeReference type)
{
return ImportScope (type.Scope);
}
protected IMetadataScope ImportScope (IMetadataScope scope)
{ {
switch (scope.MetadataScopeType) { switch (scope.MetadataScopeType) {
case MetadataScopeType.AssemblyNameReference: case MetadataScopeType.AssemblyNameReference:

View File

@ -165,6 +165,8 @@ namespace Mono.Cecil {
// we reset Body to null in ILSpy to save memory; so we need that operation to be thread-safe // we reset Body to null in ILSpy to save memory; so we need that operation to be thread-safe
lock (module.SyncRoot) { lock (module.SyncRoot) {
body = value; body = value;
if (value == null)
this.debug_info = null;
} }
} }
} }

View File

@ -38,6 +38,7 @@ namespace Mono.Cecil {
Stream symbol_stream; Stream symbol_stream;
ISymbolReaderProvider symbol_reader_provider; ISymbolReaderProvider symbol_reader_provider;
bool read_symbols; bool read_symbols;
bool throw_symbols_mismatch;
bool projections; bool projections;
bool in_memory; bool in_memory;
bool read_write; bool read_write;
@ -89,6 +90,11 @@ namespace Mono.Cecil {
set { read_symbols = value; } set { read_symbols = value; }
} }
public bool ThrowIfSymbolsAreNotMatching {
get { return throw_symbols_mismatch; }
set { throw_symbols_mismatch = value; }
}
public bool ReadWrite { public bool ReadWrite {
get { return read_write; } get { return read_write; }
set { read_write = value; } set { read_write = value; }
@ -107,6 +113,7 @@ namespace Mono.Cecil {
public ReaderParameters (ReadingMode readingMode) public ReaderParameters (ReadingMode readingMode)
{ {
this.reading_mode = readingMode; this.reading_mode = readingMode;
this.throw_symbols_mismatch = true;
} }
} }
@ -691,7 +698,7 @@ namespace Mono.Cecil {
public TypeReference GetType (string fullName, bool runtimeName) public TypeReference GetType (string fullName, bool runtimeName)
{ {
return runtimeName return runtimeName
? TypeParser.ParseType (this, fullName) ? TypeParser.ParseType (this, fullName, typeDefinitionOnly: true)
: GetType (fullName); : GetType (fullName);
} }
@ -1077,10 +1084,15 @@ namespace Mono.Cecil {
throw new InvalidOperationException (); throw new InvalidOperationException ();
var provider = new DefaultSymbolReaderProvider (throwIfNoSymbol: true); var provider = new DefaultSymbolReaderProvider (throwIfNoSymbol: true);
ReadSymbols (provider.GetSymbolReader (this, file_name)); ReadSymbols (provider.GetSymbolReader (this, file_name), throwIfSymbolsAreNotMaching: true);
} }
public void ReadSymbols (ISymbolReader reader) public void ReadSymbols (ISymbolReader reader)
{
ReadSymbols(reader, throwIfSymbolsAreNotMaching: true);
}
public void ReadSymbols (ISymbolReader reader, bool throwIfSymbolsAreNotMaching)
{ {
if (reader == null) if (reader == null)
throw new ArgumentNullException ("reader"); throw new ArgumentNullException ("reader");
@ -1089,7 +1101,11 @@ namespace Mono.Cecil {
if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) { if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) {
symbol_reader = null; symbol_reader = null;
throw new InvalidOperationException ();
if (throwIfSymbolsAreNotMaching)
throw new SymbolsNotMatchingException ("Symbols were found but are not matching the assembly");
return;
} }
if (HasImage && ReadingMode == ReadingMode.Immediate) { if (HasImage && ReadingMode == ReadingMode.Immediate) {

View File

@ -234,20 +234,24 @@ namespace Mono.Cecil {
return fullname.Substring (start, position - start); return fullname.Substring (start, position - start);
} }
public static TypeReference ParseType (ModuleDefinition module, string fullname) public static TypeReference ParseType (ModuleDefinition module, string fullname, bool typeDefinitionOnly = false)
{ {
if (string.IsNullOrEmpty (fullname)) if (string.IsNullOrEmpty (fullname))
return null; return null;
var parser = new TypeParser (fullname); var parser = new TypeParser (fullname);
return GetTypeReference (module, parser.ParseType (true)); return GetTypeReference (module, parser.ParseType (true), typeDefinitionOnly);
} }
static TypeReference GetTypeReference (ModuleDefinition module, Type type_info) static TypeReference GetTypeReference (ModuleDefinition module, Type type_info, bool type_def_only)
{ {
TypeReference type; TypeReference type;
if (!TryGetDefinition (module, type_info, out type)) if (!TryGetDefinition (module, type_info, out type)) {
if (type_def_only)
return null;
type = CreateReference (type_info, module, GetMetadataScope (module, type_info)); type = CreateReference (type_info, module, GetMetadataScope (module, type_info));
}
return CreateSpecs (type, type_info); return CreateSpecs (type, type_info);
} }
@ -296,7 +300,7 @@ namespace Mono.Cecil {
var instance_arguments = instance.GenericArguments; var instance_arguments = instance.GenericArguments;
for (int i = 0; i < generic_arguments.Length; i++) for (int i = 0; i < generic_arguments.Length; i++)
instance_arguments.Add (GetTypeReference (type.Module, generic_arguments [i])); instance_arguments.Add (GetTypeReference (type.Module, generic_arguments [i], false));
return instance; return instance;
} }

View File

@ -11,10 +11,10 @@ using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
[assembly: AssemblyProduct (Consts.AssemblyName)] [assembly: AssemblyProduct (Consts.AssemblyName)]
[assembly: AssemblyCopyright ("Copyright © 2008 - 2015 Jb Evain")] [assembly: AssemblyCopyright ("Copyright © 2008 - 2018 Jb Evain")]
[assembly: ComVisible (false)] [assembly: ComVisible (false)]
[assembly: AssemblyVersion ("0.10.0.0")] [assembly: AssemblyVersion ("0.10.0.0")]
[assembly: AssemblyFileVersion ("0.10.0.0")] [assembly: AssemblyFileVersion ("0.10.0.0")]
[assembly: AssemblyInformationalVersion ("0.10.0.0-beta7")] [assembly: AssemblyInformationalVersion ("0.10.0.0")]

View File

@ -1,6 +1,7 @@
using System; using System;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil;
using NUnit.Framework; using NUnit.Framework;
@ -91,15 +92,16 @@ namespace Mono.Cecil.Tests {
} }
[Test] [Test]
public void MismatchedLibraryAndSymbols_DoNotThrow () public void MismatchedLibraryAndSymbols ()
{ {
// SQLite-net.dll (from nuget) shiped with mismatched symbol files, but throwIfNoSymbol did not prevent it from throwing // SQLite-net.dll (from nuget) shiped with mismatched symbol files, but throwIfNoSymbol did not prevent it from throwing
var readerParms = new ReaderParameters { var parameters = new ReaderParameters {
ReadSymbols = true, ReadSymbols = true,
SymbolReaderProvider = new Cil.DefaultSymbolReaderProvider (throwIfNoSymbol: false) SymbolReaderProvider = new DefaultSymbolReaderProvider (throwIfNoSymbol: false),
ThrowIfSymbolsAreNotMatching = false,
}; };
using (var module = GetResourceModule ("SQLite-net.dll", readerParms)) { using (var module = GetResourceModule ("SQLite-net.dll", parameters)) {
Assert.Null (module.SymbolReader); Assert.Null (module.SymbolReader);
} }
} }

View File

@ -254,6 +254,15 @@ namespace Mono.Cecil.Tests {
} }
} }
[Test]
public void GetNonExistentTypeRuntimeName ()
{
using (var module = GetResourceModule ("libhello.dll")) {
var type = module.GetType ("DoesNotExist", runtimeName: true);
Assert.IsNull (type);
}
}
[Test] [Test]
public void OpenModuleImmediate () public void OpenModuleImmediate ()
{ {

View File

@ -50,6 +50,36 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual (typeof (PortablePdbReader), module.SymbolReader.GetType ()); Assert.AreEqual (typeof (PortablePdbReader), module.SymbolReader.GetType ());
}, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider), verify: !Platform.OnMono); }, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider), verify: !Platform.OnMono);
} }
[Test]
public void MdbMismatch ()
{
Assert.Throws<SymbolsNotMatchingException> (() => GetResourceModule ("mdb-mismatch.dll", new ReaderParameters { SymbolReaderProvider = new MdbReaderProvider () }));
}
[Test]
public void MdbIgnoreMismatch()
{
using (var module = GetResourceModule ("mdb-mismatch.dll", new ReaderParameters { SymbolReaderProvider = new MdbReaderProvider (), ThrowIfSymbolsAreNotMatching = false })) {
Assert.IsNull (module.SymbolReader);
Assert.IsFalse (module.HasSymbols);
}
}
[Test]
public void PortablePdbMismatch ()
{
Assert.Throws<SymbolsNotMatchingException> (() => GetResourceModule ("pdb-mismatch.dll", new ReaderParameters { SymbolReaderProvider = new PortablePdbReaderProvider () }));
}
[Test]
public void PortablePdbIgnoreMismatch()
{
using (var module = GetResourceModule ("pdb-mismatch.dll", new ReaderParameters { SymbolReaderProvider = new PortablePdbReaderProvider (), ThrowIfSymbolsAreNotMatching = false })) {
Assert.IsNull (module.SymbolReader);
Assert.IsFalse (module.HasSymbols);
}
}
} }
} }
#endif #endif

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@ namespace Mono.Cecil.Mdb {
Mixin.CheckModule (module); Mixin.CheckModule (module);
Mixin.CheckFileName (fileName); Mixin.CheckFileName (fileName);
return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (Mixin.GetMdbFileName (fileName), module.Mvid)); return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (Mixin.GetMdbFileName (fileName)));
} }
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
@ -33,15 +33,7 @@ namespace Mono.Cecil.Mdb {
Mixin.CheckModule (module); Mixin.CheckModule (module);
Mixin.CheckStream (symbolStream); Mixin.CheckStream (symbolStream);
var file = MonoSymbolFile.ReadSymbolFile (symbolStream); return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (symbolStream));
if (module.Mvid != file.Guid) {
var file_stream = symbolStream as FileStream;
if (file_stream != null)
throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", file_stream.Name);
throw new MonoSymbolFileException ("Symbol file from stream does not match assembly");
}
return new MdbReader (module, file);
} }
} }

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