Imported Upstream version 5.4.0.199

Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-09-25 16:57:44 +00:00
parent 536cd135cc
commit 5924117973
223 changed files with 3826 additions and 487 deletions

View File

@ -254,7 +254,7 @@ namespace Mono.Cecil {
#endif
public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, IDisposable {
public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, ICustomDebugInformationProvider, IDisposable {
internal Image Image;
internal MetadataSystem MetadataSystem;
@ -294,6 +294,8 @@ namespace Mono.Cecil {
Collection<ExportedType> exported_types;
TypeDefinitionCollection types;
internal Collection<CustomDebugInformation> custom_infos;
public bool IsMain {
get { return kind != ModuleKind.NetModule; }
}
@ -386,7 +388,7 @@ namespace Mono.Cecil {
internal IReflectionImporter ReflectionImporter {
get {
if (reflection_importer == null)
Interlocked.CompareExchange (ref reflection_importer, new ReflectionImporter (this), null);
Interlocked.CompareExchange (ref reflection_importer, new DefaultReflectionImporter (this), null);
return reflection_importer;
}
@ -395,13 +397,13 @@ namespace Mono.Cecil {
internal IMetadataImporter MetadataImporter {
get {
if (metadata_importer == null)
Interlocked.CompareExchange (ref metadata_importer, new MetadataImporter (this), null);
Interlocked.CompareExchange (ref metadata_importer, new DefaultMetadataImporter (this), null);
return metadata_importer;
}
}
internal void SetMetadataImporter (MetadataImporter importer)
internal void SetMetadataImporter (IMetadataImporter importer)
{
if (this.metadata_importer != null)
throw new InvalidOperationException ();
@ -580,6 +582,18 @@ namespace Mono.Cecil {
set { entry_point = value; }
}
public bool HasCustomDebugInformations {
get {
return custom_infos != null && custom_infos.Count > 0;
}
}
public Collection<CustomDebugInformation> CustomDebugInformations {
get {
return custom_infos ?? (custom_infos = new Collection<CustomDebugInformation> ());
}
}
internal ModuleDefinition ()
{
this.MetadataSystem = new MetadataSystem ();
@ -1149,7 +1163,7 @@ namespace Mono.Cecil {
{
Mixin.CheckParameters (parameters);
var file = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
ModuleWriter.WriteModuleTo (this, Disposable.Owned (file), parameters);
ModuleWriter.WriteModule (this, Disposable.Owned (file), parameters);
}
public void Write ()
@ -1176,7 +1190,7 @@ namespace Mono.Cecil {
Mixin.CheckWriteSeek (stream);
Mixin.CheckParameters (parameters);
ModuleWriter.WriteModuleTo (this, Disposable.NotOwned (stream), parameters);
ModuleWriter.WriteModule (this, Disposable.NotOwned (stream), parameters);
}
#endif
@ -1237,17 +1251,15 @@ namespace Mono.Cecil {
public static void CheckWriteSeek (Stream stream)
{
if (!stream.CanWrite || !stream.CanSeek)
throw new ArgumentException ();
throw new ArgumentException ("Stream must be writable and seekable.");
}
public static void CheckReadSeek (Stream stream)
{
if (!stream.CanRead || !stream.CanSeek)
throw new ArgumentException ();
throw new ArgumentException ("Stream must be readable and seekable.");
}
#if !READ_ONLY
public static void CheckType (object type)
{
if (type == null)
@ -1272,8 +1284,6 @@ namespace Mono.Cecil {
throw new ArgumentNullException (Argument.method.ToString ());
}
#endif
public static void CheckParameters (object parameters)
{
if (parameters == null)