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 ()
|
||||
{
|
||||
|
||||
10
external/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
10
external/cecil/Mono.Cecil/AssemblyInfo.cs
vendored
@@ -14,11 +14,11 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[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 {
|
||||
|
||||
101
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
101
external/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,23 +93,15 @@ namespace Mono.Cecil {
|
||||
{
|
||||
var symbol_reader_provider = parameters.SymbolReaderProvider;
|
||||
|
||||
#if !PCL
|
||||
if (symbol_reader_provider == null && parameters.ReadSymbols)
|
||||
symbol_reader_provider = new DefaultSymbolReaderProvider ();
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
if (reader != null)
|
||||
module.ReadSymbols (reader);
|
||||
@@ -663,7 +651,6 @@ namespace Mono.Cecil {
|
||||
if (attributes != FileAttributes.ContainsMetaData)
|
||||
continue;
|
||||
|
||||
#if !PCL
|
||||
var parameters = new ReaderParameters {
|
||||
ReadingMode = module.ReadingMode,
|
||||
SymbolReaderProvider = module.SymbolReaderProvider,
|
||||
@@ -672,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)
|
||||
@@ -689,7 +672,6 @@ namespace Mono.Cecil {
|
||||
var path = Path.GetDirectoryName (module.FileName);
|
||||
return Path.Combine (path, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void InitializeModuleReferences ()
|
||||
{
|
||||
@@ -874,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)
|
||||
@@ -911,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)
|
||||
@@ -931,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)
|
||||
@@ -1224,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);
|
||||
}
|
||||
@@ -1232,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),
|
||||
@@ -1260,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);
|
||||
@@ -2028,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);
|
||||
@@ -2062,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 (
|
||||
@@ -2080,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);
|
||||
@@ -2115,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);
|
||||
@@ -2439,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 ();
|
||||
@@ -2882,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);
|
||||
@@ -2901,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) {
|
||||
@@ -3794,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;
|
||||
}
|
||||
|
||||
76
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
76
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
@@ -72,7 +72,13 @@ namespace Mono.Cecil {
|
||||
|
||||
static class ModuleWriter {
|
||||
|
||||
public static void WriteModuleTo (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
public static void WriteModule (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
{
|
||||
using (stream)
|
||||
Write (module, stream, parameters);
|
||||
}
|
||||
|
||||
static void Write (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
{
|
||||
if ((module.Attributes & ModuleAttributes.ILOnly) == 0)
|
||||
throw new NotSupportedException ("Writing mixed-mode assemblies is not supported");
|
||||
@@ -90,38 +96,32 @@ namespace Mono.Cecil {
|
||||
|
||||
var name = module.assembly != null ? module.assembly.Name : null;
|
||||
var fq_name = stream.value.GetFileName ();
|
||||
var timestamp = parameters.Timestamp ?? module.timestamp;
|
||||
var symbol_writer_provider = parameters.SymbolWriterProvider;
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
if (symbol_writer_provider == null && parameters.WriteSymbols)
|
||||
symbol_writer_provider = new DefaultSymbolWriterProvider ();
|
||||
#endif
|
||||
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);
|
||||
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);
|
||||
|
||||
BuildMetadata (module, metadata);
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
stream.value.SetLength (0);
|
||||
writer.WriteImage ();
|
||||
|
||||
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 (parameters.StrongNameKeyPair != null)
|
||||
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
|
||||
|
||||
stream.Dispose ();
|
||||
#if !NET_CORE
|
||||
if (parameters.StrongNameKeyPair != null)
|
||||
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void BuildMetadata (ModuleDefinition module, MetadataBuilder metadata)
|
||||
@@ -145,11 +145,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +793,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;
|
||||
@@ -860,14 +856,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 = module.timestamp;
|
||||
this.timestamp = timestamp;
|
||||
this.symbol_writer_provider = symbol_writer_provider;
|
||||
|
||||
if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ()) {
|
||||
@@ -875,12 +869,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);
|
||||
@@ -1085,7 +1078,7 @@ namespace Mono.Cecil {
|
||||
if (module.IsMain)
|
||||
continue;
|
||||
|
||||
#if PCL || NET_CORE
|
||||
#if NET_CORE
|
||||
throw new NotSupportedException ();
|
||||
#else
|
||||
var parameters = new WriterParameters {
|
||||
@@ -1105,7 +1098,7 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
string GetModuleFileName (string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty (name))
|
||||
@@ -1206,7 +1199,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
|
||||
@@ -2061,6 +2054,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 ();
|
||||
@@ -2071,6 +2069,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 ();
|
||||
|
||||
@@ -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;
|
||||
@@ -45,19 +45,27 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
public AssemblyResolutionException (AssemblyNameReference reference)
|
||||
: base (string.Format ("Failed to resolve assembly: '{0}'", reference))
|
||||
: this (reference, null)
|
||||
{
|
||||
}
|
||||
|
||||
public AssemblyResolutionException (AssemblyNameReference reference, Exception innerException)
|
||||
: base (string.Format ("Failed to resolve assembly: '{0}'", reference), innerException)
|
||||
{
|
||||
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;
|
||||
@@ -120,9 +128,12 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
|
||||
var framework_dirs = on_mono
|
||||
? new [] { framework_dir, Path.Combine (framework_dir, "Facades") }
|
||||
: new [] { framework_dir };
|
||||
|
||||
if (IsZero (name.Version)) {
|
||||
assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
|
||||
assembly = SearchDirectory (name, framework_dirs, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
@@ -137,7 +148,7 @@ namespace Mono.Cecil {
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
|
||||
assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
|
||||
assembly = SearchDirectory (name, framework_dirs, parameters);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
|
||||
@@ -341,6 +352,5 @@ namespace Mono.Cecil {
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
1
external/cecil/Mono.Cecil/Consts.cs
vendored
1
external/cecil/Mono.Cecil/Consts.cs
vendored
@@ -1,4 +1,5 @@
|
||||
static class Consts
|
||||
{
|
||||
public const string AssemblyName = "Mono.Cecil";
|
||||
public const string PublicKey = "00240000048000009400000006020000002400005253413100040000010001002b5c9f7f04346c324a3176f8d3ee823bbf2d60efdbc35f86fd9e65ea3e6cd11bcdcba3a353e55133c8ac5c4caaba581b2c6dfff2cc2d0edc43959ddb86b973300a479a82419ef489c3225f1fe429a708507bd515835160e10bc743d20ca33ab9570cfd68d479fcf0bc797a763bec5d1000f0159ef619e709d915975e87beebaf";
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
45
external/cecil/Mono.Cecil/Import.cs
vendored
45
external/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;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Mono.Cecil {
|
||||
MethodDefinition Resolve (MethodReference method);
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
public sealed class ResolutionException : Exception {
|
||||
@@ -59,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)
|
||||
|
||||
43
external/cecil/Mono.Cecil/MetadataSystem.cs
vendored
43
external/cecil/Mono.Cecil/MetadataSystem.cs
vendored
@@ -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;
|
||||
}
|
||||
|
||||
@@ -171,11 +171,11 @@ namespace Mono.Cecil {
|
||||
|
||||
public MethodDebugInformation DebugInformation {
|
||||
get {
|
||||
Mixin.Read (Body);
|
||||
|
||||
if (debug_info != null)
|
||||
return debug_info;
|
||||
|
||||
Mixin.Read (Body);
|
||||
|
||||
return debug_info ?? (debug_info = new MethodDebugInformation (this));
|
||||
}
|
||||
}
|
||||
|
||||
139
external/cecil/Mono.Cecil/ModuleDefinition.cs
vendored
139
external/cecil/Mono.Cecil/ModuleDefinition.cs
vendored
@@ -33,9 +33,7 @@ namespace Mono.Cecil {
|
||||
internal IMetadataResolver metadata_resolver;
|
||||
#if !READ_ONLY
|
||||
internal IMetadataImporterProvider metadata_importer_provider;
|
||||
#if !PCL && !NET_CORE
|
||||
internal IReflectionImporterProvider reflection_importer_provider;
|
||||
#endif
|
||||
#endif
|
||||
Stream symbol_stream;
|
||||
ISymbolReaderProvider symbol_reader_provider;
|
||||
@@ -70,12 +68,10 @@ namespace Mono.Cecil {
|
||||
set { metadata_importer_provider = value; }
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
public IReflectionImporterProvider ReflectionImporterProvider {
|
||||
get { return reflection_importer_provider; }
|
||||
set { reflection_importer_provider = value; }
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public Stream SymbolStream {
|
||||
@@ -88,12 +84,10 @@ namespace Mono.Cecil {
|
||||
set { symbol_reader_provider = value; }
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public bool ReadSymbols {
|
||||
get { return read_symbols; }
|
||||
set { read_symbols = value; }
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool ReadWrite {
|
||||
get { return read_write; }
|
||||
@@ -122,14 +116,13 @@ namespace Mono.Cecil {
|
||||
|
||||
ModuleKind kind;
|
||||
TargetRuntime runtime;
|
||||
uint? timestamp;
|
||||
TargetArchitecture architecture;
|
||||
IAssemblyResolver assembly_resolver;
|
||||
IMetadataResolver metadata_resolver;
|
||||
#if !READ_ONLY
|
||||
IMetadataImporterProvider metadata_importer_provider;
|
||||
#if !PCL && !NET_CORE
|
||||
IReflectionImporterProvider reflection_importer_provider;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public ModuleKind Kind {
|
||||
@@ -142,6 +135,11 @@ namespace Mono.Cecil {
|
||||
set { runtime = value; }
|
||||
}
|
||||
|
||||
public uint? Timestamp {
|
||||
get { return timestamp; }
|
||||
set { timestamp = value; }
|
||||
}
|
||||
|
||||
public TargetArchitecture Architecture {
|
||||
get { return architecture; }
|
||||
set { architecture = value; }
|
||||
@@ -163,12 +161,10 @@ namespace Mono.Cecil {
|
||||
set { metadata_importer_provider = value; }
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
public IReflectionImporterProvider ReflectionImporterProvider {
|
||||
get { return reflection_importer_provider; }
|
||||
set { reflection_importer_provider = value; }
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public ModuleParameters ()
|
||||
@@ -180,10 +176,10 @@ namespace Mono.Cecil {
|
||||
|
||||
static TargetRuntime GetCurrentRuntime ()
|
||||
{
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
return typeof (object).Assembly.ImageRuntimeVersion.ParseRuntime ();
|
||||
#else
|
||||
var corlib_name = AssemblyNameReference.Parse (typeof (object).GetAssembly ().FullName);
|
||||
var corlib_name = AssemblyNameReference.Parse (typeof (object).Assembly ().FullName);
|
||||
var corlib_version = corlib_name.Version;
|
||||
|
||||
switch (corlib_version.Major) {
|
||||
@@ -220,12 +216,19 @@ namespace Mono.Cecil {
|
||||
|
||||
public sealed class WriterParameters {
|
||||
|
||||
uint? timestamp;
|
||||
Stream symbol_stream;
|
||||
ISymbolWriterProvider symbol_writer_provider;
|
||||
bool write_symbols;
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
SR.StrongNameKeyPair key_pair;
|
||||
#endif
|
||||
|
||||
public uint? Timestamp {
|
||||
get { return timestamp; }
|
||||
set { timestamp = value; }
|
||||
}
|
||||
|
||||
public Stream SymbolStream {
|
||||
get { return symbol_stream; }
|
||||
set { symbol_stream = value; }
|
||||
@@ -236,14 +239,12 @@ namespace Mono.Cecil {
|
||||
set { symbol_writer_provider = value; }
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public bool WriteSymbols {
|
||||
get { return write_symbols; }
|
||||
set { write_symbols = value; }
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
public SR.StrongNameKeyPair StrongNameKeyPair {
|
||||
get { return key_pair; }
|
||||
set { key_pair = value; }
|
||||
@@ -282,9 +283,7 @@ namespace Mono.Cecil {
|
||||
MethodDefinition entry_point;
|
||||
|
||||
#if !READ_ONLY
|
||||
#if !PCL && !NET_CORE
|
||||
internal IReflectionImporter reflection_importer;
|
||||
#endif
|
||||
internal IMetadataImporter metadata_importer;
|
||||
ICustomMetadataWriter custom_writer;
|
||||
#endif
|
||||
@@ -384,7 +383,6 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
#if !PCL && !NET_CORE
|
||||
internal IReflectionImporter ReflectionImporter {
|
||||
get {
|
||||
if (reflection_importer == null)
|
||||
@@ -393,7 +391,7 @@ namespace Mono.Cecil {
|
||||
return reflection_importer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
internal IMetadataImporter MetadataImporter {
|
||||
get {
|
||||
if (metadata_importer == null)
|
||||
@@ -418,7 +416,7 @@ namespace Mono.Cecil {
|
||||
|
||||
public IAssemblyResolver AssemblyResolver {
|
||||
get {
|
||||
#if !PCL && !NET_CORE
|
||||
#if !NET_CORE
|
||||
if (assembly_resolver.value == null) {
|
||||
lock (module_lock) {
|
||||
assembly_resolver = Disposable.Owned (new DefaultAssemblyResolver () as IAssemblyResolver);
|
||||
@@ -598,7 +596,7 @@ namespace Mono.Cecil {
|
||||
this.attributes = image.Attributes;
|
||||
this.characteristics = image.Characteristics;
|
||||
this.file_name = image.FileName;
|
||||
this.timestamp = image.TimeStamp;
|
||||
this.timestamp = image.Timestamp;
|
||||
|
||||
this.reader = new MetadataReader (this);
|
||||
}
|
||||
@@ -742,7 +740,7 @@ namespace Mono.Cecil {
|
||||
|
||||
internal FieldDefinition Resolve (FieldReference field)
|
||||
{
|
||||
#if PCL || NET_CORE
|
||||
#if NET_CORE
|
||||
if (MetadataResolver == null)
|
||||
throw new NotSupportedException ();
|
||||
#endif
|
||||
@@ -751,7 +749,7 @@ namespace Mono.Cecil {
|
||||
|
||||
internal MethodDefinition Resolve (MethodReference method)
|
||||
{
|
||||
#if PCL || NET_CORE
|
||||
#if NET_CORE
|
||||
if (MetadataResolver == null)
|
||||
throw new NotSupportedException ();
|
||||
#endif
|
||||
@@ -760,7 +758,7 @@ namespace Mono.Cecil {
|
||||
|
||||
internal TypeDefinition Resolve (TypeReference type)
|
||||
{
|
||||
#if PCL || NET_CORE
|
||||
#if NET_CORE
|
||||
if (MetadataResolver == null)
|
||||
throw new NotSupportedException ();
|
||||
#endif
|
||||
@@ -778,13 +776,6 @@ namespace Mono.Cecil {
|
||||
throw new ArgumentException ();
|
||||
}
|
||||
|
||||
static ImportGenericContext GenericContextFor (IGenericParameterProvider context)
|
||||
{
|
||||
return context != null ? new ImportGenericContext (context) : default (ImportGenericContext);
|
||||
}
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
|
||||
[Obsolete ("Use ImportReference", error: false)]
|
||||
public TypeReference Import (Type type)
|
||||
{
|
||||
@@ -859,7 +850,6 @@ namespace Mono.Cecil {
|
||||
|
||||
return ReflectionImporter.ImportReference (method, context);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Obsolete ("Use ImportReference", error: false)]
|
||||
public TypeReference Import (TypeReference type)
|
||||
@@ -1000,32 +990,12 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
public bool HasDebugHeader {
|
||||
get { return Image != null && !Image.Debug.IsZero; }
|
||||
get { return Image != null && Image.DebugHeader != null; }
|
||||
}
|
||||
|
||||
public ImageDebugDirectory GetDebugHeader (out byte [] header)
|
||||
public ImageDebugHeader GetDebugHeader ()
|
||||
{
|
||||
if (!HasDebugHeader)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
return Image.GetDebugHeader (out header);
|
||||
}
|
||||
|
||||
void ProcessDebugHeader ()
|
||||
{
|
||||
if (!HasDebugHeader)
|
||||
return;
|
||||
|
||||
try {
|
||||
byte [] header;
|
||||
var directory = GetDebugHeader (out header);
|
||||
|
||||
if (!symbol_reader.ProcessDebugHeader (directory, header))
|
||||
throw new InvalidOperationException ();
|
||||
} catch {
|
||||
symbol_reader = null;
|
||||
throw;
|
||||
}
|
||||
return Image.DebugHeader ?? new ImageDebugHeader ();
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
@@ -1043,6 +1013,7 @@ namespace Mono.Cecil {
|
||||
var module = new ModuleDefinition {
|
||||
Name = name,
|
||||
kind = parameters.Kind,
|
||||
timestamp = parameters.Timestamp ?? Mixin.GetTimestamp (),
|
||||
Runtime = parameters.Runtime,
|
||||
architecture = parameters.Architecture,
|
||||
mvid = Guid.NewGuid (),
|
||||
@@ -1059,10 +1030,8 @@ namespace Mono.Cecil {
|
||||
#if !READ_ONLY
|
||||
if (parameters.MetadataImporterProvider != null)
|
||||
module.metadata_importer = parameters.MetadataImporterProvider.GetMetadataImporter (module);
|
||||
#if !PCL && !NET_CORE
|
||||
if (parameters.ReflectionImporterProvider != null)
|
||||
module.reflection_importer = parameters.ReflectionImporterProvider.GetReflectionImporter (module);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (parameters.Kind != ModuleKind.NetModule) {
|
||||
@@ -1087,7 +1056,6 @@ namespace Mono.Cecil {
|
||||
|
||||
#endif
|
||||
|
||||
#if !PCL && !NET_CORE
|
||||
public void ReadSymbols ()
|
||||
{
|
||||
if (string.IsNullOrEmpty (file_name))
|
||||
@@ -1096,7 +1064,6 @@ namespace Mono.Cecil {
|
||||
var provider = new DefaultSymbolReaderProvider (throwIfNoSymbol: true);
|
||||
ReadSymbols (provider.GetSymbolReader (this, file_name));
|
||||
}
|
||||
#endif
|
||||
|
||||
public void ReadSymbols (ISymbolReader reader)
|
||||
{
|
||||
@@ -1105,7 +1072,10 @@ namespace Mono.Cecil {
|
||||
|
||||
symbol_reader = reader;
|
||||
|
||||
ProcessDebugHeader ();
|
||||
if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) {
|
||||
symbol_reader = null;
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
if (HasImage && ReadingMode == ReadingMode.Immediate) {
|
||||
var immediate_reader = new ImmediateModuleReader (Image);
|
||||
@@ -1113,7 +1083,6 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public static ModuleDefinition ReadModule (string fileName)
|
||||
{
|
||||
return ReadModule (fileName, new ReaderParameters (ReadingMode.Deferred));
|
||||
@@ -1146,7 +1115,6 @@ namespace Mono.Cecil {
|
||||
|
||||
return new FileStream (fileName, mode, access, share);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static ModuleDefinition ReadModule (Stream stream)
|
||||
{
|
||||
@@ -1158,7 +1126,7 @@ namespace Mono.Cecil {
|
||||
Mixin.CheckStream (stream);
|
||||
Mixin.CheckReadSeek (stream);
|
||||
|
||||
return ReadModule (Disposable.NotOwned (stream), "", parameters);
|
||||
return ReadModule (Disposable.NotOwned (stream), stream.GetFileName (), parameters);
|
||||
}
|
||||
|
||||
static ModuleDefinition ReadModule (Disposable<Stream> stream, string fileName, ReaderParameters parameters)
|
||||
@@ -1172,7 +1140,6 @@ namespace Mono.Cecil {
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
#if !PCL
|
||||
public void Write (string fileName)
|
||||
{
|
||||
Write (fileName, new WriterParameters ());
|
||||
@@ -1181,10 +1148,9 @@ namespace Mono.Cecil {
|
||||
public void Write (string fileName, WriterParameters parameters)
|
||||
{
|
||||
Mixin.CheckParameters (parameters);
|
||||
var file = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
|
||||
ModuleWriter.WriteModuleTo (this, Disposable.Owned (file), parameters);
|
||||
var file = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
|
||||
ModuleWriter.WriteModule (this, Disposable.Owned (file), parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Write ()
|
||||
{
|
||||
@@ -1196,9 +1162,7 @@ namespace Mono.Cecil {
|
||||
if (!HasImage)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
var image_stream = Image.Stream.value;
|
||||
image_stream.Position = 0;
|
||||
Write (image_stream, parameters);
|
||||
Write (Image.Stream.value, parameters);
|
||||
}
|
||||
|
||||
public void Write (Stream stream)
|
||||
@@ -1212,7 +1176,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
|
||||
@@ -1282,8 +1246,6 @@ namespace Mono.Cecil {
|
||||
throw new ArgumentException ();
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
public static void CheckType (object type)
|
||||
{
|
||||
if (type == null)
|
||||
@@ -1308,46 +1270,29 @@ namespace Mono.Cecil {
|
||||
throw new ArgumentNullException (Argument.method.ToString ());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public static void CheckParameters (object parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
throw new ArgumentNullException (Argument.parameters.ToString ());
|
||||
}
|
||||
|
||||
public static uint GetTimestamp ()
|
||||
{
|
||||
return (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
|
||||
}
|
||||
|
||||
public static bool HasImage (this ModuleDefinition self)
|
||||
{
|
||||
return self != null && self.HasImage;
|
||||
}
|
||||
|
||||
public static bool IsCoreLibrary (this ModuleDefinition module)
|
||||
{
|
||||
if (module.Assembly == null)
|
||||
return false;
|
||||
|
||||
var assembly_name = module.Assembly.Name.Name;
|
||||
|
||||
if (assembly_name != "mscorlib" && assembly_name != "System.Runtime")
|
||||
return false;
|
||||
|
||||
if (module.HasImage && module.Read (module, (m, reader) => reader.image.GetTableLength (Table.AssemblyRef) > 0))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetFileName (this Stream self)
|
||||
{
|
||||
#if !PCL
|
||||
var file_stream = self as FileStream;
|
||||
if (file_stream == null)
|
||||
return string.Empty;
|
||||
|
||||
return Path.GetFullPath (file_stream.Name);
|
||||
#else
|
||||
return string.Empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !NET_4_0
|
||||
@@ -1395,7 +1340,6 @@ namespace Mono.Cecil {
|
||||
return module.MetadataKind != MetadataKind.Ecma335;
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public static byte [] ReadAll (this Stream self)
|
||||
{
|
||||
int read;
|
||||
@@ -1407,7 +1351,6 @@ namespace Mono.Cecil {
|
||||
|
||||
return memory.ToArray ();
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void Read (object o)
|
||||
{
|
||||
|
||||
10
external/cecil/Mono.Cecil/ModuleKind.cs
vendored
10
external/cecil/Mono.Cecil/ModuleKind.cs
vendored
@@ -26,10 +26,12 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
public enum TargetArchitecture {
|
||||
I386,
|
||||
AMD64,
|
||||
IA64,
|
||||
ARMv7,
|
||||
I386 = 0x014c,
|
||||
AMD64 = 0x8664,
|
||||
IA64 = 0x0200,
|
||||
ARM = 0x01c0,
|
||||
ARMv7 = 0x01c4,
|
||||
ARM64 = 0xaa64,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
2
external/cecil/Mono.Cecil/TypeDefinition.cs
vendored
2
external/cecil/Mono.Cecil/TypeDefinition.cs
vendored
@@ -421,7 +421,7 @@ namespace Mono.Cecil {
|
||||
public override bool IsPrimitive {
|
||||
get {
|
||||
ElementType primitive_etype;
|
||||
return MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype);
|
||||
return MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype) && primitive_etype.IsPrimitive ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
70
external/cecil/Mono.Cecil/TypeSystem.cs
vendored
70
external/cecil/Mono.Cecil/TypeSystem.cs
vendored
@@ -95,17 +95,11 @@ namespace Mono.Cecil {
|
||||
if (core_library != null)
|
||||
return core_library;
|
||||
|
||||
const string mscorlib = "mscorlib";
|
||||
const string system_runtime = "System.Runtime";
|
||||
|
||||
if (TryLookupReference (mscorlib, out core_library))
|
||||
return core_library;
|
||||
|
||||
if (TryLookupReference (system_runtime, out core_library))
|
||||
if (module.TryGetCoreLibraryReference (out core_library))
|
||||
return core_library;
|
||||
|
||||
core_library = new AssemblyNameReference {
|
||||
Name = mscorlib,
|
||||
Name = Mixin.mscorlib,
|
||||
Version = GetCorlibVersion (),
|
||||
PublicKeyToken = new byte [] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 },
|
||||
};
|
||||
@@ -115,20 +109,6 @@ namespace Mono.Cecil {
|
||||
return core_library;
|
||||
}
|
||||
|
||||
bool TryLookupReference (string name, out AssemblyNameReference reference)
|
||||
{
|
||||
var references = module.AssemblyReferences;
|
||||
|
||||
for (int i = 0; i < references.Count; i++) {
|
||||
reference = references [i];
|
||||
if (reference.Name == name)
|
||||
return true;
|
||||
}
|
||||
|
||||
reference = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
Version GetCorlibVersion ()
|
||||
{
|
||||
switch (module.Runtime) {
|
||||
@@ -296,4 +276,50 @@ namespace Mono.Cecil {
|
||||
get { return type_typedref ?? (LookupSystemValueType (ref type_typedref, "TypedReference", ElementType.TypedByRef)); }
|
||||
}
|
||||
}
|
||||
|
||||
static partial class Mixin {
|
||||
|
||||
public const string mscorlib = "mscorlib";
|
||||
public const string system_runtime = "System.Runtime";
|
||||
public const string system_private_corelib = "System.Private.CoreLib";
|
||||
public const string netstandard = "netstandard";
|
||||
|
||||
public static bool TryGetCoreLibraryReference (this ModuleDefinition module, out AssemblyNameReference reference)
|
||||
{
|
||||
var references = module.AssemblyReferences;
|
||||
|
||||
for (int i = 0; i < references.Count; i++) {
|
||||
reference = references [i];
|
||||
if (IsCoreLibrary (reference))
|
||||
return true;
|
||||
}
|
||||
|
||||
reference = null;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static bool IsCoreLibrary (this ModuleDefinition module)
|
||||
{
|
||||
if (module.Assembly == null)
|
||||
return false;
|
||||
|
||||
if (!IsCoreLibrary (module.Assembly.Name))
|
||||
return false;
|
||||
|
||||
if (module.HasImage && module.Read (module, (m, reader) => reader.image.GetTableLength (Table.AssemblyRef) > 0))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool IsCoreLibrary (AssemblyNameReference reference)
|
||||
{
|
||||
var name = reference.Name;
|
||||
return name == mscorlib
|
||||
|| name == system_runtime
|
||||
|| name == system_private_corelib
|
||||
|| name == netstandard;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user