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

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

View File

@@ -282,6 +282,12 @@ namespace Mono.Cecil {
if (File.Exists (file))
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;
}

View File

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

View File

@@ -38,6 +38,7 @@ namespace Mono.Cecil {
Stream symbol_stream;
ISymbolReaderProvider symbol_reader_provider;
bool read_symbols;
bool throw_symbols_mismatch;
bool projections;
bool in_memory;
bool read_write;
@@ -89,6 +90,11 @@ namespace Mono.Cecil {
set { read_symbols = value; }
}
public bool ThrowIfSymbolsAreNotMatching {
get { return throw_symbols_mismatch; }
set { throw_symbols_mismatch = value; }
}
public bool ReadWrite {
get { return read_write; }
set { read_write = value; }
@@ -107,6 +113,7 @@ namespace Mono.Cecil {
public ReaderParameters (ReadingMode readingMode)
{
this.reading_mode = readingMode;
this.throw_symbols_mismatch = true;
}
}
@@ -691,7 +698,7 @@ namespace Mono.Cecil {
public TypeReference GetType (string fullName, bool runtimeName)
{
return runtimeName
? TypeParser.ParseType (this, fullName)
? TypeParser.ParseType (this, fullName, typeDefinitionOnly: true)
: GetType (fullName);
}
@@ -1077,10 +1084,15 @@ namespace Mono.Cecil {
throw new InvalidOperationException ();
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)
{
ReadSymbols(reader, throwIfSymbolsAreNotMaching: true);
}
public void ReadSymbols (ISymbolReader reader, bool throwIfSymbolsAreNotMaching)
{
if (reader == null)
throw new ArgumentNullException ("reader");
@@ -1089,7 +1101,11 @@ namespace Mono.Cecil {
if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) {
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) {

View File

@@ -234,20 +234,24 @@ namespace Mono.Cecil {
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))
return null;
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;
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));
}
return CreateSpecs (type, type_info);
}
@@ -296,7 +300,7 @@ namespace Mono.Cecil {
var instance_arguments = instance.GenericArguments;
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;
}