You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -124,7 +124,6 @@ namespace Mono.Cecil {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PCL
|
||||
public static AssemblyDefinition ReadAssembly (string fileName)
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (fileName));
|
||||
@@ -134,7 +133,6 @@ namespace Mono.Cecil {
|
||||
{
|
||||
return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters));
|
||||
}
|
||||
#endif
|
||||
|
||||
public static AssemblyDefinition ReadAssembly (Stream stream)
|
||||
{
|
||||
@@ -157,7 +155,6 @@ namespace Mono.Cecil {
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
#if !PCL
|
||||
public void Write (string fileName)
|
||||
{
|
||||
Write (fileName, new WriterParameters ());
|
||||
@@ -167,7 +164,6 @@ namespace Mono.Cecil {
|
||||
{
|
||||
main_module.Write (fileName, parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Write ()
|
||||
{
|
||||
|
||||
12
external/linker/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
12
external/linker/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
@@ -12,13 +12,13 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Cecil")]
|
||||
[assembly: AssemblyTitle (Consts.AssemblyName)]
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
|
||||
#endif
|
||||
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=" + Consts.PublicKey)]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=" + Consts.PublicKey)]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=" + Consts.PublicKey)]
|
||||
[assembly: InternalsVisibleTo ("Mono.Cecil.Tests, PublicKey=" + Consts.PublicKey)]
|
||||
|
||||
@@ -109,7 +109,6 @@ namespace Mono.Cecil {
|
||||
|
||||
byte [] HashPublicKey ()
|
||||
{
|
||||
#if !PCL
|
||||
HashAlgorithm algorithm;
|
||||
|
||||
switch (hash_algorithm) {
|
||||
@@ -124,12 +123,6 @@ namespace Mono.Cecil {
|
||||
|
||||
using (algorithm)
|
||||
return algorithm.ComputeHash (public_key);
|
||||
#else
|
||||
if (hash_algorithm != AssemblyHashAlgorithm.SHA1)
|
||||
throw new NotSupportedException ();
|
||||
|
||||
return new SHA1Managed ().ComputeHash (public_key);
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual MetadataScopeType MetadataScopeType {
|
||||
@@ -238,8 +231,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public AssemblyNameReference (string name, Version version)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
Mixin.CheckName (name);
|
||||
|
||||
this.name = name;
|
||||
this.version = Mixin.CheckVersion (version);
|
||||
|
||||
135
external/linker/cecil/Mono.Cecil/AssemblyReader.cs
vendored
135
external/linker/cecil/Mono.Cecil/AssemblyReader.cs
vendored
@@ -24,12 +24,10 @@ namespace Mono.Cecil {
|
||||
|
||||
abstract class ModuleReader {
|
||||
|
||||
readonly protected Image image;
|
||||
readonly protected ModuleDefinition module;
|
||||
|
||||
protected ModuleReader (Image image, ReadingMode mode)
|
||||
{
|
||||
this.image = image;
|
||||
this.module = new ModuleDefinition (image);
|
||||
this.module.ReadingMode = mode;
|
||||
}
|
||||
@@ -73,10 +71,8 @@ namespace Mono.Cecil {
|
||||
#if !READ_ONLY
|
||||
if (parameters.metadata_importer_provider != null)
|
||||
module.metadata_importer = parameters.metadata_importer_provider.GetMetadataImporter (module);
|
||||
#if !PCL && !NET_CORE
|
||||
if (parameters.reflection_importer_provider != null)
|
||||
module.reflection_importer = parameters.reflection_importer_provider.GetReflectionImporter (module);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
GetMetadataKind (module, parameters);
|
||||
@@ -97,25 +93,18 @@ namespace Mono.Cecil {
|
||||
{
|
||||
var symbol_reader_provider = parameters.SymbolReaderProvider;
|
||||
|
||||
#if !PCL
|
||||
if (symbol_reader_provider == null && parameters.ReadSymbols)
|
||||
symbol_reader_provider = SymbolProvider.GetPlatformReaderProvider ();
|
||||
#endif
|
||||
symbol_reader_provider = new DefaultSymbolReaderProvider ();
|
||||
|
||||
if (symbol_reader_provider != null) {
|
||||
module.SymbolReaderProvider = symbol_reader_provider;
|
||||
#if !PCL
|
||||
|
||||
var reader = parameters.SymbolStream != null
|
||||
? symbol_reader_provider.GetSymbolReader (module, parameters.SymbolStream)
|
||||
: symbol_reader_provider.GetSymbolReader (module, module.FileName);
|
||||
#else
|
||||
if (parameters.SymbolStream == null)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
var reader = symbol_reader_provider.GetSymbolReader (module, parameters.SymbolStream);
|
||||
#endif
|
||||
|
||||
module.ReadSymbols (reader);
|
||||
if (reader != null)
|
||||
module.ReadSymbols (reader);
|
||||
}
|
||||
|
||||
if (module.Image.HasDebugTables ())
|
||||
@@ -417,7 +406,7 @@ namespace Mono.Cecil {
|
||||
for (int i = 0; i < methods.Count; i++) {
|
||||
var method = methods [i];
|
||||
|
||||
if (method.HasBody && method.debug_info == null)
|
||||
if (method.HasBody && method.token.RID != 0 && method.debug_info == null)
|
||||
method.debug_info = symbol_reader.Read (method);
|
||||
}
|
||||
}
|
||||
@@ -662,7 +651,6 @@ namespace Mono.Cecil {
|
||||
if (attributes != FileAttributes.ContainsMetaData)
|
||||
continue;
|
||||
|
||||
#if !PCL
|
||||
var parameters = new ReaderParameters {
|
||||
ReadingMode = module.ReadingMode,
|
||||
SymbolReaderProvider = module.SymbolReaderProvider,
|
||||
@@ -671,15 +659,11 @@ namespace Mono.Cecil {
|
||||
|
||||
modules.Add (ModuleDefinition.ReadModule (
|
||||
GetModuleFileName (name), parameters));
|
||||
#else
|
||||
throw new NotSupportedException ();
|
||||
#endif
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
string GetModuleFileName (string name)
|
||||
{
|
||||
if (module.FileName == null)
|
||||
@@ -688,7 +672,6 @@ namespace Mono.Cecil {
|
||||
var path = Path.GetDirectoryName (module.FileName);
|
||||
return Path.Combine (path, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void InitializeModuleReferences ()
|
||||
{
|
||||
@@ -873,25 +856,25 @@ namespace Mono.Cecil {
|
||||
|
||||
public bool HasNestedTypes (TypeDefinition type)
|
||||
{
|
||||
uint [] mapping;
|
||||
Collection<uint> mapping;
|
||||
InitializeNestedTypes ();
|
||||
|
||||
if (!metadata.TryGetNestedTypeMapping (type, out mapping))
|
||||
return false;
|
||||
|
||||
return mapping.Length > 0;
|
||||
return mapping.Count > 0;
|
||||
}
|
||||
|
||||
public Collection<TypeDefinition> ReadNestedTypes (TypeDefinition type)
|
||||
{
|
||||
InitializeNestedTypes ();
|
||||
uint [] mapping;
|
||||
Collection<uint> mapping;
|
||||
if (!metadata.TryGetNestedTypeMapping (type, out mapping))
|
||||
return new MemberDefinitionCollection<TypeDefinition> (type);
|
||||
|
||||
var nested_types = new MemberDefinitionCollection<TypeDefinition> (type, mapping.Length);
|
||||
var nested_types = new MemberDefinitionCollection<TypeDefinition> (type, mapping.Count);
|
||||
|
||||
for (int i = 0; i < mapping.Length; i++) {
|
||||
for (int i = 0; i < mapping.Count; i++) {
|
||||
var nested_type = GetTypeDefinition (mapping [i]);
|
||||
|
||||
if (nested_type != null)
|
||||
@@ -910,7 +893,7 @@ namespace Mono.Cecil {
|
||||
|
||||
var length = MoveTo (Table.NestedClass);
|
||||
|
||||
metadata.NestedTypes = new Dictionary<uint, uint []> (length);
|
||||
metadata.NestedTypes = new Dictionary<uint, Collection<uint>> (length);
|
||||
metadata.ReverseNestedTypes = new Dictionary<uint, uint> (length);
|
||||
|
||||
if (length == 0)
|
||||
@@ -930,18 +913,14 @@ namespace Mono.Cecil {
|
||||
metadata.SetReverseNestedTypeMapping (nested, declaring);
|
||||
}
|
||||
|
||||
static TValue [] AddMapping<TKey, TValue> (Dictionary<TKey, TValue []> cache, TKey key, TValue value)
|
||||
static Collection<TValue> AddMapping<TKey, TValue> (Dictionary<TKey, Collection<TValue>> cache, TKey key, TValue value)
|
||||
{
|
||||
TValue [] mapped;
|
||||
Collection<TValue> mapped;
|
||||
if (!cache.TryGetValue (key, out mapped)) {
|
||||
mapped = new [] { value };
|
||||
return mapped;
|
||||
mapped = new Collection<TValue> ();
|
||||
}
|
||||
|
||||
var new_mapped = new TValue [mapped.Length + 1];
|
||||
Array.Copy (mapped, new_mapped, mapped.Length);
|
||||
new_mapped [mapped.Length] = value;
|
||||
return new_mapped;
|
||||
mapped.Add (value);
|
||||
return mapped;
|
||||
}
|
||||
|
||||
TypeDefinition ReadType (uint rid)
|
||||
@@ -1223,7 +1202,7 @@ namespace Mono.Cecil {
|
||||
public bool HasInterfaces (TypeDefinition type)
|
||||
{
|
||||
InitializeInterfaces ();
|
||||
Row<uint, MetadataToken> [] mapping;
|
||||
Collection<Row<uint, MetadataToken>> mapping;
|
||||
|
||||
return metadata.TryGetInterfaceMapping (type, out mapping);
|
||||
}
|
||||
@@ -1231,16 +1210,16 @@ namespace Mono.Cecil {
|
||||
public InterfaceImplementationCollection ReadInterfaces (TypeDefinition type)
|
||||
{
|
||||
InitializeInterfaces ();
|
||||
Row<uint, MetadataToken> [] mapping;
|
||||
Collection<Row<uint, MetadataToken>> mapping;
|
||||
|
||||
if (!metadata.TryGetInterfaceMapping (type, out mapping))
|
||||
return new InterfaceImplementationCollection (type);
|
||||
|
||||
var interfaces = new InterfaceImplementationCollection (type, mapping.Length);
|
||||
var interfaces = new InterfaceImplementationCollection (type, mapping.Count);
|
||||
|
||||
this.context = type;
|
||||
|
||||
for (int i = 0; i < mapping.Length; i++) {
|
||||
for (int i = 0; i < mapping.Count; i++) {
|
||||
interfaces.Add (
|
||||
new InterfaceImplementation (
|
||||
GetTypeDefOrRef (mapping [i].Col2),
|
||||
@@ -1259,7 +1238,7 @@ namespace Mono.Cecil {
|
||||
|
||||
int length = MoveTo (Table.InterfaceImpl);
|
||||
|
||||
metadata.Interfaces = new Dictionary<uint, Row<uint, MetadataToken> []> (length);
|
||||
metadata.Interfaces = new Dictionary<uint, Collection<Row<uint, MetadataToken>>> (length);
|
||||
|
||||
for (uint i = 1; i <= length; i++) {
|
||||
var type = ReadTableIndex (Table.TypeDef);
|
||||
@@ -2027,26 +2006,26 @@ namespace Mono.Cecil {
|
||||
{
|
||||
InitializeGenericConstraints ();
|
||||
|
||||
MetadataToken [] mapping;
|
||||
Collection<MetadataToken> mapping;
|
||||
if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping))
|
||||
return false;
|
||||
|
||||
return mapping.Length > 0;
|
||||
return mapping.Count > 0;
|
||||
}
|
||||
|
||||
public Collection<TypeReference> ReadGenericConstraints (GenericParameter generic_parameter)
|
||||
{
|
||||
InitializeGenericConstraints ();
|
||||
|
||||
MetadataToken [] mapping;
|
||||
Collection<MetadataToken> mapping;
|
||||
if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping))
|
||||
return new Collection<TypeReference> ();
|
||||
|
||||
var constraints = new Collection<TypeReference> (mapping.Length);
|
||||
var constraints = new Collection<TypeReference> (mapping.Count);
|
||||
|
||||
this.context = (IGenericContext) generic_parameter.Owner;
|
||||
|
||||
for (int i = 0; i < mapping.Length; i++)
|
||||
for (int i = 0; i < mapping.Count; i++)
|
||||
constraints.Add (GetTypeDefOrRef (mapping [i]));
|
||||
|
||||
metadata.RemoveGenericConstraintMapping (generic_parameter);
|
||||
@@ -2061,7 +2040,7 @@ namespace Mono.Cecil {
|
||||
|
||||
var length = MoveTo (Table.GenericParamConstraint);
|
||||
|
||||
metadata.GenericConstraints = new Dictionary<uint, MetadataToken []> (length);
|
||||
metadata.GenericConstraints = new Dictionary<uint, Collection<MetadataToken>> (length);
|
||||
|
||||
for (int i = 1; i <= length; i++)
|
||||
AddGenericConstraintMapping (
|
||||
@@ -2079,27 +2058,27 @@ namespace Mono.Cecil {
|
||||
public bool HasOverrides (MethodDefinition method)
|
||||
{
|
||||
InitializeOverrides ();
|
||||
MetadataToken [] mapping;
|
||||
Collection<MetadataToken> mapping;
|
||||
|
||||
if (!metadata.TryGetOverrideMapping (method, out mapping))
|
||||
return false;
|
||||
|
||||
return mapping.Length > 0;
|
||||
return mapping.Count > 0;
|
||||
}
|
||||
|
||||
public Collection<MethodReference> ReadOverrides (MethodDefinition method)
|
||||
{
|
||||
InitializeOverrides ();
|
||||
|
||||
MetadataToken [] mapping;
|
||||
Collection<MetadataToken> mapping;
|
||||
if (!metadata.TryGetOverrideMapping (method, out mapping))
|
||||
return new Collection<MethodReference> ();
|
||||
|
||||
var overrides = new Collection<MethodReference> (mapping.Length);
|
||||
var overrides = new Collection<MethodReference> (mapping.Count);
|
||||
|
||||
this.context = method;
|
||||
|
||||
for (int i = 0; i < mapping.Length; i++)
|
||||
for (int i = 0; i < mapping.Count; i++)
|
||||
overrides.Add ((MethodReference) LookupToken (mapping [i]));
|
||||
|
||||
metadata.RemoveOverrideMapping (method);
|
||||
@@ -2114,7 +2093,7 @@ namespace Mono.Cecil {
|
||||
|
||||
var length = MoveTo (Table.MethodImpl);
|
||||
|
||||
metadata.Overrides = new Dictionary<uint, MetadataToken []> (length);
|
||||
metadata.Overrides = new Dictionary<uint, Collection<MetadataToken>> (length);
|
||||
|
||||
for (int i = 1; i <= length; i++) {
|
||||
ReadTableIndex (Table.TypeDef);
|
||||
@@ -2438,6 +2417,17 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
public TypeReference ReadConstantSignature (MetadataToken token)
|
||||
{
|
||||
if (token.TokenType != TokenType.Signature)
|
||||
throw new NotSupportedException ();
|
||||
|
||||
if (!MoveTo (Table.StandAloneSig, token.RID))
|
||||
return null;
|
||||
|
||||
return ReadFieldType (ReadBlobIndex ());
|
||||
}
|
||||
|
||||
public object ReadConstant (IConstantProvider owner)
|
||||
{
|
||||
InitializeConstants ();
|
||||
@@ -2558,6 +2548,17 @@ namespace Mono.Cecil {
|
||||
return (int) size;
|
||||
}
|
||||
|
||||
public IEnumerable<CustomAttribute> GetCustomAttributes ()
|
||||
{
|
||||
InitializeTypeDefinitions ();
|
||||
|
||||
var length = image.TableHeap [Table.CustomAttribute].Length;
|
||||
var custom_attributes = new Collection<CustomAttribute> ((int) length);
|
||||
ReadCustomAttributeRange (new Range (1, length), custom_attributes);
|
||||
|
||||
return custom_attributes;
|
||||
}
|
||||
|
||||
public byte [] ReadCustomAttributeBlob (uint signature)
|
||||
{
|
||||
return ReadBlob (signature);
|
||||
@@ -2848,10 +2849,15 @@ namespace Mono.Cecil {
|
||||
InitializeDocuments ();
|
||||
|
||||
if (!MoveTo (Table.MethodDebugInformation, method.MetadataToken.RID))
|
||||
return new Collection<SequencePoint> ();
|
||||
return new Collection<SequencePoint> (0);
|
||||
|
||||
var document = metadata.GetDocument (ReadTableIndex (Table.Document));
|
||||
var reader = ReadSignature (ReadBlobIndex ());
|
||||
var document_index = ReadTableIndex (Table.Document);
|
||||
var signature = ReadBlobIndex ();
|
||||
if (signature == 0)
|
||||
return new Collection<SequencePoint> (0);
|
||||
|
||||
var document = metadata.GetDocument (document_index);
|
||||
var reader = ReadSignature (signature);
|
||||
|
||||
return reader.ReadSequencePoints (document);
|
||||
}
|
||||
@@ -2865,7 +2871,7 @@ namespace Mono.Cecil {
|
||||
|
||||
int length = MoveTo (Table.LocalScope);
|
||||
|
||||
metadata.LocalScopes = new Dictionary<uint, Row<uint, Range, Range, uint, uint, uint> []> ();
|
||||
metadata.LocalScopes = new Dictionary<uint, Collection<Row<uint, Range, Range, uint, uint, uint>>> ();
|
||||
|
||||
for (uint i = 1; i <= length; i++) {
|
||||
var method = ReadTableIndex (Table.Method);
|
||||
@@ -2884,13 +2890,13 @@ namespace Mono.Cecil {
|
||||
InitializeLocalScopes ();
|
||||
InitializeImportScopes ();
|
||||
|
||||
Row<uint, Range, Range, uint, uint, uint> [] records;
|
||||
Collection<Row<uint, Range, Range, uint, uint, uint>> records;
|
||||
if (!metadata.TryGetLocalScopes (method, out records))
|
||||
return null;
|
||||
|
||||
var method_scope = null as ScopeDebugInformation;
|
||||
|
||||
for (int i = 0; i < records.Length; i++) {
|
||||
for (int i = 0; i < records.Count; i++) {
|
||||
var scope = ReadLocalScope (records [i]);
|
||||
|
||||
if (i == 0) {
|
||||
@@ -3044,7 +3050,6 @@ namespace Mono.Cecil {
|
||||
byte [] blob;
|
||||
int index, count;
|
||||
|
||||
|
||||
GetBlobView (signature, out blob, out index, out count);
|
||||
if (count == 0)
|
||||
return string.Empty;
|
||||
@@ -3739,7 +3744,9 @@ namespace Mono.Cecil {
|
||||
if (i > 0 && separator != 0)
|
||||
builder.Append (separator);
|
||||
|
||||
builder.Append (reader.ReadUTF8StringBlob (ReadCompressedUInt32 ()));
|
||||
uint part = ReadCompressedUInt32 ();
|
||||
if (part != 0)
|
||||
builder.Append (reader.ReadUTF8StringBlob (part));
|
||||
}
|
||||
|
||||
return builder.ToString ();
|
||||
@@ -3776,7 +3783,9 @@ namespace Mono.Cecil {
|
||||
if (delta_lines == 0 && delta_columns == 0) {
|
||||
sequence_points.Add (new SequencePoint (offset, document) {
|
||||
StartLine = 0xfeefee,
|
||||
StartColumn = 0xfeefee,
|
||||
EndLine = 0xfeefee,
|
||||
StartColumn = 0,
|
||||
EndColumn = 0,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
102
external/linker/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
102
external/linker/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
@@ -85,37 +85,41 @@ namespace Mono.Cecil {
|
||||
|
||||
module.MetadataSystem.Clear ();
|
||||
|
||||
if (module.symbol_reader != null)
|
||||
module.symbol_reader.Dispose ();
|
||||
|
||||
var name = module.assembly != null ? module.assembly.Name : null;
|
||||
var fq_name = stream.value.GetFileName ();
|
||||
var symbol_writer_provider = parameters.SymbolWriterProvider;
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
if (symbol_writer_provider == null && parameters.WriteSymbols)
|
||||
symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider ();
|
||||
#endif
|
||||
symbol_writer_provider = new DefaultSymbolWriterProvider ();
|
||||
|
||||
var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters);
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
if (parameters.StrongNameKeyPair != null && name != null) {
|
||||
name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
|
||||
module.Attributes |= ModuleAttributes.StrongNameSigned;
|
||||
}
|
||||
#endif
|
||||
|
||||
var metadata = new MetadataBuilder (module, fq_name, symbol_writer_provider, symbol_writer);
|
||||
var timestamp = parameters.Timestamp ?? module.timestamp;
|
||||
|
||||
var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider, symbol_writer);
|
||||
|
||||
BuildMetadata (module, metadata);
|
||||
|
||||
if (module.symbol_reader != null)
|
||||
module.symbol_reader.Dispose ();
|
||||
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
|
||||
stream.value.SetLength (0);
|
||||
|
||||
writer.WriteImage ();
|
||||
|
||||
if (metadata.symbol_writer != null)
|
||||
metadata.symbol_writer.Dispose ();
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
if (parameters.StrongNameKeyPair != null)
|
||||
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
|
||||
|
||||
@@ -144,11 +148,7 @@ namespace Mono.Cecil {
|
||||
if (parameters.SymbolStream != null)
|
||||
return symbol_writer_provider.GetSymbolWriter (module, parameters.SymbolStream);
|
||||
|
||||
#if !PCL
|
||||
return symbol_writer_provider.GetSymbolWriter (module, fq_name);
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Mono.Cecil {
|
||||
public abstract int Length { get; }
|
||||
|
||||
public bool IsLarge {
|
||||
get { return Length > 65535; }
|
||||
get { return Length > ushort.MaxValue; }
|
||||
}
|
||||
|
||||
public abstract void Write (TableHeapBuffer buffer);
|
||||
@@ -796,7 +796,7 @@ namespace Mono.Cecil {
|
||||
readonly internal ISymbolWriter symbol_writer;
|
||||
readonly internal TextMap text_map;
|
||||
readonly internal string fq_name;
|
||||
readonly internal uint time_stamp;
|
||||
readonly internal uint timestamp;
|
||||
|
||||
readonly Dictionary<TypeRefRow, MetadataToken> type_ref_map;
|
||||
readonly Dictionary<uint, MetadataToken> type_spec_map;
|
||||
@@ -859,14 +859,12 @@ namespace Mono.Cecil {
|
||||
readonly Dictionary<ImportScopeRow, MetadataToken> import_scope_map;
|
||||
readonly Dictionary<string, MetadataToken> document_map;
|
||||
|
||||
readonly internal bool write_symbols;
|
||||
|
||||
public MetadataBuilder (ModuleDefinition module, string fq_name, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer)
|
||||
public MetadataBuilder (ModuleDefinition module, string fq_name, uint timestamp, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer)
|
||||
{
|
||||
this.module = module;
|
||||
this.text_map = CreateTextMap ();
|
||||
this.fq_name = fq_name;
|
||||
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
|
||||
this.timestamp = timestamp;
|
||||
this.symbol_writer_provider = symbol_writer_provider;
|
||||
|
||||
if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ()) {
|
||||
@@ -874,12 +872,11 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
this.symbol_writer = symbol_writer;
|
||||
this.write_symbols = symbol_writer != null;
|
||||
|
||||
var pdb_writer = symbol_writer as PortablePdbWriter;
|
||||
var pdb_writer = symbol_writer as IMetadataSymbolWriter;
|
||||
if (pdb_writer != null) {
|
||||
portable_pdb = true;
|
||||
pdb_writer.SetModuleMetadata (this);
|
||||
pdb_writer.SetMetadata (this);
|
||||
}
|
||||
|
||||
this.code = new CodeWriter (this);
|
||||
@@ -1007,6 +1004,8 @@ namespace Mono.Cecil {
|
||||
{
|
||||
BuildModule ();
|
||||
|
||||
table_heap.string_offsets = string_heap.WriteStrings ();
|
||||
table_heap.ComputeTableInformations ();
|
||||
table_heap.WriteTableHeap ();
|
||||
}
|
||||
|
||||
@@ -1082,7 +1081,7 @@ namespace Mono.Cecil {
|
||||
if (module.IsMain)
|
||||
continue;
|
||||
|
||||
#if PCL || NET_CORE
|
||||
#if NET_CORE
|
||||
throw new NotSupportedException ();
|
||||
#else
|
||||
var parameters = new WriterParameters {
|
||||
@@ -1102,7 +1101,7 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
string GetModuleFileName (string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty (name))
|
||||
@@ -1203,7 +1202,7 @@ namespace Mono.Cecil {
|
||||
var table = GetTable<FileTable> (Table.File);
|
||||
var hash = resource.Hash;
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
if (hash.IsNullOrEmpty ())
|
||||
hash = CryptoService.ComputeHash (resource.File);
|
||||
#endif
|
||||
@@ -1265,7 +1264,7 @@ namespace Mono.Cecil {
|
||||
return;
|
||||
|
||||
AttachTokens ();
|
||||
AddTypeDefs ();
|
||||
AddTypes ();
|
||||
AddGenericParameters ();
|
||||
}
|
||||
|
||||
@@ -1274,33 +1273,33 @@ namespace Mono.Cecil {
|
||||
var types = module.Types;
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
AttachTypeDefToken (types [i]);
|
||||
AttachTypeToken (types [i]);
|
||||
}
|
||||
|
||||
void AttachTypeDefToken (TypeDefinition type)
|
||||
void AttachTypeToken (TypeDefinition type)
|
||||
{
|
||||
type.token = new MetadataToken (TokenType.TypeDef, type_rid++);
|
||||
type.fields_range.Start = field_rid;
|
||||
type.methods_range.Start = method_rid;
|
||||
|
||||
if (type.HasFields)
|
||||
AttachFieldsDefToken (type);
|
||||
AttachFieldsToken (type);
|
||||
|
||||
if (type.HasMethods)
|
||||
AttachMethodsDefToken (type);
|
||||
AttachMethodsToken (type);
|
||||
|
||||
if (type.HasNestedTypes)
|
||||
AttachNestedTypesDefToken (type);
|
||||
AttachNestedTypesToken (type);
|
||||
}
|
||||
|
||||
void AttachNestedTypesDefToken (TypeDefinition type)
|
||||
void AttachNestedTypesToken (TypeDefinition type)
|
||||
{
|
||||
var nested_types = type.NestedTypes;
|
||||
for (int i = 0; i < nested_types.Count; i++)
|
||||
AttachTypeDefToken (nested_types [i]);
|
||||
AttachTypeToken (nested_types [i]);
|
||||
}
|
||||
|
||||
void AttachFieldsDefToken (TypeDefinition type)
|
||||
void AttachFieldsToken (TypeDefinition type)
|
||||
{
|
||||
var fields = type.Fields;
|
||||
type.fields_range.Length = (uint) fields.Count;
|
||||
@@ -1308,7 +1307,7 @@ namespace Mono.Cecil {
|
||||
fields [i].token = new MetadataToken (TokenType.Field, field_rid++);
|
||||
}
|
||||
|
||||
void AttachMethodsDefToken (TypeDefinition type)
|
||||
void AttachMethodsToken (TypeDefinition type)
|
||||
{
|
||||
var methods = type.Methods;
|
||||
type.methods_range.Length = (uint) methods.Count;
|
||||
@@ -1413,7 +1412,7 @@ namespace Mono.Cecil {
|
||||
return token;
|
||||
}
|
||||
|
||||
void AddTypeDefs ()
|
||||
void AddTypes ()
|
||||
{
|
||||
var types = module.Types;
|
||||
|
||||
@@ -2058,6 +2057,11 @@ namespace Mono.Cecil {
|
||||
return GetBlobIndex (GetMethodSignature (call_site));
|
||||
}
|
||||
|
||||
public uint GetConstantTypeBlobIndex (TypeReference constant_type)
|
||||
{
|
||||
return GetBlobIndex (GetConstantTypeSignature (constant_type));
|
||||
}
|
||||
|
||||
SignatureWriter GetVariablesSignature (Collection<VariableDefinition> variables)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
@@ -2068,6 +2072,14 @@ namespace Mono.Cecil {
|
||||
return signature;
|
||||
}
|
||||
|
||||
SignatureWriter GetConstantTypeSignature (TypeReference constant_type)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
signature.WriteByte (0x6);
|
||||
signature.WriteTypeSignature (constant_type);
|
||||
return signature;
|
||||
}
|
||||
|
||||
SignatureWriter GetFieldSignature (FieldReference field)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
@@ -2257,7 +2269,7 @@ namespace Mono.Cecil {
|
||||
{
|
||||
var rid = local_scope_table.AddRow (new LocalScopeRow (
|
||||
method_info.Method.MetadataToken.RID,
|
||||
AddImportScope (scope.Import),
|
||||
scope.import != null ? AddImportScope (scope.import) : 0,
|
||||
local_variable_rid,
|
||||
local_constant_rid,
|
||||
(uint) scope.Start.Offset,
|
||||
@@ -2273,9 +2285,6 @@ namespace Mono.Cecil {
|
||||
if (scope.HasConstants)
|
||||
AddLocalConstants (scope);
|
||||
|
||||
if (scope.Import != null)
|
||||
AddImportScope (scope.Import);
|
||||
|
||||
for (int i = 0; i < scope.Scopes.Count; i++)
|
||||
AddLocalScope (method_info, scope.Scopes [i]);
|
||||
}
|
||||
@@ -2516,10 +2525,13 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
signature.WriteByte ((byte) separator);
|
||||
|
||||
var parts = name.Split (new [] { separator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (parts [i]));
|
||||
var parts = name.Split (new [] { separator });
|
||||
for (int i = 0; i < parts.Length; i++) {
|
||||
if (parts [i] == String.Empty)
|
||||
signature.WriteCompressedUInt32 (0);
|
||||
else
|
||||
signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (parts [i]));
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
@@ -3216,7 +3228,7 @@ namespace Mono.Cecil {
|
||||
|
||||
#endif
|
||||
|
||||
static partial class Mixin {
|
||||
static partial class Mixin {
|
||||
|
||||
public static bool TryGetUniqueDocument (this MethodDebugInformation info, out Document document)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -35,7 +33,9 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#if !NET_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
public sealed class AssemblyResolutionException : FileNotFoundException {
|
||||
|
||||
readonly AssemblyNameReference reference;
|
||||
@@ -50,14 +50,17 @@ namespace Mono.Cecil {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
#if !NET_CORE
|
||||
AssemblyResolutionException (
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !NET_CORE
|
||||
public abstract class BaseAssemblyResolver : IAssemblyResolver {
|
||||
|
||||
static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null;
|
||||
@@ -83,19 +86,6 @@ namespace Mono.Cecil {
|
||||
return directories;
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (string fullName)
|
||||
{
|
||||
return Resolve (fullName, new ReaderParameters ());
|
||||
}
|
||||
|
||||
public virtual AssemblyDefinition Resolve (string fullName, ReaderParameters parameters)
|
||||
{
|
||||
if (fullName == null)
|
||||
throw new ArgumentNullException ("fullName");
|
||||
|
||||
return Resolve (AssemblyNameReference.Parse (fullName), parameters);
|
||||
}
|
||||
|
||||
public event AssemblyResolveEventHandler ResolveFailure;
|
||||
|
||||
protected BaseAssemblyResolver ()
|
||||
@@ -118,10 +108,8 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (parameters == null)
|
||||
parameters = new ReaderParameters ();
|
||||
Mixin.CheckName (name);
|
||||
Mixin.CheckParameters (parameters);
|
||||
|
||||
var assembly = SearchDirectory (name, directories, parameters);
|
||||
if (assembly != null)
|
||||
@@ -171,8 +159,13 @@ namespace Mono.Cecil {
|
||||
foreach (var directory in directories) {
|
||||
foreach (var extension in extensions) {
|
||||
string file = Path.Combine (directory, name.Name + extension);
|
||||
if (File.Exists (file))
|
||||
if (!File.Exists (file))
|
||||
continue;
|
||||
try {
|
||||
return GetAssembly (file, parameters);
|
||||
} catch (System.BadImageFormatException) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +344,5 @@ namespace Mono.Cecil {
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
5
external/linker/cecil/Mono.Cecil/Consts.cs
vendored
Normal file
5
external/linker/cecil/Mono.Cecil/Consts.cs
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
static class Consts
|
||||
{
|
||||
public const string AssemblyName = "Mono.Cecil";
|
||||
public const string PublicKey = "00240000048000009400000006020000002400005253413100040000010001002b5c9f7f04346c324a3176f8d3ee823bbf2d60efdbc35f86fd9e65ea3e6cd11bcdcba3a353e55133c8ac5c4caaba581b2c6dfff2cc2d0edc43959ddb86b973300a479a82419ef489c3225f1fe429a708507bd515835160e10bc743d20ca33ab9570cfd68d479fcf0bc797a763bec5d1000f0159ef619e709d915975e87beebaf";
|
||||
}
|
||||
@@ -200,15 +200,4 @@ namespace Mono.Cecil {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static partial class Mixin {
|
||||
|
||||
public static void CheckName (string name)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (name.Length == 0)
|
||||
throw new ArgumentException ("Empty name");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -26,8 +26,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public override AssemblyDefinition Resolve (AssemblyNameReference name)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
Mixin.CheckName (name);
|
||||
|
||||
AssemblyDefinition assembly;
|
||||
if (cache.TryGetValue (name.FullName, out assembly))
|
||||
|
||||
@@ -28,9 +28,7 @@ namespace Mono.Cecil {
|
||||
protected EventReference (string name, TypeReference eventType)
|
||||
: base (name)
|
||||
{
|
||||
if (eventType == null)
|
||||
throw new ArgumentNullException ("eventType");
|
||||
|
||||
Mixin.CheckType (eventType, Mixin.Argument.eventType);
|
||||
event_type = eventType;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,14 @@ namespace Mono.Cecil {
|
||||
|
||||
return scope;
|
||||
}
|
||||
set {
|
||||
if (declaring_type != null) {
|
||||
declaring_type.Scope = value;
|
||||
return;
|
||||
}
|
||||
|
||||
scope = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ExportedType DeclaringType {
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace Mono.Cecil {
|
||||
public FieldReference (string name, TypeReference fieldType)
|
||||
: base (name)
|
||||
{
|
||||
if (fieldType == null)
|
||||
throw new ArgumentNullException ("fieldType");
|
||||
Mixin.CheckType (fieldType, Mixin.Argument.fieldType);
|
||||
|
||||
this.field_type = fieldType;
|
||||
this.token = new MetadataToken (TokenType.MemberRef);
|
||||
@@ -47,8 +46,7 @@ namespace Mono.Cecil {
|
||||
public FieldReference (string name, TypeReference fieldType, TypeReference declaringType)
|
||||
: this (name, fieldType)
|
||||
{
|
||||
if (declaringType == null)
|
||||
throw new ArgumentNullException("declaringType");
|
||||
Mixin.CheckType (declaringType, Mixin.Argument.declaringType);
|
||||
|
||||
this.DeclaringType = declaringType;
|
||||
}
|
||||
|
||||
@@ -188,8 +188,7 @@ namespace Mono.Cecil {
|
||||
internal GenericParameter (int position, GenericParameterType type, ModuleDefinition module)
|
||||
: base (string.Empty, string.Empty)
|
||||
{
|
||||
if (module == null)
|
||||
throw new ArgumentNullException ();
|
||||
Mixin.CheckModule (module);
|
||||
|
||||
this.position = position;
|
||||
this.type = type;
|
||||
|
||||
47
external/linker/cecil/Mono.Cecil/Import.cs
vendored
47
external/linker/cecil/Mono.Cecil/Import.cs
vendored
@@ -29,8 +29,6 @@ namespace Mono.Cecil {
|
||||
MethodReference ImportReference (MethodReference method, IGenericParameterProvider context);
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
public interface IReflectionImporterProvider {
|
||||
IReflectionImporter GetReflectionImporter (ModuleDefinition module);
|
||||
}
|
||||
@@ -41,8 +39,6 @@ namespace Mono.Cecil {
|
||||
MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct ImportGenericContext {
|
||||
|
||||
Collection<IGenericParameterProvider> stack;
|
||||
@@ -126,8 +122,6 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
public class ReflectionImporter : IReflectionImporter {
|
||||
|
||||
readonly ModuleDefinition module;
|
||||
@@ -159,7 +153,9 @@ namespace Mono.Cecil {
|
||||
{ typeof (float), ElementType.R4 },
|
||||
{ typeof (double), ElementType.R8 },
|
||||
{ typeof (string), ElementType.String },
|
||||
#if !NET_CORE
|
||||
{ typeof (TypedReference), ElementType.TypedByRef },
|
||||
#endif
|
||||
{ typeof (IntPtr), ElementType.I },
|
||||
{ typeof (UIntPtr), ElementType.U },
|
||||
{ typeof (object), ElementType.Object },
|
||||
@@ -179,8 +175,8 @@ namespace Mono.Cecil {
|
||||
string.Empty,
|
||||
type.Name,
|
||||
module,
|
||||
ImportScope (type.Assembly),
|
||||
type.IsValueType);
|
||||
ImportScope (type.Assembly ()),
|
||||
type.IsValueType ());
|
||||
|
||||
reference.etype = ImportElementType (type);
|
||||
|
||||
@@ -189,7 +185,7 @@ namespace Mono.Cecil {
|
||||
else
|
||||
reference.Namespace = type.Namespace ?? string.Empty;
|
||||
|
||||
if (type.IsGenericType)
|
||||
if (type.IsGenericType ())
|
||||
ImportGenericParameters (reference, type.GetGenericArguments ());
|
||||
|
||||
return reference;
|
||||
@@ -197,7 +193,7 @@ namespace Mono.Cecil {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static bool ImportOpenGenericMethod (SR.MethodBase method, ImportGenericKind import_kind)
|
||||
@@ -221,7 +217,7 @@ namespace Mono.Cecil {
|
||||
if (type.IsArray)
|
||||
return new ArrayType (ImportType (type.GetElementType (), context), type.GetArrayRank ());
|
||||
|
||||
if (type.IsGenericType)
|
||||
if (type.IsGenericType ())
|
||||
return ImportGenericInstance (type, context);
|
||||
|
||||
if (type.IsGenericParameter)
|
||||
@@ -235,8 +231,8 @@ namespace Mono.Cecil {
|
||||
if (context.IsEmpty)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
if (type.DeclaringMethod != null)
|
||||
return context.MethodParameter (NormalizeMethodName (type.DeclaringMethod), type.GenericParameterPosition);
|
||||
if (type.DeclaringMethod () != null)
|
||||
return context.MethodParameter (NormalizeMethodName (type.DeclaringMethod ()), type.GenericParameterPosition);
|
||||
|
||||
if (type.DeclaringType != null)
|
||||
return context.TypeParameter (NormalizeTypeFullName (type.DeclaringType), type.GenericParameterPosition);
|
||||
@@ -284,7 +280,7 @@ namespace Mono.Cecil {
|
||||
|
||||
static bool IsGenericInstance (Type type)
|
||||
{
|
||||
return type.IsGenericType && !type.IsGenericTypeDefinition;
|
||||
return type.IsGenericType () && !type.IsGenericTypeDefinition ();
|
||||
}
|
||||
|
||||
static ElementType ImportElementType (Type type)
|
||||
@@ -306,9 +302,11 @@ namespace Mono.Cecil {
|
||||
return scope;
|
||||
|
||||
scope = new AssemblyNameReference (name.Name, name.Version) {
|
||||
Culture = name.CultureInfo.Name,
|
||||
PublicKeyToken = name.GetPublicKeyToken (),
|
||||
#if !NET_CORE
|
||||
Culture = name.CultureInfo.Name,
|
||||
HashAlgorithm = (AssemblyHashAlgorithm) name.HashAlgorithm,
|
||||
#endif
|
||||
};
|
||||
|
||||
module.AssemblyReferences.Add (scope);
|
||||
@@ -354,7 +352,20 @@ namespace Mono.Cecil {
|
||||
|
||||
static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field)
|
||||
{
|
||||
#if NET_CORE
|
||||
throw new NotImplementedException ();
|
||||
#else
|
||||
return field.Module.ResolveField (field.MetadataToken);
|
||||
#endif
|
||||
}
|
||||
|
||||
static SR.MethodBase ResolveMethodDefinition (SR.MethodBase method)
|
||||
{
|
||||
#if NET_CORE
|
||||
throw new NotImplementedException ();
|
||||
#else
|
||||
return method.Module.ResolveMethod (method.MetadataToken);
|
||||
#endif
|
||||
}
|
||||
|
||||
MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind)
|
||||
@@ -365,7 +376,7 @@ namespace Mono.Cecil {
|
||||
var declaring_type = ImportType (method.DeclaringType, context);
|
||||
|
||||
if (IsGenericInstance (method.DeclaringType))
|
||||
method = method.Module.ResolveMethod (method.MetadataToken);
|
||||
method = ResolveMethodDefinition (method);
|
||||
|
||||
var reference = new MethodReference {
|
||||
Name = method.Name,
|
||||
@@ -466,8 +477,6 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public class MetadataImporter : IMetadataImporter {
|
||||
|
||||
readonly ModuleDefinition module;
|
||||
@@ -740,7 +749,7 @@ namespace Mono.Cecil {
|
||||
public static void CheckModule (ModuleDefinition module)
|
||||
{
|
||||
if (module == null)
|
||||
throw new ArgumentNullException ("module");
|
||||
throw new ArgumentNullException (Argument.module.ToString ());
|
||||
}
|
||||
|
||||
public static bool TryGetAssemblyNameReference (this ModuleDefinition module, AssemblyNameReference name_reference, out AssemblyNameReference assembly_reference)
|
||||
|
||||
@@ -17,9 +17,6 @@ namespace Mono.Cecil {
|
||||
public interface IAssemblyResolver : IDisposable {
|
||||
AssemblyDefinition Resolve (AssemblyNameReference name);
|
||||
AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters);
|
||||
|
||||
AssemblyDefinition Resolve (string fullName);
|
||||
AssemblyDefinition Resolve (string fullName, ReaderParameters parameters);
|
||||
}
|
||||
|
||||
public interface IMetadataResolver {
|
||||
@@ -28,7 +25,7 @@ namespace Mono.Cecil {
|
||||
MethodDefinition Resolve (MethodReference method);
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
public sealed class ResolutionException : Exception {
|
||||
@@ -62,7 +59,7 @@ namespace Mono.Cecil {
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
ResolutionException (
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context)
|
||||
@@ -90,8 +87,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual TypeDefinition Resolve (TypeReference type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
Mixin.CheckType (type);
|
||||
|
||||
type = type.GetElementType ();
|
||||
|
||||
@@ -162,8 +158,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual FieldDefinition Resolve (FieldReference field)
|
||||
{
|
||||
if (field == null)
|
||||
throw new ArgumentNullException ("field");
|
||||
Mixin.CheckField (field);
|
||||
|
||||
var type = Resolve (field.DeclaringType);
|
||||
if (type == null)
|
||||
@@ -210,8 +205,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public virtual MethodDefinition Resolve (MethodReference method)
|
||||
{
|
||||
if (method == null)
|
||||
throw new ArgumentNullException ("method");
|
||||
Mixin.CheckMethod (method);
|
||||
|
||||
var type = Resolve (method.DeclaringType);
|
||||
if (type == null)
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Cecil.Metadata;
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil {
|
||||
|
||||
@@ -39,15 +40,15 @@ namespace Mono.Cecil {
|
||||
internal MethodDefinition [] Methods;
|
||||
internal MemberReference [] MemberReferences;
|
||||
|
||||
internal Dictionary<uint, uint []> NestedTypes;
|
||||
internal Dictionary<uint, Collection<uint>> NestedTypes;
|
||||
internal Dictionary<uint, uint> ReverseNestedTypes;
|
||||
internal Dictionary<uint, Row<uint, MetadataToken> []> Interfaces;
|
||||
internal Dictionary<uint, Collection<Row<uint, MetadataToken>>> Interfaces;
|
||||
internal Dictionary<uint, Row<ushort, uint>> ClassLayouts;
|
||||
internal Dictionary<uint, uint> FieldLayouts;
|
||||
internal Dictionary<uint, uint> FieldRVAs;
|
||||
internal Dictionary<MetadataToken, uint> FieldMarshals;
|
||||
internal Dictionary<MetadataToken, Row<ElementType, uint>> Constants;
|
||||
internal Dictionary<uint, MetadataToken []> Overrides;
|
||||
internal Dictionary<uint, Collection<MetadataToken>> Overrides;
|
||||
internal Dictionary<MetadataToken, Range []> CustomAttributes;
|
||||
internal Dictionary<MetadataToken, Range []> SecurityDeclarations;
|
||||
internal Dictionary<uint, Range> Events;
|
||||
@@ -55,10 +56,10 @@ namespace Mono.Cecil {
|
||||
internal Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> Semantics;
|
||||
internal Dictionary<uint, Row<PInvokeAttributes, uint, uint>> PInvokes;
|
||||
internal Dictionary<MetadataToken, Range []> GenericParameters;
|
||||
internal Dictionary<uint, MetadataToken []> GenericConstraints;
|
||||
internal Dictionary<uint, Collection<MetadataToken>> GenericConstraints;
|
||||
|
||||
internal Document [] Documents;
|
||||
internal Dictionary<uint, Row<uint, Range, Range, uint, uint, uint> []> LocalScopes;
|
||||
internal Dictionary<uint, Collection<Row<uint, Range, Range, uint, uint, uint>>> LocalScopes;
|
||||
internal ImportDebugInformation [] ImportScopes;
|
||||
internal Dictionary<uint, uint> StateMachineMethods;
|
||||
internal Dictionary<MetadataToken, Row<Guid, uint, uint> []> CustomDebugInformations;
|
||||
@@ -114,7 +115,7 @@ namespace Mono.Cecil {
|
||||
return false;
|
||||
|
||||
Row<ElementType, bool> primitive_data;
|
||||
if (TryGetPrimitiveData (type, out primitive_data) && primitive_data.Col1.IsPrimitive ()) {
|
||||
if (TryGetPrimitiveData (type, out primitive_data)) {
|
||||
etype = primitive_data.Col1;
|
||||
return true;
|
||||
}
|
||||
@@ -132,15 +133,15 @@ namespace Mono.Cecil {
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
if (NestedTypes != null) NestedTypes = new Dictionary<uint, uint []> (capacity: 0);
|
||||
if (NestedTypes != null) NestedTypes = new Dictionary<uint, Collection<uint>> (capacity: 0);
|
||||
if (ReverseNestedTypes != null) ReverseNestedTypes = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (Interfaces != null) Interfaces = new Dictionary<uint, Row<uint, MetadataToken> []> (capacity: 0);
|
||||
if (Interfaces != null) Interfaces = new Dictionary<uint, Collection<Row<uint, MetadataToken>>> (capacity: 0);
|
||||
if (ClassLayouts != null) ClassLayouts = new Dictionary<uint, Row<ushort, uint>> (capacity: 0);
|
||||
if (FieldLayouts != null) FieldLayouts = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (FieldRVAs != null) FieldRVAs = new Dictionary<uint, uint> (capacity: 0);
|
||||
if (FieldMarshals != null) FieldMarshals = new Dictionary<MetadataToken, uint> (capacity: 0);
|
||||
if (Constants != null) Constants = new Dictionary<MetadataToken, Row<ElementType, uint>> (capacity: 0);
|
||||
if (Overrides != null) Overrides = new Dictionary<uint, MetadataToken []> (capacity: 0);
|
||||
if (Overrides != null) Overrides = new Dictionary<uint, Collection<MetadataToken>> (capacity: 0);
|
||||
if (CustomAttributes != null) CustomAttributes = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (SecurityDeclarations != null) SecurityDeclarations = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (Events != null) Events = new Dictionary<uint, Range> (capacity: 0);
|
||||
@@ -148,11 +149,11 @@ namespace Mono.Cecil {
|
||||
if (Semantics != null) Semantics = new Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> (capacity: 0);
|
||||
if (PInvokes != null) PInvokes = new Dictionary<uint, Row<PInvokeAttributes, uint, uint>> (capacity: 0);
|
||||
if (GenericParameters != null) GenericParameters = new Dictionary<MetadataToken, Range []> (capacity: 0);
|
||||
if (GenericConstraints != null) GenericConstraints = new Dictionary<uint, MetadataToken []> (capacity: 0);
|
||||
if (GenericConstraints != null) GenericConstraints = new Dictionary<uint, Collection<MetadataToken>> (capacity: 0);
|
||||
|
||||
Documents = Empty<Document>.Array;
|
||||
ImportScopes = Empty<ImportDebugInformation>.Array;
|
||||
if (LocalScopes != null) LocalScopes = new Dictionary<uint, Row<uint, Range, Range, uint, uint, uint> []> (capacity: 0);
|
||||
if (LocalScopes != null) LocalScopes = new Dictionary<uint, Collection<Row<uint, Range, Range, uint, uint, uint>>> (capacity: 0);
|
||||
if (StateMachineMethods != null) StateMachineMethods = new Dictionary<uint, uint> (capacity: 0);
|
||||
}
|
||||
|
||||
@@ -229,12 +230,12 @@ namespace Mono.Cecil {
|
||||
MemberReferences [member.token.RID - 1] = member;
|
||||
}
|
||||
|
||||
public bool TryGetNestedTypeMapping (TypeDefinition type, out uint [] mapping)
|
||||
public bool TryGetNestedTypeMapping (TypeDefinition type, out Collection<uint> mapping)
|
||||
{
|
||||
return NestedTypes.TryGetValue (type.token.RID, out mapping);
|
||||
}
|
||||
|
||||
public void SetNestedTypeMapping (uint type_rid, uint [] mapping)
|
||||
public void SetNestedTypeMapping (uint type_rid, Collection<uint> mapping)
|
||||
{
|
||||
NestedTypes [type_rid] = mapping;
|
||||
}
|
||||
@@ -259,12 +260,12 @@ namespace Mono.Cecil {
|
||||
ReverseNestedTypes.Remove (type.token.RID);
|
||||
}
|
||||
|
||||
public bool TryGetInterfaceMapping (TypeDefinition type, out Row<uint, MetadataToken> [] mapping)
|
||||
public bool TryGetInterfaceMapping (TypeDefinition type, out Collection<Row<uint, MetadataToken>> mapping)
|
||||
{
|
||||
return Interfaces.TryGetValue (type.token.RID, out mapping);
|
||||
}
|
||||
|
||||
public void SetInterfaceMapping (uint type_rid, Row<uint, MetadataToken> [] mapping)
|
||||
public void SetInterfaceMapping (uint type_rid, Collection<Row<uint, MetadataToken>> mapping)
|
||||
{
|
||||
Interfaces [type_rid] = mapping;
|
||||
}
|
||||
@@ -334,12 +335,12 @@ namespace Mono.Cecil {
|
||||
SecurityDeclarations.Remove (owner.MetadataToken);
|
||||
}
|
||||
|
||||
public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out MetadataToken [] mapping)
|
||||
public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out Collection<MetadataToken> mapping)
|
||||
{
|
||||
return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping);
|
||||
}
|
||||
|
||||
public void SetGenericConstraintMapping (uint gp_rid, MetadataToken [] mapping)
|
||||
public void SetGenericConstraintMapping (uint gp_rid, Collection<MetadataToken> mapping)
|
||||
{
|
||||
GenericConstraints [gp_rid] = mapping;
|
||||
}
|
||||
@@ -349,12 +350,12 @@ namespace Mono.Cecil {
|
||||
GenericConstraints.Remove (generic_parameter.token.RID);
|
||||
}
|
||||
|
||||
public bool TryGetOverrideMapping (MethodDefinition method, out MetadataToken [] mapping)
|
||||
public bool TryGetOverrideMapping (MethodDefinition method, out Collection<MetadataToken> mapping)
|
||||
{
|
||||
return Overrides.TryGetValue (method.token.RID, out mapping);
|
||||
}
|
||||
|
||||
public void SetOverrideMapping (uint rid, MetadataToken [] mapping)
|
||||
public void SetOverrideMapping (uint rid, Collection<MetadataToken> mapping)
|
||||
{
|
||||
Overrides [rid] = mapping;
|
||||
}
|
||||
@@ -372,12 +373,12 @@ namespace Mono.Cecil {
|
||||
return Documents [rid - 1];
|
||||
}
|
||||
|
||||
public bool TryGetLocalScopes (MethodDefinition method, out Row<uint, Range, Range, uint, uint, uint> [] scopes)
|
||||
public bool TryGetLocalScopes (MethodDefinition method, out Collection<Row<uint, Range, Range, uint, uint, uint>> scopes)
|
||||
{
|
||||
return LocalScopes.TryGetValue (method.MetadataToken.RID, out scopes);
|
||||
}
|
||||
|
||||
public void SetLocalScopes (uint method_rid, Row<uint, Range, Range, uint, uint, uint> [] records)
|
||||
public void SetLocalScopes (uint method_rid, Collection<Row<uint, Range, Range, uint, uint, uint>> records)
|
||||
{
|
||||
LocalScopes [method_rid] = records;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,9 @@ namespace Mono.Cecil {
|
||||
if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter)
|
||||
return true;
|
||||
|
||||
if (!HasParameters)
|
||||
return false;
|
||||
|
||||
var parameters = this.Parameters;
|
||||
|
||||
for (int i = 0; i < parameters.Count; i++)
|
||||
@@ -141,8 +144,7 @@ namespace Mono.Cecil {
|
||||
public MethodReference (string name, TypeReference returnType)
|
||||
: base (name)
|
||||
{
|
||||
if (returnType == null)
|
||||
throw new ArgumentNullException ("returnType");
|
||||
Mixin.CheckType (returnType, Mixin.Argument.returnType);
|
||||
|
||||
this.return_type = new MethodReturnType (this);
|
||||
this.return_type.ReturnType = returnType;
|
||||
@@ -152,8 +154,7 @@ namespace Mono.Cecil {
|
||||
public MethodReference (string name, TypeReference returnType, TypeReference declaringType)
|
||||
: this (name, returnType)
|
||||
{
|
||||
if (declaringType == null)
|
||||
throw new ArgumentNullException ("declaringType");
|
||||
Mixin.CheckType (declaringType, Mixin.Argument.declaringType);
|
||||
|
||||
this.DeclaringType = declaringType;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@ namespace Mono.Cecil {
|
||||
set { Parameter.Attributes = value; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return Parameter.Name; }
|
||||
set { Parameter.Name = value; }
|
||||
}
|
||||
|
||||
public bool HasCustomAttributes {
|
||||
get { return parameter != null && parameter.HasCustomAttributes; }
|
||||
}
|
||||
|
||||
@@ -70,8 +70,7 @@ namespace Mono.Cecil {
|
||||
|
||||
internal MethodSpecification (MethodReference method)
|
||||
{
|
||||
if (method == null)
|
||||
throw new ArgumentNullException ("method");
|
||||
Mixin.CheckMethod (method);
|
||||
|
||||
this.method = method;
|
||||
this.token = new MetadataToken (TokenType.MethodSpec);
|
||||
|
||||
19
external/linker/cecil/Mono.Cecil/Modifiers.cs
vendored
19
external/linker/cecil/Mono.Cecil/Modifiers.cs
vendored
@@ -56,7 +56,9 @@ namespace Mono.Cecil {
|
||||
public OptionalModifierType (TypeReference modifierType, TypeReference type)
|
||||
: base (type)
|
||||
{
|
||||
Mixin.CheckModifier (modifierType, type);
|
||||
if (modifierType == null)
|
||||
throw new ArgumentNullException (Mixin.Argument.modifierType.ToString ());
|
||||
Mixin.CheckType (type);
|
||||
this.modifier_type = modifierType;
|
||||
this.etype = MD.ElementType.CModOpt;
|
||||
}
|
||||
@@ -99,21 +101,12 @@ namespace Mono.Cecil {
|
||||
public RequiredModifierType (TypeReference modifierType, TypeReference type)
|
||||
: base (type)
|
||||
{
|
||||
Mixin.CheckModifier (modifierType, type);
|
||||
if (modifierType == null)
|
||||
throw new ArgumentNullException (Mixin.Argument.modifierType.ToString ());
|
||||
Mixin.CheckType (type);
|
||||
this.modifier_type = modifierType;
|
||||
this.etype = MD.ElementType.CModReqD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static partial class Mixin {
|
||||
|
||||
public static void CheckModifier (TypeReference modifierType, TypeReference type)
|
||||
{
|
||||
if (modifierType == null)
|
||||
throw new ArgumentNullException ("modifierType");
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user