summaryrefslogtreecommitdiff
path: root/external/cecil
diff options
context:
space:
mode:
Diffstat (limited to 'external/cecil')
-rw-r--r--external/cecil/.gitattributes1
-rw-r--r--external/cecil/Mono.Cecil.PE/Image.cs1
-rw-r--r--external/cecil/Mono.Cecil.PE/ImageReader.cs10
-rw-r--r--external/cecil/Mono.Cecil.PE/ImageWriter.cs39
-rw-r--r--external/cecil/Mono.Cecil.nuspec2
-rwxr-xr-xexternal/cecil/Mono.Cecil.sln.DotSettings35
-rw-r--r--external/cecil/Mono.Cecil/AssemblyNameReference.cs11
-rw-r--r--external/cecil/Mono.Cecil/AssemblyReader.cs126
-rw-r--r--external/cecil/Mono.Cecil/AssemblyWriter.cs2
-rw-r--r--external/cecil/Mono.Cecil/BaseAssemblyResolver.cs7
-rw-r--r--external/cecil/Mono.Cecil/EventDefinition.cs4
-rw-r--r--external/cecil/Mono.Cecil/FunctionPointerType.cs1
-rw-r--r--external/cecil/Mono.Cecil/GenericParameter.cs10
-rw-r--r--external/cecil/Mono.Cecil/Import.cs235
-rw-r--r--external/cecil/Mono.Cecil/MetadataResolver.cs17
-rw-r--r--external/cecil/Mono.Cecil/MetadataSystem.cs23
-rw-r--r--external/cecil/Mono.Cecil/ModuleDefinition.cs123
-rw-r--r--external/cecil/Mono.Cecil/ModuleKind.cs10
-rw-r--r--external/cecil/Mono.Cecil/TypeParser.cs10
-rw-r--r--external/cecil/Mono.Cecil/TypeReference.cs9
-rw-r--r--external/cecil/Mono.Cecil/TypeSpecification.cs5
-rw-r--r--external/cecil/Mono.Cecil/TypeSystem.cs31
-rw-r--r--external/cecil/Mono/Empty.cs14
-rw-r--r--external/cecil/Test/Mono.Cecil.Tests.csproj12
-rw-r--r--external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs17
-rw-r--r--external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs64
-rw-r--r--external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs4
-rw-r--r--external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs15
-rwxr-xr-x[-rw-r--r--]external/cecil/Test/libs/nunit-2.6.2/license.txt (renamed from external/cecil/Test/libs/nunit-2.4.8/license.txt)4
-rw-r--r--external/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj12
-rw-r--r--external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs19
-rw-r--r--external/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj12
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs6
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs218
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs56
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs2
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs5
-rw-r--r--external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs33
-rw-r--r--external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj7
-rw-r--r--external/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs7
-rw-r--r--external/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj12
41 files changed, 876 insertions, 355 deletions
diff --git a/external/cecil/.gitattributes b/external/cecil/.gitattributes
new file mode 100644
index 0000000000..7d07d70cc8
--- /dev/null
+++ b/external/cecil/.gitattributes
@@ -0,0 +1 @@
+* text=lf
diff --git a/external/cecil/Mono.Cecil.PE/Image.cs b/external/cecil/Mono.Cecil.PE/Image.cs
index e5d8075251..a11cf1c404 100644
--- a/external/cecil/Mono.Cecil.PE/Image.cs
+++ b/external/cecil/Mono.Cecil.PE/Image.cs
@@ -41,6 +41,7 @@ namespace Mono.Cecil.PE {
public ModuleKind Kind;
public TargetRuntime Runtime;
public TargetArchitecture Architecture;
+ public ModuleCharacteristics Characteristics;
public string FileName;
public Section [] Sections;
diff --git a/external/cecil/Mono.Cecil.PE/ImageReader.cs b/external/cecil/Mono.Cecil.PE/ImageReader.cs
index b320169192..c96c1db318 100644
--- a/external/cecil/Mono.Cecil.PE/ImageReader.cs
+++ b/external/cecil/Mono.Cecil.PE/ImageReader.cs
@@ -99,13 +99,14 @@ namespace Mono.Cecil.PE {
// Characteristics 2
ushort characteristics = ReadUInt16 ();
- ushort subsystem;
- ReadOptionalHeaders (out subsystem);
+ ushort subsystem, dll_characteristics;
+ ReadOptionalHeaders (out subsystem, out dll_characteristics);
ReadSections (sections);
ReadCLIHeader ();
ReadMetadata ();
image.Kind = GetModuleKind (characteristics, subsystem);
+ image.Characteristics = (ModuleCharacteristics) dll_characteristics;
}
TargetArchitecture ReadArchitecture ()
@@ -136,7 +137,7 @@ namespace Mono.Cecil.PE {
return ModuleKind.Console;
}
- void ReadOptionalHeaders (out ushort subsystem)
+ void ReadOptionalHeaders (out ushort subsystem, out ushort dll_characteristics)
{
// - PEOptionalHeader
// - StandardFieldsHeader
@@ -176,6 +177,7 @@ namespace Mono.Cecil.PE {
subsystem = ReadUInt16 ();
// DLLFlags 2
+ dll_characteristics = ReadUInt16 ();
// StackReserveSize 4 || 8
// StackCommitSize 4 || 8
// HeapReserveSize 4 || 8
@@ -192,7 +194,7 @@ namespace Mono.Cecil.PE {
// CertificateTable 8
// BaseRelocationTable 8
- Advance (pe64 ? 90 : 74);
+ Advance (pe64 ? 88 : 72);
// Debug 8
image.Debug = ReadDataDirectory ();
diff --git a/external/cecil/Mono.Cecil.PE/ImageWriter.cs b/external/cecil/Mono.Cecil.PE/ImageWriter.cs
index 8a991d8319..08f9ea2b76 100644
--- a/external/cecil/Mono.Cecil.PE/ImageWriter.cs
+++ b/external/cecil/Mono.Cecil.PE/ImageWriter.cs
@@ -58,6 +58,7 @@ namespace Mono.Cecil.PE {
internal const RVA text_rva = 0x2000;
readonly bool pe64;
+ readonly bool has_reloc;
readonly uint time_stamp;
internal Section text;
@@ -71,11 +72,12 @@ namespace Mono.Cecil.PE {
{
this.module = module;
this.metadata = metadata;
- this.pe64 = module.Architecture != TargetArchitecture.I386;
+ this.pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64;
+ this.has_reloc = module.Architecture == TargetArchitecture.I386;
this.GetDebugHeader ();
this.GetWin32Resources ();
this.text_map = BuildTextMap ();
- this.sections = (ushort) (pe64 ? 1 : 2); // text + reloc
+ this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
}
@@ -133,7 +135,7 @@ namespace Mono.Cecil.PE {
previous = rsrc;
}
- if (!pe64)
+ if (has_reloc)
reloc = CreateSection (".reloc", 12u, previous);
}
@@ -213,6 +215,8 @@ namespace Mono.Cecil.PE {
return 0x8664;
case TargetArchitecture.IA64:
return 0x0200;
+ case TargetArchitecture.ARMv7:
+ return 0x01c4;
}
throw new NotSupportedException ();
@@ -267,7 +271,7 @@ namespace Mono.Cecil.PE {
WriteUInt32 (0); // Checksum
WriteUInt16 (GetSubSystem ()); // SubSystem
- WriteUInt16 (0x8540); // DLLFlags
+ WriteUInt16 ((ushort) module.Characteristics); // DLLFlags
const ulong stack_reserve = 0x100000;
const ulong stack_commit = 0x1000;
@@ -398,7 +402,7 @@ namespace Mono.Cecil.PE {
// ImportAddressTable
- if (!pe64) {
+ if (has_reloc) {
WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
WriteRVA (0);
}
@@ -453,7 +457,7 @@ namespace Mono.Cecil.PE {
WriteDebugDirectory ();
}
- if (pe64)
+ if (!has_reloc)
return;
// ImportDirectory
@@ -696,7 +700,7 @@ namespace Mono.Cecil.PE {
map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4);
- if (pe64) {
+ if (!has_reloc) {
var start = map.GetNextRVA (TextSegment.DebugDirectory);
map.AddMap (TextSegment.ImportDirectory, new Range (start, 0));
map.AddMap (TextSegment.ImportHintNameTable, new Range (start, 0));
@@ -754,17 +758,18 @@ namespace Mono.Cecil.PE {
return 0;
var public_key = module.Assembly.Name.PublicKey;
+ if (public_key.IsNullOrEmpty ())
+ return 0;
- if (public_key != null) {
- // in fx 2.0 the key may be from 384 to 16384 bits
- // so we must calculate the signature size based on
- // the size of the public key (minus the 32 byte header)
- int size = public_key.Length;
- if (size > 32)
- return size - 32;
- // note: size == 16 for the ECMA "key" which is replaced
- // by the runtime with a 1024 bits key (128 bytes)
- }
+ // in fx 2.0 the key may be from 384 to 16384 bits
+ // so we must calculate the signature size based on
+ // the size of the public key (minus the 32 byte header)
+ int size = public_key.Length;
+ if (size > 32)
+ return size - 32;
+
+ // note: size == 16 for the ECMA "key" which is replaced
+ // by the runtime with a 1024 bits key (128 bytes)
return 128; // default strongname signature size
}
diff --git a/external/cecil/Mono.Cecil.nuspec b/external/cecil/Mono.Cecil.nuspec
index 021e794e67..9901dfcf2c 100644
--- a/external/cecil/Mono.Cecil.nuspec
+++ b/external/cecil/Mono.Cecil.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Mono.Cecil</id>
- <version>0.9.5.2</version>
+ <version>0.9.5.4</version>
<title>Mono.Cecil</title>
<authors>Jb Evain</authors>
<owners>Jb Evain</owners>
diff --git a/external/cecil/Mono.Cecil.sln.DotSettings b/external/cecil/Mono.Cecil.sln.DotSettings
new file mode 100755
index 0000000000..6d06ad79ae
--- /dev/null
+++ b/external/cecil/Mono.Cecil.sln.DotSettings
@@ -0,0 +1,35 @@
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+ <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
+ <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
+ <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
+ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
+ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
+ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
+ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">END_OF_LINE</s:String>
+ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OTHER_BRACES/@EntryValue">END_OF_LINE</s:String>
+ <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
+ <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ELSE_ON_NEW_LINE/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CATCH_ON_NEW_LINE/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_METHOD_CALL_PARENTHESES/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_EMPTY_METHOD_CALL_PARENTHESES/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_ARRAY_ACCESS_BRACKETS/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_METHOD_PARENTHESES/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_EMPTY_METHOD_PARENTHESES/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_PARAMETER/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_FIRST_ARG_BY_PAREN/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_EMBRACED_INITIALIZER_BLOCK/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">False</s:Boolean>
+ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_CASE_FROM_SWITCH/@EntryValue">False</s:Boolean>
+ <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
+ <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
+ <s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=3888B4217219C6449A29410818F112E6/@KeyIndexDefined">True</s:Boolean>
+ <s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=3888B4217219C6449A29410818F112E6/AbsolutePath/@EntryValue">C:\sources\cecil\Mono.Cecil.sln.DotSettings</s:String>
+ <s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File3888B4217219C6449A29410818F112E6/@KeyIndexDefined">True</s:Boolean>
+ <s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File3888B4217219C6449A29410818F112E6/RelativePriority/@EntryValue">1</s:Double>
+ <s:String x:Key="/Default/Environment/UserInterface/ShortcutSchemeName/@EntryValue">None</s:String></wpf:ResourceDictionary> \ No newline at end of file
diff --git a/external/cecil/Mono.Cecil/AssemblyNameReference.cs b/external/cecil/Mono.Cecil/AssemblyNameReference.cs
index 3da978057b..4f58fe2d15 100644
--- a/external/cecil/Mono.Cecil/AssemblyNameReference.cs
+++ b/external/cecil/Mono.Cecil/AssemblyNameReference.cs
@@ -98,7 +98,7 @@ namespace Mono.Cecil {
}
public byte [] PublicKey {
- get { return public_key; }
+ get { return public_key ?? Empty<byte>.Array; }
set {
public_key = value;
HasPublicKey = !public_key.IsNullOrEmpty ();
@@ -116,7 +116,7 @@ namespace Mono.Cecil {
Array.Copy (hash, (hash.Length - 8), public_key_token, 0, 8);
Array.Reverse (public_key_token, 0, 8);
}
- return public_key_token;
+ return public_key_token ?? Empty<byte>.Array;
}
set {
public_key_token = value;
@@ -175,9 +175,10 @@ namespace Mono.Cecil {
builder.Append (sep);
builder.Append ("PublicKeyToken=");
- if (this.PublicKeyToken != null && public_key_token.Length > 0) {
- for (int i = 0 ; i < public_key_token.Length ; i++) {
- builder.Append (public_key_token [i].ToString ("x2"));
+ var pk_token = PublicKeyToken;
+ if (!pk_token.IsNullOrEmpty () && pk_token.Length > 0) {
+ for (int i = 0 ; i < pk_token.Length ; i++) {
+ builder.Append (pk_token [i].ToString ("x2"));
}
} else
builder.Append ("null");
diff --git a/external/cecil/Mono.Cecil/AssemblyReader.cs b/external/cecil/Mono.Cecil/AssemblyReader.cs
index 9aa5b13658..a9f0b6a1d0 100644
--- a/external/cecil/Mono.Cecil/AssemblyReader.cs
+++ b/external/cecil/Mono.Cecil/AssemblyReader.cs
@@ -552,6 +552,7 @@ namespace Mono.Cecil {
var parameters = new ReaderParameters {
ReadingMode = module.ReadingMode,
SymbolReaderProvider = module.SymbolReaderProvider,
+ AssemblyResolver = module.AssemblyResolver
};
modules.Add (ModuleDefinition.ReadModule (
@@ -778,8 +779,12 @@ namespace Mono.Cecil {
var nested_types = new MemberDefinitionCollection<TypeDefinition> (type, mapping.Length);
- for (int i = 0; i < mapping.Length; i++)
- nested_types.Add (GetTypeDefinition (mapping [i]));
+ for (int i = 0; i < mapping.Length; i++) {
+ var nested_type = GetTypeDefinition (mapping [i]);
+
+ if (nested_type != null)
+ nested_types.Add (nested_type);
+ }
metadata.RemoveNestedTypeMapping (type);
@@ -1783,25 +1788,35 @@ namespace Mono.Cecil {
{
InitializeGenericParameters ();
- Range range;
- if (!metadata.TryGetGenericParameterRange (provider, out range))
+ Range [] ranges;
+ if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
return false;
- return range.Length > 0;
+ return RangesSize (ranges) > 0;
}
public Collection<GenericParameter> ReadGenericParameters (IGenericParameterProvider provider)
{
InitializeGenericParameters ();
- Range range;
- if (!metadata.TryGetGenericParameterRange (provider, out range)
- || !MoveTo (Table.GenericParam, range.Start))
+ Range [] ranges;
+ if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
return new GenericParameterCollection (provider);
metadata.RemoveGenericParameterRange (provider);
- var generic_parameters = new GenericParameterCollection (provider, (int) range.Length);
+ var generic_parameters = new GenericParameterCollection (provider, RangesSize (ranges));
+
+ for (int i = 0; i < ranges.Length; i++)
+ ReadGenericParametersRange (ranges [i], provider, generic_parameters);
+
+ return generic_parameters;
+ }
+
+ void ReadGenericParametersRange (Range range, IGenericParameterProvider provider, GenericParameterCollection generic_parameters)
+ {
+ if (!MoveTo (Table.GenericParam, range.Start))
+ return;
for (uint i = 0; i < range.Length; i++) {
ReadUInt16 (); // index
@@ -1815,8 +1830,6 @@ namespace Mono.Cecil {
generic_parameters.Add (parameter);
}
-
- return generic_parameters;
}
void InitializeGenericParameters ()
@@ -1833,10 +1846,10 @@ namespace Mono.Cecil {
});
}
- Dictionary<MetadataToken, Range> InitializeRanges (Table table, Func<MetadataToken> get_next)
+ Dictionary<MetadataToken, Range []> InitializeRanges (Table table, Func<MetadataToken> get_next)
{
int length = MoveTo (table);
- var ranges = new Dictionary<MetadataToken, Range> (length);
+ var ranges = new Dictionary<MetadataToken, Range []> (length);
if (length == 0)
return ranges;
@@ -1851,20 +1864,34 @@ namespace Mono.Cecil {
owner = next;
range.Length++;
} else if (next != owner) {
- if (owner.RID != 0)
- ranges.Add (owner, range);
+ AddRange (ranges, owner, range);
range = new Range (i, 1);
owner = next;
} else
range.Length++;
}
- if (owner != MetadataToken.Zero && !ranges.ContainsKey (owner))
- ranges.Add (owner, range);
+ AddRange (ranges, owner, range);
return ranges;
}
+ static void AddRange (Dictionary<MetadataToken, Range []> ranges, MetadataToken owner, Range range)
+ {
+ if (owner.RID == 0)
+ return;
+
+ Range [] slots;
+ if (!ranges.TryGetValue (owner, out slots)) {
+ ranges.Add (owner, new [] { range });
+ return;
+ }
+
+ slots = slots.Resize (slots.Length + 1);
+ slots [slots.Length - 1] = range;
+ ranges [owner] = slots;
+ }
+
public bool HasGenericConstraints (GenericParameter generic_parameter)
{
InitializeGenericConstraints ();
@@ -2328,23 +2355,35 @@ namespace Mono.Cecil {
{
InitializeCustomAttributes ();
- Range range;
- if (!metadata.TryGetCustomAttributeRange (owner, out range))
+ Range [] ranges;
+ if (!metadata.TryGetCustomAttributeRanges (owner, out ranges))
return false;
- return range.Length > 0;
+ return RangesSize (ranges) > 0;
}
public Collection<CustomAttribute> ReadCustomAttributes (ICustomAttributeProvider owner)
{
InitializeCustomAttributes ();
- Range range;
- if (!metadata.TryGetCustomAttributeRange (owner, out range)
- || !MoveTo (Table.CustomAttribute, range.Start))
+ Range [] ranges;
+ if (!metadata.TryGetCustomAttributeRanges (owner, out ranges))
return new Collection<CustomAttribute> ();
- var custom_attributes = new Collection<CustomAttribute> ((int) range.Length);
+ var custom_attributes = new Collection<CustomAttribute> (RangesSize (ranges));
+
+ for (int i = 0; i < ranges.Length; i++)
+ ReadCustomAttributeRange (ranges [i], custom_attributes);
+
+ metadata.RemoveCustomAttributeRange (owner);
+
+ return custom_attributes;
+ }
+
+ void ReadCustomAttributeRange (Range range, Collection<CustomAttribute> custom_attributes)
+ {
+ if (!MoveTo (Table.CustomAttribute, range.Start))
+ return;
for (int i = 0; i < range.Length; i++) {
ReadMetadataToken (CodedIndex.HasCustomAttribute);
@@ -2356,10 +2395,15 @@ namespace Mono.Cecil {
custom_attributes.Add (new CustomAttribute (signature, constructor));
}
+ }
- metadata.RemoveCustomAttributeRange (owner);
+ static int RangesSize (Range [] ranges)
+ {
+ uint size = 0;
+ for (int i = 0; i < ranges.Length; i++)
+ size += ranges [i].Length;
- return custom_attributes;
+ return (int) size;
}
public byte [] ReadCustomAttributeBlob (uint signature)
@@ -2451,23 +2495,35 @@ namespace Mono.Cecil {
{
InitializeSecurityDeclarations ();
- Range range;
- if (!metadata.TryGetSecurityDeclarationRange (owner, out range))
+ Range [] ranges;
+ if (!metadata.TryGetSecurityDeclarationRanges (owner, out ranges))
return false;
- return range.Length > 0;
+ return RangesSize (ranges) > 0;
}
public Collection<SecurityDeclaration> ReadSecurityDeclarations (ISecurityDeclarationProvider owner)
{
InitializeSecurityDeclarations ();
- Range range;
- if (!metadata.TryGetSecurityDeclarationRange (owner, out range)
- || !MoveTo (Table.DeclSecurity, range.Start))
+ Range [] ranges;
+ if (!metadata.TryGetSecurityDeclarationRanges (owner, out ranges))
return new Collection<SecurityDeclaration> ();
- var security_declarations = new Collection<SecurityDeclaration> ((int) range.Length);
+ var security_declarations = new Collection<SecurityDeclaration> (RangesSize (ranges));
+
+ for (int i = 0; i < ranges.Length; i++)
+ ReadSecurityDeclarationRange (ranges [i], security_declarations);
+
+ metadata.RemoveSecurityDeclarationRange (owner);
+
+ return security_declarations;
+ }
+
+ void ReadSecurityDeclarationRange (Range range, Collection<SecurityDeclaration> security_declarations)
+ {
+ if (!MoveTo (Table.DeclSecurity, range.Start))
+ return;
for (int i = 0; i < range.Length; i++) {
var action = (SecurityAction) ReadUInt16 ();
@@ -2476,10 +2532,6 @@ namespace Mono.Cecil {
security_declarations.Add (new SecurityDeclaration (action, signature, module));
}
-
- metadata.RemoveSecurityDeclarationRange (owner);
-
- return security_declarations;
}
public byte [] ReadSecurityDeclarationBlob (uint signature)
diff --git a/external/cecil/Mono.Cecil/AssemblyWriter.cs b/external/cecil/Mono.Cecil/AssemblyWriter.cs
index bffa439c60..0597bc0b5d 100644
--- a/external/cecil/Mono.Cecil/AssemblyWriter.cs
+++ b/external/cecil/Mono.Cecil/AssemblyWriter.cs
@@ -82,7 +82,7 @@ namespace Mono.Cecil {
public static void WriteModuleTo (ModuleDefinition module, Stream stream, WriterParameters parameters)
{
if ((module.Attributes & ModuleAttributes.ILOnly) == 0)
- throw new ArgumentException ();
+ throw new NotSupportedException ("Writing mixed-mode assemblies is not supported");
if (module.HasImage && module.ReadingMode == ReadingMode.Deferred)
ImmediateModuleReader.ReadModule (module);
diff --git a/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs b/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs
index 10ab2c34a8..90be7bfb99 100644
--- a/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs
+++ b/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs
@@ -150,6 +150,13 @@ namespace Mono.Cecil {
return assembly;
#if !SILVERLIGHT && !CF
+ if (name.IsRetargetable) {
+ // if the reference is retargetable, zero it
+ name = new AssemblyNameReference (name.Name, new Version (0, 0, 0, 0)) {
+ PublicKeyToken = Empty<byte>.Array,
+ };
+ }
+
var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
if (IsZero (name.Version)) {
diff --git a/external/cecil/Mono.Cecil/EventDefinition.cs b/external/cecil/Mono.Cecil/EventDefinition.cs
index 565186c5d7..89b55483f7 100644
--- a/external/cecil/Mono.Cecil/EventDefinition.cs
+++ b/external/cecil/Mono.Cecil/EventDefinition.cs
@@ -124,8 +124,8 @@ namespace Mono.Cecil {
}
public bool IsRuntimeSpecialName {
- get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); }
- set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); }
+ get { return attributes.GetAttributes ((ushort) EventAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) EventAttributes.RTSpecialName, value); }
}
#endregion
diff --git a/external/cecil/Mono.Cecil/FunctionPointerType.cs b/external/cecil/Mono.Cecil/FunctionPointerType.cs
index db80f76215..756d31f6ff 100644
--- a/external/cecil/Mono.Cecil/FunctionPointerType.cs
+++ b/external/cecil/Mono.Cecil/FunctionPointerType.cs
@@ -85,6 +85,7 @@ namespace Mono.Cecil {
public override IMetadataScope Scope {
get { return function.ReturnType.Scope; }
+ set { throw new InvalidOperationException (); }
}
public override bool IsFunctionPointer {
diff --git a/external/cecil/Mono.Cecil/GenericParameter.cs b/external/cecil/Mono.Cecil/GenericParameter.cs
index d694e296d7..d66cc914cb 100644
--- a/external/cecil/Mono.Cecil/GenericParameter.cs
+++ b/external/cecil/Mono.Cecil/GenericParameter.cs
@@ -107,6 +107,16 @@ namespace Mono.Cecil {
? ((MethodReference) owner).DeclaringType.Scope
: ((TypeReference) owner).Scope;
}
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override TypeReference DeclaringType {
+ get { return owner as TypeReference; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public MethodReference DeclaringMethod {
+ get { return owner as MethodReference; }
}
public override ModuleDefinition Module {
diff --git a/external/cecil/Mono.Cecil/Import.cs b/external/cecil/Mono.Cecil/Import.cs
index 38d0120412..a32eb3c241 100644
--- a/external/cecil/Mono.Cecil/Import.cs
+++ b/external/cecil/Mono.Cecil/Import.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
+using Mono.Collections.Generic;
using SR = System.Reflection;
using Mono.Cecil.Metadata;
@@ -39,6 +40,76 @@ namespace Mono.Cecil {
Open,
}
+ struct ImportGenericContext {
+
+ Collection<IGenericParameterProvider> stack;
+
+ public bool IsEmpty { get { return stack == null; } }
+
+ public ImportGenericContext (IGenericParameterProvider provider)
+ {
+ stack = null;
+
+ Push (provider);
+ }
+
+ public void Push (IGenericParameterProvider provider)
+ {
+ if (stack == null)
+ stack = new Collection<IGenericParameterProvider> (1) { provider };
+ else
+ stack.Add (provider);
+ }
+
+ public void Pop ()
+ {
+ stack.RemoveAt (stack.Count - 1);
+ }
+
+ public TypeReference MethodParameter (string method, int position)
+ {
+ for (int i = stack.Count - 1; i >= 0; i--) {
+ var candidate = stack [i] as MethodReference;
+ if (candidate == null)
+ continue;
+
+ if (method != candidate.Name)
+ continue;
+
+ return candidate.GenericParameters [position];
+ }
+
+ throw new InvalidOperationException ();
+ }
+
+ public TypeReference TypeParameter (string type, int position)
+ {
+ for (int i = stack.Count - 1; i >= 0; i--) {
+ var candidate = GenericTypeFor (stack [i]);
+
+ if (candidate.FullName != type)
+ continue;
+
+ return candidate.GenericParameters [position];
+ }
+
+ throw new InvalidOperationException ();
+ }
+
+ static TypeReference GenericTypeFor (IGenericParameterProvider context)
+ {
+ var type = context as TypeReference;
+ if (type != null)
+ return type.GetElementType ();
+
+ var method = context as MethodReference;
+ if (method != null)
+ return method.DeclaringType.GetElementType ();
+
+ throw new InvalidOperationException ();
+ }
+ }
+
class MetadataImporter {
readonly ModuleDefinition module;
@@ -70,12 +141,12 @@ namespace Mono.Cecil {
{ typeof (object), ElementType.Object },
};
- public TypeReference ImportType (Type type, IGenericContext context)
+ public TypeReference ImportType (Type type, ImportGenericContext context)
{
return ImportType (type, context, ImportGenericKind.Open);
}
- public TypeReference ImportType (Type type, IGenericContext context, ImportGenericKind import_kind)
+ public TypeReference ImportType (Type type, ImportGenericContext context, ImportGenericKind import_kind)
{
if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind))
return ImportTypeSpecification (type, context);
@@ -119,7 +190,7 @@ namespace Mono.Cecil {
#endif
}
- TypeReference ImportTypeSpecification (Type type, IGenericContext context)
+ TypeReference ImportTypeSpecification (Type type, ImportGenericContext context)
{
if (type.IsByRef)
return new ByReferenceType (ImportType (type.GetElementType (), context));
@@ -139,32 +210,44 @@ namespace Mono.Cecil {
throw new NotSupportedException (type.FullName);
}
- static TypeReference ImportGenericParameter (Type type, IGenericContext context)
+ static TypeReference ImportGenericParameter (Type type, ImportGenericContext context)
{
- if (context == null)
+ if (context.IsEmpty)
throw new InvalidOperationException ();
- var owner = type.DeclaringMethod != null
- ? context.Method
- : context.Type;
+ if (type.DeclaringMethod != null)
+ return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);
- if (owner == null)
- throw new InvalidOperationException ();
+ if (type.DeclaringType != null)
+ return context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);
+
+ throw new InvalidOperationException();
+ }
+
+ private static string NormalizedFullName (Type type)
+ {
+ if (IsNestedType (type))
+ return NormalizedFullName (type.DeclaringType) + "/" + type.Name;
- return owner.GenericParameters [type.GenericParameterPosition];
+ return type.FullName;
}
- TypeReference ImportGenericInstance (Type type, IGenericContext context)
+ TypeReference ImportGenericInstance (Type type, ImportGenericContext context)
{
var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition);
var instance = new GenericInstanceType (element_type);
var arguments = type.GetGenericArguments ();
var instance_arguments = instance.GenericArguments;
- for (int i = 0; i < arguments.Length; i++)
- instance_arguments.Add (ImportType (arguments [i], context ?? element_type));
+ context.Push (element_type);
+ try {
+ for (int i = 0; i < arguments.Length; i++)
+ instance_arguments.Add (ImportType (arguments [i], context));
- return instance;
+ return instance;
+ } finally {
+ context.Pop ();
+ }
}
static bool IsTypeSpecification (Type type)
@@ -237,18 +320,23 @@ namespace Mono.Cecil {
}
#endif
- public FieldReference ImportField (SR.FieldInfo field, IGenericContext context)
+ public FieldReference ImportField (SR.FieldInfo field, ImportGenericContext context)
{
var declaring_type = ImportType (field.DeclaringType, context);
if (IsGenericInstance (field.DeclaringType))
field = ResolveFieldDefinition (field);
- return new FieldReference {
- Name = field.Name,
- DeclaringType = declaring_type,
- FieldType = ImportType (field.FieldType, context ?? declaring_type),
- };
+ context.Push (declaring_type);
+ try {
+ return new FieldReference {
+ Name = field.Name,
+ DeclaringType = declaring_type,
+ FieldType = ImportType (field.FieldType, context),
+ };
+ } finally {
+ context.Pop ();
+ }
}
static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field)
@@ -263,7 +351,7 @@ namespace Mono.Cecil {
#endif
}
- public MethodReference ImportMethod (SR.MethodBase method, IGenericContext context, ImportGenericKind import_kind)
+ public MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind)
{
if (IsMethodSpecification (method) || ImportOpenGenericMethod (method, import_kind))
return ImportMethodSpecification (method, context);
@@ -286,21 +374,26 @@ namespace Mono.Cecil {
if (method.IsGenericMethod)
ImportGenericParameters (reference, method.GetGenericArguments ());
- var method_info = method as SR.MethodInfo;
- reference.ReturnType = method_info != null
- ? ImportType (method_info.ReturnType, context ?? reference)
- : ImportType (typeof (void), null);
+ context.Push (reference);
+ try {
+ var method_info = method as SR.MethodInfo;
+ reference.ReturnType = method_info != null
+ ? ImportType (method_info.ReturnType, context)
+ : ImportType (typeof (void), default (ImportGenericContext));
- var parameters = method.GetParameters ();
- var reference_parameters = reference.Parameters;
+ var parameters = method.GetParameters ();
+ var reference_parameters = reference.Parameters;
- for (int i = 0; i < parameters.Length; i++)
- reference_parameters.Add (
- new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference)));
+ for (int i = 0; i < parameters.Length; i++)
+ reference_parameters.Add (
+ new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
- reference.DeclaringType = declaring_type;
+ reference.DeclaringType = declaring_type;
- return reference;
+ return reference;
+ } finally {
+ context.Pop ();
+ }
}
static void ImportGenericParameters (IGenericParameterProvider provider, Type [] arguments)
@@ -316,7 +409,7 @@ namespace Mono.Cecil {
return method.IsGenericMethod && !method.IsGenericMethodDefinition;
}
- MethodReference ImportMethodSpecification (SR.MethodBase method, IGenericContext context)
+ MethodReference ImportMethodSpecification (SR.MethodBase method, ImportGenericContext context)
{
var method_info = method as SR.MethodInfo;
if (method_info == null)
@@ -327,10 +420,15 @@ namespace Mono.Cecil {
var arguments = method.GetGenericArguments ();
var instance_arguments = instance.GenericArguments;
- for (int i = 0; i < arguments.Length; i++)
- instance_arguments.Add (ImportType (arguments [i], context ?? element_method));
+ context.Push (element_method);
+ try {
+ for (int i = 0; i < arguments.Length; i++)
+ instance_arguments.Add (ImportType (arguments [i], context));
- return instance;
+ return instance;
+ } finally {
+ context.Pop ();
+ }
}
static bool HasCallingConvention (SR.MethodBase method, SR.CallingConventions conventions)
@@ -339,7 +437,7 @@ namespace Mono.Cecil {
}
#endif
- public TypeReference ImportType (TypeReference type, IGenericContext context)
+ public TypeReference ImportType (TypeReference type, ImportGenericContext context)
{
if (type.IsTypeSpecification ())
return ImportTypeSpecification (type, context);
@@ -427,7 +525,7 @@ namespace Mono.Cecil {
imported_parameters.Add (new GenericParameter (parameters [i].Name, imported));
}
- TypeReference ImportTypeSpecification (TypeReference type, IGenericContext context)
+ TypeReference ImportTypeSpecification (TypeReference type, ImportGenericContext context)
{
switch (type.etype) {
case ElementType.SzArray:
@@ -486,32 +584,33 @@ namespace Mono.Cecil {
return imported_instance;
case ElementType.Var:
- if (context == null || context.Type == null)
- throw new InvalidOperationException ();
-
- return ((TypeReference) context.Type).GetElementType ().GenericParameters [((GenericParameter) type).Position];
+ var var_parameter = (GenericParameter) type;
+ return context.TypeParameter (type.DeclaringType.FullName, var_parameter.Position);
case ElementType.MVar:
- if (context == null || context.Method == null)
- throw new InvalidOperationException ();
-
- return context.Method.GenericParameters [((GenericParameter) type).Position];
+ var mvar_parameter = (GenericParameter) type;
+ return context.MethodParameter (mvar_parameter.DeclaringMethod.Name, mvar_parameter.Position);
}
throw new NotSupportedException (type.etype.ToString ());
}
- public FieldReference ImportField (FieldReference field, IGenericContext context)
+ public FieldReference ImportField (FieldReference field, ImportGenericContext context)
{
var declaring_type = ImportType (field.DeclaringType, context);
- return new FieldReference {
- Name = field.Name,
- DeclaringType = declaring_type,
- FieldType = ImportType (field.FieldType, context ?? declaring_type),
- };
+ context.Push (declaring_type);
+ try {
+ return new FieldReference {
+ Name = field.Name,
+ DeclaringType = declaring_type,
+ FieldType = ImportType (field.FieldType, context),
+ };
+ } finally {
+ context.Pop ();
+ }
}
- public MethodReference ImportMethod (MethodReference method, IGenericContext context)
+ public MethodReference ImportMethod (MethodReference method, ImportGenericContext context)
{
if (method.IsGenericInstance)
return ImportMethodSpecification (method, context);
@@ -523,29 +622,33 @@ namespace Mono.Cecil {
HasThis = method.HasThis,
ExplicitThis = method.ExplicitThis,
DeclaringType = declaring_type,
+ CallingConvention = method.CallingConvention,
};
- reference.CallingConvention = method.CallingConvention;
-
if (method.HasGenericParameters)
ImportGenericParameters (reference, method);
- reference.ReturnType = ImportType (method.ReturnType, context ?? reference);
+ context.Push (reference);
+ try {
+ reference.ReturnType = ImportType (method.ReturnType, context);
- if (!method.HasParameters)
- return reference;
+ if (!method.HasParameters)
+ return reference;
- var reference_parameters = reference.Parameters;
+ var reference_parameters = reference.Parameters;
- var parameters = method.Parameters;
- for (int i = 0; i < parameters.Count; i++)
- reference_parameters.Add (
- new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference)));
+ var parameters = method.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
+ reference_parameters.Add (
+ new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
- return reference;
+ return reference;
+ } finally {
+ context.Pop();
+ }
}
- MethodSpecification ImportMethodSpecification (MethodReference method, IGenericContext context)
+ MethodSpecification ImportMethodSpecification (MethodReference method, ImportGenericContext context)
{
if (!method.IsGenericInstance)
throw new NotSupportedException ();
diff --git a/external/cecil/Mono.Cecil/MetadataResolver.cs b/external/cecil/Mono.Cecil/MetadataResolver.cs
index e69fcd7150..55433770f2 100644
--- a/external/cecil/Mono.Cecil/MetadataResolver.cs
+++ b/external/cecil/Mono.Cecil/MetadataResolver.cs
@@ -57,9 +57,26 @@ namespace Mono.Cecil {
get { return member; }
}
+ public IMetadataScope Scope {
+ get {
+ var type = member as TypeReference;
+ if (type != null)
+ return type.Scope;
+
+ var declaring_type = member.DeclaringType;
+ if (declaring_type != null)
+ return declaring_type.Scope;
+
+ throw new NotSupportedException ();
+ }
+ }
+
public ResolutionException (MemberReference member)
: base ("Failed to resolve " + member.FullName)
{
+ if (member == null)
+ throw new ArgumentNullException ("member");
+
this.member = member;
}
diff --git a/external/cecil/Mono.Cecil/MetadataSystem.cs b/external/cecil/Mono.Cecil/MetadataSystem.cs
index 693202b6ba..3ae2015bb5 100644
--- a/external/cecil/Mono.Cecil/MetadataSystem.cs
+++ b/external/cecil/Mono.Cecil/MetadataSystem.cs
@@ -65,13 +65,13 @@ namespace Mono.Cecil {
internal Dictionary<MetadataToken, uint> FieldMarshals;
internal Dictionary<MetadataToken, Row<ElementType, uint>> Constants;
internal Dictionary<uint, MetadataToken []> Overrides;
- internal Dictionary<MetadataToken, Range> CustomAttributes;
- internal Dictionary<MetadataToken, Range> SecurityDeclarations;
+ internal Dictionary<MetadataToken, Range []> CustomAttributes;
+ internal Dictionary<MetadataToken, Range []> SecurityDeclarations;
internal Dictionary<uint, Range> Events;
internal Dictionary<uint, Range> Properties;
internal Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> Semantics;
internal Dictionary<uint, Row<PInvokeAttributes, uint, uint>> PInvokes;
- internal Dictionary<MetadataToken, Range> GenericParameters;
+ internal Dictionary<MetadataToken, Range []> GenericParameters;
internal Dictionary<uint, MetadataToken []> GenericConstraints;
static Dictionary<string, Row<ElementType, bool>> primitive_value_types;
@@ -106,7 +106,7 @@ namespace Mono.Cecil {
return;
var scope = type.scope;
- if (scope == null || scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference || scope.Name != "mscorlib")
+ if (scope == null || scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
return;
Row<ElementType, bool> primitive_data;
@@ -124,9 +124,6 @@ namespace Mono.Cecil {
if (type.Namespace != "System")
return false;
- if (!type.HasImage || !type.Module.IsCorlib ())
- return false;
-
Row<ElementType, bool> primitive_data;
if (TryGetPrimitiveData (type, out primitive_data) && primitive_data.Col1.IsPrimitive ()) {
etype = primitive_data.Col1;
@@ -305,9 +302,9 @@ namespace Mono.Cecil {
Events.Remove (type.token.RID);
}
- public bool TryGetGenericParameterRange (IGenericParameterProvider owner, out Range range)
+ public bool TryGetGenericParameterRanges (IGenericParameterProvider owner, out Range [] ranges)
{
- return GenericParameters.TryGetValue (owner.MetadataToken, out range);
+ return GenericParameters.TryGetValue (owner.MetadataToken, out ranges);
}
public void RemoveGenericParameterRange (IGenericParameterProvider owner)
@@ -315,9 +312,9 @@ namespace Mono.Cecil {
GenericParameters.Remove (owner.MetadataToken);
}
- public bool TryGetCustomAttributeRange (ICustomAttributeProvider owner, out Range range)
+ public bool TryGetCustomAttributeRanges (ICustomAttributeProvider owner, out Range [] ranges)
{
- return CustomAttributes.TryGetValue (owner.MetadataToken, out range);
+ return CustomAttributes.TryGetValue (owner.MetadataToken, out ranges);
}
public void RemoveCustomAttributeRange (ICustomAttributeProvider owner)
@@ -325,9 +322,9 @@ namespace Mono.Cecil {
CustomAttributes.Remove (owner.MetadataToken);
}
- public bool TryGetSecurityDeclarationRange (ISecurityDeclarationProvider owner, out Range range)
+ public bool TryGetSecurityDeclarationRanges (ISecurityDeclarationProvider owner, out Range [] ranges)
{
- return SecurityDeclarations.TryGetValue (owner.MetadataToken, out range);
+ return SecurityDeclarations.TryGetValue (owner.MetadataToken, out ranges);
}
public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner)
diff --git a/external/cecil/Mono.Cecil/ModuleDefinition.cs b/external/cecil/Mono.Cecil/ModuleDefinition.cs
index 66ac0270e0..7f75cbd17e 100644
--- a/external/cecil/Mono.Cecil/ModuleDefinition.cs
+++ b/external/cecil/Mono.Cecil/ModuleDefinition.cs
@@ -208,6 +208,7 @@ namespace Mono.Cecil {
TargetRuntime runtime;
TargetArchitecture architecture;
ModuleAttributes attributes;
+ ModuleCharacteristics characteristics;
Guid mvid;
internal AssemblyDefinition assembly;
@@ -247,6 +248,11 @@ namespace Mono.Cecil {
set { attributes = value; }
}
+ public ModuleCharacteristics Characteristics {
+ get { return characteristics; }
+ set { characteristics = value; }
+ }
+
public string FullyQualifiedName {
get { return fq_name; }
}
@@ -442,6 +448,7 @@ namespace Mono.Cecil {
this.runtime = image.Runtime;
this.architecture = image.Architecture;
this.attributes = image.Attributes;
+ this.characteristics = image.Characteristics;
this.fq_name = image.FileName;
this.reader = new MetadataReader (this);
@@ -616,89 +623,57 @@ namespace Mono.Cecil {
throw new ArgumentException ();
}
-#if !CF
- public TypeReference Import (Type type)
+ static ImportGenericContext GenericContextFor (IGenericParameterProvider context)
{
- CheckType (type);
-
- return MetadataImporter.ImportType (type, null, ImportGenericKind.Definition);
+ return context != null ? new ImportGenericContext (context) : default (ImportGenericContext);
}
- public TypeReference Import (Type type, TypeReference context)
- {
- return Import (type, (IGenericParameterProvider) context);
- }
+#if !CF
- public TypeReference Import (Type type, MethodReference context)
+ public TypeReference Import (Type type)
{
- return Import (type, (IGenericParameterProvider) context);
+ return Import (type, null);
}
- TypeReference Import (Type type, IGenericParameterProvider context)
+ public TypeReference Import (Type type, IGenericParameterProvider context)
{
CheckType (type);
CheckContext (context, this);
return MetadataImporter.ImportType (
type,
- (IGenericContext) context,
- context != null
- ? ImportGenericKind.Open
- : ImportGenericKind.Definition);
+ GenericContextFor (context),
+ context != null ? ImportGenericKind.Open : ImportGenericKind.Definition);
}
public FieldReference Import (SR.FieldInfo field)
{
- CheckField (field);
-
- return MetadataImporter.ImportField (field, null);
- }
-
- public FieldReference Import (SR.FieldInfo field, TypeReference context)
- {
- return Import (field, (IGenericParameterProvider) context);
- }
-
- public FieldReference Import (SR.FieldInfo field, MethodReference context)
- {
- return Import (field, (IGenericParameterProvider) context);
+ return Import (field, null);
}
- FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context)
+ public FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context)
{
CheckField (field);
CheckContext (context, this);
- return MetadataImporter.ImportField (field, (IGenericContext) context);
+ return MetadataImporter.ImportField (field, GenericContextFor (context));
}
public MethodReference Import (SR.MethodBase method)
{
CheckMethod (method);
- return MetadataImporter.ImportMethod (method, null, ImportGenericKind.Definition);
- }
-
- public MethodReference Import (SR.MethodBase method, TypeReference context)
- {
- return Import (method, (IGenericParameterProvider) context);
- }
-
- public MethodReference Import (SR.MethodBase method, MethodReference context)
- {
- return Import (method, (IGenericParameterProvider) context);
+ return MetadataImporter.ImportMethod (method, default (ImportGenericContext), ImportGenericKind.Definition);
}
- MethodReference Import (SR.MethodBase method, IGenericParameterProvider context)
+ public MethodReference Import (SR.MethodBase method, IGenericParameterProvider context)
{
CheckMethod (method);
CheckContext (context, this);
return MetadataImporter.ImportMethod (method,
- (IGenericContext) context,
- context != null
- ? ImportGenericKind.Open
- : ImportGenericKind.Definition);
+ GenericContextFor (context),
+ context != null ? ImportGenericKind.Open : ImportGenericKind.Definition);
}
#endif
@@ -709,20 +684,10 @@ namespace Mono.Cecil {
if (type.Module == this)
return type;
- return MetadataImporter.ImportType (type, null);
+ return MetadataImporter.ImportType (type, default (ImportGenericContext));
}
- public TypeReference Import (TypeReference type, TypeReference context)
- {
- return Import (type, (IGenericParameterProvider) context);
- }
-
- public TypeReference Import (TypeReference type, MethodReference context)
- {
- return Import (type, (IGenericParameterProvider) context);
- }
-
- TypeReference Import (TypeReference type, IGenericParameterProvider context)
+ public TypeReference Import (TypeReference type, IGenericParameterProvider context)
{
CheckType (type);
@@ -731,7 +696,7 @@ namespace Mono.Cecil {
CheckContext (context, this);
- return MetadataImporter.ImportType (type, (IGenericContext) context);
+ return MetadataImporter.ImportType (type, GenericContextFor (context));
}
public FieldReference Import (FieldReference field)
@@ -741,20 +706,10 @@ namespace Mono.Cecil {
if (field.Module == this)
return field;
- return MetadataImporter.ImportField (field, null);
- }
-
- public FieldReference Import (FieldReference field, TypeReference context)
- {
- return Import (field, (IGenericParameterProvider) context);
- }
-
- public FieldReference Import (FieldReference field, MethodReference context)
- {
- return Import (field, (IGenericParameterProvider) context);
+ return MetadataImporter.ImportField (field, default (ImportGenericContext));
}
- FieldReference Import (FieldReference field, IGenericParameterProvider context)
+ public FieldReference Import (FieldReference field, IGenericParameterProvider context)
{
CheckField (field);
@@ -763,30 +718,15 @@ namespace Mono.Cecil {
CheckContext (context, this);
- return MetadataImporter.ImportField (field, (IGenericContext) context);
+ return MetadataImporter.ImportField (field, GenericContextFor (context));
}
public MethodReference Import (MethodReference method)
{
- CheckMethod (method);
-
- if (method.Module == this)
- return method;
-
- return MetadataImporter.ImportMethod (method, null);
- }
-
- public MethodReference Import (MethodReference method, TypeReference context)
- {
- return Import (method, (IGenericParameterProvider) context);
- }
-
- public MethodReference Import (MethodReference method, MethodReference context)
- {
- return Import (method, (IGenericParameterProvider) context);
+ return Import (method, null);
}
- MethodReference Import (MethodReference method, IGenericParameterProvider context)
+ public MethodReference Import (MethodReference method, IGenericParameterProvider context)
{
CheckMethod (method);
@@ -795,7 +735,7 @@ namespace Mono.Cecil {
CheckContext (context, this);
- return MetadataImporter.ImportMethod (method, (IGenericContext) context);
+ return MetadataImporter.ImportMethod (method, GenericContextFor (context));
}
#endif
@@ -866,6 +806,7 @@ namespace Mono.Cecil {
architecture = parameters.Architecture,
mvid = Guid.NewGuid (),
Attributes = ModuleAttributes.ILOnly,
+ Characteristics = (ModuleCharacteristics) 0x8540,
};
if (parameters.AssemblyResolver != null)
diff --git a/external/cecil/Mono.Cecil/ModuleKind.cs b/external/cecil/Mono.Cecil/ModuleKind.cs
index bbbad72801..c29da887d8 100644
--- a/external/cecil/Mono.Cecil/ModuleKind.cs
+++ b/external/cecil/Mono.Cecil/ModuleKind.cs
@@ -51,4 +51,14 @@ namespace Mono.Cecil {
StrongNameSigned = 8,
Preferred32Bit = 0x00020000,
}
+
+ [Flags]
+ public enum ModuleCharacteristics {
+ HighEntropyVA = 0x0020,
+ DynamicBase = 0x0040,
+ NoSEH = 0x0400,
+ NXCompat = 0x0100,
+ AppContainer = 0x1000,
+ TerminalServerAware = 0x8000,
+ }
}
diff --git a/external/cecil/Mono.Cecil/TypeParser.cs b/external/cecil/Mono.Cecil/TypeParser.cs
index 06dc935a58..90e04a6f41 100644
--- a/external/cecil/Mono.Cecil/TypeParser.cs
+++ b/external/cecil/Mono.Cecil/TypeParser.cs
@@ -173,13 +173,7 @@ namespace Mono.Cecil {
return;
}
-#if !CF
- Array.Resize (ref array, array.Length + 1);
-#else
- var copy = new T [array.Length + 1];
- Array.Copy (array, copy, array.Length);
- array = copy;
-#endif
+ array = array.Resize (array.Length + 1);
array [array.Length - 1] = item;
}
@@ -272,7 +266,7 @@ namespace Mono.Cecil {
public static TypeReference ParseType (ModuleDefinition module, string fullname)
{
- if (fullname == null)
+ if (string.IsNullOrEmpty (fullname))
return null;
var parser = new TypeParser (fullname);
diff --git a/external/cecil/Mono.Cecil/TypeReference.cs b/external/cecil/Mono.Cecil/TypeReference.cs
index ff28c636fe..f811b4f018 100644
--- a/external/cecil/Mono.Cecil/TypeReference.cs
+++ b/external/cecil/Mono.Cecil/TypeReference.cs
@@ -147,6 +147,15 @@ namespace Mono.Cecil {
return scope;
}
+ set {
+ var declaring_type = this.DeclaringType;
+ if (declaring_type != null) {
+ declaring_type.Scope = value;
+ return;
+ }
+
+ scope = value;
+ }
}
public bool IsNested {
diff --git a/external/cecil/Mono.Cecil/TypeSpecification.cs b/external/cecil/Mono.Cecil/TypeSpecification.cs
index aa9b653f07..75651be59c 100644
--- a/external/cecil/Mono.Cecil/TypeSpecification.cs
+++ b/external/cecil/Mono.Cecil/TypeSpecification.cs
@@ -42,16 +42,17 @@ namespace Mono.Cecil {
public override string Name {
get { return element_type.Name; }
- set { throw new NotSupportedException (); }
+ set { throw new InvalidOperationException (); }
}
public override string Namespace {
get { return element_type.Namespace; }
- set { throw new NotSupportedException (); }
+ set { throw new InvalidOperationException (); }
}
public override IMetadataScope Scope {
get { return element_type.Scope; }
+ set { throw new InvalidOperationException (); }
}
public override ModuleDefinition Module {
diff --git a/external/cecil/Mono.Cecil/TypeSystem.cs b/external/cecil/Mono.Cecil/TypeSystem.cs
index 60ccae4e5d..63f6aea287 100644
--- a/external/cecil/Mono.Cecil/TypeSystem.cs
+++ b/external/cecil/Mono.Cecil/TypeSystem.cs
@@ -34,15 +34,24 @@ namespace Mono.Cecil {
public abstract class TypeSystem {
- sealed class CorlibTypeSystem : TypeSystem {
+ sealed class CoreTypeSystem : TypeSystem {
- public CorlibTypeSystem (ModuleDefinition module)
+ public CoreTypeSystem (ModuleDefinition module)
: base (module)
{
}
internal override TypeReference LookupType (string @namespace, string name)
{
+ var type = LookupTypeDefinition (@namespace, name) ?? LookupTypeForwarded (@namespace, name);
+ if (type != null)
+ return type;
+
+ throw new NotSupportedException ();
+ }
+
+ TypeReference LookupTypeDefinition (string @namespace, string name)
+ {
var metadata = module.MetadataSystem;
if (metadata.Types == null)
Initialize (module.Types);
@@ -64,6 +73,22 @@ namespace Mono.Cecil {
});
}
+ TypeReference LookupTypeForwarded (string @namespace, string name)
+ {
+ if (!module.HasExportedTypes)
+ return null;
+
+ var exported_types = module.ExportedTypes;
+ for (int i = 0; i < exported_types.Count; i++) {
+ var exported_type = exported_types [i];
+
+ if (exported_type.Name == name && exported_type.Namespace == @namespace)
+ return exported_type.CreateReference ();
+ }
+
+ return null;
+ }
+
static void Initialize (object obj)
{
}
@@ -159,7 +184,7 @@ namespace Mono.Cecil {
internal static TypeSystem CreateTypeSystem (ModuleDefinition module)
{
if (module.IsCorlib ())
- return new CorlibTypeSystem (module);
+ return new CoreTypeSystem (module);
return new CommonTypeSystem (module);
}
diff --git a/external/cecil/Mono/Empty.cs b/external/cecil/Mono/Empty.cs
index d043a35fa5..c9e5d7d614 100644
--- a/external/cecil/Mono/Empty.cs
+++ b/external/cecil/Mono/Empty.cs
@@ -26,6 +26,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using Mono.Collections.Generic;
namespace Mono {
@@ -49,5 +50,18 @@ namespace Mono.Cecil {
{
return self == null || self.size == 0;
}
+
+ public static T [] Resize<T> (this T [] self, int length)
+ {
+#if !CF
+ Array.Resize (ref self, length);
+#else
+ var copy = new T [length];
+ Array.Copy (self, copy, self.Length);
+ self = copy;
+#endif
+
+ return self;
+ }
}
}
diff --git a/external/cecil/Test/Mono.Cecil.Tests.csproj b/external/cecil/Test/Mono.Cecil.Tests.csproj
index 2ff2951f8e..eeebf78ce5 100644
--- a/external/cecil/Test/Mono.Cecil.Tests.csproj
+++ b/external/cecil/Test/Mono.Cecil.Tests.csproj
@@ -75,17 +75,17 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core">
<SpecificVersion>False</SpecificVersion>
- <HintPath>libs\nunit-2.5.10\nunit.core.dll</HintPath>
+ <HintPath>libs\nunit-2.6.2\nunit.core.dll</HintPath>
</Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core.interfaces">
<SpecificVersion>False</SpecificVersion>
- <HintPath>libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
+ <HintPath>libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>libs\nunit-2.5.10\nunit.framework.dll</HintPath>
+ <HintPath>libs\nunit-2.6.2\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs
index e33da5128f..8f68e5fc8f 100644
--- a/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs
+++ b/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs
@@ -119,9 +119,26 @@ namespace Mono.Cecil.Tests {
[TestModule ("delay-signed.dll")]
public void DelaySignedAssembly (ModuleDefinition module)
{
+ Assert.IsNotNull (module.Assembly.Name.PublicKey);
+ Assert.AreNotEqual (0, module.Assembly.Name.PublicKey.Length);
Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress);
Assert.AreNotEqual (0, module.Image.StrongName.Size);
}
+
+ [TestModule ("wp7.dll", Verify = false)]
+ public void WindowsPhoneNonSignedAssembly (ModuleDefinition module)
+ {
+ Assert.AreEqual (0, module.Assembly.Name.PublicKey.Length);
+ Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
+ Assert.AreEqual (0, module.Image.StrongName.VirtualAddress);
+ Assert.AreEqual (0, module.Image.StrongName.Size);
+ }
+
+ [TestModule ("metro.exe", Verify = false)]
+ public void MetroAssembly (ModuleDefinition module)
+ {
+ Assert.AreEqual (ModuleCharacteristics.AppContainer, module.Characteristics & ModuleCharacteristics.AppContainer);
+ }
}
}
diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs
index 3fa04068eb..ae9a8551b9 100644
--- a/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs
+++ b/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -220,6 +221,69 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual ("T Mono.Cecil.Tests.ImportCecilTests/Generic`1::Method(T)", method.FullName);
}
+ public class ContextGeneric1Method2<G1>
+ {
+ public G1 GenericMethod<R1, S1> (R1 r, S1 s)
+ {
+ return default (G1);
+ }
+ }
+
+ public class ContextGeneric2Method1<G2, H2>
+ {
+ public R2 GenericMethod<R2> (G2 g, H2 h)
+ {
+ return default (R2);
+ }
+ }
+
+ public class NestedGenericsA<A>
+ {
+ public class NestedGenericsB<B>
+ {
+ public class NestedGenericsC<C>
+ {
+ public A GenericMethod (B b, C c)
+ {
+ return default (A);
+ }
+ }
+ }
+ }
+
+ [Test]
+ public void ContextGenericTest ()
+ {
+ var module = ModuleDefinition.ReadModule (typeof (ContextGeneric1Method2<>).Module.FullyQualifiedName);
+ // by mixing open generics with 2 & 1 parameters, we make sure the right context is used (because otherwise, an exception will be thrown)
+ var type = typeof (ContextGeneric1Method2<>).MakeGenericType (typeof (ContextGeneric2Method1<,>));
+ var meth = type.GetMethod ("GenericMethod");
+ var imported_type = module.Import (type);
+ var method = module.Import (meth, imported_type);
+ Assert.AreEqual ("G1 Mono.Cecil.Tests.ImportCecilTests/ContextGeneric1Method2`1<Mono.Cecil.Tests.ImportCecilTests/ContextGeneric2Method1`2<G2,H2>>::GenericMethod<R1,S1>(R1,S1)", method.FullName);
+
+ // and the other way around
+ type = typeof (ContextGeneric2Method1<,>).MakeGenericType (typeof (ContextGeneric1Method2<>), typeof (IList<>));
+ meth = type.GetMethod ("GenericMethod");
+ imported_type = module.Import (type);
+ method = module.Import (meth, imported_type);
+ Assert.AreEqual ("R2 Mono.Cecil.Tests.ImportCecilTests/ContextGeneric2Method1`2<Mono.Cecil.Tests.ImportCecilTests/ContextGeneric1Method2`1<G1>,System.Collections.Generic.IList`1<T>>::GenericMethod<R2>(G2,H2)", method.FullName);
+
+ // not sure about this one
+ type = typeof (NestedGenericsA<string>.NestedGenericsB<int>.NestedGenericsC<float>);
+ meth = type.GetMethod ("GenericMethod");
+ imported_type = module.Import (type);
+ method = module.Import (meth, imported_type);
+ Assert.AreEqual ("A Mono.Cecil.Tests.ImportCecilTests/NestedGenericsA`1/NestedGenericsB`1/NestedGenericsC`1<System.String,System.Int32,System.Single>::GenericMethod(B,C)", method.FullName);
+
+ // We need both the method & type !
+ type = typeof (Generic<>).MakeGenericType (typeof (string));
+ meth = type.GetMethod ("ComplexGenericMethod");
+ imported_type = module.Import (type);
+ method = module.Import (meth, imported_type);
+ Assert.AreEqual ("Mono.Cecil.Tests.ImportCecilTests/Generic`1<TS> Mono.Cecil.Tests.ImportCecilTests/Generic`1<System.String>::ComplexGenericMethod<TS>(T,TS)", method.FullName);
+ }
+
delegate void Emitter (ModuleDefinition module, MethodBody body);
[MethodImpl (MethodImplOptions.NoInlining)]
diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs
index dd1d28a121..6ded91c92d 100644
--- a/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs
+++ b/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs
@@ -275,7 +275,7 @@ namespace Mono.Cecil.Tests {
var generic_field = module.Import (generic_list_foo_open_field, foo_def);
- Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Field",
+ Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Field",
generic_field.FullName);
}
@@ -291,7 +291,7 @@ namespace Mono.Cecil.Tests {
var generic_method = module.Import (generic_list_foo_open_method, foo_def);
- Assert.AreEqual ("TFoo Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Method(TFoo)",
+ Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1<System.Collections.Generic.List`1<TFoo>>::Method(T)",
generic_method.FullName);
}
diff --git a/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs
index 9ec1be8f26..cb7512d070 100644
--- a/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs
+++ b/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs
@@ -211,6 +211,21 @@ namespace Mono.Cecil.Tests {
Assert.IsNotNull (resolver.Resolve (reference));
}
+ [Test]
+ public void ResolvePortableClassLibraryReference ()
+ {
+ var resolver = new DefaultAssemblyResolver ();
+ var parameters = new ReaderParameters { AssemblyResolver = resolver };
+ var pcl = GetResourceModule ("PortableClassLibrary.dll", parameters);
+
+ foreach (var reference in pcl.AssemblyReferences) {
+ Assert.IsTrue (reference.IsRetargetable);
+ var assembly = resolver.Resolve (reference);
+ Assert.IsNotNull (assembly);
+ Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version);
+ }
+ }
+
static TRet GetReference<TDel, TRet> (TDel code)
{
var @delegate = code as Delegate;
diff --git a/external/cecil/Test/libs/nunit-2.4.8/license.txt b/external/cecil/Test/libs/nunit-2.6.2/license.txt
index fef69103dc..724e4652e8 100644..100755
--- a/external/cecil/Test/libs/nunit-2.4.8/license.txt
+++ b/external/cecil/Test/libs/nunit-2.6.2/license.txt
@@ -1,4 +1,4 @@
-Copyright © 2002-2007 Charlie Poole
+Copyright © 2002-2012 Charlie Poole
Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
Copyright © 2000-2002 Philip A. Craig
@@ -8,7 +8,7 @@ Permission is granted to anyone to use this software for any purpose, including
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
-Portions Copyright © 2002-2007 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
+Portions Copyright © 2002-2012 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
diff --git a/external/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj b/external/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
index 3e7b8deb37..93c5550e50 100644
--- a/external/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
+++ b/external/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
@@ -51,17 +51,17 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\Test\libs\nunit-2.5.10\nunit.core.dll</HintPath>
+ <HintPath>..\..\Test\libs\nunit-2.6.2\nunit.core.dll</HintPath>
</Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core.interfaces">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\Test\libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
+ <HintPath>..\..\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
+ <HintPath>..\..\Test\libs\nunit-2.6.2\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
diff --git a/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs b/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
index 2db0419650..2440a6642b 100644
--- a/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
+++ b/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
@@ -40,7 +40,7 @@ namespace Mono.Cecil.Mdb {
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
{
- return new MdbReader (MonoSymbolFile.ReadSymbolFile (module, fileName));
+ return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (module, fileName));
}
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
@@ -51,18 +51,20 @@ namespace Mono.Cecil.Mdb {
public class MdbReader : ISymbolReader {
+ readonly ModuleDefinition module;
readonly MonoSymbolFile symbol_file;
readonly Dictionary<string, Document> documents;
- public MdbReader (MonoSymbolFile symFile)
+ public MdbReader (ModuleDefinition module, MonoSymbolFile symFile)
{
- symbol_file = symFile;
- documents = new Dictionary<string, Document> ();
+ this.module = module;
+ this.symbol_file = symFile;
+ this.documents = new Dictionary<string, Document> ();
}
public bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header)
{
- return true;
+ return symbol_file.Guid == module.Mvid;
}
public void Read (MethodBody body, InstructionMapper mapper)
@@ -80,7 +82,11 @@ namespace Mono.Cecil.Mdb {
static void ReadLocalVariables (MethodEntry entry, MethodBody body, Scope [] scopes)
{
var locals = entry.GetLocals ();
+
foreach (var local in locals) {
+ if (local.Index < 0 || local.Index >= body.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = body.Variables [local.Index];
variable.Name = local.Name;
@@ -200,6 +206,9 @@ namespace Mono.Cecil.Mdb {
static void ReadLocalVariables (MethodEntry entry, MethodSymbols symbols)
{
foreach (var local in entry.GetLocals ()) {
+ if (local.Index < 0 || local.Index >= symbols.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = symbols.Variables [local.Index];
variable.Name = local.Name;
}
diff --git a/external/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj b/external/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
index 708f8009f5..2123470382 100644
--- a/external/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
+++ b/external/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
@@ -95,17 +95,17 @@
<Content Include="Resources\assemblies\hello.exe.mdb" />
</ItemGroup>
<ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.dll</HintPath>
</Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core.interfaces">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
index e8e77b0bc8..d92a5b7491 100644
--- a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
@@ -189,6 +189,12 @@ namespace Microsoft.Cci.Pdb {
offset += len;
}
+ internal string ReadBString(int len) {
+ var result = Encoding.UTF8.GetString(buffer, offset, len);
+ offset += len;
+ return result;
+ }
+
internal void ReadCString(out string value) {
int len = 0;
while (offset + len < buffer.Length && buffer[offset + len] != 0) {
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
index 9e56028122..47191ef156 100644
--- a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
@@ -131,11 +131,11 @@ namespace Microsoft.Cci.Pdb {
return ht;
}
- private static PdbFunction match = new PdbFunction();
-
private static int FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
- match.segment = sec;
- match.address = off;
+ var match = new PdbFunction {
+ segment = sec,
+ address = off,
+ };
return Array.BinarySearch(funcs, match, PdbFunction.byAddress);
}
@@ -148,52 +148,9 @@ namespace Microsoft.Cci.Pdb {
PdbReader reader,
uint limit) {
Array.Sort(funcs, PdbFunction.byAddressAndToken);
- IntHashTable checks = new IntHashTable();
- // Read the files first
int begin = bits.Position;
- while (bits.Position < limit) {
- int sig;
- int siz;
- bits.ReadInt32(out sig);
- bits.ReadInt32(out siz);
- int place = bits.Position;
- int endSym = bits.Position + siz;
-
- switch ((DEBUG_S_SUBSECTION)sig) {
- case DEBUG_S_SUBSECTION.FILECHKSMS:
- while (bits.Position < endSym) {
- CV_FileCheckSum chk;
-
- int ni = bits.Position - place;
- bits.ReadUInt32(out chk.name);
- bits.ReadUInt8(out chk.len);
- bits.ReadUInt8(out chk.type);
-
- string name = (string)names[(int)chk.name];
- int guidStream;
- Guid doctypeGuid = SymDocumentType.Text;
- Guid languageGuid = Guid.Empty;
- Guid vendorGuid = Guid.Empty;
- if (nameIndex.TryGetValue("/SRC/FILES/"+name.ToUpperInvariant(), out guidStream)) {
- var guidBits = new BitAccess(0x100);
- dir.streams[guidStream].Read(reader, guidBits);
- LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid);
- }
-
- PdbSource src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid);
- checks.Add(ni, src);
- bits.Position += chk.len;
- bits.Align(4);
- }
- bits.Position = endSym;
- break;
-
- default:
- bits.Position = endSym;
- break;
- }
- }
+ IntHashTable checks = ReadSourceFileInfo(bits, limit, names, dir, nameIndex, reader);
// Read the lines next.
bits.Position = begin;
@@ -222,7 +179,7 @@ namespace Microsoft.Cci.Pdb {
func = f;
funcIndex--;
}
- } else {
+ } else {
while (funcIndex < funcs.Length-1 && func.lines != null) {
var f = funcs[funcIndex+1];
if (f.segment != sec.sec || f.address != sec.off) break;
@@ -380,12 +337,9 @@ namespace Microsoft.Cci.Pdb {
bits.Position = end;
}
- internal static PdbFunction[] LoadFunctions(Stream read, bool readAllStrings, out int age, out Guid guid) {
+ internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary<uint, PdbTokenLine> tokenToSourceMapping, out string sourceServerData, out int age, out Guid guid) {
+ tokenToSourceMapping = new Dictionary<uint, PdbTokenLine>();
BitAccess bits = new BitAccess(512 * 1024);
- return LoadFunctions(read, bits, readAllStrings, out age, out guid);
- }
-
- internal static PdbFunction[] LoadFunctions(Stream read, BitAccess bits, bool readAllStrings, out int age, out Guid guid) {
PdbFileHeader head = new PdbFileHeader(read, bits);
PdbReader reader = new PdbReader(read, head.pageSize);
MsfDirectory dir = new MsfDirectory(reader, head, bits);
@@ -398,21 +352,34 @@ namespace Microsoft.Cci.Pdb {
if (!nameIndex.TryGetValue("/NAMES", out nameStream)) {
throw new PdbException("No `name' stream");
}
-
dir.streams[nameStream].Read(reader, bits);
IntHashTable names = LoadNameStream(bits);
+ int srcsrvStream;
+ if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream))
+ sourceServerData = string.Empty;
+ else {
+ DataStream dataStream = dir.streams[srcsrvStream];
+ byte[] bytes = new byte[dataStream.contentSize];
+ dataStream.Read(reader, bits);
+ sourceServerData = bits.ReadBString(bytes.Length);
+ }
+
dir.streams[3].Read(reader, bits);
- LoadDbiStream(bits, out modules, out header, readAllStrings);
+ LoadDbiStream(bits, out modules, out header, true);
ArrayList funcList = new ArrayList();
if (modules != null) {
for (int m = 0; m < modules.Length; m++) {
- if (modules[m].stream > 0) {
- dir.streams[modules[m].stream].Read(reader, bits);
- LoadFuncsFromDbiModule(bits, modules[m], names, funcList,
- readAllStrings, dir, nameIndex, reader);
+ var module = modules[m];
+ if (module.stream > 0) {
+ dir.streams[module.stream].Read(reader, bits);
+ if (module.moduleName == "TokenSourceLineInfo") {
+ LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping);
+ continue;
+ }
+ LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader);
}
}
}
@@ -435,5 +402,136 @@ namespace Microsoft.Cci.Pdb {
//Array.Sort(funcs, PdbFunction.byToken);
return funcs;
}
+
+ private static void LoadTokenToSourceInfo(BitAccess bits, DbiModuleInfo module, IntHashTable names, MsfDirectory dir,
+ Dictionary<string, int> nameIndex, PdbReader reader, Dictionary<uint, PdbTokenLine> tokenToSourceMapping) {
+ bits.Position = 0;
+ int sig;
+ bits.ReadInt32(out sig);
+ if (sig != 4) {
+ throw new PdbDebugException("Invalid signature. (sig={0})", sig);
+ }
+
+ bits.Position = 4;
+
+ while (bits.Position < module.cbSyms) {
+ ushort siz;
+ ushort rec;
+
+ bits.ReadUInt16(out siz);
+ int star = bits.Position;
+ int stop = bits.Position + siz;
+ bits.Position = star;
+ bits.ReadUInt16(out rec);
+
+ switch ((SYM)rec) {
+ case SYM.S_OEM:
+ OemSymbol oem;
+
+ bits.ReadGuid(out oem.idOem);
+ bits.ReadUInt32(out oem.typind);
+ // internal byte[] rgl; // user data, force 4-byte alignment
+
+ if (oem.idOem == PdbFunction.msilMetaData) {
+ string name = bits.ReadString();
+ if (name == "TSLI") {
+ uint token;
+ uint file_id;
+ uint line;
+ uint column;
+ uint endLine;
+ uint endColumn;
+ bits.ReadUInt32(out token);
+ bits.ReadUInt32(out file_id);
+ bits.ReadUInt32(out line);
+ bits.ReadUInt32(out column);
+ bits.ReadUInt32(out endLine);
+ bits.ReadUInt32(out endColumn);
+ PdbTokenLine tokenLine;
+ if (!tokenToSourceMapping.TryGetValue(token, out tokenLine))
+ tokenToSourceMapping.Add(token, new PdbTokenLine(token, file_id, line, column, endLine, endColumn));
+ else {
+ while (tokenLine.nextLine != null) tokenLine = tokenLine.nextLine;
+ tokenLine.nextLine = new PdbTokenLine(token, file_id, line, column, endLine, endColumn);
+ }
+ }
+ bits.Position = stop;
+ break;
+ } else {
+ throw new PdbDebugException("OEM section: guid={0} ti={1}",
+ oem.idOem, oem.typind);
+ // bits.Position = stop;
+ }
+
+ case SYM.S_END:
+ bits.Position = stop;
+ break;
+
+ default:
+ //Console.WriteLine("{0,6}: {1:x2} {2}",
+ // bits.Position, rec, (SYM)rec);
+ bits.Position = stop;
+ break;
+ }
+ }
+
+ bits.Position = module.cbSyms + module.cbOldLines;
+ int limit = module.cbSyms + module.cbOldLines + module.cbLines;
+ IntHashTable sourceFiles = ReadSourceFileInfo(bits, (uint)limit, names, dir, nameIndex, reader);
+ foreach (var tokenLine in tokenToSourceMapping.Values) {
+ tokenLine.sourceFile = (PdbSource)sourceFiles[(int)tokenLine.file_id];
+ }
+
+ }
+
+ private static IntHashTable ReadSourceFileInfo(BitAccess bits, uint limit, IntHashTable names, MsfDirectory dir,
+ Dictionary<string, int> nameIndex, PdbReader reader) {
+ IntHashTable checks = new IntHashTable();
+
+ int begin = bits.Position;
+ while (bits.Position < limit) {
+ int sig;
+ int siz;
+ bits.ReadInt32(out sig);
+ bits.ReadInt32(out siz);
+ int place = bits.Position;
+ int endSym = bits.Position + siz;
+
+ switch ((DEBUG_S_SUBSECTION)sig) {
+ case DEBUG_S_SUBSECTION.FILECHKSMS:
+ while (bits.Position < endSym) {
+ CV_FileCheckSum chk;
+
+ int ni = bits.Position - place;
+ bits.ReadUInt32(out chk.name);
+ bits.ReadUInt8(out chk.len);
+ bits.ReadUInt8(out chk.type);
+
+ string name = (string)names[(int)chk.name];
+ int guidStream;
+ Guid doctypeGuid = SymDocumentType.Text;
+ Guid languageGuid = Guid.Empty;
+ Guid vendorGuid = Guid.Empty;
+ if (nameIndex.TryGetValue("/SRC/FILES/"+name.ToUpperInvariant(), out guidStream)) {
+ var guidBits = new BitAccess(0x100);
+ dir.streams[guidStream].Read(reader, guidBits);
+ LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid);
+ }
+
+ PdbSource src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid);
+ checks.Add(ni, src);
+ bits.Position += chk.len;
+ bits.Align(4);
+ }
+ bits.Position = endSym;
+ break;
+
+ default:
+ bits.Position = endSym;
+ break;
+ }
+ }
+ return checks;
+ }
}
}
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
index d1daba14e9..72622314e8 100644
--- a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
@@ -22,6 +22,7 @@ namespace Microsoft.Cci.Pdb {
internal uint token;
internal uint slotToken;
+ internal uint tokenOfMethodWhoseUsingInfoAppliesToThisMethod;
//internal string name;
//internal string module;
//internal ushort flags;
@@ -40,6 +41,7 @@ namespace Microsoft.Cci.Pdb {
internal IEnumerable<INamespaceScope>/*?*/ namespaceScopes;
internal string/*?*/ iteratorClass;
internal List<ILocalScope>/*?*/ iteratorScopes;
+ internal PdbSynchronizationInformation/*?*/ synchronizationInformation;
private static string StripNamespace(string module) {
int li = module.LastIndexOf('.');
@@ -267,6 +269,8 @@ namespace Microsoft.Cci.Pdb {
while (count-- > 0)
this.ReadCustomMetadata(bits);
}
+ } else if (name == "asyncMethodInfo") {
+ this.synchronizationInformation = new PdbSynchronizationInformation(bits);
}
bits.Position = stop;
break;
@@ -294,8 +298,7 @@ namespace Microsoft.Cci.Pdb {
}
case SYM.S_MANSLOT:
- uint typind;
- slots[slot++] = new PdbSlot(bits, out typind);
+ slots[slot++] = new PdbSlot(bits);
bits.Position = stop;
break;
@@ -349,7 +352,7 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt32(out numberOfBytesInItem);
switch (kind) {
case 0: this.ReadUsingInfo(bits); break;
- case 1: break; // this.ReadForwardInfo(bits); break;
+ case 1: this.ReadForwardInfo(bits); break;
case 2: break; // this.ReadForwardedToModuleInfo(bits); break;
case 3: this.ReadIteratorLocals(bits); break;
case 4: this.ReadForwardIterator(bits); break;
@@ -378,8 +381,9 @@ namespace Microsoft.Cci.Pdb {
//private void ReadForwardedToModuleInfo(BitAccess bits) {
//}
- //private void ReadForwardInfo(BitAccess bits) {
- //}
+ private void ReadForwardInfo(BitAccess bits) {
+ bits.ReadUInt32(out this.tokenOfMethodWhoseUsingInfoAppliesToThisMethod);
+ }
private void ReadUsingInfo(BitAccess bits) {
ushort numberOfNamespaces;
@@ -449,4 +453,46 @@ namespace Microsoft.Cci.Pdb {
//}
}
+
+ internal class PdbSynchronizationInformation {
+ internal uint kickoffMethodToken;
+ internal uint generatedCatchHandlerIlOffset;
+ internal PdbSynchronizationPoint[] synchronizationPoints;
+
+ internal PdbSynchronizationInformation(BitAccess bits) {
+ uint asyncStepInfoCount;
+ bits.ReadUInt32(out this.kickoffMethodToken);
+ bits.ReadUInt32(out this.generatedCatchHandlerIlOffset);
+ bits.ReadUInt32(out asyncStepInfoCount);
+ this.synchronizationPoints = new PdbSynchronizationPoint[asyncStepInfoCount];
+ for (uint i = 0; i < asyncStepInfoCount; i += 1) {
+ this.synchronizationPoints[i] = new PdbSynchronizationPoint(bits);
+ }
+ }
+
+ public uint GeneratedCatchHandlerOffset {
+ get { return this.generatedCatchHandlerIlOffset; }
+ }
+ }
+
+ internal class PdbSynchronizationPoint {
+ internal uint synchronizeOffset;
+ internal uint continuationMethodToken;
+ internal uint continuationOffset;
+
+ internal PdbSynchronizationPoint(BitAccess bits) {
+ bits.ReadUInt32(out this.synchronizeOffset);
+ bits.ReadUInt32(out this.continuationMethodToken);
+ bits.ReadUInt32(out this.continuationOffset);
+ }
+
+ public uint SynchronizeOffset {
+ get { return this.synchronizeOffset; }
+ }
+
+ public uint ContinuationOffset {
+ get { return this.continuationOffset; }
+ }
+ }
+
}
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
index c46220b80b..92ac385e99 100644
--- a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
@@ -80,7 +80,7 @@ namespace Microsoft.Cci.Pdb {
}
case SYM.S_MANSLOT:
- slots[slot++] = new PdbSlot(bits, out typind);
+ slots[slot++] = new PdbSlot(bits);
bits.Position = stop;
break;
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
index 0dc89ad4d8..e2b76d5fb8 100644
--- a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
@@ -13,12 +13,13 @@ using System;
namespace Microsoft.Cci.Pdb {
internal class PdbSlot {
internal uint slot;
+ internal uint typeToken;
internal string name;
internal ushort flags;
//internal uint segment;
//internal uint address;
- internal PdbSlot(BitAccess bits, out uint typind) {
+ internal PdbSlot(BitAccess bits) {
AttrSlotSym slot;
bits.ReadUInt32(out slot.index);
@@ -29,12 +30,12 @@ namespace Microsoft.Cci.Pdb {
bits.ReadCString(out slot.name);
this.slot = slot.index;
+ this.typeToken = slot.typind;
this.name = slot.name;
this.flags = slot.flags;
//this.segment = slot.segCod;
//this.address = slot.offCod;
- typind = slot.typind;
}
}
}
diff --git a/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs
new file mode 100644
index 0000000000..879339b23a
--- /dev/null
+++ b/external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs
@@ -0,0 +1,33 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//-----------------------------------------------------------------------------
+using System;
+
+namespace Microsoft.Cci.Pdb {
+ internal class PdbTokenLine {
+ internal uint token;
+ internal uint file_id;
+ internal uint line;
+ internal uint column;
+ internal uint endLine;
+ internal uint endColumn;
+ internal PdbSource sourceFile;
+ internal PdbTokenLine/*?*/ nextLine;
+
+ internal PdbTokenLine(uint token, uint file_id, uint line, uint column, uint endLine, uint endColumn) {
+ this.token = token;
+ this.file_id = file_id;
+ this.line = line;
+ this.column = column;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+ }
+}
diff --git a/external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj b/external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
index 5248bad358..e35add055d 100644
--- a/external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
+++ b/external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
@@ -108,7 +108,10 @@
<Compile Include="Microsoft.Cci.Pdb\PdbScope.cs" />
<Compile Include="Microsoft.Cci.Pdb\PdbSlot.cs" />
<Compile Include="Microsoft.Cci.Pdb\PdbSource.cs" />
- <Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs" />
+ <Compile Include="Microsoft.Cci.Pdb\PdbTokenLine.cs" />
+ <Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
<Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
<Compile Include="Mono.Cecil.Pdb\ISymUnmanagedWriter2.cs" />
diff --git a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
index 9d7166638d..6d4fd09844 100644
--- a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
+++ b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
@@ -86,11 +86,14 @@ namespace Mono.Cecil.Pdb {
bool PopulateFunctions ()
{
using (pdb_file) {
+ Dictionary<uint, PdbTokenLine> tokenToSourceMapping;
+ string sourceServerData;
int age;
Guid guid;
- var funcs = PdbFile.LoadFunctions (pdb_file, true, out age, out guid);
- if (this.age != 0 && this.guid != guid)
+ var funcs = PdbFile.LoadFunctions (pdb_file, out tokenToSourceMapping, out sourceServerData, out age, out guid);
+
+ if (this.guid != guid)
return false;
foreach (PdbFunction function in funcs)
diff --git a/external/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/external/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
index 7bf3ed40b8..657e351ba8 100644
--- a/external/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
+++ b/external/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
@@ -100,17 +100,17 @@
<Content Include="Resources\assemblies\VBConsApp.pdb" />
</ItemGroup>
<ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.dll</HintPath>
</Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.core.interfaces">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.framework">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
+ <HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />