[Pkg-mono-svn-commits] [mono-basic] 01/05: Imported Upstream version 4.0.1

Jo Shields directhex at moszumanska.debian.org
Wed Sep 9 10:49:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

directhex pushed a commit to annotated tag debian/4.0.1-1
in repository mono-basic.

commit a0b28354584c560518531b82aa66108caf129c6b
Author: Jo Shields <jo.shields at xamarin.com>
Date:   Wed Sep 9 11:34:06 2015 +0100

    Imported Upstream version 4.0.1
---
 build/library.make                                 |   2 +-
 build/profiles/net_2_0.make                        |   7 -
 build/profiles/net_4_0.make                        |   7 -
 build/rules.make                                   |   7 +-
 class/lib/bootstrap/Microsoft.VisualBasic.dll      | Bin 350208 -> 350720 bytes
 class/lib/bootstrap/Microsoft.VisualBasic.dll.mdb  | Bin 82103 -> 81178 bytes
 class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll          | Bin 43520 -> 45568 bytes
 class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll.mdb      | Bin 15962 -> 18054 bytes
 class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll          | Bin 83968 -> 84480 bytes
 class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll.mdb      | Bin 25183 -> 24989 bytes
 class/lib/bootstrap/Mono.Cecil.VB.dll              | Bin 284160 -> 321024 bytes
 class/lib/bootstrap/Mono.Cecil.VB.dll.mdb          | Bin 149404 -> 161418 bytes
 class/lib/bootstrap/vbnc.exe                       | Bin 1150464 -> 1171968 bytes
 class/lib/bootstrap/vbnc.exe.mdb                   | Bin 302823 -> 288730 bytes
 configure                                          |   5 +-
 vbnc/cecil/Makefile                                |   3 +-
 vbnc/cecil/Mono.Cecil-SL.csproj                    | 200 -------
 vbnc/cecil/Mono.Cecil.Cil/Code.cs                  |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/CodeReader.cs            |  24 +-
 vbnc/cecil/Mono.Cecil.Cil/CodeWriter.cs            |  35 +-
 vbnc/cecil/Mono.Cecil.Cil/Document.cs              |   3 +-
 vbnc/cecil/Mono.Cecil.Cil/ExceptionHandler.cs      |   8 +-
 vbnc/cecil/Mono.Cecil.Cil/ILProcessor.cs           |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/Instruction.cs           |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/MethodBody.cs            |  21 +-
 vbnc/cecil/Mono.Cecil.Cil/OpCode.cs                | 549 +++++++++----------
 vbnc/cecil/Mono.Cecil.Cil/OpCodes.cs               |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/SequencePoint.cs         |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/Symbols.cs               |   9 +-
 vbnc/cecil/Mono.Cecil.Cil/VariableDefinition.cs    |   2 +-
 vbnc/cecil/Mono.Cecil.Cil/VariableReference.cs     |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/BlobHeap.cs         |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/Buffers.cs          |   6 +-
 vbnc/cecil/Mono.Cecil.Metadata/CodedIndex.cs       |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/ElementType.cs      |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/GuidHeap.cs         |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/Heap.cs             |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/MetadataToken.cs    |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/Row.cs              |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/StringHeap.cs       |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/TableHeap.cs        |  52 +-
 vbnc/cecil/Mono.Cecil.Metadata/TokenType.cs        |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/UserStringHeap.cs   |   2 +-
 vbnc/cecil/Mono.Cecil.Metadata/Utilities.cs        |   2 +-
 vbnc/cecil/Mono.Cecil.PE/BinaryStreamReader.cs     |   2 +-
 vbnc/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs     |   2 +-
 vbnc/cecil/Mono.Cecil.PE/ByteBuffer.cs             |  31 +-
 .../Mono.Cecil.PE/ByteBufferEqualityComparer.cs    |  19 +-
 vbnc/cecil/Mono.Cecil.PE/DataDirectory.cs          |   2 +-
 vbnc/cecil/Mono.Cecil.PE/Image.cs                  |  11 +-
 vbnc/cecil/Mono.Cecil.PE/ImageReader.cs            |  46 +-
 vbnc/cecil/Mono.Cecil.PE/ImageWriter.cs            | 170 +++---
 vbnc/cecil/Mono.Cecil.PE/Section.cs                |   2 +-
 vbnc/cecil/Mono.Cecil.PE/TextMap.cs                |   2 +-
 vbnc/cecil/Mono.Cecil.VB.csproj                    | 433 ++++++++-------
 vbnc/cecil/Mono.Cecil.csproj                       |  47 +-
 vbnc/cecil/Mono.Cecil/ArrayType.cs                 |   2 +-
 vbnc/cecil/Mono.Cecil/AssemblyDefinition.cs        |  10 +-
 vbnc/cecil/Mono.Cecil/AssemblyFlags.cs             |   3 +-
 vbnc/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs     |   2 +-
 vbnc/cecil/Mono.Cecil/AssemblyInfo.cs              |   8 +-
 vbnc/cecil/Mono.Cecil/AssemblyLinkedResource.cs    |   2 +-
 vbnc/cecil/Mono.Cecil/AssemblyNameDefinition.cs    |   2 +-
 vbnc/cecil/Mono.Cecil/AssemblyNameReference.cs     |  39 +-
 vbnc/cecil/Mono.Cecil/AssemblyReader.cs            | 581 +++++++++++++++------
 vbnc/cecil/Mono.Cecil/AssemblyWriter.cs            | 224 +++++---
 vbnc/cecil/Mono.Cecil/BaseAssemblyResolver.cs      | 117 ++++-
 vbnc/cecil/Mono.Cecil/CallSite.cs                  |  85 ++-
 vbnc/cecil/Mono.Cecil/CustomAttribute.cs           |  26 +-
 vbnc/cecil/Mono.Cecil/DefaultAssemblyResolver.cs   |   9 +-
 vbnc/cecil/Mono.Cecil/EmbeddedResource.cs          |  28 +-
 vbnc/cecil/Mono.Cecil/EventAttributes.cs           |   2 +-
 vbnc/cecil/Mono.Cecil/EventDefinition.cs           |  32 +-
 vbnc/cecil/Mono.Cecil/EventReference.cs            |   4 +-
 vbnc/cecil/Mono.Cecil/ExportedType.cs              |  29 +-
 vbnc/cecil/Mono.Cecil/FieldAttributes.cs           |   2 +-
 vbnc/cecil/Mono.Cecil/FieldDefinition.cs           |  16 +-
 vbnc/cecil/Mono.Cecil/FieldReference.cs            |   4 +-
 vbnc/cecil/Mono.Cecil/FileAttributes.cs            |   2 +-
 vbnc/cecil/Mono.Cecil/FunctionPointerType.cs       |  15 +-
 vbnc/cecil/Mono.Cecil/GenericInstanceMethod.cs     |  21 +-
 vbnc/cecil/Mono.Cecil/GenericInstanceType.cs       |  14 +-
 vbnc/cecil/Mono.Cecil/GenericParameter.cs          | 138 ++++-
 .../cecil/Mono.Cecil/GenericParameterAttributes.cs |   2 +-
 vbnc/cecil/Mono.Cecil/IConstantProvider.cs         |  20 +-
 vbnc/cecil/Mono.Cecil/ICustomAttributeProvider.cs  |  12 +-
 vbnc/cecil/Mono.Cecil/IGenericInstance.cs          |   2 +-
 vbnc/cecil/Mono.Cecil/IGenericParameterProvider.cs |  11 +-
 vbnc/cecil/Mono.Cecil/IMarshalInfoProvider.cs      |   9 +-
 vbnc/cecil/Mono.Cecil/IMemberDefinition.cs         |   2 +-
 vbnc/cecil/Mono.Cecil/IMetadataScope.cs            |   2 +-
 vbnc/cecil/Mono.Cecil/IMetadataTokenProvider.cs    |   2 +-
 vbnc/cecil/Mono.Cecil/IMethodSignature.cs          |   7 +-
 vbnc/cecil/Mono.Cecil/Import.cs                    | 249 ++++++---
 vbnc/cecil/Mono.Cecil/LinkedResource.cs            |   2 +-
 .../cecil/Mono.Cecil/ManifestResourceAttributes.cs |   2 +-
 vbnc/cecil/Mono.Cecil/MarshalInfo.cs               |   2 +-
 .../cecil/Mono.Cecil/MemberDefinitionCollection.cs |   2 +-
 vbnc/cecil/Mono.Cecil/MemberReference.cs           |   4 +-
 vbnc/cecil/Mono.Cecil/MetadataResolver.cs          | 167 +++++-
 vbnc/cecil/Mono.Cecil/MetadataSystem.cs            |  65 ++-
 vbnc/cecil/Mono.Cecil/MethodAttributes.cs          |   2 +-
 vbnc/cecil/Mono.Cecil/MethodCallingConvention.cs   |   2 +-
 vbnc/cecil/Mono.Cecil/MethodDefinition.cs          |  68 ++-
 vbnc/cecil/Mono.Cecil/MethodImplAttributes.cs      |   3 +-
 vbnc/cecil/Mono.Cecil/MethodReference.cs           |  12 +-
 vbnc/cecil/Mono.Cecil/MethodReturnType.cs          |  28 +-
 vbnc/cecil/Mono.Cecil/MethodSemanticsAttributes.cs |   2 +-
 vbnc/cecil/Mono.Cecil/MethodSpecification.cs       |   4 +-
 vbnc/cecil/Mono.Cecil/Modifiers.cs                 |   6 +-
 vbnc/cecil/Mono.Cecil/ModuleDefinition.cs          | 382 +++++++++-----
 vbnc/cecil/Mono.Cecil/ModuleKind.cs                |  14 +-
 vbnc/cecil/Mono.Cecil/ModuleReference.cs           |   3 +-
 vbnc/cecil/Mono.Cecil/NativeType.cs                |   2 +-
 vbnc/cecil/Mono.Cecil/PInvokeAttributes.cs         |   4 +-
 vbnc/cecil/Mono.Cecil/PInvokeInfo.cs               |  10 +-
 vbnc/cecil/Mono.Cecil/ParameterAttributes.cs       |   4 +-
 vbnc/cecil/Mono.Cecil/ParameterDefinition.cs       |  46 +-
 .../Mono.Cecil/ParameterDefinitionCollection.cs    |   2 +-
 vbnc/cecil/Mono.Cecil/ParameterReference.cs        |   2 +-
 vbnc/cecil/Mono.Cecil/PinnedType.cs                |   2 +-
 vbnc/cecil/Mono.Cecil/PointerType.cs               |   2 +-
 vbnc/cecil/Mono.Cecil/PropertyAttributes.cs        |   2 +-
 vbnc/cecil/Mono.Cecil/PropertyDefinition.cs        |  36 +-
 vbnc/cecil/Mono.Cecil/PropertyReference.cs         |   4 +-
 vbnc/cecil/Mono.Cecil/ReferenceType.cs             |   2 +-
 vbnc/cecil/Mono.Cecil/Resource.cs                  |   2 +-
 vbnc/cecil/Mono.Cecil/SecurityDeclaration.cs       |  24 +-
 vbnc/cecil/Mono.Cecil/SentinelType.cs              |   2 +-
 vbnc/cecil/Mono.Cecil/TargetRuntime.cs             |   2 +-
 vbnc/cecil/Mono.Cecil/TypeAttributes.cs            |   3 +-
 vbnc/cecil/Mono.Cecil/TypeDefinition.cs            |  52 +-
 vbnc/cecil/Mono.Cecil/TypeDefinitionCollection.cs  |   2 +-
 vbnc/cecil/Mono.Cecil/TypeParser.cs                |  46 +-
 vbnc/cecil/Mono.Cecil/TypeReference.cs             | 121 ++++-
 vbnc/cecil/Mono.Cecil/TypeSpecification.cs         |  17 +-
 vbnc/cecil/Mono.Cecil/TypeSystem.cs                | 135 +++--
 vbnc/cecil/Mono.Cecil/VariantType.cs               |   2 +-
 vbnc/cecil/Mono.Collections.Generic/Collection.cs  |  44 +-
 .../Mono.Security.Cryptography/CryptoConvert.cs    |  11 +-
 .../Mono.Security.Cryptography/CryptoService.cs    |  35 +-
 vbnc/cecil/Mono/Actions.cs                         |   4 +-
 vbnc/cecil/Mono/Empty.cs                           |  22 +-
 vbnc/cecil/Mono/Funcs.cs                           |   2 +-
 vbnc/cecil/NOTES.txt                               | 189 -------
 .../ExtensionAttribute.cs                          |   2 +-
 vbnc/cecil/symbols/mdb/Makefile                    |   2 +-
 vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.VB.csproj    | 196 +++----
 vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj       |  41 +-
 .../symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs     |   8 +-
 vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs |  21 +-
 vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs |   2 +-
 .../MonoSymbolFile.cs                              |  83 +--
 .../MonoSymbolTable.cs                             |  42 +-
 .../MonoSymbolWriter.cs                            |  53 +-
 vbnc/cecil/symbols/pdb/Makefile                    |   2 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs     | 104 ++--
 vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs |  69 +--
 vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs | 109 ++--
 .../symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs    |  95 ++--
 .../symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs     |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs     |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs |  11 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs     |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs  | 262 +++++-----
 .../symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs  |  21 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs   |  12 +-
 .../pdb/Microsoft.Cci.Pdb/PdbDebugException.cs     |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs  |   7 +-
 .../cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs | 280 +++++++---
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs |  88 ++--
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs   | 163 ++++--
 .../cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs      |   7 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs     |  13 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs      |  34 +-
 .../cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs |  20 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs     |  13 +-
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs  |  33 ++
 .../symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs     | 129 -----
 .../Microsoft.Cci.Pdb/SourceLocationProvider.cs    |  33 --
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.VB.csproj    | 254 ++++-----
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj       |  45 +-
 .../symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs     |   8 +-
 .../Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs  |   4 +
 .../pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs     |   4 +
 .../symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs   | 105 +++-
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs |  11 +-
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs |  17 +-
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs |   8 +-
 .../pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs        |   4 +
 vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs |   4 +
 .../symbols/pdb/Mono.Cecil.VB.Pdb.dll.sources      |   2 +-
 vbnc/vbnc/source/Emit/EmitLog.vb                   |   3 +-
 vbnc/vbnc/source/General/CecilHelper.vb            |  28 +-
 vbnc/vbnc/source/General/Compiler.vb               |   6 +-
 vbnc/vbnc/source/General/Helper.vb                 |   2 +-
 vbnc/vbnc/source/General/Version.vb                |   2 +-
 vbnc/vbnc/source/Members/Parameter.vb              |   2 +-
 .../source/TypeDeclarations/AssemblyDeclaration.vb |   2 +
 vbruntime/Microsoft.VisualBasic/AssemblyInfo.vb    |   8 +-
 vbruntime/Test/Makefile                            |   3 +-
 202 files changed, 4324 insertions(+), 3267 deletions(-)

diff --git a/build/library.make b/build/library.make
index f1ea35c..7e16bcc 100644
--- a/build/library.make
+++ b/build/library.make
@@ -229,7 +229,7 @@ dist-local: dist-default
 
 ifdef LIBRARY_NEEDS_POSTPROCESSING
 dist-local: dist-fixup
-FIXUP_PROFILES = default net_2_0
+FIXUP_PROFILES = default net_4_0
 dist-fixup:
 	$(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
 endif
diff --git a/build/profiles/net_2_0.make b/build/profiles/net_2_0.make
deleted file mode 100644
index 5a6086b..0000000
--- a/build/profiles/net_2_0.make
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- makefile -*-
-
-profile-check:
-	@:
-
-PROFILE_VBNC_FLAGS = /sdkpath:$(prefix)/lib/mono/2.0/
-FRAMEWORK_VERSION = 2.0
diff --git a/build/profiles/net_4_0.make b/build/profiles/net_4_0.make
deleted file mode 100644
index 275379e..0000000
--- a/build/profiles/net_4_0.make
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- makefile -*-
-
-profile-check:
-	@:
-
-PROFILE_VBNC_FLAGS = /sdkpath:$(prefix)/lib/mono/4.0/
-FRAMEWORK_VERSION = 4.0
diff --git a/build/rules.make b/build/rules.make
index 5af79b3..2eccdf4 100644
--- a/build/rules.make
+++ b/build/rules.make
@@ -30,7 +30,6 @@ INSTALL_LIB = $(INSTALL_BIN)
 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
 INTERNAL_MCS = mcs
 INTERNAL_VBNC = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/vbnc.exe
-INTERNAL_GMCS = gmcs
 INTERNAL_ILASM = ilasm
 INTERNAL_RESGEN = resgen
 corlib = mscorlib.dll
@@ -100,8 +99,8 @@ include $(topdir)/build/profiles/$(PROFILE).make
 -include $(topdir)/build/config.make
 
 
-# vbnc is built in one the profiles (currently net_2_0, this will likely change to net_4_0 soon)
-PROFILES = net_2_0 net_4_0 net_4_5 $(CONFIGURED_PROFILES)
+# vbnc is built in one the profiles
+PROFILES = $(CONFIGURED_PROFILES)
 PLATFORMS = linux win32
 
 
@@ -181,4 +180,4 @@ dll-sources:
 	cd Test; ls */*.cs > ../$(LIBRARY:.dll=_test.dll).sources; cd ..
 
 $(depsdir):
-	mkdir -p $(depsdir)
\ No newline at end of file
+	mkdir -p $(depsdir)
diff --git a/class/lib/bootstrap/Microsoft.VisualBasic.dll b/class/lib/bootstrap/Microsoft.VisualBasic.dll
index c7b36fc..f722be4 100644
Binary files a/class/lib/bootstrap/Microsoft.VisualBasic.dll and b/class/lib/bootstrap/Microsoft.VisualBasic.dll differ
diff --git a/class/lib/bootstrap/Microsoft.VisualBasic.dll.mdb b/class/lib/bootstrap/Microsoft.VisualBasic.dll.mdb
index 3117476..d54f701 100755
Binary files a/class/lib/bootstrap/Microsoft.VisualBasic.dll.mdb and b/class/lib/bootstrap/Microsoft.VisualBasic.dll.mdb differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll b/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll
index 3eafd36..ec0409d 100755
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll and b/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll.mdb b/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll.mdb
index 49f3abf..86ae1f6 100644
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll.mdb and b/class/lib/bootstrap/Mono.Cecil.VB.Mdb.dll.mdb differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll b/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll
index f829503..b47ee4d 100755
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll and b/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll.mdb b/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll.mdb
index a27887c..bf43973 100644
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll.mdb and b/class/lib/bootstrap/Mono.Cecil.VB.Pdb.dll.mdb differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.dll b/class/lib/bootstrap/Mono.Cecil.VB.dll
index b148fe8..024693b 100755
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.dll and b/class/lib/bootstrap/Mono.Cecil.VB.dll differ
diff --git a/class/lib/bootstrap/Mono.Cecil.VB.dll.mdb b/class/lib/bootstrap/Mono.Cecil.VB.dll.mdb
index 6a3c1c2..4457dfd 100644
Binary files a/class/lib/bootstrap/Mono.Cecil.VB.dll.mdb and b/class/lib/bootstrap/Mono.Cecil.VB.dll.mdb differ
diff --git a/class/lib/bootstrap/vbnc.exe b/class/lib/bootstrap/vbnc.exe
index afcd486..4f1cc4a 100644
Binary files a/class/lib/bootstrap/vbnc.exe and b/class/lib/bootstrap/vbnc.exe differ
diff --git a/class/lib/bootstrap/vbnc.exe.mdb b/class/lib/bootstrap/vbnc.exe.mdb
index bba9c07..7534944 100755
Binary files a/class/lib/bootstrap/vbnc.exe.mdb and b/class/lib/bootstrap/vbnc.exe.mdb differ
diff --git a/configure b/configure
index 920a914..782dd1d 100755
--- a/configure
+++ b/configure
@@ -1,8 +1,8 @@
 #!/bin/sh
 
-VERSION=3.8
+VERSION=4.0.1
 prefix=/usr/local
-configured_profiles=
+configured_profiles="net_4_5"
 moonlight_sdk_location=
 monotouch_sdk_location="`pwd`/../mono/mcs/class/lib/monotouch"
 monodroid_sdk_location="`pwd`/../mono/mcs/class/lib/monodroid"
@@ -41,6 +41,7 @@ while test x$1 != x; do
         shift
 done
 
+
 if test "x$moonlight_sdk_location" = "x"; then
 	if test "x`echo $configured_profiles | grep moonlight`" != "x"; then
 		echo Configure error: --with-moonlight=yes requires --moonlight-sdk-location
diff --git a/vbnc/cecil/Makefile b/vbnc/cecil/Makefile
index cf305a5..b22c1ad 100644
--- a/vbnc/cecil/Makefile
+++ b/vbnc/cecil/Makefile
@@ -4,14 +4,13 @@ SUBDIRS := symbols
 include ../../build/rules.make
 
 LIBRARY = Mono.Cecil.VB.dll
-LIBRARY_COMPILE = dmcs -keyfile:$(topdir)/$(thisdir)/mono.snk -d:CECIL -debug
+LIBRARY_COMPILE = mcs -keyfile:$(topdir)/$(thisdir)/mono.snk -d:CECIL -debug
 #LIBRARY_SNK = $(topdir)/$(thisdir)/mono.snk
 
 include ../../build/library.make
 
 DISTFILES = \
 	$(wildcard *.csproj)	\
-	NOTES.txt	\
 	mono.snk	\
 	Mono.Cecil.VB.dll.sources
 
diff --git a/vbnc/cecil/Mono.Cecil-SL.csproj b/vbnc/cecil/Mono.Cecil-SL.csproj
deleted file mode 100644
index e3fb85c..0000000
--- a/vbnc/cecil/Mono.Cecil-SL.csproj
+++ /dev/null
@@ -1,200 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
-  </PropertyGroup>
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{59019979-D337-441B-851F-2133452191A8}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Mono.Cecil</RootNamespace>
-    <AssemblyName>Mono.Cecil</AssemblyName>
-    <TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
-    <SilverlightApplication>false</SilverlightApplication>
-    <DefineConstants>TRACE;DEBUG;SILVERLIGHT</DefineConstants>
-    <NoStdLib>true</NoStdLib>
-    <NoConfig>true</NoConfig>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
-    <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
-    <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\DebugSL\</OutputPath>
-    <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\ReleaseSL\</OutputPath>
-    <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="mscorlib" />
-    <Reference Include="system" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Mono.Cecil.Cil\Code.cs" />
-    <Compile Include="Mono.Cecil.Cil\CodeWriter.cs" />
-    <Compile Include="Mono.Cecil.Cil\CodeReader.cs" />
-    <Compile Include="Mono.Cecil.Cil\Document.cs" />
-    <Compile Include="Mono.Cecil.Cil\ExceptionHandler.cs" />
-    <Compile Include="Mono.Cecil.Cil\ILProcessor.cs" />
-    <Compile Include="Mono.Cecil.Cil\Instruction.cs" />
-    <Compile Include="Mono.Cecil.Cil\MethodBody.cs" />
-    <Compile Include="Mono.Cecil.Cil\OpCode.cs" />
-    <Compile Include="Mono.Cecil.Cil\OpCodes.cs" />
-    <Compile Include="Mono.Cecil.Cil\SequencePoint.cs" />
-    <Compile Include="Mono.Cecil.Cil\Symbols.cs" />
-    <Compile Include="Mono.Cecil.Cil\VariableDefinition.cs" />
-    <Compile Include="Mono.Cecil.Cil\VariableReference.cs" />
-    <Compile Include="Mono.Cecil.Metadata\BlobHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Buffers.cs" />
-    <Compile Include="Mono.Cecil.Metadata\CodedIndex.cs" />
-    <Compile Include="Mono.Cecil.Metadata\ElementType.cs" />
-    <Compile Include="Mono.Cecil.Metadata\GuidHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Heap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\MetadataToken.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Row.cs" />
-    <Compile Include="Mono.Cecil.Metadata\StringHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\TableHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\TokenType.cs" />
-    <Compile Include="Mono.Cecil.Metadata\UserStringHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Utilities.cs" />
-    <Compile Include="Mono.Cecil.PE\BinaryStreamReader.cs" />
-    <Compile Include="Mono.Cecil.PE\BinaryStreamWriter.cs" />
-    <Compile Include="Mono.Cecil.PE\ByteBuffer.cs" />
-    <Compile Include="Mono.Cecil.PE\ByteBufferEqualityComparer.cs" />
-    <Compile Include="Mono.Cecil.PE\DataDirectory.cs" />
-    <Compile Include="Mono.Cecil.PE\Image.cs" />
-    <Compile Include="Mono.Cecil.PE\ImageReader.cs" />
-    <Compile Include="Mono.Cecil.PE\ImageWriter.cs" />
-    <Compile Include="Mono.Cecil.PE\Section.cs" />
-    <Compile Include="Mono.Cecil.PE\TextMap.cs" />
-    <Compile Include="Mono.Cecil\ArrayType.cs" />
-    <Compile Include="Mono.Cecil\AssemblyDefinition.cs" />
-    <Compile Include="Mono.Cecil\AssemblyFlags.cs" />
-    <Compile Include="Mono.Cecil\AssemblyHashAlgorithm.cs" />
-    <Compile Include="Mono.Cecil\AssemblyInfo.cs" />
-    <Compile Include="Mono.Cecil\AssemblyLinkedResource.cs" />
-    <Compile Include="Mono.Cecil\AssemblyNameDefinition.cs" />
-    <Compile Include="Mono.Cecil\AssemblyNameReference.cs" />
-    <Compile Include="Mono.Cecil\AssemblyReader.cs" />
-    <Compile Include="Mono.Cecil\AssemblyWriter.cs" />
-    <Compile Include="Mono.Cecil\BaseAssemblyResolver.cs" />
-    <Compile Include="Mono.Cecil\CallSite.cs" />
-    <Compile Include="Mono.Cecil\CustomAttribute.cs" />
-    <Compile Include="Mono.Cecil\DefaultAssemblyResolver.cs" />
-    <Compile Include="Mono.Cecil\ExportedType.cs" />
-    <Compile Include="Mono.Cecil\FileAttributes.cs" />
-    <Compile Include="Mono.Cecil\FunctionPointerType.cs" />
-    <Compile Include="Mono.Cecil\GenericInstanceMethod.cs" />
-    <Compile Include="Mono.Cecil\GenericInstanceType.cs" />
-    <Compile Include="Mono.Cecil\GenericParameter.cs" />
-    <Compile Include="Mono.Cecil\GenericParameterAttributes.cs" />
-    <Compile Include="Mono.Cecil\IConstantProvider.cs" />
-    <Compile Include="Mono.Cecil\ICustomAttributeProvider.cs" />
-    <Compile Include="Mono.Cecil\IGenericInstance.cs" />
-    <Compile Include="Mono.Cecil\IGenericParameterProvider.cs" />
-    <Compile Include="Mono.Cecil\IMarshalInfoProvider.cs" />
-    <Compile Include="Mono.Cecil\MarshalInfo.cs" />
-    <Compile Include="Mono.Cecil\MetadataResolver.cs" />
-    <Compile Include="Mono.Cecil\Modifiers.cs" />
-    <Compile Include="Mono.Cecil\NativeType.cs" />
-    <Compile Include="Mono.Cecil\PinnedType.cs" />
-    <Compile Include="Mono.Cecil\MetadataSystem.cs" />
-    <Compile Include="Mono.Cecil\IMethodSignature.cs" />
-    <Compile Include="Mono.Cecil\ParameterDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\EmbeddedResource.cs" />
-    <Compile Include="Mono.Cecil\EventAttributes.cs" />
-    <Compile Include="Mono.Cecil\EventDefinition.cs" />
-    <Compile Include="Mono.Cecil\EventReference.cs" />
-    <Compile Include="Mono.Cecil\FieldAttributes.cs" />
-    <Compile Include="Mono.Cecil\FieldDefinition.cs" />
-    <Compile Include="Mono.Cecil\FieldReference.cs" />
-    <Compile Include="Mono.Cecil\IMemberDefinition.cs" />
-    <Compile Include="Mono.Cecil\Import.cs" />
-    <Compile Include="Mono.Cecil\LinkedResource.cs" />
-    <Compile Include="Mono.Cecil\MemberReference.cs" />
-    <Compile Include="Mono.Cecil\MethodAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodCallingConvention.cs" />
-    <Compile Include="Mono.Cecil\MethodDefinition.cs" />
-    <Compile Include="Mono.Cecil\MethodImplAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodReference.cs" />
-    <Compile Include="Mono.Cecil\MethodReturnType.cs" />
-    <Compile Include="Mono.Cecil\MethodSemanticsAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodSpecification.cs" />
-    <Compile Include="Mono.Cecil\ParameterAttributes.cs" />
-    <Compile Include="Mono.Cecil\ParameterDefinition.cs" />
-    <Compile Include="Mono.Cecil\ParameterReference.cs" />
-    <Compile Include="Mono.Cecil\PInvokeAttributes.cs" />
-    <Compile Include="Mono.Cecil\PInvokeInfo.cs" />
-    <Compile Include="Mono.Cecil\PointerType.cs" />
-    <Compile Include="Mono.Cecil\PropertyAttributes.cs" />
-    <Compile Include="Mono.Cecil\PropertyDefinition.cs" />
-    <Compile Include="Mono.Cecil\PropertyReference.cs" />
-    <Compile Include="Mono.Cecil\ReferenceType.cs" />
-    <Compile Include="Mono.Cecil\IMetadataScope.cs" />
-    <Compile Include="Mono.Cecil\IMetadataTokenProvider.cs" />
-    <Compile Include="Mono.Cecil\ManifestResourceAttributes.cs" />
-    <Compile Include="Mono.Cecil\ModuleReference.cs" />
-    <Compile Include="Mono.Cecil\MemberDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\ModuleDefinition.cs" />
-    <Compile Include="Mono.Cecil\ModuleKind.cs" />
-    <Compile Include="Mono.Cecil\Resource.cs" />
-    <Compile Include="Mono.Cecil\SecurityDeclaration.cs" />
-    <Compile Include="Mono.Cecil\SentinelType.cs" />
-    <Compile Include="Mono.Cecil\TargetRuntime.cs" />
-    <Compile Include="Mono.Cecil\TypeAttributes.cs" />
-    <Compile Include="Mono.Cecil\TypeDefinition.cs" />
-    <Compile Include="Mono.Cecil\TypeDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\TypeParser.cs" />
-    <Compile Include="Mono.Cecil\TypeReference.cs" />
-    <Compile Include="Mono.Cecil\TypeSpecification.cs" />
-    <Compile Include="Mono.Cecil\TypeSystem.cs" />
-    <Compile Include="Mono.Cecil\VariantType.cs" />
-    <Compile Include="Mono.Collections.Generic\Collection.cs" />
-    <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" />
-    <Compile Include="Mono.Security.Cryptography\CryptoService.cs" />
-    <Compile Include="Mono\Actions.cs" />
-    <Compile Include="Mono\Empty.cs" />
-    <Compile Include="Mono\Funcs.cs" />
-    <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="NOTES.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="mono.snk" />
-  </ItemGroup>
-  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-  <ProjectExtensions>
-    <VisualStudio>
-      <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
-        <SilverlightProjectProperties />
-      </FlavorProperties>
-    </VisualStudio>
-  </ProjectExtensions>
-</Project>
\ No newline at end of file
diff --git a/vbnc/cecil/Mono.Cecil.Cil/Code.cs b/vbnc/cecil/Mono.Cecil.Cil/Code.cs
index bd18b84..fa88b63 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/Code.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/Code.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/CodeReader.cs b/vbnc/cecil/Mono.Cecil.Cil/CodeReader.cs
index c780cc7..12ca5a2 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/CodeReader.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/CodeReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -49,18 +49,13 @@ namespace Mono.Cecil.Cil {
 			get { return base.position - start; }
 		}
 
-		CodeReader (Section section, MetadataReader reader)
+		public CodeReader (Section section, MetadataReader reader)
 			: base (section.Data)
 		{
 			this.code_section = section;
 			this.reader = reader;
 		}
 
-		public static CodeReader CreateCodeReader (MetadataReader metadata)
-		{
-			return new CodeReader (metadata.image.MetadataSection, metadata);
-		}
-
 		public MethodBody ReadMethodBody (MethodDefinition method)
 		{
 			this.method = method;
@@ -107,7 +102,7 @@ namespace Mono.Cecil.Cil {
 				throw new InvalidOperationException ();
 			}
 
-			var symbol_reader = reader.module.SymbolReader;
+			var symbol_reader = reader.module.symbol_reader;
 
 			if (symbol_reader != null) {
 				var instructions = body.Instructions;
@@ -123,7 +118,7 @@ namespace Mono.Cecil.Cil {
 			body.local_var_token = new MetadataToken (ReadUInt32 ());
 			body.init_locals = (flags & 0x10) != 0;
 
-			if (body.LocalVarToken.RID != 0)
+			if (body.local_var_token.RID != 0)
 				body.variables = ReadVariables (body.local_var_token);
 
 			ReadCode ();
@@ -145,8 +140,12 @@ namespace Mono.Cecil.Cil {
 		{
 			start = position;
 			var code_size = body.code_size;
+
+			if (code_size < 0 || buffer.Length <= (uint) (code_size + position))
+				code_size = 0;
+
 			var end = start + code_size;
-			var instructions = body.instructions = new InstructionCollection (code_size / 3);
+			var instructions = body.instructions = new InstructionCollection ((code_size + 1) / 2);
 
 			while (position < end) {
 				var offset = base.position - start;
@@ -231,7 +230,7 @@ namespace Mono.Cecil.Cil {
 
 		public VariableDefinition GetVariable (int index)
 		{
-			return body.Variables [index];
+			return body.GetVariable (index);
 		}
 
 		public CallSite GetCallSite (MetadataToken token)
@@ -360,7 +359,6 @@ namespace Mono.Cecil.Cil {
 				break;
 			case ExceptionHandlerType.Filter:
 				handler.FilterStart = GetInstruction (ReadInt32 ());
-				handler.FilterEnd = handler.HandlerStart.Previous;
 				break;
 			default:
 				Advance (4);
@@ -411,7 +409,7 @@ namespace Mono.Cecil.Cil {
 				throw new NotSupportedException ();
 			}
 
-			var symbol_reader = reader.module.SymbolReader;
+			var symbol_reader = reader.module.symbol_reader;
 			if (symbol_reader != null && writer.metadata.write_symbols) {
 				symbols.method_token = GetOriginalToken (writer.metadata, method);
 				symbols.local_var_token = local_var_token;
diff --git a/vbnc/cecil/Mono.Cecil.Cil/CodeWriter.cs b/vbnc/cecil/Mono.Cecil.Cil/CodeWriter.cs
index 8ccef6d..ac093ca 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/CodeWriter.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/CodeWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -67,8 +67,12 @@ namespace Mono.Cecil.Cil {
 					return 0;
 
 				WriteUnresolvedMethodBody (method);
-			}  else
+			} else {
+				if (IsEmptyMethodBody (method.Body))
+					return 0;
+
 				WriteResolvedMethodBody (method);
+			}
 
 			Align (4);
 
@@ -76,6 +80,12 @@ namespace Mono.Cecil.Cil {
 			return rva;
 		}
 
+		static bool IsEmptyMethodBody (MethodBody body)
+		{
+			return body.instructions.IsNullOrEmpty ()
+				&& body.variables.IsNullOrEmpty ();
+		}
+
 		static bool IsUnresolved (MethodDefinition method)
 		{
 			return method.HasBody && method.HasImage && method.body == null;
@@ -414,10 +424,18 @@ namespace Mono.Cecil.Cil {
 			switch (instruction.opcode.FlowControl) {
 			case FlowControl.Call: {
 				var method = (IMethodSignature) instruction.operand;
-				stack_size -= (method.HasParameters ? method.Parameters.Count : 0)
-					+ (method.HasThis && instruction.opcode.Code != Code.Newobj ? 1 : 0);
-				stack_size += (method.ReturnType.etype == ElementType.Void ? 0 : 1)
-					+ (method.HasThis && instruction.opcode.Code == Code.Newobj ? 1 : 0);
+				// pop 'this' argument
+				if (method.HasImplicitThis() && instruction.opcode.Code != Code.Newobj)
+					stack_size--;
+				// pop normal arguments
+				if (method.HasParameters)
+					stack_size -= method.Parameters.Count;
+				// pop function pointer
+				if (instruction.opcode.Code == Code.Calli)
+					stack_size--;
+				// push return value
+				if (method.ReturnType.etype != ElementType.Void || instruction.opcode.Code == Code.Newobj)
+					stack_size++;
 				break;
 			}
 			default:
@@ -500,7 +518,7 @@ namespace Mono.Cecil.Cil {
 					return true;
 
 				if (handler.HandlerType == ExceptionHandlerType.Filter
-					&& IsFatRange (handler.FilterStart, handler.FilterEnd))
+					&& IsFatRange (handler.FilterStart, handler.HandlerStart))
 					return true;
 			}
 
@@ -509,6 +527,9 @@ namespace Mono.Cecil.Cil {
 
 		static bool IsFatRange (Instruction start, Instruction end)
 		{
+			if (start == null)
+				throw new ArgumentException ();
+
 			if (end == null)
 				return true;
 
diff --git a/vbnc/cecil/Mono.Cecil.Cil/Document.cs b/vbnc/cecil/Mono.Cecil.Cil/Document.cs
index e46d2c1..1dbdc44 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/Document.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/Document.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -54,6 +54,7 @@ namespace Mono.Cecil.Cil {
 		JScript,
 		Smc,
 		MCpp,
+		FSharp,
 	}
 
 	public enum DocumentLanguageVendor {
diff --git a/vbnc/cecil/Mono.Cecil.Cil/ExceptionHandler.cs b/vbnc/cecil/Mono.Cecil.Cil/ExceptionHandler.cs
index a76f8f3..c61ff23 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/ExceptionHandler.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/ExceptionHandler.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -40,7 +40,6 @@ namespace Mono.Cecil.Cil {
 		Instruction try_start;
 		Instruction try_end;
 		Instruction filter_start;
-		Instruction filter_end;
 		Instruction handler_start;
 		Instruction handler_end;
 
@@ -62,11 +61,6 @@ namespace Mono.Cecil.Cil {
 			set { filter_start = value; }
 		}
 
-		public Instruction FilterEnd {
-			get { return filter_end; }
-			set { filter_end = value; }
-		}
-
 		public Instruction HandlerStart {
 			get { return handler_start; }
 			set { handler_start = value; }
diff --git a/vbnc/cecil/Mono.Cecil.Cil/ILProcessor.cs b/vbnc/cecil/Mono.Cecil.Cil/ILProcessor.cs
index 1300b3e..cd5dbb4 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/ILProcessor.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/ILProcessor.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/Instruction.cs b/vbnc/cecil/Mono.Cecil.Cil/Instruction.cs
index e8d36c4..c28d4c9 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/Instruction.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/Instruction.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/MethodBody.cs b/vbnc/cecil/Mono.Cecil.Cil/MethodBody.cs
index b57900e..608fcbb 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/MethodBody.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/MethodBody.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.Threading;
 
 using Mono.Collections.Generic;
 
@@ -100,10 +101,26 @@ namespace Mono.Cecil.Cil {
 				if (method == null || method.DeclaringType == null)
 					throw new NotSupportedException ();
 
-				return this_parameter ?? (this_parameter = new ParameterDefinition ("0", ParameterAttributes.None, method.DeclaringType));
+				if (!method.HasThis)
+					return null;
+
+				if (this_parameter == null)
+					Interlocked.CompareExchange (ref this_parameter, CreateThisParameter (method), null);
+
+				return this_parameter;
 			}
 		}
 
+		static ParameterDefinition CreateThisParameter (MethodDefinition method)
+		{
+			var declaring_type = method.DeclaringType;
+			var type = declaring_type.IsValueType || declaring_type.IsPrimitive
+				? new PointerType (declaring_type)
+				: declaring_type as TypeReference;
+
+			return new ParameterDefinition (type, method);
+		}
+
 		public MethodBody (MethodDefinition method)
 		{
 			this.method = method;
diff --git a/vbnc/cecil/Mono.Cecil.Cil/OpCode.cs b/vbnc/cecil/Mono.Cecil.Cil/OpCode.cs
index aad4ba4..1a14421 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/OpCode.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/OpCode.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -116,7 +116,7 @@ namespace Mono.Cecil.Cil {
 		readonly byte stack_behavior_push;
 
 		public string Name {
-			get { return OpCodeNames.names [op1 == 0xff ? op2 : op2 + 256]; }
+			get { return OpCodeNames.names [(int) Code]; }
 		}
 
 		public int Size {
@@ -132,7 +132,7 @@ namespace Mono.Cecil.Cil {
 		}
 
 		public short Value {
-			get { return (short) ((op1 << 8) | op2); }
+			get { return op1 == 0xff ? op2 : (short) ((op1 << 8) | op2); }
 		}
 
 		public Code Code {
@@ -214,311 +214,242 @@ namespace Mono.Cecil.Cil {
 
 	static class OpCodeNames {
 
-		internal static readonly string [] names = {
-			"nop",
-			"break",
-			"ldarg.0",
-			"ldarg.1",
-			"ldarg.2",
-			"ldarg.3",
-			"ldloc.0",
-			"ldloc.1",
-			"ldloc.2",
-			"ldloc.3",
-			"stloc.0",
-			"stloc.1",
-			"stloc.2",
-			"stloc.3",
-			"ldarg.s",
-			"ldarga.s",
-			"starg.s",
-			"ldloc.s",
-			"ldloca.s",
-			"stloc.s",
-			"ldnull",
-			"ldc.i4.m1",
-			"ldc.i4.0",
-			"ldc.i4.1",
-			"ldc.i4.2",
-			"ldc.i4.3",
-			"ldc.i4.4",
-			"ldc.i4.5",
-			"ldc.i4.6",
-			"ldc.i4.7",
-			"ldc.i4.8",
-			"ldc.i4.s",
-			"ldc.i4",
-			"ldc.i8",
-			"ldc.r4",
-			"ldc.r8",
-			null,
-			"dup",
-			"pop",
-			"jmp",
-			"call",
-			"calli",
-			"ret",
-			"br.s",
-			"brfalse.s",
-			"brtrue.s",
-			"beq.s",
-			"bge.s",
-			"bgt.s",
-			"ble.s",
-			"blt.s",
-			"bne.un.s",
-			"bge.un.s",
-			"bgt.un.s",
-			"ble.un.s",
-			"blt.un.s",
-			"br",
-			"brfalse",
-			"brtrue",
-			"beq",
-			"bge",
-			"bgt",
-			"ble",
-			"blt",
-			"bne.un",
-			"bge.un",
-			"bgt.un",
-			"ble.un",
-			"blt.un",
-			"switch",
-			"ldind.i1",
-			"ldind.u1",
-			"ldind.i2",
-			"ldind.u2",
-			"ldind.i4",
-			"ldind.u4",
-			"ldind.i8",
-			"ldind.i",
-			"ldind.r4",
-			"ldind.r8",
-			"ldind.ref",
-			"stind.ref",
-			"stind.i1",
-			"stind.i2",
-			"stind.i4",
-			"stind.i8",
-			"stind.r4",
-			"stind.r8",
-			"add",
-			"sub",
-			"mul",
-			"div",
-			"div.un",
-			"rem",
-			"rem.un",
-			"and",
-			"or",
-			"xor",
-			"shl",
-			"shr",
-			"shr.un",
-			"neg",
-			"not",
-			"conv.i1",
-			"conv.i2",
-			"conv.i4",
-			"conv.i8",
-			"conv.r4",
-			"conv.r8",
-			"conv.u4",
-			"conv.u8",
-			"callvirt",
-			"cpobj",
-			"ldobj",
-			"ldstr",
-			"newobj",
-			"castclass",
-			"isinst",
-			"conv.r.un",
-			null,
-			null,
-			"unbox",
-			"throw",
-			"ldfld",
-			"ldflda",
-			"stfld",
-			"ldsfld",
-			"ldsflda",
-			"stsfld",
-			"stobj",
-			"conv.ovf.i1.un",
-			"conv.ovf.i2.un",
-			"conv.ovf.i4.un",
-			"conv.ovf.i8.un",
-			"conv.ovf.u1.un",
-			"conv.ovf.u2.un",
-			"conv.ovf.u4.un",
-			"conv.ovf.u8.un",
-			"conv.ovf.i.un",
-			"conv.ovf.u.un",
-			"box",
-			"newarr",
-			"ldlen",
-			"ldelema",
-			"ldelem.i1",
-			"ldelem.u1",
-			"ldelem.i2",
-			"ldelem.u2",
-			"ldelem.i4",
-			"ldelem.u4",
-			"ldelem.i8",
-			"ldelem.i",
-			"ldelem.r4",
-			"ldelem.r8",
-			"ldelem.ref",
-			"stelem.i",
-			"stelem.i1",
-			"stelem.i2",
-			"stelem.i4",
-			"stelem.i8",
-			"stelem.r4",
-			"stelem.r8",
-			"stelem.ref",
-			"ldelem.any",
-			"stelem.any",
-			"unbox.any",
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			"conv.ovf.i1",
-			"conv.ovf.u1",
-			"conv.ovf.i2",
-			"conv.ovf.u2",
-			"conv.ovf.i4",
-			"conv.ovf.u4",
-			"conv.ovf.i8",
-			"conv.ovf.u8",
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			"refanyval",
-			"ckfinite",
-			null,
-			null,
-			"mkrefany",
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			"ldtoken",
-			"conv.u2",
-			"conv.u1",
-			"conv.i",
-			"conv.ovf.i",
-			"conv.ovf.u",
-			"add.ovf",
-			"add.ovf.un",
-			"mul.ovf",
-			"mul.ovf.un",
-			"sub.ovf",
-			"sub.ovf.un",
-			"endfinally",
-			"leave",
-			"leave.s",
-			"stind.i",
-			"conv.u",
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			"prefix7",
-			"prefix6",
-			"prefix5",
-			"prefix4",
-			"prefix3",
-			"prefix2",
-			"prefix1",
-			"prefixref",
-			"arglist",
-			"ceq",
-			"cgt",
-			"cgt.un",
-			"clt",
-			"clt.un",
-			"ldftn",
-			"ldvirtftn",
-			null,
-			"ldarg",
-			"ldarga",
-			"starg",
-			"ldloc",
-			"ldloca",
-			"stloc",
-			"localloc",
-			null,
-			"endfilter",
-			"unaligned.",
-			"volatile.",
-			"tail.",
-			"initobj",
-			"constrained.",
-			"cpblk",
-			"initblk",
-			"no.",		// added by spouliot to match Cecil existing definitions
-			"rethrow",
-			null,
-			"sizeof",
-			"refanytype",
-			"readonly.",	// added by spouliot to match Cecil existing definitions
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-			null,
-		};
+		internal static readonly string [] names;
+
+		static OpCodeNames ()
+		{
+			var table = new byte [] {
+				3, 110, 111, 112,
+				5, 98, 114, 101, 97, 107,
+				7, 108, 100, 97, 114, 103, 46, 48,
+				7, 108, 100, 97, 114, 103, 46, 49,
+				7, 108, 100, 97, 114, 103, 46, 50,
+				7, 108, 100, 97, 114, 103, 46, 51,
+				7, 108, 100, 108, 111, 99, 46, 48,
+				7, 108, 100, 108, 111, 99, 46, 49,
+				7, 108, 100, 108, 111, 99, 46, 50,
+				7, 108, 100, 108, 111, 99, 46, 51,
+				7, 115, 116, 108, 111, 99, 46, 48,
+				7, 115, 116, 108, 111, 99, 46, 49,
+				7, 115, 116, 108, 111, 99, 46, 50,
+				7, 115, 116, 108, 111, 99, 46, 51,
+				7, 108, 100, 97, 114, 103, 46, 115,
+				8, 108, 100, 97, 114, 103, 97, 46, 115,
+				7, 115, 116, 97, 114, 103, 46, 115,
+				7, 108, 100, 108, 111, 99, 46, 115,
+				8, 108, 100, 108, 111, 99, 97, 46, 115,
+				7, 115, 116, 108, 111, 99, 46, 115,
+				6, 108, 100, 110, 117, 108, 108,
+				9, 108, 100, 99, 46, 105, 52, 46, 109, 49,
+				8, 108, 100, 99, 46, 105, 52, 46, 48,
+				8, 108, 100, 99, 46, 105, 52, 46, 49,
+				8, 108, 100, 99, 46, 105, 52, 46, 50,
+				8, 108, 100, 99, 46, 105, 52, 46, 51,
+				8, 108, 100, 99, 46, 105, 52, 46, 52,
+				8, 108, 100, 99, 46, 105, 52, 46, 53,
+				8, 108, 100, 99, 46, 105, 52, 46, 54,
+				8, 108, 100, 99, 46, 105, 52, 46, 55,
+				8, 108, 100, 99, 46, 105, 52, 46, 56,
+				8, 108, 100, 99, 46, 105, 52, 46, 115,
+				6, 108, 100, 99, 46, 105, 52,
+				6, 108, 100, 99, 46, 105, 56,
+				6, 108, 100, 99, 46, 114, 52,
+				6, 108, 100, 99, 46, 114, 56,
+				3, 100, 117, 112,
+				3, 112, 111, 112,
+				3, 106, 109, 112,
+				4, 99, 97, 108, 108,
+				5, 99, 97, 108, 108, 105,
+				3, 114, 101, 116,
+				4, 98, 114, 46, 115,
+				9, 98, 114, 102, 97, 108, 115, 101, 46, 115,
+				8, 98, 114, 116, 114, 117, 101, 46, 115,
+				5, 98, 101, 113, 46, 115,
+				5, 98, 103, 101, 46, 115,
+				5, 98, 103, 116, 46, 115,
+				5, 98, 108, 101, 46, 115,
+				5, 98, 108, 116, 46, 115,
+				8, 98, 110, 101, 46, 117, 110, 46, 115,
+				8, 98, 103, 101, 46, 117, 110, 46, 115,
+				8, 98, 103, 116, 46, 117, 110, 46, 115,
+				8, 98, 108, 101, 46, 117, 110, 46, 115,
+				8, 98, 108, 116, 46, 117, 110, 46, 115,
+				2, 98, 114,
+				7, 98, 114, 102, 97, 108, 115, 101,
+				6, 98, 114, 116, 114, 117, 101,
+				3, 98, 101, 113,
+				3, 98, 103, 101,
+				3, 98, 103, 116,
+				3, 98, 108, 101,
+				3, 98, 108, 116,
+				6, 98, 110, 101, 46, 117, 110,
+				6, 98, 103, 101, 46, 117, 110,
+				6, 98, 103, 116, 46, 117, 110,
+				6, 98, 108, 101, 46, 117, 110,
+				6, 98, 108, 116, 46, 117, 110,
+				6, 115, 119, 105, 116, 99, 104,
+				8, 108, 100, 105, 110, 100, 46, 105, 49,
+				8, 108, 100, 105, 110, 100, 46, 117, 49,
+				8, 108, 100, 105, 110, 100, 46, 105, 50,
+				8, 108, 100, 105, 110, 100, 46, 117, 50,
+				8, 108, 100, 105, 110, 100, 46, 105, 52,
+				8, 108, 100, 105, 110, 100, 46, 117, 52,
+				8, 108, 100, 105, 110, 100, 46, 105, 56,
+				7, 108, 100, 105, 110, 100, 46, 105,
+				8, 108, 100, 105, 110, 100, 46, 114, 52,
+				8, 108, 100, 105, 110, 100, 46, 114, 56,
+				9, 108, 100, 105, 110, 100, 46, 114, 101, 102,
+				9, 115, 116, 105, 110, 100, 46, 114, 101, 102,
+				8, 115, 116, 105, 110, 100, 46, 105, 49,
+				8, 115, 116, 105, 110, 100, 46, 105, 50,
+				8, 115, 116, 105, 110, 100, 46, 105, 52,
+				8, 115, 116, 105, 110, 100, 46, 105, 56,
+				8, 115, 116, 105, 110, 100, 46, 114, 52,
+				8, 115, 116, 105, 110, 100, 46, 114, 56,
+				3, 97, 100, 100,
+				3, 115, 117, 98,
+				3, 109, 117, 108,
+				3, 100, 105, 118,
+				6, 100, 105, 118, 46, 117, 110,
+				3, 114, 101, 109,
+				6, 114, 101, 109, 46, 117, 110,
+				3, 97, 110, 100,
+				2, 111, 114,
+				3, 120, 111, 114,
+				3, 115, 104, 108,
+				3, 115, 104, 114,
+				6, 115, 104, 114, 46, 117, 110,
+				3, 110, 101, 103,
+				3, 110, 111, 116,
+				7, 99, 111, 110, 118, 46, 105, 49,
+				7, 99, 111, 110, 118, 46, 105, 50,
+				7, 99, 111, 110, 118, 46, 105, 52,
+				7, 99, 111, 110, 118, 46, 105, 56,
+				7, 99, 111, 110, 118, 46, 114, 52,
+				7, 99, 111, 110, 118, 46, 114, 56,
+				7, 99, 111, 110, 118, 46, 117, 52,
+				7, 99, 111, 110, 118, 46, 117, 56,
+				8, 99, 97, 108, 108, 118, 105, 114, 116,
+				5, 99, 112, 111, 98, 106,
+				5, 108, 100, 111, 98, 106,
+				5, 108, 100, 115, 116, 114,
+				6, 110, 101, 119, 111, 98, 106,
+				9, 99, 97, 115, 116, 99, 108, 97, 115, 115,
+				6, 105, 115, 105, 110, 115, 116,
+				9, 99, 111, 110, 118, 46, 114, 46, 117, 110,
+				5, 117, 110, 98, 111, 120,
+				5, 116, 104, 114, 111, 119,
+				5, 108, 100, 102, 108, 100,
+				6, 108, 100, 102, 108, 100, 97,
+				5, 115, 116, 102, 108, 100,
+				6, 108, 100, 115, 102, 108, 100,
+				7, 108, 100, 115, 102, 108, 100, 97,
+				6, 115, 116, 115, 102, 108, 100,
+				5, 115, 116, 111, 98, 106,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52, 46, 117, 110,
+				14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56, 46, 117, 110,
+				13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 46, 117, 110,
+				13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 46, 117, 110,
+				3, 98, 111, 120,
+				6, 110, 101, 119, 97, 114, 114,
+				5, 108, 100, 108, 101, 110,
+				7, 108, 100, 101, 108, 101, 109, 97,
+				9, 108, 100, 101, 108, 101, 109, 46, 105, 49,
+				9, 108, 100, 101, 108, 101, 109, 46, 117, 49,
+				9, 108, 100, 101, 108, 101, 109, 46, 105, 50,
+				9, 108, 100, 101, 108, 101, 109, 46, 117, 50,
+				9, 108, 100, 101, 108, 101, 109, 46, 105, 52,
+				9, 108, 100, 101, 108, 101, 109, 46, 117, 52,
+				9, 108, 100, 101, 108, 101, 109, 46, 105, 56,
+				8, 108, 100, 101, 108, 101, 109, 46, 105,
+				9, 108, 100, 101, 108, 101, 109, 46, 114, 52,
+				9, 108, 100, 101, 108, 101, 109, 46, 114, 56,
+				10, 108, 100, 101, 108, 101, 109, 46, 114, 101, 102,
+				8, 115, 116, 101, 108, 101, 109, 46, 105,
+				9, 115, 116, 101, 108, 101, 109, 46, 105, 49,
+				9, 115, 116, 101, 108, 101, 109, 46, 105, 50,
+				9, 115, 116, 101, 108, 101, 109, 46, 105, 52,
+				9, 115, 116, 101, 108, 101, 109, 46, 105, 56,
+				9, 115, 116, 101, 108, 101, 109, 46, 114, 52,
+				9, 115, 116, 101, 108, 101, 109, 46, 114, 56,
+				10, 115, 116, 101, 108, 101, 109, 46, 114, 101, 102,
+				10, 108, 100, 101, 108, 101, 109, 46, 97, 110, 121,
+				10, 115, 116, 101, 108, 101, 109, 46, 97, 110, 121,
+				9, 117, 110, 98, 111, 120, 46, 97, 110, 121,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56,
+				11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56,
+				9, 114, 101, 102, 97, 110, 121, 118, 97, 108,
+				8, 99, 107, 102, 105, 110, 105, 116, 101,
+				8, 109, 107, 114, 101, 102, 97, 110, 121,
+				7, 108, 100, 116, 111, 107, 101, 110,
+				7, 99, 111, 110, 118, 46, 117, 50,
+				7, 99, 111, 110, 118, 46, 117, 49,
+				6, 99, 111, 110, 118, 46, 105,
+				10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105,
+				10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117,
+				7, 97, 100, 100, 46, 111, 118, 102,
+				10, 97, 100, 100, 46, 111, 118, 102, 46, 117, 110,
+				7, 109, 117, 108, 46, 111, 118, 102,
+				10, 109, 117, 108, 46, 111, 118, 102, 46, 117, 110,
+				7, 115, 117, 98, 46, 111, 118, 102,
+				10, 115, 117, 98, 46, 111, 118, 102, 46, 117, 110,
+				10, 101, 110, 100, 102, 105, 110, 97, 108, 108, 121,
+				5, 108, 101, 97, 118, 101,
+				7, 108, 101, 97, 118, 101, 46, 115,
+				7, 115, 116, 105, 110, 100, 46, 105,
+				6, 99, 111, 110, 118, 46, 117,
+				7, 97, 114, 103, 108, 105, 115, 116,
+				3, 99, 101, 113,
+				3, 99, 103, 116,
+				6, 99, 103, 116, 46, 117, 110,
+				3, 99, 108, 116,
+				6, 99, 108, 116, 46, 117, 110,
+				5, 108, 100, 102, 116, 110,
+				9, 108, 100, 118, 105, 114, 116, 102, 116, 110,
+				5, 108, 100, 97, 114, 103,
+				6, 108, 100, 97, 114, 103, 97,
+				5, 115, 116, 97, 114, 103,
+				5, 108, 100, 108, 111, 99,
+				6, 108, 100, 108, 111, 99, 97,
+				5, 115, 116, 108, 111, 99,
+				8, 108, 111, 99, 97, 108, 108, 111, 99,
+				9, 101, 110, 100, 102, 105, 108, 116, 101, 114,
+				10, 117, 110, 97, 108, 105, 103, 110, 101, 100, 46,
+				9, 118, 111, 108, 97, 116, 105, 108, 101, 46,
+				5, 116, 97, 105, 108, 46,
+				7, 105, 110, 105, 116, 111, 98, 106,
+				12, 99, 111, 110, 115, 116, 114, 97, 105, 110, 101, 100, 46,
+				5, 99, 112, 98, 108, 107,
+				7, 105, 110, 105, 116, 98, 108, 107,
+				3, 110, 111, 46,
+				7, 114, 101, 116, 104, 114, 111, 119,
+				6, 115, 105, 122, 101, 111, 102,
+				10, 114, 101, 102, 97, 110, 121, 116, 121, 112, 101,
+				9, 114, 101, 97, 100, 111, 110, 108, 121, 46,
+			};
+
+			names = new string [219];
+
+			for (int i = 0, p = 0; i < names.Length; i++) {
+				var buffer = new char [table [p++]];
+
+				for (int j = 0; j < buffer.Length; j++)
+					buffer [j] = (char) table [p++];
+
+				names [i] = new string (buffer);
+			}
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil.Cil/OpCodes.cs b/vbnc/cecil/Mono.Cecil.Cil/OpCodes.cs
index ce468a1..85712ec 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/OpCodes.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/OpCodes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/SequencePoint.cs b/vbnc/cecil/Mono.Cecil.Cil/SequencePoint.cs
index 189b5f5..ef87e30 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/SequencePoint.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/SequencePoint.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/Symbols.cs b/vbnc/cecil/Mono.Cecil.Cil/Symbols.cs
index 4251d4d..68c7502 100755
--- a/vbnc/cecil/Mono.Cecil.Cil/Symbols.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/Symbols.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -151,10 +151,15 @@ namespace Mono.Cecil.Cil {
 			get { return local_var_token; }
 		}
 
-		public MethodSymbols (string methodName)
+		internal MethodSymbols (string methodName)
 		{
 			this.method_name = methodName;
 		}
+
+		public MethodSymbols (MetadataToken methodToken)
+		{
+			this.method_token = methodToken;
+		}
 	}
 
 	public delegate Instruction InstructionMapper (int offset);
diff --git a/vbnc/cecil/Mono.Cecil.Cil/VariableDefinition.cs b/vbnc/cecil/Mono.Cecil.Cil/VariableDefinition.cs
index 690543e..f501bca 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/VariableDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/VariableDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Cil/VariableReference.cs b/vbnc/cecil/Mono.Cecil.Cil/VariableReference.cs
index 5453845..ce0b4cd 100644
--- a/vbnc/cecil/Mono.Cecil.Cil/VariableReference.cs
+++ b/vbnc/cecil/Mono.Cecil.Cil/VariableReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/BlobHeap.cs b/vbnc/cecil/Mono.Cecil.Metadata/BlobHeap.cs
index 94e5f0a..28670d7 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/BlobHeap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/BlobHeap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/Buffers.cs b/vbnc/cecil/Mono.Cecil.Metadata/Buffers.cs
index e8759d7..b63412d 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/Buffers.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/Buffers.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -261,7 +261,7 @@ namespace Mono.Cecil.Metadata {
 	abstract class HeapBuffer : ByteBuffer {
 
 		public bool IsLarge {
-			get { return base.length > 65536; }
+			get { return base.length > 65535; }
 		}
 
 		public abstract bool IsEmpty { get; }
@@ -274,7 +274,7 @@ namespace Mono.Cecil.Metadata {
 
 	class StringHeapBuffer : HeapBuffer {
 
-		readonly Dictionary<string, uint> strings = new Dictionary<string, uint> ();
+		readonly Dictionary<string, uint> strings = new Dictionary<string, uint> (StringComparer.Ordinal);
 
 		public sealed override bool IsEmpty {
 			get { return length <= 1; }
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/CodedIndex.cs b/vbnc/cecil/Mono.Cecil.Metadata/CodedIndex.cs
index f93b5a2..f79e9d7 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/CodedIndex.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/CodedIndex.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/ElementType.cs b/vbnc/cecil/Mono.Cecil.Metadata/ElementType.cs
index 1ede042..72fc1cc 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/ElementType.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/ElementType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/GuidHeap.cs b/vbnc/cecil/Mono.Cecil.Metadata/GuidHeap.cs
index 983a575..3a33fdf 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/GuidHeap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/GuidHeap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/Heap.cs b/vbnc/cecil/Mono.Cecil.Metadata/Heap.cs
index 80ec5b1..fcaf634 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/Heap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/Heap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/MetadataToken.cs b/vbnc/cecil/Mono.Cecil.Metadata/MetadataToken.cs
index 8c1338e..bda56b0 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/MetadataToken.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/MetadataToken.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/Row.cs b/vbnc/cecil/Mono.Cecil.Metadata/Row.cs
index ab491a6..dfda00a 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/Row.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/Row.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/StringHeap.cs b/vbnc/cecil/Mono.Cecil.Metadata/StringHeap.cs
index 200b92e..05b3ce3 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/StringHeap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/StringHeap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/TableHeap.cs b/vbnc/cecil/Mono.Cecil.Metadata/TableHeap.cs
index 888a0cd..69e3711 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/TableHeap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/TableHeap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -62,6 +62,8 @@ namespace Mono.Cecil.Metadata {
 		TypeSpec = 0x1b,
 		ImplMap = 0x1c,
 		FieldRVA = 0x1d,
+		EncLog = 0x1e,
+		EncMap = 0x1f,
 		Assembly = 0x20,
 		AssemblyProcessor = 0x21,
 		AssemblyOS = 0x22,
@@ -88,53 +90,9 @@ namespace Mono.Cecil.Metadata {
 		public long Valid;
 		public long Sorted;
 
-		public static readonly Table [] TableIdentifiers = new [] {
-			Table.Module,
-			Table.TypeRef,
-			Table.TypeDef,
-			Table.FieldPtr,
-			Table.Field,
-			Table.MethodPtr,
-			Table.Method,
-			Table.ParamPtr,
-			Table.Param,
-			Table.InterfaceImpl,
-			Table.MemberRef,
-			Table.Constant,
-			Table.CustomAttribute,
-			Table.FieldMarshal,
-			Table.DeclSecurity,
-			Table.ClassLayout,
-			Table.FieldLayout,
-			Table.StandAloneSig,
-			Table.EventMap,
-			Table.EventPtr,
-			Table.Event,
-			Table.PropertyMap,
-			Table.PropertyPtr,
-			Table.Property,
-			Table.MethodSemantics,
-			Table.MethodImpl,
-			Table.ModuleRef,
-			Table.TypeSpec,
-			Table.ImplMap,
-			Table.FieldRVA,
-			Table.Assembly,
-			Table.AssemblyProcessor,
-			Table.AssemblyOS,
-			Table.AssemblyRef,
-			Table.AssemblyRefProcessor,
-			Table.AssemblyRefOS,
-			Table.File,
-			Table.ExportedType,
-			Table.ManifestResource,
-			Table.NestedClass,
-			Table.GenericParam,
-			Table.MethodSpec,
-			Table.GenericParamConstraint,
-		};
+		public const int TableCount = 45;
 
-		public readonly TableInformation [] Tables = new TableInformation [45];
+		public readonly TableInformation [] Tables = new TableInformation [TableCount];
 
 		public TableInformation this [Table table] {
 			get { return Tables [(int) table]; }
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/TokenType.cs b/vbnc/cecil/Mono.Cecil.Metadata/TokenType.cs
index f822b6d..2c2010f 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/TokenType.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/TokenType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/UserStringHeap.cs b/vbnc/cecil/Mono.Cecil.Metadata/UserStringHeap.cs
index aa03189..c63b5ac 100755
--- a/vbnc/cecil/Mono.Cecil.Metadata/UserStringHeap.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/UserStringHeap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.Metadata/Utilities.cs b/vbnc/cecil/Mono.Cecil.Metadata/Utilities.cs
index 496c61b..d752b24 100644
--- a/vbnc/cecil/Mono.Cecil.Metadata/Utilities.cs
+++ b/vbnc/cecil/Mono.Cecil.Metadata/Utilities.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.PE/BinaryStreamReader.cs b/vbnc/cecil/Mono.Cecil.PE/BinaryStreamReader.cs
index 8f5b38e..ec2477c 100644
--- a/vbnc/cecil/Mono.Cecil.PE/BinaryStreamReader.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/BinaryStreamReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs b/vbnc/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
index 37189cb..2bf6ccc 100644
--- a/vbnc/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.PE/ByteBuffer.cs b/vbnc/cecil/Mono.Cecil.PE/ByteBuffer.cs
index 4303b6d..c7ae7ae 100644
--- a/vbnc/cecil/Mono.Cecil.PE/ByteBuffer.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/ByteBuffer.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -140,11 +140,16 @@ namespace Mono.Cecil.PE {
 
 		public int ReadCompressedInt32 ()
 		{
-			var value = (int) ReadCompressedUInt32 ();
-
-			return (value & 1) != 0
-				? -(value >> 1)
-				: value >> 1;
+			var value = (int) (ReadCompressedUInt32 () >> 1);
+			if ((value & 1) == 0)
+				return value;
+			if (value < 0x40)
+				return value - 0x40;
+			if (value < 0x2000)
+				return value - 0x2000;
+			if (value < 0x10000000)
+				return value - 0x10000000;
+			return value - 0x20000000;
 		}
 
 		public float ReadSingle ()
@@ -267,7 +272,19 @@ namespace Mono.Cecil.PE {
 
 		public void WriteCompressedInt32 (int value)
 		{
-			WriteCompressedUInt32 ((uint) ((value < 0) ? ((-value) << 1) | 1 : value << 1));
+			if (value >= 0) {
+				WriteCompressedUInt32 ((uint) (value << 1));
+				return;
+			}
+
+			if (value > -0x40)
+				value = 0x40 + value;
+			else if (value >= -0x2000)
+				value = 0x2000 + value;
+			else if (value >= -0x20000000)
+				value = 0x20000000 + value;
+
+			WriteCompressedUInt32 ((uint) ((value << 1) | 1));
 		}
 
 		public void WriteBytes (byte [] bytes)
diff --git a/vbnc/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs b/vbnc/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
index fd78025..70e8916 100644
--- a/vbnc/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -50,12 +50,29 @@ namespace Mono.Cecil.PE {
 
 		public int GetHashCode (ByteBuffer buffer)
 		{
+#if !BYTE_BUFFER_WELL_DISTRIBUTED_HASH
 			var hash = 0;
 			var bytes = buffer.buffer;
 			for (int i = 0; i < buffer.length; i++)
 				hash = (hash * 37) ^ bytes [i];
 
 			return hash;
+#else
+			const uint p = 16777619;
+			uint hash = 2166136261;
+
+			var bytes = buffer.buffer;
+			for (int i = 0; i < buffer.length; i++)
+			    hash = (hash ^ bytes [i]) * p;
+
+			hash += hash << 13;
+			hash ^= hash >> 7;
+			hash += hash << 3;
+			hash ^= hash >> 17;
+			hash += hash << 5;
+
+			return (int) hash;
+#endif
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil.PE/DataDirectory.cs b/vbnc/cecil/Mono.Cecil.PE/DataDirectory.cs
index a1676b1..6e0cb49 100755
--- a/vbnc/cecil/Mono.Cecil.PE/DataDirectory.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/DataDirectory.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.PE/Image.cs b/vbnc/cecil/Mono.Cecil.PE/Image.cs
index 93768df..dfdbd7c 100755
--- a/vbnc/cecil/Mono.Cecil.PE/Image.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/Image.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -39,8 +39,9 @@ namespace Mono.Cecil.PE {
 	public sealed class Image {
 
 		public ModuleKind Kind;
-		public TargetRuntime Runtime;
+		public string RuntimeVersion;
 		public TargetArchitecture Architecture;
+		public ModuleCharacteristics Characteristics;
 		public string FileName;
 
 		public Section [] Sections;
@@ -52,6 +53,7 @@ namespace Mono.Cecil.PE {
 
 		public DataDirectory Debug;
 		public DataDirectory Resources;
+		public DataDirectory StrongName;
 
 		public StringHeap StringHeap;
 		public BlobHeap BlobHeap;
@@ -148,6 +150,11 @@ namespace Mono.Cecil.PE {
 				PointerToRawData = buffer.ReadInt32 (),
 			};
 
+			if (directory.SizeOfData == 0 || directory.PointerToRawData == 0) {
+				header = Empty<byte>.Array;
+				return directory;
+			}
+
 			buffer.position = (int) (directory.PointerToRawData - section.PointerToRawData);
 
 			header = new byte [directory.SizeOfData];
diff --git a/vbnc/cecil/Mono.Cecil.PE/ImageReader.cs b/vbnc/cecil/Mono.Cecil.PE/ImageReader.cs
index a228c1f..42e924e 100644
--- a/vbnc/cecil/Mono.Cecil.PE/ImageReader.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/ImageReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -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 ()
@@ -118,6 +119,8 @@ namespace Mono.Cecil.PE {
 				return TargetArchitecture.AMD64;
 			case 0x0200:
 				return TargetArchitecture.IA64;
+			case 0x01c4:
+				return TargetArchitecture.ARMv7;
 			}
 
 			throw new NotSupportedException ();
@@ -134,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
@@ -174,6 +177,7 @@ namespace Mono.Cecil.PE {
 			subsystem = ReadUInt16 ();
 
 			// DLLFlags				2
+			dll_characteristics = ReadUInt16 ();
 			// StackReserveSize		4 || 8
 			// StackCommitSize		4 || 8
 			// HeapReserveSize		4 || 8
@@ -190,7 +194,7 @@ namespace Mono.Cecil.PE {
 			// CertificateTable		8
 			// BaseRelocationTable	8
 
-			Advance (pe64 ? 90 : 74);
+			Advance (pe64 ? 88 : 72);
 
 			// Debug				8
 			image.Debug = ReadDataDirectory ();
@@ -276,9 +280,6 @@ namespace Mono.Cecil.PE {
 
 				sections [i] = section;
 
-				if (section.Name == ".reloc")
-					continue;
-
 				ReadSectionData (section);
 			}
 
@@ -323,6 +324,7 @@ namespace Mono.Cecil.PE {
 			// Resources				8
 			image.Resources = ReadDataDirectory ();
 			// StrongNameSignature		8
+			image.StrongName = ReadDataDirectory ();
 			// CodeManagerTable			8
 			// VTableFixups				8
 			// ExportAddressTableJumps	8
@@ -341,8 +343,7 @@ namespace Mono.Cecil.PE {
 			// Reserved				4
 			Advance (8);
 
-			var version = ReadZeroTerminatedString (ReadInt32 ());
-			image.Runtime = version.ParseRuntime ();
+			image.RuntimeVersion = ReadZeroTerminatedString (ReadInt32 ());
 
 			// Flags		2
 			Advance (2);
@@ -416,12 +417,11 @@ namespace Mono.Cecil.PE {
 			// Sorted			8
 			heap.Sorted = ReadInt64 ();
 
-			for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
-				var table = TableHeap.TableIdentifiers [i];
-				if (!heap.HasTable (table))
+			for (int i = 0; i < TableHeap.TableCount; i++) {
+				if (!heap.HasTable ((Table) i))
 					continue;
 
-				heap.Tables [(int) table].Length = ReadUInt32 ();
+				heap.Tables [i].Length = ReadUInt32 ();
 			}
 
 			SetIndexSize (image.StringHeap, sizes, 0x1);
@@ -459,8 +459,8 @@ namespace Mono.Cecil.PE {
 			var heap = image.TableHeap;
 			var tables = heap.Tables;
 
-			for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
-				var table = TableHeap.TableIdentifiers [i];
+			for (int i = 0; i < TableHeap.TableCount; i++) {
+				var table = (Table) i;
 				if (!heap.HasTable (table))
 					continue;
 
@@ -595,6 +595,12 @@ namespace Mono.Cecil.PE {
 					size = 4	// RVA
 						+ GetTableIndexSize (Table.Field);	// Field
 					break;
+				case Table.EncLog:
+					size = 8;
+					break;
+				case Table.EncMap:
+					size = 4;
+					break;
 				case Table.Assembly:
 					size = 16 // HashAlgId 4, Version 4 * 2, Flags 4
 						+ blobidx_size	// PublicKey
@@ -655,12 +661,10 @@ namespace Mono.Cecil.PE {
 					throw new NotSupportedException ();
 				}
 
-				int index = (int) table;
-
-				tables [index].RowSize = (uint) size;
-				tables [index].Offset = offset;
+				tables [i].RowSize = (uint) size;
+				tables [i].Offset = offset;
 
-				offset += (uint) size * tables [index].Length;
+				offset += (uint) size * tables [i].Length;
 			}
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil.PE/ImageWriter.cs b/vbnc/cecil/Mono.Cecil.PE/ImageWriter.cs
index f948608..4506d8d 100755
--- a/vbnc/cecil/Mono.Cecil.PE/ImageWriter.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/ImageWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -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.AMD64 || module.Architecture == TargetArchitecture.IA64;
+			this.has_reloc = module.Architecture == TargetArchitecture.I386;
 			this.GetDebugHeader ();
 			this.GetWin32Resources ();
 			this.text_map = BuildTextMap ();
-			this.sections = 2; // text + reloc
-			this.pe64 = module.Architecture != TargetArchitecture.I386;
+			this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
 			this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
 		}
 
@@ -139,7 +141,8 @@ namespace Mono.Cecil.PE {
 				previous = rsrc;
 			}
 
-			reloc = CreateSection (".reloc", 12u, previous);
+			if (has_reloc)
+				reloc = CreateSection (".reloc", 12u, previous);
 		}
 
 		Section CreateSection (string name, uint size, Section previous)
@@ -218,25 +221,36 @@ namespace Mono.Cecil.PE {
 				return 0x8664;
 			case TargetArchitecture.IA64:
 				return 0x0200;
+			case TargetArchitecture.ARMv7:
+				return 0x01c4;
 			}
 
 			throw new NotSupportedException ();
 		}
 
+		Section LastSection ()
+		{
+			if (reloc != null)
+				return reloc;
+
+			if (rsrc != null)
+				return rsrc;
+
+			return text;
+		}
+
 		void WriteOptionalHeaders ()
 		{
 			WriteUInt16 ((ushort) (!pe64 ? 0x10b : 0x20b));	// Magic
 			WriteByte (8);	// LMajor
 			WriteByte (0);	// LMinor
 			WriteUInt32 (text.SizeOfRawData);	// CodeSize
-			WriteUInt32 (reloc.SizeOfRawData
+			WriteUInt32 ((reloc != null ? reloc.SizeOfRawData : 0)
 				+ (rsrc != null ? rsrc.SizeOfRawData : 0));	// InitializedDataSize
 			WriteUInt32 (0);	// UninitializedDataSize
 
-			var entry_point_rva = text_map.GetRVA (TextSegment.StartupStub);
-			if (module.Architecture == TargetArchitecture.IA64)
-				entry_point_rva += 0x20;
-			WriteUInt32 (entry_point_rva); // EntryPointRVA
+			var startub_stub = text_map.GetRange (TextSegment.StartupStub);
+			WriteUInt32 (startub_stub.Length > 0 ? startub_stub.Start : 0);  // EntryPointRVA
 			WriteUInt32 (text_rva);	// BaseOfCode
 
 			if (!pe64) {
@@ -257,12 +271,13 @@ namespace Mono.Cecil.PE {
 			WriteUInt16 (0);	// SubSysMinor
 			WriteUInt32 (0);	// Reserved
 
-			WriteUInt32 (reloc.VirtualAddress + Align (reloc.VirtualSize, section_alignment));	// ImageSize
+			var last_section = LastSection();
+			WriteUInt32 (last_section.VirtualAddress + Align (last_section.VirtualSize, section_alignment));	// ImageSize
 			WriteUInt32 (text.PointerToRawData);	// HeaderSize
 
 			WriteUInt32 (0);	// Checksum
 			WriteUInt16 (GetSubSystem ());	// SubSystem
-			WriteUInt16 (0x8540);	// DLLFlags
+			WriteUInt16 ((ushort) module.Characteristics);	// DLLFlags
 
 			const ulong stack_reserve = 0x100000;
 			const ulong stack_commit = 0x1000;
@@ -294,8 +309,8 @@ namespace Mono.Cecil.PE {
 
 			WriteZeroDataDirectory ();	// ExceptionTable
 			WriteZeroDataDirectory ();	// CertificateTable
-			WriteUInt32 (reloc.VirtualAddress);			// BaseRelocationTable
-			WriteUInt32 (reloc.VirtualSize);
+			WriteUInt32 (reloc != null ? reloc.VirtualAddress : 0);			// BaseRelocationTable
+			WriteUInt32 (reloc != null ? reloc.VirtualSize : 0);
 
 			if (text_map.GetLength (TextSegment.DebugDirectory) > 0) {
 				WriteUInt32 (text_map.GetRVA (TextSegment.DebugDirectory));
@@ -341,7 +356,8 @@ namespace Mono.Cecil.PE {
 			if (rsrc != null)
 				WriteSection (rsrc, 0x40000040);
 
-			WriteSection (reloc, 0x42000040);
+			if (reloc != null)
+				WriteSection (reloc, 0x42000040);
 		}
 
 		void WriteSection (Section section, uint characteristics)
@@ -386,14 +402,39 @@ namespace Mono.Cecil.PE {
 				WriteUInt64 (rva);
 		}
 
+		void PrepareSection (Section section)
+		{
+			MoveTo (section.PointerToRawData);
+
+			const int buffer_size = 4096;
+
+			if (section.SizeOfRawData <= buffer_size) {
+				Write (new byte [section.SizeOfRawData]);
+				MoveTo (section.PointerToRawData);
+				return;
+			}
+
+			var written = 0;
+			var buffer = new byte [buffer_size];
+			while (written != section.SizeOfRawData) {
+				var write_size = System.Math.Min((int) section.SizeOfRawData - written, buffer_size);
+				Write (buffer, 0, write_size);
+				written += write_size;
+			}
+
+			MoveTo (section.PointerToRawData);
+		}
+
 		void WriteText ()
 		{
-			MoveTo (text.PointerToRawData);
+			PrepareSection (text);
 
 			// ImportAddressTable
 
-			WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
-			WriteRVA (0);
+			if (has_reloc) {
+				WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
+				WriteRVA (0);
+			}
 
 			// CLIHeader
 
@@ -445,6 +486,9 @@ namespace Mono.Cecil.PE {
 				WriteDebugDirectory ();
 			}
 
+			if (!has_reloc)
+				return;
+
 			// ImportDirectory
 			MoveToRVA (TextSegment.ImportDirectory);
 			WriteImportDirectory ();
@@ -466,7 +510,7 @@ namespace Mono.Cecil.PE {
 			WriteUInt16 (1);	// MinorVersion
 			WriteUInt32 (0);	// Reserved
 
-			var version = GetZeroTerminatedString (GetVersion ());
+			var version = GetZeroTerminatedString (module.runtime_version);
 			WriteUInt32 ((uint) version.Length);
 			WriteBytes (version);
 			WriteUInt16 (0);	// Flags
@@ -481,21 +525,6 @@ namespace Mono.Cecil.PE {
 			WriteStreamHeader (ref offset, TextSegment.BlobHeap, "#Blob");
 		}
 
-		string GetVersion ()
-		{
-			switch (module.Runtime) {
-			case TargetRuntime.Net_1_0:
-				return "v1.0.3705";
-			case TargetRuntime.Net_1_1:
-				return "v1.1.4322";
-			case TargetRuntime.Net_2_0:
-				return "v2.0.50727";
-			case TargetRuntime.Net_4_0:
-			default:
-				return "v4.0.30319";
-			}
-		}
-
 		ushort GetStreamCount ()
 		{
 			return (ushort) (
@@ -611,31 +640,20 @@ namespace Mono.Cecil.PE {
 				WriteUInt16 (0x25ff);
 				WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
 				return;
-			case TargetArchitecture.AMD64:
-				WriteUInt16 (0xa148);
-				WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
-				WriteUInt16 (0xe0ff);
-				return;
-			case TargetArchitecture.IA64:
-				WriteBytes (new byte [] {
-					0x0b, 0x48, 0x00, 0x02, 0x18, 0x10, 0xa0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
-					0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
-				});
-				WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.StartupStub));
-				WriteUInt32 ((uint) image_base + text_rva);
-				return;
+			default:
+				throw new NotSupportedException ();
 			}
 		}
 
 		void WriteRsrc ()
 		{
-			MoveTo (rsrc.PointerToRawData);
+			PrepareSection (rsrc);
 			WriteBuffer (win32_resources);
 		}
 
 		void WriteReloc ()
 		{
-			MoveTo (reloc.PointerToRawData);
+			PrepareSection (reloc);
 
 			var reloc_rva = text_map.GetRVA (TextSegment.StartupStub);
 			reloc_rva += module.Architecture == TargetArchitecture.IA64 ? 0x20u : 2;
@@ -648,16 +666,9 @@ namespace Mono.Cecil.PE {
 			case TargetArchitecture.I386:
 				WriteUInt32 (0x3000 + reloc_rva - page_rva);
 				break;
-			case TargetArchitecture.AMD64:
-				WriteUInt32 (0xa000 + reloc_rva - page_rva);
-				break;
-			case TargetArchitecture.IA64:
-				WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva));
-				WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva + 8));
-				break;
+			default:
+				throw new NotSupportedException();
 			}
-
-			WriteBytes (new byte [file_alignment - reloc.VirtualSize]);
 		}
 
 		public void WriteImage ()
@@ -669,7 +680,8 @@ namespace Mono.Cecil.PE {
 			WriteText ();
 			if (rsrc != null)
 				WriteRsrc ();
-			WriteReloc ();
+			if (reloc != null)
+				WriteReloc ();
 		}
 
 		TextMap BuildTextMap ()
@@ -700,8 +712,16 @@ namespace Mono.Cecil.PE {
 
 			map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4);
 
+			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));
+				map.AddMap (TextSegment.StartupStub, new Range (start, 0));
+				return map;
+			}
+
 			RVA import_dir_rva = map.GetNextRVA (TextSegment.DebugDirectory);
-			RVA import_hnt_rva = import_dir_rva + (!pe64 ? 48u : 52u);
+			RVA import_hnt_rva = import_dir_rva + 48u;
 			import_hnt_rva = (import_hnt_rva + 15u) & ~15u;
 			uint import_dir_len = (import_hnt_rva - import_dir_rva) + 27u;
 
@@ -722,12 +742,8 @@ namespace Mono.Cecil.PE {
 			switch (module.Architecture) {
 			case TargetArchitecture.I386:
 				return 6;
-			case TargetArchitecture.AMD64:
-				return 12;
-			case TargetArchitecture.IA64:
-				return 48;
 			default:
-				throw new InvalidOperationException ();
+				throw new NotSupportedException ();
 			}
 		}
 
@@ -750,24 +766,22 @@ namespace Mono.Cecil.PE {
 
 		int GetStrongNameLength ()
 		{
-			if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0)
-				return 0;
-
 			if (module.Assembly == null)
-				throw new InvalidOperationException ();
+				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/vbnc/cecil/Mono.Cecil.PE/Section.cs b/vbnc/cecil/Mono.Cecil.PE/Section.cs
index 4d2927e..526ea37 100755
--- a/vbnc/cecil/Mono.Cecil.PE/Section.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/Section.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.PE/TextMap.cs b/vbnc/cecil/Mono.Cecil.PE/TextMap.cs
index daeda0c..047a4c1 100644
--- a/vbnc/cecil/Mono.Cecil.PE/TextMap.cs
+++ b/vbnc/cecil/Mono.Cecil.PE/TextMap.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil.VB.csproj b/vbnc/cecil/Mono.Cecil.VB.csproj
index 6dfe6ad..390fb43 100755
--- a/vbnc/cecil/Mono.Cecil.VB.csproj
+++ b/vbnc/cecil/Mono.Cecil.VB.csproj
@@ -1,218 +1,215 @@
-<?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)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Mono.Cecil</RootNamespace>
-    <AssemblyName>Mono.Cecil.VB</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
-    <FileUpgradeFlags>
-    </FileUpgradeFlags>
-    <OldToolsVersion>3.5</OldToolsVersion>
-    <UpgradeBackupLocation />
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Mono.Cecil.Cil\Code.cs" />
-    <Compile Include="Mono.Cecil.Cil\CodeWriter.cs" />
-    <Compile Include="Mono.Cecil.Cil\CodeReader.cs" />
-    <Compile Include="Mono.Cecil.Cil\Document.cs" />
-    <Compile Include="Mono.Cecil.Cil\ExceptionHandler.cs" />
-    <Compile Include="Mono.Cecil.Cil\ILProcessor.cs" />
-    <Compile Include="Mono.Cecil.Cil\Instruction.cs" />
-    <Compile Include="Mono.Cecil.Cil\MethodBody.cs" />
-    <Compile Include="Mono.Cecil.Cil\OpCode.cs" />
-    <Compile Include="Mono.Cecil.Cil\OpCodes.cs" />
-    <Compile Include="Mono.Cecil.Cil\SequencePoint.cs" />
-    <Compile Include="Mono.Cecil.Cil\Symbols.cs" />
-    <Compile Include="Mono.Cecil.Cil\VariableDefinition.cs" />
-    <Compile Include="Mono.Cecil.Cil\VariableReference.cs" />
-    <Compile Include="Mono.Cecil.Metadata\BlobHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Buffers.cs" />
-    <Compile Include="Mono.Cecil.Metadata\CodedIndex.cs" />
-    <Compile Include="Mono.Cecil.Metadata\ElementType.cs" />
-    <Compile Include="Mono.Cecil.Metadata\GuidHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Heap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\MetadataToken.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Row.cs" />
-    <Compile Include="Mono.Cecil.Metadata\StringHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\TableHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\TokenType.cs" />
-    <Compile Include="Mono.Cecil.Metadata\UserStringHeap.cs" />
-    <Compile Include="Mono.Cecil.Metadata\Utilities.cs" />
-    <Compile Include="Mono.Cecil.PE\BinaryStreamReader.cs" />
-    <Compile Include="Mono.Cecil.PE\BinaryStreamWriter.cs" />
-    <Compile Include="Mono.Cecil.PE\ByteBufferEqualityComparer.cs" />
-    <Compile Include="Mono.Cecil.PE\ByteBuffer.cs" />
-    <Compile Include="Mono.Cecil.PE\DataDirectory.cs" />
-    <Compile Include="Mono.Cecil.PE\Image.cs" />
-    <Compile Include="Mono.Cecil.PE\ImageReader.cs" />
-    <Compile Include="Mono.Cecil.PE\ImageWriter.cs" />
-    <Compile Include="Mono.Cecil.PE\Section.cs" />
-    <Compile Include="Mono.Cecil.PE\TextMap.cs" />
-    <Compile Include="Mono.Cecil\ArrayType.cs" />
-    <Compile Include="Mono.Cecil\AssemblyDefinition.cs" />
-    <Compile Include="Mono.Cecil\AssemblyFlags.cs" />
-    <Compile Include="Mono.Cecil\AssemblyHashAlgorithm.cs" />
-    <Compile Include="Mono.Cecil\AssemblyInfo.cs" />
-    <Compile Include="Mono.Cecil\AssemblyLinkedResource.cs" />
-    <Compile Include="Mono.Cecil\AssemblyNameDefinition.cs" />
-    <Compile Include="Mono.Cecil\AssemblyNameReference.cs" />
-    <Compile Include="Mono.Cecil\AssemblyReader.cs" />
-    <Compile Include="Mono.Cecil\AssemblyWriter.cs" />
-    <Compile Include="Mono.Cecil\BaseAssemblyResolver.cs" />
-    <Compile Include="Mono.Cecil\CallSite.cs" />
-    <Compile Include="Mono.Cecil\Import.cs" />
-    <Compile Include="Mono.Cecil\TypeParser.cs" />
-    <Compile Include="Mono.Collections.Generic\Collection.cs" />
-    <Compile Include="Mono.Cecil\ExportedType.cs" />
-    <Compile Include="Mono.Cecil\SecurityDeclaration.cs" />
-    <Compile Include="Mono.Cecil\CustomAttribute.cs" />
-    <Compile Include="Mono.Cecil\DefaultAssemblyResolver.cs" />
-    <Compile Include="Mono.Cecil\FileAttributes.cs" />
-    <Compile Include="Mono.Cecil\FunctionPointerType.cs" />
-    <Compile Include="Mono.Cecil\GenericInstanceMethod.cs" />
-    <Compile Include="Mono.Cecil\GenericInstanceType.cs" />
-    <Compile Include="Mono.Cecil\GenericParameter.cs" />
-    <Compile Include="Mono.Cecil\GenericParameterAttributes.cs" />
-    <Compile Include="Mono.Cecil\IConstantProvider.cs" />
-    <Compile Include="Mono.Cecil\ICustomAttributeProvider.cs" />
-    <Compile Include="Mono.Cecil\IGenericInstance.cs" />
-    <Compile Include="Mono.Cecil\IGenericParameterProvider.cs" />
-    <Compile Include="Mono.Cecil\IMarshalInfoProvider.cs" />
-    <Compile Include="Mono.Cecil\MarshalInfo.cs" />
-    <Compile Include="Mono.Cecil\MetadataResolver.cs" />
-    <Compile Include="Mono.Cecil\Modifiers.cs" />
-    <Compile Include="Mono.Cecil\NativeType.cs" />
-    <Compile Include="Mono.Cecil\PinnedType.cs" />
-    <Compile Include="Mono.Cecil\MetadataSystem.cs" />
-    <Compile Include="Mono.Cecil\IMethodSignature.cs" />
-    <Compile Include="Mono.Cecil\ParameterDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\EmbeddedResource.cs" />
-    <Compile Include="Mono.Cecil\EventAttributes.cs" />
-    <Compile Include="Mono.Cecil\EventDefinition.cs" />
-    <Compile Include="Mono.Cecil\EventReference.cs" />
-    <Compile Include="Mono.Cecil\FieldAttributes.cs" />
-    <Compile Include="Mono.Cecil\FieldDefinition.cs" />
-    <Compile Include="Mono.Cecil\FieldReference.cs" />
-    <Compile Include="Mono.Cecil\IMemberDefinition.cs" />
-    <Compile Include="Mono.Cecil\LinkedResource.cs" />
-    <Compile Include="Mono.Cecil\MemberReference.cs" />
-    <Compile Include="Mono.Cecil\MethodAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodCallingConvention.cs" />
-    <Compile Include="Mono.Cecil\MethodDefinition.cs" />
-    <Compile Include="Mono.Cecil\MethodImplAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodReference.cs" />
-    <Compile Include="Mono.Cecil\MethodReturnType.cs" />
-    <Compile Include="Mono.Cecil\MethodSemanticsAttributes.cs" />
-    <Compile Include="Mono.Cecil\MethodSpecification.cs" />
-    <Compile Include="Mono.Cecil\ParameterAttributes.cs" />
-    <Compile Include="Mono.Cecil\ParameterDefinition.cs" />
-    <Compile Include="Mono.Cecil\ParameterReference.cs" />
-    <Compile Include="Mono.Cecil\PInvokeAttributes.cs" />
-    <Compile Include="Mono.Cecil\PInvokeInfo.cs" />
-    <Compile Include="Mono.Cecil\PointerType.cs" />
-    <Compile Include="Mono.Cecil\PropertyAttributes.cs" />
-    <Compile Include="Mono.Cecil\PropertyDefinition.cs" />
-    <Compile Include="Mono.Cecil\PropertyReference.cs" />
-    <Compile Include="Mono.Cecil\ReferenceType.cs" />
-    <Compile Include="Mono.Cecil\IMetadataScope.cs" />
-    <Compile Include="Mono.Cecil\IMetadataTokenProvider.cs" />
-    <Compile Include="Mono.Cecil\ManifestResourceAttributes.cs" />
-    <Compile Include="Mono.Cecil\ModuleReference.cs" />
-    <Compile Include="Mono.Cecil\MemberDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\ModuleDefinition.cs" />
-    <Compile Include="Mono.Cecil\ModuleKind.cs" />
-    <Compile Include="Mono.Cecil\Resource.cs" />
-    <Compile Include="Mono.Cecil\SentinelType.cs" />
-    <Compile Include="Mono.Cecil\TargetRuntime.cs" />
-    <Compile Include="Mono.Cecil\TypeAttributes.cs" />
-    <Compile Include="Mono.Cecil\TypeDefinition.cs" />
-    <Compile Include="Mono.Cecil\TypeDefinitionCollection.cs" />
-    <Compile Include="Mono.Cecil\TypeReference.cs" />
-    <Compile Include="Mono.Cecil\TypeSpecification.cs" />
-    <Compile Include="Mono.Cecil\TypeSystem.cs" />
-    <Compile Include="Mono.Cecil\VariantType.cs" />
-    <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" />
-    <Compile Include="Mono.Security.Cryptography\CryptoService.cs" />
-    <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" />
-    <Compile Include="Mono\Actions.cs" />
-    <Compile Include="Mono\Empty.cs" />
-    <Compile Include="Mono\Funcs.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="NOTES.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="mono.snk" />
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
-      <Visible>False</Visible>
-      <ProductName>Windows Installer 3.1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
\ No newline at end of file
+<?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)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Mono.Cecil</RootNamespace>
+    <AssemblyName>Mono.Cecil.VB</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <OldToolsVersion>3.5</OldToolsVersion>
+    <UpgradeBackupLocation />
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Mono.Cecil.Cil\Code.cs" />
+    <Compile Include="Mono.Cecil.Cil\CodeWriter.cs" />
+    <Compile Include="Mono.Cecil.Cil\CodeReader.cs" />
+    <Compile Include="Mono.Cecil.Cil\Document.cs" />
+    <Compile Include="Mono.Cecil.Cil\ExceptionHandler.cs" />
+    <Compile Include="Mono.Cecil.Cil\ILProcessor.cs" />
+    <Compile Include="Mono.Cecil.Cil\Instruction.cs" />
+    <Compile Include="Mono.Cecil.Cil\MethodBody.cs" />
+    <Compile Include="Mono.Cecil.Cil\OpCode.cs" />
+    <Compile Include="Mono.Cecil.Cil\OpCodes.cs" />
+    <Compile Include="Mono.Cecil.Cil\SequencePoint.cs" />
+    <Compile Include="Mono.Cecil.Cil\Symbols.cs" />
+    <Compile Include="Mono.Cecil.Cil\VariableDefinition.cs" />
+    <Compile Include="Mono.Cecil.Cil\VariableReference.cs" />
+    <Compile Include="Mono.Cecil.Metadata\BlobHeap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\Buffers.cs" />
+    <Compile Include="Mono.Cecil.Metadata\CodedIndex.cs" />
+    <Compile Include="Mono.Cecil.Metadata\ElementType.cs" />
+    <Compile Include="Mono.Cecil.Metadata\GuidHeap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\Heap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\MetadataToken.cs" />
+    <Compile Include="Mono.Cecil.Metadata\Row.cs" />
+    <Compile Include="Mono.Cecil.Metadata\StringHeap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\TableHeap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\TokenType.cs" />
+    <Compile Include="Mono.Cecil.Metadata\UserStringHeap.cs" />
+    <Compile Include="Mono.Cecil.Metadata\Utilities.cs" />
+    <Compile Include="Mono.Cecil.PE\BinaryStreamReader.cs" />
+    <Compile Include="Mono.Cecil.PE\BinaryStreamWriter.cs" />
+    <Compile Include="Mono.Cecil.PE\ByteBufferEqualityComparer.cs" />
+    <Compile Include="Mono.Cecil.PE\ByteBuffer.cs" />
+    <Compile Include="Mono.Cecil.PE\DataDirectory.cs" />
+    <Compile Include="Mono.Cecil.PE\Image.cs" />
+    <Compile Include="Mono.Cecil.PE\ImageReader.cs" />
+    <Compile Include="Mono.Cecil.PE\ImageWriter.cs" />
+    <Compile Include="Mono.Cecil.PE\Section.cs" />
+    <Compile Include="Mono.Cecil.PE\TextMap.cs" />
+    <Compile Include="Mono.Cecil\ArrayType.cs" />
+    <Compile Include="Mono.Cecil\AssemblyDefinition.cs" />
+    <Compile Include="Mono.Cecil\AssemblyFlags.cs" />
+    <Compile Include="Mono.Cecil\AssemblyHashAlgorithm.cs" />
+    <Compile Include="Mono.Cecil\AssemblyInfo.cs" />
+    <Compile Include="Mono.Cecil\AssemblyLinkedResource.cs" />
+    <Compile Include="Mono.Cecil\AssemblyNameDefinition.cs" />
+    <Compile Include="Mono.Cecil\AssemblyNameReference.cs" />
+    <Compile Include="Mono.Cecil\AssemblyReader.cs" />
+    <Compile Include="Mono.Cecil\AssemblyWriter.cs" />
+    <Compile Include="Mono.Cecil\BaseAssemblyResolver.cs" />
+    <Compile Include="Mono.Cecil\CallSite.cs" />
+    <Compile Include="Mono.Cecil\Import.cs" />
+    <Compile Include="Mono.Cecil\TypeParser.cs" />
+    <Compile Include="Mono.Collections.Generic\Collection.cs" />
+    <Compile Include="Mono.Cecil\ExportedType.cs" />
+    <Compile Include="Mono.Cecil\SecurityDeclaration.cs" />
+    <Compile Include="Mono.Cecil\CustomAttribute.cs" />
+    <Compile Include="Mono.Cecil\DefaultAssemblyResolver.cs" />
+    <Compile Include="Mono.Cecil\FileAttributes.cs" />
+    <Compile Include="Mono.Cecil\FunctionPointerType.cs" />
+    <Compile Include="Mono.Cecil\GenericInstanceMethod.cs" />
+    <Compile Include="Mono.Cecil\GenericInstanceType.cs" />
+    <Compile Include="Mono.Cecil\GenericParameter.cs" />
+    <Compile Include="Mono.Cecil\GenericParameterAttributes.cs" />
+    <Compile Include="Mono.Cecil\IConstantProvider.cs" />
+    <Compile Include="Mono.Cecil\ICustomAttributeProvider.cs" />
+    <Compile Include="Mono.Cecil\IGenericInstance.cs" />
+    <Compile Include="Mono.Cecil\IGenericParameterProvider.cs" />
+    <Compile Include="Mono.Cecil\IMarshalInfoProvider.cs" />
+    <Compile Include="Mono.Cecil\MarshalInfo.cs" />
+    <Compile Include="Mono.Cecil\MetadataResolver.cs" />
+    <Compile Include="Mono.Cecil\Modifiers.cs" />
+    <Compile Include="Mono.Cecil\NativeType.cs" />
+    <Compile Include="Mono.Cecil\PinnedType.cs" />
+    <Compile Include="Mono.Cecil\MetadataSystem.cs" />
+    <Compile Include="Mono.Cecil\IMethodSignature.cs" />
+    <Compile Include="Mono.Cecil\ParameterDefinitionCollection.cs" />
+    <Compile Include="Mono.Cecil\EmbeddedResource.cs" />
+    <Compile Include="Mono.Cecil\EventAttributes.cs" />
+    <Compile Include="Mono.Cecil\EventDefinition.cs" />
+    <Compile Include="Mono.Cecil\EventReference.cs" />
+    <Compile Include="Mono.Cecil\FieldAttributes.cs" />
+    <Compile Include="Mono.Cecil\FieldDefinition.cs" />
+    <Compile Include="Mono.Cecil\FieldReference.cs" />
+    <Compile Include="Mono.Cecil\IMemberDefinition.cs" />
+    <Compile Include="Mono.Cecil\LinkedResource.cs" />
+    <Compile Include="Mono.Cecil\MemberReference.cs" />
+    <Compile Include="Mono.Cecil\MethodAttributes.cs" />
+    <Compile Include="Mono.Cecil\MethodCallingConvention.cs" />
+    <Compile Include="Mono.Cecil\MethodDefinition.cs" />
+    <Compile Include="Mono.Cecil\MethodImplAttributes.cs" />
+    <Compile Include="Mono.Cecil\MethodReference.cs" />
+    <Compile Include="Mono.Cecil\MethodReturnType.cs" />
+    <Compile Include="Mono.Cecil\MethodSemanticsAttributes.cs" />
+    <Compile Include="Mono.Cecil\MethodSpecification.cs" />
+    <Compile Include="Mono.Cecil\ParameterAttributes.cs" />
+    <Compile Include="Mono.Cecil\ParameterDefinition.cs" />
+    <Compile Include="Mono.Cecil\ParameterReference.cs" />
+    <Compile Include="Mono.Cecil\PInvokeAttributes.cs" />
+    <Compile Include="Mono.Cecil\PInvokeInfo.cs" />
+    <Compile Include="Mono.Cecil\PointerType.cs" />
+    <Compile Include="Mono.Cecil\PropertyAttributes.cs" />
+    <Compile Include="Mono.Cecil\PropertyDefinition.cs" />
+    <Compile Include="Mono.Cecil\PropertyReference.cs" />
+    <Compile Include="Mono.Cecil\ReferenceType.cs" />
+    <Compile Include="Mono.Cecil\IMetadataScope.cs" />
+    <Compile Include="Mono.Cecil\IMetadataTokenProvider.cs" />
+    <Compile Include="Mono.Cecil\ManifestResourceAttributes.cs" />
+    <Compile Include="Mono.Cecil\ModuleReference.cs" />
+    <Compile Include="Mono.Cecil\MemberDefinitionCollection.cs" />
+    <Compile Include="Mono.Cecil\ModuleDefinition.cs" />
+    <Compile Include="Mono.Cecil\ModuleKind.cs" />
+    <Compile Include="Mono.Cecil\Resource.cs" />
+    <Compile Include="Mono.Cecil\SentinelType.cs" />
+    <Compile Include="Mono.Cecil\TargetRuntime.cs" />
+    <Compile Include="Mono.Cecil\TypeAttributes.cs" />
+    <Compile Include="Mono.Cecil\TypeDefinition.cs" />
+    <Compile Include="Mono.Cecil\TypeDefinitionCollection.cs" />
+    <Compile Include="Mono.Cecil\TypeReference.cs" />
+    <Compile Include="Mono.Cecil\TypeSpecification.cs" />
+    <Compile Include="Mono.Cecil\TypeSystem.cs" />
+    <Compile Include="Mono.Cecil\VariantType.cs" />
+    <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" />
+    <Compile Include="Mono.Security.Cryptography\CryptoService.cs" />
+    <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" />
+    <Compile Include="Mono\Actions.cs" />
+    <Compile Include="Mono\Empty.cs" />
+    <Compile Include="Mono\Funcs.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="mono.snk" />
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
diff --git a/vbnc/cecil/Mono.Cecil.csproj b/vbnc/cecil/Mono.Cecil.csproj
index c3a2ba7..e24380f 100644
--- a/vbnc/cecil/Mono.Cecil.csproj
+++ b/vbnc/cecil/Mono.Cecil.csproj
@@ -1,39 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="Mono.Cecil.settings" />
   <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Mono.Cecil</RootNamespace>
     <AssemblyName>Mono.Cecil</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
+  <ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
+    <Reference Include="System.Core" />
+  </ItemGroup>
   <ItemGroup>
     <Compile Include="Mono.Cecil.Cil\Code.cs" />
     <Compile Include="Mono.Cecil.Cil\CodeWriter.cs" />
@@ -155,6 +130,7 @@
     <Compile Include="Mono.Cecil\TypeSpecification.cs" />
     <Compile Include="Mono.Cecil\TypeSystem.cs" />
     <Compile Include="Mono.Cecil\VariantType.cs" />
+    <Compile Include="Mono.Collections.Generic\ReadOnlyCollection.cs" />
     <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" />
     <Compile Include="Mono.Security.Cryptography\CryptoService.cs" />
     <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" />
@@ -162,18 +138,5 @@
     <Compile Include="Mono\Empty.cs" />
     <Compile Include="Mono\Funcs.cs" />
   </ItemGroup>
-  <ItemGroup>
-    <Content Include="NOTES.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="mono.snk" />
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
 </Project>
\ No newline at end of file
diff --git a/vbnc/cecil/Mono.Cecil/ArrayType.cs b/vbnc/cecil/Mono.Cecil/ArrayType.cs
index e3a060f..55c59d8 100644
--- a/vbnc/cecil/Mono.Cecil/ArrayType.cs
+++ b/vbnc/cecil/Mono.Cecil/ArrayType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyDefinition.cs b/vbnc/cecil/Mono.Cecil/AssemblyDefinition.cs
index bb757d3..f4e69cf 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -62,9 +62,9 @@ namespace Mono.Cecil {
 					return modules;
 
 				if (main_module.HasImage)
-					return modules = main_module.Read (this, (_, reader) => reader.ReadModules ());
+					return main_module.Read (ref modules, this, (_, reader) => reader.ReadModules ());
 
-				return modules = new Collection<ModuleDefinition> { main_module };
+				return modules = new Collection<ModuleDefinition> (1) { main_module };
 			}
 		}
 
@@ -87,7 +87,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (main_module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, main_module)); }
 		}
 
 		public bool HasSecurityDeclarations {
@@ -100,7 +100,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<SecurityDeclaration> SecurityDeclarations {
-			get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (main_module)); }
+			get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, main_module)); }
 		}
 
 		internal AssemblyDefinition ()
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyFlags.cs b/vbnc/cecil/Mono.Cecil/AssemblyFlags.cs
index 6d04c59..72a0eb0 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyFlags.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyFlags.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -35,6 +35,7 @@ namespace Mono.Cecil {
 		PublicKey					 	= 0x0001,
 		SideBySideCompatible			= 0x0000,
 		Retargetable					= 0x0100,
+		WindowsRuntime					= 0x0200,
 		DisableJITCompileOptimizer		= 0x4000,
 		EnableJITCompileTracking		= 0x8000,
 	}
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs b/vbnc/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
index 0e7bf83..79a5699 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyInfo.cs b/vbnc/cecil/Mono.Cecil/AssemblyInfo.cs
index 763a5d0..8a9f809 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyInfo.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyInfo.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,15 +32,15 @@ using System.Runtime.InteropServices;
 
 [assembly: AssemblyTitle ("Mono.Cecil")]
 [assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("Copyright © 2008 - 2010 Jb Evain")]
+[assembly: AssemblyCopyright ("Copyright © 2008 - 2011 Jb Evain")]
 
 [assembly: ComVisible (false)]
 
 [assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
 
-[assembly: AssemblyVersion ("0.9.3.0")]
+[assembly: AssemblyVersion ("0.9.5.0")]
 #if !CF
-[assembly: AssemblyFileVersion ("0.9.3.0")]
+[assembly: AssemblyFileVersion ("0.9.5.0")]
 #endif
 
 [assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyLinkedResource.cs b/vbnc/cecil/Mono.Cecil/AssemblyLinkedResource.cs
index 68e44f8..4d8bac0 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyLinkedResource.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyLinkedResource.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyNameDefinition.cs b/vbnc/cecil/Mono.Cecil/AssemblyNameDefinition.cs
index 4756cb8..dc6b905 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyNameDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyNameDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyNameReference.cs b/vbnc/cecil/Mono.Cecil/AssemblyNameReference.cs
index 2798082..e328c78 100644
--- a/vbnc/cecil/Mono.Cecil/AssemblyNameReference.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyNameReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -92,8 +92,13 @@ namespace Mono.Cecil {
 			set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); }
 		}
 
+		public bool IsWindowsRuntime {
+			get { return attributes.GetAttributes ((uint) AssemblyAttributes.WindowsRuntime); }
+			set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.WindowsRuntime, value); }
+		}
+
 		public byte [] PublicKey {
-			get { return public_key; }
+			get { return public_key ?? Empty<byte>.Array; }
 			set {
 				public_key = value;
 				HasPublicKey = !public_key.IsNullOrEmpty ();
@@ -107,11 +112,12 @@ namespace Mono.Cecil {
 				if (public_key_token.IsNullOrEmpty () && !public_key.IsNullOrEmpty ()) {
 					var hash = HashPublicKey ();
 					// we need the last 8 bytes in reverse order
-					public_key_token = new byte [8];
-					Array.Copy (hash, (hash.Length - 8), public_key_token, 0, 8);
-					Array.Reverse (public_key_token, 0, 8);
+					var local_public_key_token = new byte [8];
+					Array.Copy (hash, (hash.Length - 8), local_public_key_token, 0, 8);
+					Array.Reverse (local_public_key_token, 0, 8);
+					public_key_token = local_public_key_token; // publish only once finished (required for thread-safety)
 				}
-				return public_key_token;
+				return public_key_token ?? Empty<byte>.Array;
 			}
 			set {
 				public_key_token = value;
@@ -170,9 +176,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");
@@ -202,22 +209,22 @@ namespace Mono.Cecil {
 				if (parts.Length != 2)
 					throw new ArgumentException ("Malformed name");
 
-				switch (parts [0]) {
-				case "Version":
+				switch (parts [0].ToLowerInvariant ()) {
+				case "version":
 					name.Version = new Version (parts [1]);
 					break;
-				case "Culture":
+				case "culture":
 					name.Culture = parts [1];
 					break;
-				case "PublicKeyToken":
-					string pk_token = parts [1];
+				case "publickeytoken":
+					var pk_token = parts [1];
 					if (pk_token == "null")
 						break;
 
 					name.PublicKeyToken = new byte [pk_token.Length / 2];
-					for (int j = 0; j < name.PublicKeyToken.Length; j++) {
+					for (int j = 0; j < name.PublicKeyToken.Length; j++)
 						name.PublicKeyToken [j] = Byte.Parse (pk_token.Substring (j * 2, 2), NumberStyles.HexNumber);
-					}
+
 					break;
 				}
 			}
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyReader.cs b/vbnc/cecil/Mono.Cecil/AssemblyReader.cs
index 6e2be6c..1a01b27 100755
--- a/vbnc/cecil/Mono.Cecil/AssemblyReader.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -78,12 +78,18 @@ namespace Mono.Cecil {
 
 		public static ModuleDefinition CreateModuleFrom (Image image, ReaderParameters parameters)
 		{
-			var module = ReadModule (image, parameters);
-
-			ReadSymbols (module, parameters);
+			var reader = CreateModuleReader (image, parameters.ReadingMode);
+			var module = reader.module;
 
 			if (parameters.AssemblyResolver != null)
-				module.AssemblyResolver = parameters.AssemblyResolver;
+				module.assembly_resolver = parameters.AssemblyResolver;
+
+			if (parameters.MetadataResolver != null)
+				module.metadata_resolver = parameters.MetadataResolver;
+
+			reader.ReadModule ();
+
+			ReadSymbols (module, parameters);
 
 			return module;
 		}
@@ -106,13 +112,6 @@ namespace Mono.Cecil {
 			}
 		}
 
-		static ModuleDefinition ReadModule (Image image, ReaderParameters parameters)
-		{
-			var reader = CreateModuleReader (image, parameters.ReadingMode);
-			reader.ReadModule ();
-			return reader.module;
-		}
-
 		static ModuleReader CreateModuleReader (Image image, ReadingMode mode)
 		{
 			switch (mode) {
@@ -162,7 +161,7 @@ namespace Mono.Cecil {
 				return;
 
 			if (assembly.HasCustomAttributes)
-				Read (assembly.CustomAttributes);
+				ReadCustomAttributes (assembly);
 			if (assembly.HasSecurityDeclarations)
 				Read (assembly.SecurityDeclarations);
 		}
@@ -215,21 +214,36 @@ namespace Mono.Cecil {
 				if (parameter.HasConstraints)
 					Read (parameter.Constraints);
 
-				if (parameter.HasCustomAttributes)
-					Read (parameter.CustomAttributes);
+				ReadCustomAttributes (parameter);
 			}
 		}
 
 		static void ReadSecurityDeclarations (ISecurityDeclarationProvider provider)
 		{
-			if (provider.HasSecurityDeclarations)
-				Read (provider.SecurityDeclarations);
+			if (!provider.HasSecurityDeclarations)
+				return;
+
+			var security_declarations = provider.SecurityDeclarations;
+
+			for (int i = 0; i < security_declarations.Count; i++) {
+				var security_declaration = security_declarations [i];
+
+				Read (security_declaration.SecurityAttributes);
+			}
 		}
 
 		static void ReadCustomAttributes (ICustomAttributeProvider provider)
 		{
-			if (provider.HasCustomAttributes)
-				Read (provider.CustomAttributes);
+			if (!provider.HasCustomAttributes)
+				return;
+
+			var custom_attributes = provider.CustomAttributes;
+
+			for (int i = 0; i < custom_attributes.Count; i++) {
+				var custom_attribute = custom_attributes [i];
+
+				Read (custom_attribute.ConstructorArguments);
+			}
 		}
 
 		static void ReadFields (TypeDefinition type)
@@ -374,7 +388,7 @@ namespace Mono.Cecil {
 			this.image = module.Image;
 			this.module = module;
 			this.metadata = module.MetadataSystem;
-			this.code = CodeReader.CreateCodeReader (this);
+			this.code = new CodeReader (image.MetadataSection, this);
 		}
 
 		int GetCodedIndexSize (CodedIndex index)
@@ -476,7 +490,7 @@ namespace Mono.Cecil {
 
 		public ModuleDefinition Populate (ModuleDefinition module)
 		{
-			if (MoveTo (Table.Module) != 1)
+			if (MoveTo (Table.Module) == 0)
 				return module;
 
 			Advance (2); // Generation
@@ -487,36 +501,48 @@ namespace Mono.Cecil {
 			return module;
 		}
 
-		public Collection<AssemblyNameReference> ReadAssemblyReferences ()
+		void InitializeAssemblyReferences ()
 		{
+			if (metadata.AssemblyReferences != null)
+				return;
+
 			int length = MoveTo (Table.AssemblyRef);
-			var references = new Collection<AssemblyNameReference> (length);
+			var references = metadata.AssemblyReferences = new AssemblyNameReference [length];
 
-			for (uint i = 1; i <= length; i++) {
+			for (uint i = 0; i < length; i++) {
 				var reference = new AssemblyNameReference ();
-				reference.token = new MetadataToken (TokenType.AssemblyRef, i);
+				reference.token = new MetadataToken (TokenType.AssemblyRef, i + 1);
 
 				PopulateVersionAndFlags (reference);
 
-				reference.PublicKeyToken = ReadBlob ();
+				var key_or_token = ReadBlob ();
+
+				if (reference.HasPublicKey)
+					reference.PublicKey = key_or_token;
+				else
+					reference.PublicKeyToken = key_or_token;
 
 				PopulateNameAndCulture (reference);
 
 				reference.Hash = ReadBlob ();
 
-				references.Add (reference);
+				references [i] = reference;
 			}
+		}
+
+		public Collection<AssemblyNameReference> ReadAssemblyReferences ()
+		{
+			InitializeAssemblyReferences ();
 
-			return references;
+			return new Collection<AssemblyNameReference> (metadata.AssemblyReferences);
 		}
 
 		public MethodDefinition ReadEntryPoint ()
 		{
-			if (module.Kind != ModuleKind.Console && module.Kind != ModuleKind.Windows)
+			if (module.Image.EntryPointToken == 0)
 				return null;
 
 			var token = new MetadataToken (module.Image.EntryPointToken);
-
 			return GetMethodDefinition (token.RID);
 		}
 
@@ -537,6 +563,7 @@ namespace Mono.Cecil {
 				var parameters = new ReaderParameters {
 					ReadingMode = module.ReadingMode,
 					SymbolReaderProvider = module.SymbolReaderProvider,
+					AssemblyResolver = module.AssemblyResolver
 				};
 
 				modules.Add (ModuleDefinition.ReadModule (
@@ -555,19 +582,27 @@ namespace Mono.Cecil {
 			return Path.Combine (path, name);
 		}
 
-		public Collection<ModuleReference> ReadModuleReferences ()
+		void InitializeModuleReferences ()
 		{
+			if (metadata.ModuleReferences != null)
+				return;
+
 			int length = MoveTo (Table.ModuleRef);
-			var references = new Collection<ModuleReference> (length);
+			var references = metadata.ModuleReferences = new ModuleReference [length];
 
-			for (uint i = 1; i <= length; i++) {
+			for (uint i = 0; i < length; i++) {
 				var reference = new ModuleReference (ReadString ());
-				reference.token = new MetadataToken (TokenType.ModuleRef, i);
+				reference.token = new MetadataToken (TokenType.ModuleRef, i + 1);
 
-				references.Add (reference);
+				references [i] = reference;
 			}
+		}
+
+		public Collection<ModuleReference> ReadModuleReferences ()
+		{
+			InitializeModuleReferences ();
 
-			return references;
+			return new Collection<ModuleReference> (metadata.ModuleReferences);
 		}
 
 		public bool HasFileResource ()
@@ -682,9 +717,24 @@ namespace Mono.Cecil {
 				types.Add (type);
 			}
 
+			if (image.HasTable (Table.MethodPtr) || image.HasTable (Table.FieldPtr))
+				CompleteTypes ();
+
 			return types;
 		}
 
+		void CompleteTypes ()
+		{
+			var types = metadata.Types;
+
+			for (int i = 0; i < types.Length; i++) {
+				var type = types [i];
+
+				InitializeCollection (type.Fields);
+				InitializeCollection (type.Methods);
+			}
+		}
+
 		void InitializeTypeDefinitions ()
 		{
 			if (metadata.Types != null)
@@ -740,8 +790,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);
 
@@ -900,7 +954,7 @@ namespace Mono.Cecil {
 			return (TypeReference) LookupToken (token);
 		}
 
-		TypeDefinition GetTypeDefinition (uint rid)
+		public TypeDefinition GetTypeDefinition (uint rid)
 		{
 			InitializeTypeDefinitions ();
 
@@ -957,9 +1011,7 @@ namespace Mono.Cecil {
 			if (type != null)
 				return type;
 
-			type = ReadTypeReference (rid);
-			metadata.AddTypeReference (type);
-			return type;
+			return ReadTypeReference (rid);
 		}
 
 		TypeReference ReadTypeReference (uint rid)
@@ -968,10 +1020,9 @@ namespace Mono.Cecil {
 				return null;
 
 			TypeReference declaring_type = null;
-			var scope = ReadMetadataToken (CodedIndex.ResolutionScope);
+			IMetadataScope scope;
 
-			if (scope.TokenType == TokenType.TypeRef)
-				declaring_type = GetTypeDefOrRef (scope);
+			var scope_token = ReadMetadataToken (CodedIndex.ResolutionScope);
 
 			var name = ReadString ();
 			var @namespace = ReadString ();
@@ -979,34 +1030,55 @@ namespace Mono.Cecil {
 			var type = new TypeReference (
 				@namespace,
 				name,
-				declaring_type != null
+				module,
+				null);
+
+			type.token = new MetadataToken (TokenType.TypeRef, rid);
+
+			metadata.AddTypeReference (type);
+
+			if (scope_token.TokenType == TokenType.TypeRef) {
+				declaring_type = GetTypeDefOrRef (scope_token);
+
+				scope = declaring_type != null
 					? declaring_type.Scope
-					: GetTypeReferenceScope (scope));
+					: module;
+			} else
+				scope = GetTypeReferenceScope (scope_token);
 
+			type.scope = scope;
 			type.DeclaringType = declaring_type;
-			type.token = new MetadataToken (TokenType.TypeRef, rid);
-			type.module = module;
 
-			MetadataSystem.TryProcessPrimitiveType (type);
+			MetadataSystem.TryProcessPrimitiveTypeReference (type);
 
 			return type;
 		}
 
 		IMetadataScope GetTypeReferenceScope (MetadataToken scope)
 		{
+			if (scope.TokenType == TokenType.Module)
+				return module;
+
+			IMetadataScope[] scopes;
+
 			switch (scope.TokenType) {
-			// FIXME: both assembly refs and module refs should be in their
-			// own arrays, in case of someone modify the collections before
-			// this code is called
 			case TokenType.AssemblyRef:
-				return module.AssemblyReferences [(int) scope.RID - 1];
+				InitializeAssemblyReferences ();
+				scopes = metadata.AssemblyReferences;
+				break;
 			case TokenType.ModuleRef:
-				return module.ModuleReferences [(int) scope.RID - 1];
-			case TokenType.Module:
-				return module;
+				InitializeModuleReferences ();
+				scopes = metadata.ModuleReferences;
+				break;
 			default:
 				throw new NotSupportedException ();
 			}
+
+			var index = scope.RID - 1;
+			if (index < 0 || index >= scopes.Length)
+				return null;
+
+			return scopes [index];
 		}
 
 		public IEnumerable<TypeReference> GetTypeReferences ()
@@ -1029,7 +1101,11 @@ namespace Mono.Cecil {
 				return null;
 
 			var reader = ReadSignature (ReadBlobIndex ());
-			return reader.ReadTypeSignature ();
+			var type = reader.ReadTypeSignature ();
+			if (type.token.RID == 0)
+				type.token = new MetadataToken (TokenType.TypeSpec, rid);
+
+			return type;
 		}
 
 		SignatureReader ReadSignature (uint signature)
@@ -1096,14 +1172,19 @@ namespace Mono.Cecil {
 			var fields = new MemberDefinitionCollection<FieldDefinition> (type, (int) fields_range.Length);
 			this.context = type;
 
-			MoveTo (Table.Field, fields_range.Start);
-			for (uint i = 0; i < fields_range.Length; i++)
-				fields.Add (ReadField (fields_range.Start + i));
+			if (!MoveTo (Table.FieldPtr, fields_range.Start)) {
+				if (!MoveTo (Table.Field, fields_range.Start))
+					return fields;
+
+				for (uint i = 0; i < fields_range.Length; i++)
+					ReadField (fields_range.Start + i, fields);
+			} else
+				ReadPointers (Table.FieldPtr, Table.Field, fields_range, fields, ReadField);
 
 			return fields;
 		}
 
-		FieldDefinition ReadField (uint field_rid)
+		void ReadField (uint field_rid, Collection<FieldDefinition> fields)
 		{
 			var attributes = (FieldAttributes) ReadUInt16 ();
 			var name = ReadString ();
@@ -1113,7 +1194,10 @@ namespace Mono.Cecil {
 			field.token = new MetadataToken (TokenType.Field, field_rid);
 			metadata.AddFieldDefinition (field);
 
-			return field;
+			if (IsDeleted (field))
+				return;
+
+			fields.Add (field);
 		}
 
 		void InitializeFields ()
@@ -1201,8 +1285,8 @@ namespace Mono.Cecil {
 			case ElementType.CModReqD:
 				return GetFieldTypeSize (((IModifierType) type).ElementType);
 			default:
-				var field_type = type.CheckedResolve ();
-				if (field_type.HasLayoutInfo)
+				var field_type = type.Resolve ();
+				if (field_type != null && field_type.HasLayoutInfo)
 					size = field_type.ClassSize;
 
 				break;
@@ -1281,18 +1365,24 @@ namespace Mono.Cecil {
 
 			metadata.RemoveEventsRange (type);
 
-			if (range.Length == 0 || !MoveTo (Table.Event, range.Start))
+			if (range.Length == 0)
 				return events;
 
 			this.context = type;
 
-			for (uint i = 0; i < range.Length; i++)
-				events.Add (ReadEvent (range.Start + i));
+			if (!MoveTo (Table.EventPtr, range.Start)) {
+				if (!MoveTo (Table.Event, range.Start))
+					return events;
+
+				for (uint i = 0; i < range.Length; i++)
+					ReadEvent (range.Start + i, events);
+			} else
+				ReadPointers (Table.EventPtr, Table.Event, range, events, ReadEvent);
 
 			return events;
 		}
 
-		EventDefinition ReadEvent (uint event_rid)
+		void ReadEvent (uint event_rid, Collection<EventDefinition> events)
 		{
 			var attributes = (EventAttributes) ReadUInt16 ();
 			var name = ReadString ();
@@ -1300,7 +1390,11 @@ namespace Mono.Cecil {
 
 			var @event = new EventDefinition (name, attributes, event_type);
 			@event.token = new MetadataToken (TokenType.Event, event_rid);
-			return @event;
+
+			if (IsDeleted (@event))
+				return;
+
+			events.Add (@event);
 		}
 
 		void InitializeEvents ()
@@ -1348,18 +1442,23 @@ namespace Mono.Cecil {
 
 			var properties = new MemberDefinitionCollection<PropertyDefinition> (type, (int) range.Length);
 
-			if (range.Length == 0 || !MoveTo (Table.Property, range.Start))
+			if (range.Length == 0)
 				return properties;
 
 			this.context = type;
 
-			for (uint i = 0; i < range.Length; i++)
-				properties.Add (ReadProperty (range.Start + i));
+			if (!MoveTo (Table.PropertyPtr, range.Start)) {
+				if (!MoveTo (Table.Property, range.Start))
+					return properties;
+				for (uint i = 0; i < range.Length; i++)
+					ReadProperty (range.Start + i, properties);
+			} else
+				ReadPointers (Table.PropertyPtr, Table.Property, range, properties, ReadProperty);
 
 			return properties;
 		}
 
-		PropertyDefinition ReadProperty (uint property_rid)
+		void ReadProperty (uint property_rid, Collection<PropertyDefinition> properties)
 		{
 			var attributes = (PropertyAttributes) ReadUInt16 ();
 			var name = ReadString ();
@@ -1381,7 +1480,10 @@ namespace Mono.Cecil {
 			property.HasThis = has_this;
 			property.token = new MetadataToken (TokenType.Property, property_rid);
 
-			return property;
+			if (IsDeleted (property))
+				return;
+
+			properties.Add (property);
 		}
 
 		void InitializeProperties ()
@@ -1405,14 +1507,13 @@ namespace Mono.Cecil {
 			return ReadListRange (rid, Table.PropertyMap, Table.Property);
 		}
 
-		public MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method)
+		MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method)
 		{
 			InitializeMethodSemantics ();
 			Row<MethodSemanticsAttributes, MetadataToken> row;
 			if (!metadata.Semantics.TryGetValue (method.token.RID, out row))
 				return MethodSemanticsAttributes.None;
 
-			method.SemanticsAttributes = row.Col1;
 			var type = method.DeclaringType;
 
 			switch (row.Col1) {
@@ -1479,7 +1580,7 @@ namespace Mono.Cecil {
 			return GetMember (type.Properties, token);
 		}
 
-		static TMember GetMember<TMember> (IList<TMember> members, MetadataToken token) where TMember : IMemberDefinition
+		static TMember GetMember<TMember> (Collection<TMember> members, MetadataToken token) where TMember : IMemberDefinition
 		{
 			for (int i = 0; i < members.Count; i++) {
 				var member = members [i];
@@ -1504,9 +1605,7 @@ namespace Mono.Cecil {
 				var method_rid = ReadTableIndex (Table.Method);
 				var association = ReadMetadataToken (CodedIndex.HasSemantics);
 
-				semantics.Add (
-					method_rid,
-					new Row<MethodSemanticsAttributes, MetadataToken> (attributes, association));
+				semantics [method_rid] = new Row<MethodSemanticsAttributes, MetadataToken> (attributes, association);
 			}
 		}
 
@@ -1522,11 +1621,24 @@ namespace Mono.Cecil {
 			return @event;
 		}
 
-		static void ReadAllSemantics (TypeDefinition type)
+		public MethodSemanticsAttributes ReadAllSemantics (MethodDefinition method)
+		{
+			ReadAllSemantics (method.DeclaringType);
+
+			return method.SemanticsAttributes;
+		}
+
+		void ReadAllSemantics (TypeDefinition type)
 		{
 			var methods = type.Methods;
-			for (int i = 0; i < methods.Count; i++)
-				methods [i].ReadSemantics ();
+			for (int i = 0; i < methods.Count; i++) {
+				var method = methods [i];
+				if (method.sem_attrs_ready)
+					continue;
+
+				method.sem_attrs = ReadMethodSemantics (method);
+				method.sem_attrs_ready = true;
+			}
 		}
 
 		Range ReadParametersRange (uint method_rid)
@@ -1541,14 +1653,36 @@ namespace Mono.Cecil {
 				return new MemberDefinitionCollection<MethodDefinition> (type);
 
 			var methods = new MemberDefinitionCollection<MethodDefinition> (type, (int) methods_range.Length);
+			if (!MoveTo (Table.MethodPtr, methods_range.Start)) {
+				if (!MoveTo (Table.Method, methods_range.Start))
+					return methods;
 
-			MoveTo (Table.Method, methods_range.Start);
-			for (uint i = 0; i < methods_range.Length; i++)
-				ReadMethod (methods_range.Start + i, methods);
+				for (uint i = 0; i < methods_range.Length; i++)
+					ReadMethod (methods_range.Start + i, methods);
+			} else
+				ReadPointers (Table.MethodPtr, Table.Method, methods_range, methods, ReadMethod);
 
 			return methods;
 		}
 
+		void ReadPointers<TMember> (Table ptr, Table table, Range range, Collection<TMember> members, Action<uint, Collection<TMember>> reader)
+			where TMember : IMemberDefinition
+		{
+			for (uint i = 0; i < range.Length; i++) {
+				MoveTo (ptr, range.Start + i);
+
+				var rid = ReadTableIndex (table);
+				MoveTo (table, rid);
+
+				reader (rid, members);
+			}
+		}
+
+		static bool IsDeleted (IMemberDefinition member)
+		{
+			return member.IsSpecialName && member.Name == "_Deleted";
+		}
+
 		void InitializeMethods ()
 		{
 			if (metadata.Methods != null)
@@ -1566,6 +1700,9 @@ namespace Mono.Cecil {
 			method.Name = ReadString ();
 			method.token = new MetadataToken (TokenType.Method, method_rid);
 
+			if (IsDeleted (method))
+				return;
+
 			methods.Add (method); // attach method
 
 			var signature = ReadBlobIndex ();
@@ -1586,22 +1723,44 @@ namespace Mono.Cecil {
 
 		void ReadParameters (MethodDefinition method, Range param_range)
 		{
-			MoveTo (Table.Param, param_range.Start);
-			for (uint i = 0; i < param_range.Length; i++) {
-				var attributes = (ParameterAttributes) ReadUInt16 ();
-				var sequence = ReadUInt16 ();
-				var name = ReadString ();
+			if (!MoveTo (Table.ParamPtr, param_range.Start)) {
+				if (!MoveTo (Table.Param, param_range.Start))
+					return;
+
+				for (uint i = 0; i < param_range.Length; i++)
+					ReadParameter (param_range.Start + i, method);
+			} else
+				ReadParameterPointers (method, param_range);
+		}
+
+		void ReadParameterPointers (MethodDefinition method, Range range)
+		{
+			for (uint i = 0; i < range.Length; i++) {
+				MoveTo (Table.ParamPtr, range.Start + i);
+
+				var rid = ReadTableIndex (Table.Param);
 
-				var parameter = sequence == 0
-					? method.MethodReturnType.Parameter
-					: method.Parameters [sequence - 1];
+				MoveTo (Table.Param, rid);
 
-				parameter.token = new MetadataToken (TokenType.Param, param_range.Start + i);
-				parameter.Name = name;
-				parameter.Attributes = attributes;
+				ReadParameter (rid, method);
 			}
 		}
 
+		void ReadParameter (uint param_rid, MethodDefinition method)
+		{
+			var attributes = (ParameterAttributes) ReadUInt16 ();
+			var sequence = ReadUInt16 ();
+			var name = ReadString ();
+
+			var parameter = sequence == 0
+				? method.MethodReturnType.Parameter
+				: method.Parameters [sequence - 1];
+
+			parameter.token = new MetadataToken (TokenType.Param, param_rid);
+			parameter.Name = name;
+			parameter.Attributes = attributes;
+		}
+
 		void ReadMethodSignature (uint signature, IMethodSignature method)
 		{
 			var reader = ReadSignature (signature);
@@ -1652,25 +1811,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))
-				return new Collection<GenericParameter> ();
+			Range [] ranges;
+			if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
+				return new GenericParameterCollection (provider);
 
 			metadata.RemoveGenericParameterRange (provider);
 
-			var generic_parameters = new Collection<GenericParameter> ((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
@@ -1684,8 +1853,6 @@ namespace Mono.Cecil {
 
 				generic_parameters.Add (parameter);
 			}
-
-			return generic_parameters;
 		}
 
 		void InitializeGenericParameters ()
@@ -1702,10 +1869,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;
@@ -1720,20 +1887,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.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 ();
@@ -1863,6 +2044,8 @@ namespace Mono.Cecil {
 
 			ReadMethodSignature (signature, call_site);
 
+			call_site.MetadataToken = token;
+
 			return call_site;
 		}
 
@@ -1923,7 +2106,7 @@ namespace Mono.Cecil {
 				element = GetMethodSpecification (rid);
 				break;
 			default:
-				throw new NotSupportedException ();
+				return null;
 			}
 
 			this.position = position;
@@ -1947,7 +2130,7 @@ namespace Mono.Cecil {
 		{
 			var type = metadata.GetFieldDeclaringType (rid);
 			if (type == null)
-				throw new NotSupportedException ();
+				return null;
 
 			InitializeCollection (type.Fields);
 
@@ -1969,7 +2152,7 @@ namespace Mono.Cecil {
 		{
 			var type = metadata.GetMethodDeclaringType (rid);
 			if (type == null)
-				throw new NotSupportedException ();
+				return null;
 
 			InitializeCollection (type.Methods);
 
@@ -1981,11 +2164,13 @@ namespace Mono.Cecil {
 			if (!MoveTo (Table.MethodSpec, rid))
 				return null;
 
-			var method = (MethodReference) LookupToken (
+			var element_method = (MethodReference) LookupToken (
 				ReadMetadataToken (CodedIndex.MethodDefOrRef));
 			var signature = ReadBlobIndex ();
 
-			return ReadMethodSpecSignature (signature, method);
+			var method_spec = ReadMethodSpecSignature (signature, element_method);
+			method_spec.token = new MetadataToken (TokenType.MethodSpec, rid);
+			return method_spec;
 		}
 
 		MethodSpecification ReadMethodSpecSignature (uint signature, MethodReference method)
@@ -2014,7 +2199,7 @@ namespace Mono.Cecil {
 				return member;
 
 			member = ReadMemberReference (rid);
-			if (!member.ContainsGenericParameter)
+			if (member != null && !member.ContainsGenericParameter)
 				metadata.AddMemberReference (member);
 			return member;
 		}
@@ -2052,7 +2237,8 @@ namespace Mono.Cecil {
 		{
 			var declaring_type = GetTypeDefOrRef (type);
 
-			this.context = declaring_type;
+			if (!declaring_type.IsArray)
+				this.context = declaring_type;
 
 			var member = ReadMemberReferenceSignature (signature, declaring_type);
 			member.Name = name;
@@ -2108,7 +2294,7 @@ namespace Mono.Cecil {
 			var type_system = module.TypeSystem;
 
 			var context = new MethodReference (string.Empty, type_system.Void);
-			context.DeclaringType = new TypeReference (string.Empty, string.Empty, type_system.Corlib);
+			context.DeclaringType = new TypeReference (string.Empty, string.Empty, module, type_system.Corlib);
 
 			var member_references = new MemberReference [length];
 
@@ -2192,23 +2378,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);
@@ -2220,10 +2418,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)
@@ -2234,8 +2437,12 @@ namespace Mono.Cecil {
 		public void ReadCustomAttributeSignature (CustomAttribute attribute)
 		{
 			var reader = ReadSignature (attribute.signature);
+
+			if (!reader.CanReadMore ())
+				return;
+
 			if (reader.ReadUInt16 () != 0x0001)
-			    throw new InvalidOperationException ();
+				throw new InvalidOperationException ();
 
 			var constructor = attribute.Constructor;
 			if (constructor.HasParameters)
@@ -2311,23 +2518,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 ();
@@ -2336,10 +2555,6 @@ namespace Mono.Cecil {
 
 				security_declarations.Add (new SecurityDeclaration (action, signature, module));
 			}
-
-			metadata.RemoveSecurityDeclarationRange (owner);
-
-			return security_declarations;
 		}
 
 		public byte [] ReadSecurityDeclarationBlob (uint signature)
@@ -2357,7 +2572,7 @@ namespace Mono.Cecil {
 				return;
 			}
 
-			reader.ReadByte ();
+			reader.position++;
 			var count = reader.ReadCompressedUInt32 ();
 			var attributes = new Collection<SecurityAttribute> ((int) count);
 
@@ -2417,7 +2632,7 @@ namespace Mono.Cecil {
 					break;
 				}
 
-				var exported_type = new ExportedType (@namespace, name, scope) {
+				var exported_type = new ExportedType (@namespace, name, module, scope) {
 					Attributes = attributes,
 					Identifier = (int) identifier,
 					DeclaringType = declaring_type,
@@ -2432,21 +2647,24 @@ namespace Mono.Cecil {
 
 		IMetadataScope GetExportedTypeScope (MetadataToken token)
 		{
+			var position = this.position;
+			IMetadataScope scope;
+
 			switch (token.TokenType) {
 			case TokenType.AssemblyRef:
-				return module.AssemblyReferences [(int) token.RID - 1];
+				InitializeAssemblyReferences ();
+				scope = metadata.AssemblyReferences [(int) token.RID - 1];
+				break;
 			case TokenType.File:
-				var position = this.position;
-				var reference = GetModuleReferenceFromFile (token);
-				this.position = position;
-
-				if (reference == null)
-					throw new NotSupportedException ();
-
-				return reference;
+				InitializeModuleReferences ();
+				scope = GetModuleReferenceFromFile (token);
+				break;
 			default:
 				throw new NotSupportedException ();
 			}
+
+			this.position = position;
+			return scope;
 		}
 
 		ModuleReference GetModuleReferenceFromFile (MetadataToken token)
@@ -2458,16 +2676,15 @@ namespace Mono.Cecil {
 			var file_name = ReadString ();
 			var modules = module.ModuleReferences;
 
-			ModuleReference reference = null;
+			ModuleReference reference;
 			for (int i = 0; i < modules.Count; i++) {
-				var module_reference = modules [i];
-				if (module_reference.Name != file_name)
-					continue;
-
-				reference = module_reference;
-				break;
+				reference = modules [i];
+				if (reference.Name == file_name)
+					return reference;
 			}
 
+			reference = new ModuleReference (file_name);
+			modules.Add (reference);
 			return reference;
 		}
 
@@ -2509,9 +2726,10 @@ namespace Mono.Cecil {
 		GenericParameter GetGenericParameter (GenericParameterType type, uint var)
 		{
 			var context = reader.context;
+			int index = (int) var;
 
 			if (context == null)
-				throw new NotSupportedException ();
+				return GetUnboundGenericParameter (type, index);
 
 			IGenericParameterProvider provider;
 
@@ -2526,14 +2744,20 @@ namespace Mono.Cecil {
 				throw new NotSupportedException ();
 			}
 
-			int index = (int) var;
-
 			if (!context.IsDefinition)
 				CheckGenericContext (provider, index);
 
+			if (index >= provider.GenericParameters.Count)
+				return GetUnboundGenericParameter (type, index);
+
 			return provider.GenericParameters [index];
 		}
 
+		GenericParameter GetUnboundGenericParameter (GenericParameterType type, int index)
+		{
+			return new GenericParameter (index, type, reader.module);
+		}
+
 		static void CheckGenericContext (IGenericParameterProvider owner, int index)
 		{
 			var owner_parameters = owner.GenericParameters;
@@ -2659,12 +2883,24 @@ namespace Mono.Cecil {
 		public void ReadMethodSignature (IMethodSignature method)
 		{
 			var calling_convention = ReadByte ();
+
+			const byte has_this = 0x20;
+			const byte explicit_this = 0x40;
+
+			if ((calling_convention & has_this) != 0) {
+				method.HasThis = true;
+				calling_convention = (byte) (calling_convention & ~has_this);
+			}
+
+			if ((calling_convention & explicit_this) != 0) {
+				method.ExplicitThis = true;
+				calling_convention = (byte) (calling_convention & ~explicit_this);
+			}
+
 			method.CallingConvention = (MethodCallingConvention) calling_convention;
-			method.HasThis = (calling_convention & 0x20) != 0;
-			method.ExplicitThis = (calling_convention & 0x40) != 0;
 
 			var generic_context = method as MethodReference;
-			if (generic_context != null)
+			if (generic_context != null && !generic_context.DeclaringType.IsArray)
 				reader.context = generic_context;
 
 			if ((calling_convention & 0x10) != 0) {
@@ -2674,8 +2910,6 @@ namespace Mono.Cecil {
 					CheckGenericContext (generic_context, (int) arity -1 );
 			}
 
-			// TODO: more call_conv
-
 			var param_count = ReadCompressedUInt32 ();
 
 			method.MethodReturnType.ReturnType = ReadTypeSignature ();
@@ -2780,10 +3014,11 @@ namespace Mono.Cecil {
 			if (type.IsArray)
 				return ReadCustomAttributeFixedArrayArgument ((ArrayType) type);
 
-			if (type.etype == ElementType.Object)
-				return ReadCustomAttributeElement (ReadCustomAttributeFieldOrPropType ());
-
-			return new CustomAttributeArgument (type, ReadCustomAttributeElementValue (type));
+			return new CustomAttributeArgument (
+				type,
+				type.etype == ElementType.Object
+					? ReadCustomAttributeElement (ReadCustomAttributeFieldOrPropType ())
+					: ReadCustomAttributeElementValue (type));
 		}
 
 		object ReadCustomAttributeElementValue (TypeReference type)
diff --git a/vbnc/cecil/Mono.Cecil/AssemblyWriter.cs b/vbnc/cecil/Mono.Cecil/AssemblyWriter.cs
index 7302207..2b38ddc 100755
--- a/vbnc/cecil/Mono.Cecil/AssemblyWriter.cs
+++ b/vbnc/cecil/Mono.Cecil/AssemblyWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -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);
@@ -97,20 +97,18 @@ namespace Mono.Cecil {
 			var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider);
 
 #if !SILVERLIGHT && !CF
-			if (parameters.StrongNameKeyPair != null && name != null)
+			if (parameters.StrongNameKeyPair != null && name != null) {
 				name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
-#endif
-
-			if (name != null && name.HasPublicKey)
 				module.Attributes |= ModuleAttributes.StrongNameSigned;
-
+			}
+#endif
 			var metadata = new MetadataBuilder (module, fq_name,
 				symbol_writer_provider, symbol_writer);
 
 			BuildMetadata (module, metadata);
 
-			if (module.SymbolReader != null)
-				module.SymbolReader.Dispose ();
+			if (module.symbol_reader != null)
+				module.symbol_reader.Dispose ();
 
 			var writer = ImageWriter.CreateWriter (module, metadata, stream);
 
@@ -786,7 +784,7 @@ namespace Mono.Cecil {
 		TextMap CreateTextMap ()
 		{
 			var map = new TextMap ();
-			map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 16);
+			map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 0);
 			map.AddMap (TextSegment.CLIHeader, 0x48, 8);
 			return map;
 		}
@@ -935,11 +933,13 @@ namespace Mono.Cecil {
 					? reference.PublicKeyToken
 					: reference.PublicKey;
 
+				var version = reference.Version;
+
 				var rid = table.AddRow (new AssemblyRefRow (
-					(ushort) reference.Version.Major,
-					(ushort) reference.Version.Minor,
-					(ushort) reference.Version.Build,
-					(ushort) reference.Version.Revision,
+					(ushort) version.Major,
+					(ushort) version.Minor,
+					(ushort) version.Build,
+					(ushort) version.Revision,
 					reference.Attributes,
 					GetBlobIndex (key_or_token),
 					GetStringIndex (reference.Name),
@@ -1175,9 +1175,7 @@ namespace Mono.Cecil {
 
 		TypeRefRow CreateTypeRefRow (TypeReference type)
 		{
-			var scope_token = type.IsNested
-				? GetTypeRefToken (type.DeclaringType)
-				: type.Scope.MetadataToken;
+			var scope_token = GetScopeToken (type);
 
 			return new TypeRefRow (
 				MakeCodedRID (scope_token, CodedIndex.ResolutionScope),
@@ -1185,6 +1183,19 @@ namespace Mono.Cecil {
 				GetStringIndex (type.Namespace));
 		}
 
+		MetadataToken GetScopeToken (TypeReference type)
+		{
+			if (type.IsNested)
+				return GetTypeRefToken (type.DeclaringType);
+
+			var scope = type.Scope;
+
+			if (scope == null)
+				return MetadataToken.Zero;
+
+			return scope.MetadataToken;
+		}
+
 		static CodedRID MakeCodedRID (IMetadataTokenProvider provider, CodedIndex index)
 		{
 			return MakeCodedRID (provider.MetadataToken, index);
@@ -1413,8 +1424,7 @@ namespace Mono.Cecil {
 				GetBlobIndex (GetMethodSignature (method)),
 				param_rid));
 
-			if (method.HasParameters)
-				AddParameters (method);
+			AddParameters (method);
 
 			if (method.HasGenericParameters)
 				AddGenericParameters (method);
@@ -1434,13 +1444,16 @@ namespace Mono.Cecil {
 
 		void AddParameters (MethodDefinition method)
 		{
-			var parameters = method.Parameters;
-
 			var return_parameter = method.MethodReturnType.parameter;
 
 			if (return_parameter != null && RequiresParameterRow (return_parameter))
 				AddParameter (0, return_parameter, param_table);
 
+			if (!method.HasParameters)
+				return;
+
+			var parameters = method.Parameters;
+
 			for (int i = 0; i < parameters.Count; i++) {
 				var parameter = parameters [i];
 				if (!RequiresParameterRow (parameter))
@@ -1454,7 +1467,7 @@ namespace Mono.Cecil {
 		{
 			var pinvoke = method.PInvokeInfo;
 			if (pinvoke == null)
-				throw new ArgumentException ();
+				return;
 
 			var table = GetTable<ImplMapTable> (Table.ImplMap);
 			table.AddRow (new ImplMapRow (
@@ -1617,6 +1630,9 @@ namespace Mono.Cecil {
 
 		static ElementType GetConstantType (TypeReference constant_type, object constant)
 		{
+			if (constant == null)
+				return ElementType.Class;
+
 			var etype = constant_type.etype;
 			switch (etype) {
 			case ElementType.None:
@@ -1626,26 +1642,40 @@ namespace Mono.Cecil {
 
 				return ElementType.Class;
 			case ElementType.String:
-				return constant != null ? ElementType.String : ElementType.Class;
+				return ElementType.String;
 			case ElementType.Object:
-				if (constant != null)
-					return GetConstantType (constant.GetType ());
-
-				return ElementType.Class;
+				return GetConstantType (constant.GetType ());
 			case ElementType.Array:
 			case ElementType.SzArray:
 			case ElementType.MVar:
 			case ElementType.Var:
-				if (constant != null)
-					throw new ArgumentException ();
-
 				return ElementType.Class;
 			case ElementType.GenericInst:
+				var generic_instance = (GenericInstanceType) constant_type;
+				if (generic_instance.ElementType.IsTypeOf ("System", "Nullable`1"))
+					return GetConstantType (generic_instance.GenericArguments [0], constant);
+
+				return GetConstantType (((TypeSpecification) constant_type).ElementType, constant);
 			case ElementType.CModOpt:
 			case ElementType.CModReqD:
 			case ElementType.ByRef:
 			case ElementType.Sentinel:
 				return GetConstantType (((TypeSpecification) constant_type).ElementType, constant);
+			case ElementType.Boolean:
+			case ElementType.Char:
+			case ElementType.I:
+			case ElementType.I1:
+			case ElementType.I2:
+			case ElementType.I4:
+			case ElementType.I8:
+			case ElementType.U:
+			case ElementType.U1:
+			case ElementType.U2:
+			case ElementType.U4:
+			case ElementType.U8:
+			case ElementType.R4:
+			case ElementType.R8:
+				return GetConstantType (constant.GetType ());
 			default:
 				return etype;
 			}
@@ -1891,7 +1921,7 @@ namespace Mono.Cecil {
 				signature.WriteConstantString ((string) value);
 				break;
 			default:
-				signature.WriteConstantPrimitive (type, value);
+				signature.WriteConstantPrimitive (value);
 				break;
 			}
 
@@ -1918,21 +1948,13 @@ namespace Mono.Cecil {
 		SignatureWriter GetSecurityDeclarationSignature (SecurityDeclaration declaration)
 		{
 			var signature = CreateSignatureWriter ();
-			if (!declaration.resolved) {
-				signature.WriteBytes (declaration.GetBlob ());
-				return signature;
-			}
-
-			signature.WriteByte ((byte) '.');
-
-			var attributes = declaration.security_attributes;
-			if (attributes == null)
-				throw new NotSupportedException ();
-
-			signature.WriteCompressedUInt32 ((uint) attributes.Count);
 
-			for (int i = 0; i < attributes.Count; i++)
-				signature.WriteSecurityAttribute (attributes [i]);
+			if (!declaration.resolved)
+				signature.WriteBytes (declaration.GetBlob ());
+			else if (module.Runtime < TargetRuntime.Net_2_0)
+				signature.WriteXmlSecurityDeclaration (declaration);
+			else
+				signature.WriteSecurityDeclaration (declaration);
 
 			return signature;
 		}
@@ -1946,11 +1968,20 @@ namespace Mono.Cecil {
 			return signature;
 		}
 
+		static Exception CreateForeignMemberException (MemberReference member)
+		{
+			return new ArgumentException (string.Format ("Member '{0}' is declared in another module and needs to be imported", member));
+		}
+
 		public MetadataToken LookupToken (IMetadataTokenProvider provider)
 		{
 			if (provider == null)
 				throw new ArgumentNullException ();
 
+			var member = provider as MemberReference;
+			if (member == null || member.Module != module)
+				throw CreateForeignMemberException (member);
+
 			var token = provider.MetadataToken;
 
 			switch (token.TokenType) {
@@ -1967,7 +1998,7 @@ namespace Mono.Cecil {
 			case TokenType.MethodSpec:
 				return GetMethodSpecToken ((MethodSpecification) provider);
 			case TokenType.MemberRef:
-				return GetMemberRefToken ((MemberReference) provider);
+				return GetMemberRefToken (member);
 			default:
 				throw new NotSupportedException ();
 			}
@@ -2003,9 +2034,7 @@ namespace Mono.Cecil {
 
 		public void WriteMethodSignature (IMethodSignature method)
 		{
-			byte calling_convention = 0;
-			if (method.IsVarArg ())
-				calling_convention |= 0x5;
+			byte calling_convention = (byte) method.CallingConvention;
 			if (method.HasThis)
 				calling_convention |= 0x20;
 			if (method.ExplicitThis)
@@ -2200,9 +2229,9 @@ namespace Mono.Cecil {
 			WriteBytes (Encoding.Unicode.GetBytes (value));
 		}
 
-		public void WriteConstantPrimitive (ElementType type, object value)
+		public void WriteConstantPrimitive (object value)
 		{
-			WritePrimitiveValue (type, value);
+			WritePrimitiveValue (value);
 		}
 
 		public void WriteCustomAttributeConstructorArguments (CustomAttribute attribute)
@@ -2258,8 +2287,11 @@ namespace Mono.Cecil {
 			}
 
 			if (type.etype == ElementType.Object) {
-				WriteCustomAttributeFieldOrPropType (argument.Type);
-				WriteCustomAttributeElement (argument.Type, argument);
+				argument = (CustomAttributeArgument) argument.Value;
+				type = argument.Type;
+
+				WriteCustomAttributeFieldOrPropType (type);
+				WriteCustomAttributeElement (type, argument);
 				return;
 			}
 
@@ -2285,52 +2317,55 @@ namespace Mono.Cecil {
 					WriteCustomAttributeEnumValue (type, value);
 				break;
 			default:
-				WritePrimitiveValue (etype, value);
+				WritePrimitiveValue (value);
 				break;
 			}
 		}
 
-		void WritePrimitiveValue (ElementType type, object value)
+		void WritePrimitiveValue (object value)
 		{
-			switch (type) {
-			case ElementType.Boolean:
+			if (value == null)
+				throw new ArgumentNullException ();
+
+			switch (Type.GetTypeCode (value.GetType ())) {
+			case TypeCode.Boolean:
 				WriteByte ((byte) (((bool) value) ? 1 : 0));
 				break;
-			case ElementType.U1:
+			case TypeCode.Byte:
 				WriteByte ((byte) value);
 				break;
-			case ElementType.I1:
-				WriteByte ((byte) (sbyte) value);
+			case TypeCode.SByte:
+				WriteSByte ((sbyte) value);
 				break;
-			case ElementType.I2:
+			case TypeCode.Int16:
 				WriteInt16 ((short) value);
 				break;
-			case ElementType.U2:
+			case TypeCode.UInt16:
 				WriteUInt16 ((ushort) value);
 				break;
-			case ElementType.Char:
+			case TypeCode.Char:
 				WriteInt16 ((short) (char) value);
 				break;
-			case ElementType.I4:
+			case TypeCode.Int32:
 				WriteInt32 ((int) value);
 				break;
-			case ElementType.U4:
+			case TypeCode.UInt32:
 				WriteUInt32 ((uint) value);
 				break;
-			case ElementType.R4:
+			case TypeCode.Single:
 				WriteSingle ((float) value);
 				break;
-			case ElementType.I8:
+			case TypeCode.Int64:
 				WriteInt64 ((long) value);
 				break;
-			case ElementType.U8:
+			case TypeCode.UInt64:
 				WriteUInt64 ((ulong) value);
 				break;
-			case ElementType.R8:
+			case TypeCode.Double:
 				WriteDouble ((double) value);
 				break;
 			default:
-				throw new NotSupportedException (type.ToString ());
+				throw new NotSupportedException (value.GetType ().FullName);
 			}
 		}
 
@@ -2422,19 +2457,19 @@ namespace Mono.Cecil {
 			WriteCustomAttributeFixedArgument (argument.Type, argument);
 		}
 
-		public void WriteSecurityAttribute (SecurityAttribute attribute)
+		void WriteSecurityAttribute (SecurityAttribute attribute)
 		{
 			WriteTypeReference (attribute.AttributeType);
 
 			var count = GetNamedArgumentCount (attribute);
 
 			if (count == 0) {
-				WriteCompressedUInt32 (0); // length
+				WriteCompressedUInt32 (1); // length
 				WriteCompressedUInt32 (0); // count
 				return;
 			}
 
-            var buffer = new SignatureWriter (metadata);
+			var buffer = new SignatureWriter (metadata);
 			buffer.WriteCompressedUInt32 ((uint) count);
 			buffer.WriteICustomAttributeNamedArguments (attribute);
 
@@ -2442,6 +2477,49 @@ namespace Mono.Cecil {
 			WriteBytes (buffer);
 		}
 
+		public void WriteSecurityDeclaration (SecurityDeclaration declaration)
+		{
+			WriteByte ((byte) '.');
+
+			var attributes = declaration.security_attributes;
+			if (attributes == null)
+				throw new NotSupportedException ();
+
+			WriteCompressedUInt32 ((uint) attributes.Count);
+
+			for (int i = 0; i < attributes.Count; i++)
+				WriteSecurityAttribute (attributes [i]);
+		}
+
+		public void WriteXmlSecurityDeclaration (SecurityDeclaration declaration)
+		{
+			var xml = GetXmlSecurityDeclaration (declaration);
+			if (xml == null)
+				throw new NotSupportedException ();
+
+			WriteBytes (Encoding.Unicode.GetBytes (xml));
+		}
+
+		static string GetXmlSecurityDeclaration (SecurityDeclaration declaration)
+		{
+			if (declaration.security_attributes == null || declaration.security_attributes.Count != 1)
+				return null;
+
+			var attribute = declaration.security_attributes [0];
+
+			if (!attribute.AttributeType.IsTypeOf ("System.Security.Permissions", "PermissionSetAttribute"))
+				return null;
+
+			if (attribute.properties == null || attribute.properties.Count != 1)
+				return null;
+
+			var property = attribute.properties [0];
+			if (property.Name != "XML")
+				return null;
+
+			return (string) property.Argument.Value;
+		}
+
 		void WriteTypeReference (TypeReference type)
 		{
 			WriteUTF8String (TypeParser.ToParseable (type));
diff --git a/vbnc/cecil/Mono.Cecil/BaseAssemblyResolver.cs b/vbnc/cecil/Mono.Cecil/BaseAssemblyResolver.cs
index 0b8f08f..63c2610 100644
--- a/vbnc/cecil/Mono.Cecil/BaseAssemblyResolver.cs
+++ b/vbnc/cecil/Mono.Cecil/BaseAssemblyResolver.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -51,6 +51,33 @@ namespace Mono.Cecil {
 		}
 	}
 
+#if !SILVERLIGHT && !CF
+	[Serializable]
+#endif
+	public class AssemblyResolutionException : FileNotFoundException {
+
+		readonly AssemblyNameReference reference;
+
+		public AssemblyNameReference AssemblyReference {
+			get { return reference; }
+		}
+
+		public AssemblyResolutionException (AssemblyNameReference reference)
+			: base (string.Format ("Failed to resolve assembly: '{0}'", reference))
+		{
+			this.reference = reference;
+		}
+
+#if !SILVERLIGHT && !CF
+		protected AssemblyResolutionException (
+			System.Runtime.Serialization.SerializationInfo info,
+			System.Runtime.Serialization.StreamingContext context)
+			: base (info, context)
+		{
+		}
+#endif
+	}
+
 	public abstract class BaseAssemblyResolver : IAssemblyResolver {
 
 		static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null;
@@ -80,7 +107,15 @@ namespace Mono.Cecil {
 
 		public virtual AssemblyDefinition Resolve (string fullName)
 		{
-			return Resolve (AssemblyNameReference.Parse (fullName));
+			return Resolve (fullName, new ReaderParameters ());
+		}
+
+		public virtual AssemblyDefinition Resolve (string fullName, ReaderParameters parameters)
+		{
+			if (fullName == null)
+				throw new ArgumentNullException ("fullName");
+
+			return Resolve (AssemblyNameReference.Parse (fullName), parameters);
 		}
 
 		public event AssemblyResolveEventHandler ResolveFailure;
@@ -90,37 +125,57 @@ namespace Mono.Cecil {
 			directories = new Collection<string> (2) { ".", "bin" };
 		}
 
-		AssemblyDefinition GetAssembly (string file)
+		AssemblyDefinition GetAssembly (string file, ReaderParameters parameters)
 		{
-			return ModuleDefinition.ReadModule (file, new ReaderParameters { AssemblyResolver = this}).Assembly;
+			if (parameters.AssemblyResolver == null)
+				parameters.AssemblyResolver = this;
+
+			return ModuleDefinition.ReadModule (file, parameters).Assembly;
 		}
 
 		public virtual AssemblyDefinition Resolve (AssemblyNameReference name)
 		{
-			var assembly = SearchDirectory (name, directories);
+			return Resolve (name, new ReaderParameters ());
+		}
+
+		public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters)
+		{
+			if (name == null)
+				throw new ArgumentNullException ("name");
+			if (parameters == null)
+				parameters = new ReaderParameters ();
+
+			var assembly = SearchDirectory (name, directories, parameters);
 			if (assembly != null)
 				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)) {
-				assembly = SearchDirectory (name, new [] { framework_dir });
+				assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
 				if (assembly != null)
 					return assembly;
 			}
 
 			if (name.Name == "mscorlib") {
-				assembly = GetCorlib (name);
+				assembly = GetCorlib (name, parameters);
 				if (assembly != null)
 					return assembly;
 			}
 
-			assembly = GetAssemblyInGac (name);
+			assembly = GetAssemblyInGac (name, parameters);
 			if (assembly != null)
 				return assembly;
 
-			assembly = SearchDirectory (name, new [] { framework_dir });
+			assembly = SearchDirectory (name, new [] { framework_dir }, parameters);
 			if (assembly != null)
 				return assembly;
 #endif
@@ -131,17 +186,17 @@ namespace Mono.Cecil {
 					return assembly;
 			}
 
-			throw new FileNotFoundException ("Could not resolve: " + name);
+			throw new AssemblyResolutionException (name);
 		}
 
-		AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories)
+		AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories, ReaderParameters parameters)
 		{
 			var extensions = new [] { ".exe", ".dll" };
 			foreach (var directory in directories) {
 				foreach (var extension in extensions) {
 					string file = Path.Combine (directory, name.Name + extension);
 					if (File.Exists (file))
-						return GetAssembly (file);
+						return GetAssembly (file, parameters);
 				}
 			}
 
@@ -150,17 +205,17 @@ namespace Mono.Cecil {
 
 		static bool IsZero (Version version)
 		{
-			return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0;
+			return version == null || (version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0);
 		}
 
 #if !SILVERLIGHT && !CF
-		AssemblyDefinition GetCorlib (AssemblyNameReference reference)
+		AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters)
 		{
 			var version = reference.Version;
 			var corlib = typeof (object).Assembly.GetName ();
 
 			if (corlib.Version == version || IsZero (version))
-				return GetAssembly (typeof (object).Module.FullyQualifiedName);
+				return GetAssembly (typeof (object).Module.FullyQualifiedName, parameters);
 
 			var path = Directory.GetParent (
 				Directory.GetParent (
@@ -200,7 +255,7 @@ namespace Mono.Cecil {
 
 			var file = Path.Combine (path, "mscorlib.dll");
 			if (File.Exists (file))
-				return GetAssembly (file);
+				return GetAssembly (file, parameters);
 
 			return null;
 		}
@@ -246,10 +301,13 @@ namespace Mono.Cecil {
 
 		static string GetCurrentMonoGac ()
 		{
-			return Path.Combine (Directory.GetParent (typeof (object).Module.FullyQualifiedName).FullName, "gac");
+			return Path.Combine (
+				Directory.GetParent (
+					Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName)).FullName,
+				"gac");
 		}
 
-		AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference)
+		AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference, ReaderParameters parameters)
 		{
 			if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
 				return null;
@@ -258,26 +316,26 @@ namespace Mono.Cecil {
 				gac_paths = GetGacPaths ();
 
 			if (on_mono)
-				return GetAssemblyInMonoGac (reference);
+				return GetAssemblyInMonoGac (reference, parameters);
 
-			return GetAssemblyInNetGac (reference);
+			return GetAssemblyInNetGac (reference, parameters);
 		}
 
-		AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference)
+		AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference, ReaderParameters parameters)
 		{
 			for (int i = 0; i < gac_paths.Count; i++) {
 				var gac_path = gac_paths [i];
 				var file = GetAssemblyFile (reference, string.Empty, gac_path);
 				if (File.Exists (file))
-					return GetAssembly (file);
+					return GetAssembly (file, parameters);
 			}
 
 			return null;
 		}
 
-		AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference)
+		AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference, ReaderParameters parameters)
 		{
-			var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC" };
+			var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC_64", "GAC" };
 			var prefixes = new [] { string.Empty, "v4.0_" };
 
 			for (int i = 0; i < 2; i++) {
@@ -285,7 +343,7 @@ namespace Mono.Cecil {
 					var gac = Path.Combine (gac_paths [i], gacs [j]);
 					var file = GetAssemblyFile (reference, prefixes [i], gac);
 					if (Directory.Exists (gac) && File.Exists (file))
-						return GetAssembly (file);
+						return GetAssembly (file, parameters);
 				}
 			}
 
@@ -294,10 +352,11 @@ namespace Mono.Cecil {
 
 		static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac)
 		{
-			var gac_folder = new StringBuilder ();
-			gac_folder.Append (prefix);
-			gac_folder.Append (reference.Version);
-			gac_folder.Append ("__");
+			var gac_folder = new StringBuilder ()
+				.Append (prefix)
+				.Append (reference.Version)
+				.Append ("__");
+
 			for (int i = 0; i < reference.PublicKeyToken.Length; i++)
 				gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2"));
 
diff --git a/vbnc/cecil/Mono.Cecil/CallSite.cs b/vbnc/cecil/Mono.Cecil/CallSite.cs
index e4880ec..2d4ed41 100644
--- a/vbnc/cecil/Mono.Cecil/CallSite.cs
+++ b/vbnc/cecil/Mono.Cecil/CallSite.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -29,11 +29,70 @@
 using System;
 using System.Text;
 
+using Mono.Collections.Generic;
+
 namespace Mono.Cecil {
 
-	public sealed class CallSite : MethodReference {
+	public sealed class CallSite : IMethodSignature {
+
+		readonly MethodReference signature;
 
-		public override string FullName {
+		public bool HasThis {
+			get { return signature.HasThis; }
+			set { signature.HasThis = value; }
+		}
+
+		public bool ExplicitThis {
+			get { return signature.ExplicitThis; }
+			set { signature.ExplicitThis = value; }
+		}
+
+		public MethodCallingConvention CallingConvention {
+			get { return signature.CallingConvention; }
+			set { signature.CallingConvention = value; }
+		}
+
+		public bool HasParameters {
+			get { return signature.HasParameters; }
+		}
+
+		public Collection<ParameterDefinition> Parameters {
+			get { return signature.Parameters; }
+		}
+
+		public TypeReference ReturnType {
+			get { return signature.MethodReturnType.ReturnType; }
+			set { signature.MethodReturnType.ReturnType = value; }
+		}
+
+		public MethodReturnType MethodReturnType {
+			get { return signature.MethodReturnType; }
+		}
+
+		public string Name {
+			get { return string.Empty; }
+			set { throw new InvalidOperationException (); }
+		}
+
+		public string Namespace {
+			get { return string.Empty; }
+			set { throw new InvalidOperationException (); }
+		}
+
+		public ModuleDefinition Module {
+			get { return ReturnType.Module; }
+		}
+
+		public IMetadataScope Scope {
+			get { return signature.ReturnType.Scope; }
+		}
+
+		public MetadataToken MetadataToken {
+			get { return signature.token; }
+			set { signature.token = value; }
+		}
+
+		public string FullName {
 			get {
 				var signature = new StringBuilder ();
 				signature.Append (ReturnType.FullName);
@@ -41,5 +100,25 @@ namespace Mono.Cecil {
 				return signature.ToString ();
 			}
 		}
+
+		internal CallSite ()
+		{
+			this.signature = new MethodReference ();
+			this.signature.token = new MetadataToken (TokenType.Signature, 0);
+		}
+
+		public CallSite (TypeReference returnType)
+			: this ()
+		{
+			if (returnType == null)
+				throw new ArgumentNullException ("returnType");
+
+			this.signature.ReturnType = returnType;
+		}
+
+		public override string ToString ()
+		{
+			return FullName;
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/CustomAttribute.cs b/vbnc/cecil/Mono.Cecil/CustomAttribute.cs
index af47d8b..e8eb057 100644
--- a/vbnc/cecil/Mono.Cecil/CustomAttribute.cs
+++ b/vbnc/cecil/Mono.Cecil/CustomAttribute.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -103,6 +103,10 @@ namespace Mono.Cecil {
 			get { return constructor.DeclaringType; }
 		}
 
+		public bool IsResolved {
+			get { return resolved; }
+		}
+
 		public bool HasConstructorArguments {
 			get {
 				Resolve ();
@@ -184,10 +188,10 @@ namespace Mono.Cecil {
 			if (blob != null)
 				return blob;
 
-			if (!HasImage || signature == 0)
+			if (!HasImage)
 				throw new NotSupportedException ();
 
-			return blob = Module.Read (this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature));
+			return Module.Read (ref blob, this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature));
 		}
 
 		void Resolve ()
@@ -196,11 +200,21 @@ namespace Mono.Cecil {
 				return;
 
 			Module.Read (this, (attribute, reader) => {
-				reader.ReadCustomAttributeSignature (attribute);
+				try {
+					reader.ReadCustomAttributeSignature (attribute);
+					resolved = true;
+				} catch (ResolutionException) {
+					if (arguments != null)
+						arguments.Clear ();
+					if (fields != null)
+						fields.Clear ();
+					if (properties != null)
+						properties.Clear ();
+
+					resolved = false;
+				}
 				return this;
 			});
-
-			resolved = true;
 		}
 	}
 
diff --git a/vbnc/cecil/Mono.Cecil/DefaultAssemblyResolver.cs b/vbnc/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
index a38ebae..3f9418d 100755
--- a/vbnc/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
+++ b/vbnc/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -31,18 +31,13 @@ using System.Collections.Generic;
 
 namespace Mono.Cecil {
 
-	public static class GlobalAssemblyResolver {
-
-		public static readonly IAssemblyResolver Instance = new DefaultAssemblyResolver ();
-	}
-
 	public class DefaultAssemblyResolver : BaseAssemblyResolver {
 
 		readonly IDictionary<string, AssemblyDefinition> cache;
 
 		public DefaultAssemblyResolver ()
 		{
-			cache = new Dictionary<string, AssemblyDefinition> ();
+			cache = new Dictionary<string, AssemblyDefinition> (StringComparer.Ordinal);
 		}
 
 		public override AssemblyDefinition Resolve (AssemblyNameReference name)
diff --git a/vbnc/cecil/Mono.Cecil/EmbeddedResource.cs b/vbnc/cecil/Mono.Cecil/EmbeddedResource.cs
index e0216da..80c260c 100644
--- a/vbnc/cecil/Mono.Cecil/EmbeddedResource.cs
+++ b/vbnc/cecil/Mono.Cecil/EmbeddedResource.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -78,6 +78,9 @@ namespace Mono.Cecil {
 
 		public byte [] GetResourceData ()
 		{
+			if (stream != null)
+				return ReadStream (stream);
+
 			if (data != null)
 				return data;
 
@@ -86,5 +89,28 @@ namespace Mono.Cecil {
 
 			throw new InvalidOperationException ();
 		}
+
+		static byte [] ReadStream (Stream stream)
+		{
+			int read;
+
+			if (stream.CanSeek) {
+				var length = (int) stream.Length;
+				var data = new byte [length];
+				int offset = 0;
+
+				while ((read = stream.Read (data, offset, length - offset)) > 0)
+					offset += read;
+
+				return data;
+			}
+
+			var buffer = new byte [1024 * 8];
+			var memory = new MemoryStream ();
+			while ((read = stream.Read (buffer, 0, buffer.Length)) > 0)
+				memory.Write (buffer, 0, read);
+
+			return memory.ToArray ();
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/EventAttributes.cs b/vbnc/cecil/Mono.Cecil/EventAttributes.cs
index b5b097d..815efa5 100644
--- a/vbnc/cecil/Mono.Cecil/EventAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/EventAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/EventDefinition.cs b/vbnc/cecil/Mono.Cecil/EventDefinition.cs
index 7a80aa0..512643a 100644
--- a/vbnc/cecil/Mono.Cecil/EventDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/EventDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -113,7 +113,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		#region EventAttributes
@@ -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
@@ -148,16 +148,26 @@ namespace Mono.Cecil {
 
 		void InitializeMethods ()
 		{
-			if (add_method != null
-				|| invoke_method != null
-				|| remove_method != null)
-				return;
-
 			var module = this.Module;
-			if (!module.HasImage ())
+			if (module == null)
 				return;
 
-			module.Read (this, (@event, reader) => reader.ReadMethods (@event));
+			lock (module.SyncRoot) {
+				if (add_method != null
+					|| invoke_method != null
+					|| remove_method != null)
+					return;
+
+				if (!module.HasImage ())
+					return;
+
+				module.Read (this, (@event, reader) => reader.ReadMethods (@event));
+			}
+		}
+
+		public override EventDefinition Resolve ()
+		{
+			return this;
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/EventReference.cs b/vbnc/cecil/Mono.Cecil/EventReference.cs
index f9dda35..412b9c8 100755
--- a/vbnc/cecil/Mono.Cecil/EventReference.cs
+++ b/vbnc/cecil/Mono.Cecil/EventReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -48,5 +48,7 @@ namespace Mono.Cecil {
 		{
 			event_type = eventType;
 		}
+
+		public abstract EventDefinition Resolve ();
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/ExportedType.cs b/vbnc/cecil/Mono.Cecil/ExportedType.cs
index a1e793a..c922baa 100644
--- a/vbnc/cecil/Mono.Cecil/ExportedType.cs
+++ b/vbnc/cecil/Mono.Cecil/ExportedType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -36,6 +36,7 @@ namespace Mono.Cecil {
 		string name;
 		uint attributes;
 		IMetadataScope scope;
+		ModuleDefinition module;
 		int identifier;
 		ExportedType declaring_type;
 		internal MetadataToken token;
@@ -210,26 +211,40 @@ namespace Mono.Cecil {
 
 		public string FullName {
 			get {
-				if (declaring_type != null)
-					return declaring_type.FullName + "/" + name;
+				var fullname = string.IsNullOrEmpty (@namespace)
+					? name
+					: @namespace + '.' + name;
 
-				if (string.IsNullOrEmpty (@namespace))
-					return name;
+				if (declaring_type != null)
+					return declaring_type.FullName + "/" + fullname;
 
-				return @namespace + "." + name;
+				return fullname;
 			}
 		}
 
-		public ExportedType (string @namespace, string name, IMetadataScope scope)
+		public ExportedType (string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
 		{
 			this. at namespace = @namespace;
 			this.name = name;
 			this.scope = scope;
+			this.module = module;
 		}
 
 		public override string ToString ()
 		{
 			return FullName;
 		}
+
+		public TypeDefinition Resolve ()
+		{
+			return module.Resolve (CreateReference ());
+		}
+
+		internal TypeReference CreateReference ()
+		{
+			return new TypeReference (@namespace, name, module, scope) {
+				DeclaringType = declaring_type != null ? declaring_type.CreateReference () : null,
+			};
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/FieldAttributes.cs b/vbnc/cecil/Mono.Cecil/FieldAttributes.cs
index 947a877..dd6bf36 100644
--- a/vbnc/cecil/Mono.Cecil/FieldAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/FieldAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/FieldDefinition.cs b/vbnc/cecil/Mono.Cecil/FieldDefinition.cs
index c60a940..f992b2b 100644
--- a/vbnc/cecil/Mono.Cecil/FieldDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/FieldDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -124,7 +124,7 @@ namespace Mono.Cecil {
 
 		public bool HasConstant {
 			get {
-				ResolveConstant ();
+				this.ResolveConstant (ref constant, Module);
 
 				return constant != Mixin.NoValue;
 			}
@@ -136,14 +136,6 @@ namespace Mono.Cecil {
 			set { constant = value; }
 		}
 
-		void ResolveConstant ()
-		{
-			if (constant != Mixin.NotResolved)
-				return;
-
-			this.ResolveConstant (ref constant, Module);
-		}
-
 		public bool HasCustomAttributes {
 			get {
 				if (custom_attributes != null)
@@ -154,7 +146,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		public bool HasMarshalInfo {
@@ -167,7 +159,7 @@ namespace Mono.Cecil {
 		}
 
 		public MarshalInfo MarshalInfo {
-			get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (Module)); }
+			get { return marshal_info ?? (this.GetMarshalInfo (ref marshal_info, Module)); }
 			set { marshal_info = value; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/FieldReference.cs b/vbnc/cecil/Mono.Cecil/FieldReference.cs
index 1b7f57f..73d8e1a 100755
--- a/vbnc/cecil/Mono.Cecil/FieldReference.cs
+++ b/vbnc/cecil/Mono.Cecil/FieldReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -43,7 +43,7 @@ namespace Mono.Cecil {
 			get { return field_type.FullName + " " + MemberFullName (); }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return field_type.ContainsGenericParameter || base.ContainsGenericParameter; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/FileAttributes.cs b/vbnc/cecil/Mono.Cecil/FileAttributes.cs
index 6c2781c..4d3b6ca 100644
--- a/vbnc/cecil/Mono.Cecil/FileAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/FileAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/FunctionPointerType.cs b/vbnc/cecil/Mono.Cecil/FunctionPointerType.cs
index 4c1f1ba..b7f04cc 100644
--- a/vbnc/cecil/Mono.Cecil/FunctionPointerType.cs
+++ b/vbnc/cecil/Mono.Cecil/FunctionPointerType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -85,13 +85,14 @@ namespace Mono.Cecil {
 
 		public override IMetadataScope Scope {
 			get { return function.ReturnType.Scope; }
+			set { throw new InvalidOperationException (); }
 		}
 
 		public override bool IsFunctionPointer {
 			get { return true; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return function.ContainsGenericParameter; }
 		}
 
@@ -114,5 +115,15 @@ namespace Mono.Cecil {
 			this.function.Name = "method";
 			this.etype = MD.ElementType.FnPtr;
 		}
+
+		public override TypeDefinition Resolve ()
+		{
+			return null;
+		}
+
+		public override TypeReference GetElementType ()
+		{
+			return this;
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/GenericInstanceMethod.cs b/vbnc/cecil/Mono.Cecil/GenericInstanceMethod.cs
index 32bd488..74aad65 100755
--- a/vbnc/cecil/Mono.Cecil/GenericInstanceMethod.cs
+++ b/vbnc/cecil/Mono.Cecil/GenericInstanceMethod.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -72,12 +72,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<TypeReference> GenericArguments {
-			get {
-				if (arguments == null)
-					arguments = new Collection<TypeReference> ();
-
-				return arguments;
-			}
+			get { return arguments ?? (arguments = new Collection<TypeReference> ()); }
 		}
 
 		public override bool IsGenericInstance {
@@ -92,7 +87,7 @@ namespace Mono.Cecil {
 			get { return ElementMethod.DeclaringType; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
 		}
 
@@ -100,11 +95,11 @@ namespace Mono.Cecil {
 			get {
 				var signature = new StringBuilder ();
 				var method = this.ElementMethod;
-				signature.Append (method.ReturnType.FullName);
-				signature.Append (" ");
-				signature.Append (method.DeclaringType.FullName);
-				signature.Append ("::");
-				signature.Append (method.Name);
+				signature.Append (method.ReturnType.FullName)
+					.Append (" ")
+					.Append (method.DeclaringType.FullName)
+					.Append ("::")
+					.Append (method.Name);
 				this.GenericInstanceFullName (signature);
 				this.MethodSignatureFullName (signature);
 				return signature.ToString ();
diff --git a/vbnc/cecil/Mono.Cecil/GenericInstanceType.cs b/vbnc/cecil/Mono.Cecil/GenericInstanceType.cs
index 699acad..60ee5fc 100644
--- a/vbnc/cecil/Mono.Cecil/GenericInstanceType.cs
+++ b/vbnc/cecil/Mono.Cecil/GenericInstanceType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -44,12 +44,12 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<TypeReference> GenericArguments {
-			get {
-				if (arguments == null)
-					arguments = new Collection<TypeReference> ();
+			get { return arguments ?? (arguments = new Collection<TypeReference> ()); }
+		}
 
-				return arguments;
-			}
+		public override TypeReference DeclaringType {
+			get { return ElementType.DeclaringType; }
+			set { throw new NotSupportedException (); }
 		}
 
 		public override string FullName {
@@ -65,7 +65,7 @@ namespace Mono.Cecil {
 			get { return true; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/GenericParameter.cs b/vbnc/cecil/Mono.Cecil/GenericParameter.cs
index da0ff29..7e51558 100644
--- a/vbnc/cecil/Mono.Cecil/GenericParameter.cs
+++ b/vbnc/cecil/Mono.Cecil/GenericParameter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -36,7 +36,9 @@ namespace Mono.Cecil {
 
 	public sealed class GenericParameter : TypeReference, ICustomAttributeProvider {
 
-		readonly IGenericParameterProvider owner;
+		internal int position;
+		internal GenericParameterType type;
+		internal IGenericParameterProvider owner;
 
 		ushort attributes;
 		Collection<TypeReference> constraints;
@@ -48,12 +50,11 @@ namespace Mono.Cecil {
 		}
 
 		public int Position {
-			get {
-				if (owner == null)
-					return -1;
+			get { return position; }
+		}
 
-				return owner.GenericParameters.IndexOf (this);
-			}
+		public GenericParameterType Type {
+			get { return type; }
 		}
 
 		public IGenericParameterProvider Owner {
@@ -78,7 +79,7 @@ namespace Mono.Cecil {
 					return constraints;
 
 				if (HasImage)
-					return constraints = Module.Read (this, (generic_parameter, reader) => reader.ReadGenericConstraints (generic_parameter));
+					return Module.Read (ref constraints, this, (generic_parameter, reader) => reader.ReadGenericConstraints (generic_parameter));
 
 				return constraints = new Collection<TypeReference> ();
 			}
@@ -94,24 +95,32 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
-		}
-
-		internal new bool HasImage {
-			get { return Module != null && Module.HasImage; }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		public override IMetadataScope Scope {
 			get {
-				if (owner.GenericParameterType == GenericParameterType.Method)
-					return ((MethodReference) owner).DeclaringType.Scope;
+				if (owner == null)
+					return null;
 
-				return ((TypeReference) owner).Scope;
+				return owner.GenericParameterType == GenericParameterType.Method
+					? ((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 {
-			get { return ((MemberReference) owner).Module; }
+			get { return module ?? owner.Module; }
 		}
 
 		public override string Name {
@@ -119,7 +128,7 @@ namespace Mono.Cecil {
 				if (!string.IsNullOrEmpty (base.Name))
 					return base.Name;
 
-				return base.Name = (owner.GenericParameterType == GenericParameterType.Type ? "!" : "!!") + Position;
+				return base.Name = (type == GenericParameterType.Method ? "!!" : "!") + position;
 			}
 		}
 
@@ -136,10 +145,14 @@ namespace Mono.Cecil {
 			get { return true; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return true; }
 		}
 
+		public override MetadataType MetadataType {
+			get { return (MetadataType) etype; }
+		}
+
 		#region GenericParameterAttributes
 
 		public bool IsNonVariant {
@@ -185,8 +198,93 @@ namespace Mono.Cecil {
 			if (owner == null)
 				throw new ArgumentNullException ();
 
+			this.position = -1;
 			this.owner = owner;
-			this.etype = owner.GenericParameterType == GenericParameterType.Type ? ElementType.Var : ElementType.MVar;
+			this.type = owner.GenericParameterType;
+			this.etype = ConvertGenericParameterType (this.type);
+			this.token = new MetadataToken (TokenType.GenericParam);
+
+		}
+
+		public GenericParameter (int position, GenericParameterType type, ModuleDefinition module)
+			: base (string.Empty, string.Empty)
+		{
+			if (module == null)
+				throw new ArgumentNullException ();
+
+			this.position = position;
+			this.type = type;
+			this.etype = ConvertGenericParameterType (type);
+			this.module = module;
+			this.token = new MetadataToken (TokenType.GenericParam);
+		}
+
+		static ElementType ConvertGenericParameterType (GenericParameterType type)
+		{
+			switch (type) {
+			case GenericParameterType.Type:
+				return ElementType.Var;
+			case GenericParameterType.Method:
+				return ElementType.MVar;
+			}
+
+			throw new ArgumentOutOfRangeException ();
+		}
+
+		public override TypeDefinition Resolve ()
+		{
+			return null;
+		}
+	}
+
+	sealed class GenericParameterCollection : Collection<GenericParameter> {
+
+		readonly IGenericParameterProvider owner;
+
+		internal GenericParameterCollection (IGenericParameterProvider owner)
+		{
+			this.owner = owner;
+		}
+
+		internal GenericParameterCollection (IGenericParameterProvider owner, int capacity)
+			: base (capacity)
+		{
+			this.owner = owner;
+		}
+
+		protected override void OnAdd (GenericParameter item, int index)
+		{
+			UpdateGenericParameter (item, index);
+		}
+
+		protected override void OnInsert (GenericParameter item, int index)
+		{
+			UpdateGenericParameter (item, index);
+
+			for (int i = index; i < size; i++)
+				items[i].position = i + 1;
+		}
+
+		protected override void OnSet (GenericParameter item, int index)
+		{
+			UpdateGenericParameter (item, index);
+		}
+
+		void UpdateGenericParameter (GenericParameter item, int index)
+		{
+			item.owner = owner;
+			item.position = index;
+			item.type = owner.GenericParameterType;
+		}
+
+		protected override void OnRemove (GenericParameter item, int index)
+		{
+			item.owner = null;
+			item.position = -1;
+			item.type = GenericParameterType.Type;
+
+			for (int i = index + 1; i < size; i++)
+				items[i].position = i - 1;
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/GenericParameterAttributes.cs b/vbnc/cecil/Mono.Cecil/GenericParameterAttributes.cs
index 8999614..6d77956 100644
--- a/vbnc/cecil/Mono.Cecil/GenericParameterAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/GenericParameterAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/IConstantProvider.cs b/vbnc/cecil/Mono.Cecil/IConstantProvider.cs
index 361fbe4..36f33dd 100644
--- a/vbnc/cecil/Mono.Cecil/IConstantProvider.cs
+++ b/vbnc/cecil/Mono.Cecil/IConstantProvider.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@ namespace Mono.Cecil {
 
 	public interface IConstantProvider : IMetadataTokenProvider {
 
-		bool HasConstant { get; }
+		bool HasConstant { get; set; }
 		object Constant { get; set; }
 	}
 
@@ -44,9 +44,19 @@ namespace Mono.Cecil {
 			ref object constant,
 			ModuleDefinition module)
 		{
-			constant = module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.ReadConstant (provider))
-				: Mixin.NoValue;
+			if (module == null) {
+				constant = Mixin.NoValue;
+				return;
+			}
+
+			lock (module.SyncRoot) {
+				if (constant != Mixin.NotResolved)
+					return;
+				if (module.HasImage ())
+					constant = module.Read (self, (provider, reader) => reader.ReadConstant (provider));
+				else
+					constant = Mixin.NoValue;
+			}
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/ICustomAttributeProvider.cs b/vbnc/cecil/Mono.Cecil/ICustomAttributeProvider.cs
index 08e5f92..86bd374 100644
--- a/vbnc/cecil/Mono.Cecil/ICustomAttributeProvider.cs
+++ b/vbnc/cecil/Mono.Cecil/ICustomAttributeProvider.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,7 +27,6 @@
 //
 
 using System;
-
 using Mono.Collections.Generic;
 
 namespace Mono.Cecil {
@@ -45,18 +44,17 @@ namespace Mono.Cecil {
 			this ICustomAttributeProvider self,
 			ModuleDefinition module)
 		{
-			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.HasCustomAttributes (provider))
-				: false;
+			return module.HasImage () && module.Read (self, (provider, reader) => reader.HasCustomAttributes (provider));
 		}
 
 		public static Collection<CustomAttribute> GetCustomAttributes (
 			this ICustomAttributeProvider self,
+			ref Collection<CustomAttribute> variable,
 			ModuleDefinition module)
 		{
 			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.ReadCustomAttributes (provider))
-				: new Collection<CustomAttribute> ();
+				? module.Read (ref variable, self, (provider, reader) => reader.ReadCustomAttributes (provider))
+				: variable = new Collection<CustomAttribute>();
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/IGenericInstance.cs b/vbnc/cecil/Mono.Cecil/IGenericInstance.cs
index 2750ad0..edc406c 100644
--- a/vbnc/cecil/Mono.Cecil/IGenericInstance.cs
+++ b/vbnc/cecil/Mono.Cecil/IGenericInstance.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/IGenericParameterProvider.cs b/vbnc/cecil/Mono.Cecil/IGenericParameterProvider.cs
index 27d1669..7a392b9 100644
--- a/vbnc/cecil/Mono.Cecil/IGenericParameterProvider.cs
+++ b/vbnc/cecil/Mono.Cecil/IGenericParameterProvider.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -58,18 +58,17 @@ namespace Mono.Cecil {
 			this IGenericParameterProvider self,
 			ModuleDefinition module)
 		{
-			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.HasGenericParameters (provider))
-				: false;
+			return module.HasImage () && module.Read (self, (provider, reader) => reader.HasGenericParameters (provider));
 		}
 
 		public static Collection<GenericParameter> GetGenericParameters (
 			this IGenericParameterProvider self,
+			ref Collection<GenericParameter> collection,
 			ModuleDefinition module)
 		{
 			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.ReadGenericParameters (provider))
-				: new Collection<GenericParameter> ();
+				? module.Read (ref collection, self, (provider, reader) => reader.ReadGenericParameters (provider))
+				: collection = new GenericParameterCollection (self);
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/IMarshalInfoProvider.cs b/vbnc/cecil/Mono.Cecil/IMarshalInfoProvider.cs
index a3bba6d..e220400 100644
--- a/vbnc/cecil/Mono.Cecil/IMarshalInfoProvider.cs
+++ b/vbnc/cecil/Mono.Cecil/IMarshalInfoProvider.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -40,17 +40,16 @@ namespace Mono.Cecil {
 			this IMarshalInfoProvider self,
 			ModuleDefinition module)
 		{
-			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider))
-				: false;
+			return module.HasImage () && module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider));
 		}
 
 		public static MarshalInfo GetMarshalInfo (
 			this IMarshalInfoProvider self,
+			ref MarshalInfo variable,
 			ModuleDefinition module)
 		{
 			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.ReadMarshalInfo (provider))
+				? module.Read (ref variable, self, (provider, reader) => reader.ReadMarshalInfo (provider))
 				: null;
 		}
 	}
diff --git a/vbnc/cecil/Mono.Cecil/IMemberDefinition.cs b/vbnc/cecil/Mono.Cecil/IMemberDefinition.cs
index 09878f7..ee73d9d 100644
--- a/vbnc/cecil/Mono.Cecil/IMemberDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/IMemberDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/IMetadataScope.cs b/vbnc/cecil/Mono.Cecil/IMetadataScope.cs
index f0ab506..04a0228 100644
--- a/vbnc/cecil/Mono.Cecil/IMetadataScope.cs
+++ b/vbnc/cecil/Mono.Cecil/IMetadataScope.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/IMetadataTokenProvider.cs b/vbnc/cecil/Mono.Cecil/IMetadataTokenProvider.cs
index ff77724..6621835 100644
--- a/vbnc/cecil/Mono.Cecil/IMetadataTokenProvider.cs
+++ b/vbnc/cecil/Mono.Cecil/IMetadataTokenProvider.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/IMethodSignature.cs b/vbnc/cecil/Mono.Cecil/IMethodSignature.cs
index 6bae56a..e3d288b 100644
--- a/vbnc/cecil/Mono.Cecil/IMethodSignature.cs
+++ b/vbnc/cecil/Mono.Cecil/IMethodSignature.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -46,6 +46,11 @@ namespace Mono.Cecil {
 
 	static partial class Mixin {
 
+		public static bool HasImplicitThis (this IMethodSignature self)
+		{
+			return self.HasThis && !self.ExplicitThis;
+		}
+
 		public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder)
 		{
 			builder.Append ("(");
diff --git a/vbnc/cecil/Mono.Cecil/Import.cs b/vbnc/cecil/Mono.Cecil/Import.cs
index 52a31b0..e2337d5 100644
--- a/vbnc/cecil/Mono.Cecil/Import.cs
+++ b/vbnc/cecil/Mono.Cecil/Import.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -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);
@@ -83,16 +154,16 @@ namespace Mono.Cecil {
 			var reference = new TypeReference (
 				string.Empty,
 				type.Name,
+				module,
 				ImportScope (type.Assembly),
 				type.IsValueType);
 
 			reference.etype = ImportElementType (type);
-			reference.module = module;
 
 			if (IsNestedType (type))
 				reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind);
 			else
-				reference.Namespace = type.Namespace;
+				reference.Namespace = type.Namespace ?? string.Empty;
 
 			if (type.IsGenericType)
 				ImportGenericParameters (reference, type.GetGenericArguments ());
@@ -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);
@@ -347,12 +445,11 @@ namespace Mono.Cecil {
 			var reference = new TypeReference (
 				type.Namespace,
 				type.Name,
+				module,
 				ImportScope (type.Scope),
 				type.IsValueType);
 
-			reference.module = module;
-
-			MetadataSystem.TryProcessPrimitiveType (reference);
+			MetadataSystem.TryProcessPrimitiveTypeReference (reference);
 
 			if (type.IsNested)
 				reference.DeclaringType = ImportType (type.DeclaringType, context);
@@ -369,6 +466,7 @@ namespace Mono.Cecil {
 			case MetadataScopeType.AssemblyNameReference:
 				return ImportAssemblyName ((AssemblyNameReference) scope);
 			case MetadataScopeType.ModuleDefinition:
+				if (scope == module) return scope;
 				return ImportAssemblyName (((ModuleDefinition) scope).Assembly.Name);
 			case MetadataScopeType.ModuleReference:
 				throw new NotImplementedException ();
@@ -386,6 +484,7 @@ namespace Mono.Cecil {
 			reference = new AssemblyNameReference (name.Name, name.Version) {
 				Culture = name.Culture,
 				HashAlgorithm = name.HashAlgorithm,
+				IsRetargetable = name.IsRetargetable
 			};
 
 			var pk_token = !name.PublicKeyToken.IsNullOrEmpty ()
@@ -428,7 +527,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:
@@ -487,32 +586,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);
@@ -524,30 +624,33 @@ namespace Mono.Cecil {
 				HasThis = method.HasThis,
 				ExplicitThis = method.ExplicitThis,
 				DeclaringType = declaring_type,
+				CallingConvention = method.CallingConvention,
 			};
 
-			if (method.IsVarArg ())
-				reference.CallingConvention &= MethodCallingConvention.VarArg;
-
 			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/vbnc/cecil/Mono.Cecil/LinkedResource.cs b/vbnc/cecil/Mono.Cecil/LinkedResource.cs
index a5530fc..16c1d59 100644
--- a/vbnc/cecil/Mono.Cecil/LinkedResource.cs
+++ b/vbnc/cecil/Mono.Cecil/LinkedResource.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/ManifestResourceAttributes.cs b/vbnc/cecil/Mono.Cecil/ManifestResourceAttributes.cs
index d72d1d0..7d6bb19 100644
--- a/vbnc/cecil/Mono.Cecil/ManifestResourceAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/ManifestResourceAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MarshalInfo.cs b/vbnc/cecil/Mono.Cecil/MarshalInfo.cs
index 1fce23a..9d58738 100644
--- a/vbnc/cecil/Mono.Cecil/MarshalInfo.cs
+++ b/vbnc/cecil/Mono.Cecil/MarshalInfo.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MemberDefinitionCollection.cs b/vbnc/cecil/Mono.Cecil/MemberDefinitionCollection.cs
index 1e70302..707f36f 100644
--- a/vbnc/cecil/Mono.Cecil/MemberDefinitionCollection.cs
+++ b/vbnc/cecil/Mono.Cecil/MemberDefinitionCollection.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MemberReference.cs b/vbnc/cecil/Mono.Cecil/MemberReference.cs
index 22f2b52..4934fd2 100755
--- a/vbnc/cecil/Mono.Cecil/MemberReference.cs
+++ b/vbnc/cecil/Mono.Cecil/MemberReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -132,7 +132,7 @@ namespace Mono.Cecil {
 			get { return false; }
 		}
 
-		internal virtual bool ContainsGenericParameter {
+		public virtual bool ContainsGenericParameter {
 			get { return declaring_type != null && declaring_type.ContainsGenericParameter; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/MetadataResolver.cs b/vbnc/cecil/Mono.Cecil/MetadataResolver.cs
index 1cfddb9..0b3c9dc 100644
--- a/vbnc/cecil/Mono.Cecil/MetadataResolver.cs
+++ b/vbnc/cecil/Mono.Cecil/MetadataResolver.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,7 +27,6 @@
 //
 
 using System;
-using System.Collections.Generic;
 
 using Mono.Collections.Generic;
 
@@ -35,19 +34,93 @@ namespace Mono.Cecil {
 
 	public interface IAssemblyResolver {
 		AssemblyDefinition Resolve (AssemblyNameReference name);
+		AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters);
+
 		AssemblyDefinition Resolve (string fullName);
+		AssemblyDefinition Resolve (string fullName, ReaderParameters parameters);
+	}
+
+	public interface IMetadataResolver {
+		TypeDefinition Resolve (TypeReference type);
+		FieldDefinition Resolve (FieldReference field);
+		MethodDefinition Resolve (MethodReference method);
 	}
 
-	static class MetadataResolver {
+#if !SILVERLIGHT && !CF
+	[Serializable]
+#endif
+	public class ResolutionException : Exception {
+
+		readonly MemberReference member;
+
+		public MemberReference Member {
+			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;
 
-		public static TypeDefinition Resolve (IAssemblyResolver resolver, TypeReference type)
+				throw new NotSupportedException ();
+			}
+		}
+
+		public ResolutionException (MemberReference member)
+			: base ("Failed to resolve " + member.FullName)
+		{
+			if (member == null)
+				throw new ArgumentNullException ("member");
+
+			this.member = member;
+		}
+
+#if !SILVERLIGHT && !CF
+		protected ResolutionException (
+			System.Runtime.Serialization.SerializationInfo info,
+			System.Runtime.Serialization.StreamingContext context)
+			: base (info, context)
 		{
+		}
+#endif
+	}
+
+	public class MetadataResolver : IMetadataResolver {
+
+		readonly IAssemblyResolver assembly_resolver;
+
+		public IAssemblyResolver AssemblyResolver {
+			get { return assembly_resolver; }
+		}
+
+		public MetadataResolver (IAssemblyResolver assemblyResolver)
+		{
+			if (assemblyResolver == null)
+				throw new ArgumentNullException ("assemblyResolver");
+
+			assembly_resolver = assemblyResolver;
+		}
+
+		public virtual TypeDefinition Resolve (TypeReference type)
+		{
+			if (type == null)
+				throw new ArgumentNullException ("type");
+
 			type = type.GetElementType ();
 
 			var scope = type.Scope;
+
+			if (scope == null)
+				return null;
+
 			switch (scope.MetadataScopeType) {
 			case MetadataScopeType.AssemblyNameReference:
-				var assembly = resolver.Resolve ((AssemblyNameReference) scope);
+				var assembly = assembly_resolver.Resolve ((AssemblyNameReference) scope);
 				if (assembly == null)
 					return null;
 
@@ -68,7 +141,32 @@ namespace Mono.Cecil {
 			throw new NotSupportedException ();
 		}
 
-		static TypeDefinition GetType (ModuleDefinition module, TypeReference type)
+		static TypeDefinition GetType (ModuleDefinition module, TypeReference reference)
+		{
+			var type = GetTypeDefinition (module, reference);
+			if (type != null)
+				return type;
+
+			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 != reference.Name)
+					continue;
+
+				if (exported_type.Namespace != reference.Namespace)
+					continue;
+
+				return exported_type.Resolve ();
+			}
+
+			return null;
+		}
+
+		static TypeDefinition GetTypeDefinition (ModuleDefinition module, TypeReference type)
 		{
 			if (!type.IsNested)
 				return module.GetType (type.Namespace, type.Name);
@@ -77,22 +175,25 @@ namespace Mono.Cecil {
 			if (declaring_type == null)
 				return null;
 
-			return declaring_type.GetNestedType (type.Name);
+			return declaring_type.GetNestedType (type.TypeFullName ());
 		}
 
-		public static FieldDefinition Resolve (IAssemblyResolver resolver, FieldReference field)
+		public virtual FieldDefinition Resolve (FieldReference field)
 		{
-			var type = Resolve (resolver, field.DeclaringType);
+			if (field == null)
+				throw new ArgumentNullException ("field");
+
+			var type = Resolve (field.DeclaringType);
 			if (type == null)
 				return null;
 
 			if (!type.HasFields)
 				return null;
 
-			return GetField (resolver, type, field);
+			return GetField (type, field);
 		}
 
-		static FieldDefinition GetField (IAssemblyResolver resolver, TypeDefinition type, FieldReference reference)
+		FieldDefinition GetField (TypeDefinition type, FieldReference reference)
 		{
 			while (type != null) {
 				var field = GetField (type.Fields, reference);
@@ -102,13 +203,13 @@ namespace Mono.Cecil {
 				if (type.BaseType == null)
 					return null;
 
-				type = Resolve (resolver, type.BaseType);
+				type = Resolve (type.BaseType);
 			}
 
 			return null;
 		}
 
-		static FieldDefinition GetField (IList<FieldDefinition> fields, FieldReference reference)
+		static FieldDefinition GetField (Collection<FieldDefinition> fields, FieldReference reference)
 		{
 			for (int i = 0; i < fields.Count; i++) {
 				var field = fields [i];
@@ -125,9 +226,12 @@ namespace Mono.Cecil {
 			return null;
 		}
 
-		public static MethodDefinition Resolve (IAssemblyResolver resolver, MethodReference method)
+		public virtual MethodDefinition Resolve (MethodReference method)
 		{
-			var type = Resolve (resolver, method.DeclaringType);
+			if (method == null)
+				throw new ArgumentNullException ("method");
+
+			var type = Resolve (method.DeclaringType);
 			if (type == null)
 				return null;
 
@@ -136,10 +240,10 @@ namespace Mono.Cecil {
 			if (!type.HasMethods)
 				return null;
 
-			return GetMethod (resolver, type, method);
+			return GetMethod (type, method);
 		}
 
-		static MethodDefinition GetMethod (IAssemblyResolver resolver, TypeDefinition type, MethodReference reference)
+		MethodDefinition GetMethod (TypeDefinition type, MethodReference reference)
 		{
 			while (type != null) {
 				var method = GetMethod (type.Methods, reference);
@@ -149,13 +253,13 @@ namespace Mono.Cecil {
 				if (type.BaseType == null)
 					return null;
 
-				type = Resolve (resolver, type.BaseType);
+				type = Resolve (type.BaseType);
 			}
 
 			return null;
 		}
 
-		public static MethodDefinition GetMethod (IList<MethodDefinition> methods, MethodReference reference)
+		public static MethodDefinition GetMethod (Collection<MethodDefinition> methods, MethodReference reference)
 		{
 			for (int i = 0; i < methods.Count; i++) {
 				var method = methods [i];
@@ -163,6 +267,12 @@ namespace Mono.Cecil {
 				if (method.Name != reference.Name)
 					continue;
 
+				if (method.HasGenericParameters != reference.HasGenericParameters)
+					continue;
+
+				if (method.HasGenericParameters && method.GenericParameters.Count != reference.GenericParameters.Count)
+					continue;
+
 				if (!AreSame (method.ReturnType, reference.ReturnType))
 					continue;
 
@@ -232,12 +342,6 @@ namespace Mono.Cecil {
 
 		static bool AreSame (GenericInstanceType a, GenericInstanceType b)
 		{
-			if (!a.HasGenericArguments)
-				return !b.HasGenericArguments;
-
-			if (!b.HasGenericArguments)
-				return false;
-
 			if (a.GenericArguments.Count != b.GenericArguments.Count)
 				return false;
 
@@ -255,6 +359,12 @@ namespace Mono.Cecil {
 
 		static bool AreSame (TypeReference a, TypeReference b)
 		{
+			if (ReferenceEquals (a, b))
+				return true;
+
+			if (a == null || b == null)
+				return false;
+
 			if (a.etype != b.etype)
 				return false;
 
@@ -264,7 +374,12 @@ namespace Mono.Cecil {
 			if (a.IsTypeSpecification ())
 				return AreSame ((TypeSpecification) a, (TypeSpecification) b);
 
-			return a.FullName == b.FullName;
+			if (a.Name != b.Name || a.Namespace != b.Namespace)
+				return false;
+
+			//TODO: check scope
+
+			return AreSame (a.DeclaringType, b.DeclaringType);
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/MetadataSystem.cs b/vbnc/cecil/Mono.Cecil/MetadataSystem.cs
index a114707..3ae2015 100644
--- a/vbnc/cecil/Mono.Cecil/MetadataSystem.cs
+++ b/vbnc/cecil/Mono.Cecil/MetadataSystem.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -46,6 +46,9 @@ namespace Mono.Cecil {
 
 	sealed class MetadataSystem {
 
+		internal AssemblyNameReference [] AssemblyReferences;
+		internal ModuleReference [] ModuleReferences;
+
 		internal TypeDefinition [] Types;
 		internal TypeReference [] TypeReferences;
 
@@ -62,20 +65,20 @@ 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;
 
 		static void InitializePrimitives ()
 		{
-			primitive_value_types = new Dictionary<string, Row<ElementType, bool>> (18) {
+			primitive_value_types = new Dictionary<string, Row<ElementType, bool>> (18, StringComparer.Ordinal) {
 				{ "Void", new Row<ElementType, bool> (ElementType.Void, false) },
 				{ "Boolean", new Row<ElementType, bool> (ElementType.Boolean, true) },
 				{ "Char", new Row<ElementType, bool> (ElementType.Char, true) },
@@ -97,27 +100,45 @@ namespace Mono.Cecil {
 			};
 		}
 
-		public static void TryProcessPrimitiveType (TypeReference type)
+		public static void TryProcessPrimitiveTypeReference (TypeReference type)
 		{
+			if (type.Namespace != "System")
+				return;
+
 			var scope = type.scope;
-			if (scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
+			if (scope == null || scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
 				return;
 
-			if (scope.Name != "mscorlib")
+			Row<ElementType, bool> primitive_data;
+			if (!TryGetPrimitiveData (type, out primitive_data))
 				return;
 
+			type.etype = primitive_data.Col1;
+			type.IsValueType = primitive_data.Col2;
+		}
+
+		public static bool TryGetPrimitiveElementType (TypeDefinition type, out ElementType etype)
+		{
+			etype = ElementType.None;
+
 			if (type.Namespace != "System")
-				return;
+				return false;
 
+			Row<ElementType, bool> primitive_data;
+			if (TryGetPrimitiveData (type, out primitive_data) && primitive_data.Col1.IsPrimitive ()) {
+				etype = primitive_data.Col1;
+				return true;
+			}
+
+			return false;
+		}
+
+		static bool TryGetPrimitiveData (TypeReference type, out Row<ElementType, bool> primitive_data)
+		{
 			if (primitive_value_types == null)
 				InitializePrimitives ();
 
-			Row<ElementType, bool> primitive_data;
-			if (!primitive_value_types.TryGetValue (type.Name, out primitive_data))
-				return;
-
-			type.etype = primitive_data.Col1;
-			type.IsValueType = primitive_data.Col2;
+			return primitive_value_types.TryGetValue (type.Name, out primitive_data);
 		}
 
 		public void Clear ()
@@ -281,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)
@@ -291,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)
@@ -301,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)
@@ -368,7 +389,7 @@ namespace Mono.Cecil {
 					return type;
 			}
 
-			throw new ArgumentException ();
+			return null;
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/MethodAttributes.cs b/vbnc/cecil/Mono.Cecil/MethodAttributes.cs
index 3446702..626a97b 100644
--- a/vbnc/cecil/Mono.Cecil/MethodAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MethodCallingConvention.cs b/vbnc/cecil/Mono.Cecil/MethodCallingConvention.cs
index c96dc1c..bd7188d 100644
--- a/vbnc/cecil/Mono.Cecil/MethodCallingConvention.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodCallingConvention.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MethodDefinition.cs b/vbnc/cecil/Mono.Cecil/MethodDefinition.cs
index 38d27e6..2fc6f28 100644
--- a/vbnc/cecil/Mono.Cecil/MethodDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -37,7 +37,8 @@ namespace Mono.Cecil {
 
 		ushort attributes;
 		ushort impl_attributes;
-		MethodSemanticsAttributes? sem_attrs;
+		internal volatile bool sem_attrs_ready;
+		internal MethodSemanticsAttributes sem_attrs;
 		Collection<CustomAttribute> custom_attributes;
 		Collection<SecurityDeclaration> security_declarations;
 
@@ -59,34 +60,34 @@ namespace Mono.Cecil {
 
 		public MethodSemanticsAttributes SemanticsAttributes {
 			get {
-				if (sem_attrs.HasValue)
-					return sem_attrs.Value;
+				if (sem_attrs_ready)
+					return sem_attrs;
 
 				if (HasImage) {
 					ReadSemantics ();
-					return sem_attrs.Value;
+					return sem_attrs;
 				}
 
 				sem_attrs = MethodSemanticsAttributes.None;
-				return sem_attrs.Value;
+				sem_attrs_ready = true;
+				return sem_attrs;
 			}
 			set { sem_attrs = value; }
 		}
 
 		internal void ReadSemantics ()
 		{
-			var type = DeclaringType;
-			if (type == null)
+			if (sem_attrs_ready)
 				return;
 
-			var module = type.Module;
+			var module = this.Module;
 			if (module == null)
 				return;
 
 			if (!module.HasImage)
 				return;
 
-			sem_attrs = module.Read (this, (method, reader) => reader.ReadMethodSemantics (method));
+			module.Read (this, (method, reader) => reader.ReadAllSemantics (method));
 		}
 
 		public bool HasSecurityDeclarations {
@@ -99,7 +100,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<SecurityDeclaration> SecurityDeclarations {
-			get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); }
+			get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, Module)); }
 		}
 
 		public bool HasCustomAttributes {
@@ -112,7 +113,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		public int RVA {
@@ -132,18 +133,30 @@ namespace Mono.Cecil {
 
 		public MethodBody Body {
 			get {
-				if (body != null)
-					return body;
+				MethodBody localBody = this.body;
+				if (localBody != null)
+					return localBody;
 
 				if (!HasBody)
 					return null;
 
 				if (HasImage && rva != 0)
-					return body = Module.Read (this, (method, reader) => reader.ReadMethodBody (method));
+					return Module.Read (ref body, this, (method, reader) => reader.ReadMethodBody (method));
 
 				return body = new MethodBody (this);
 			}
-			set { body = value; }
+			set {
+				var module = this.Module;
+				if (module == null) {
+					body = value;
+					return;
+				}
+
+				// we reset Body to null in ILSpy to save memory; so we need that operation to be thread-safe
+				lock (module.SyncRoot) {
+					body = value;
+				}
+			}
 		}
 
 		public bool HasPInvokeInfo {
@@ -161,7 +174,7 @@ namespace Mono.Cecil {
 					return pinvoke;
 
 				if (HasImage && IsPInvokeImpl)
-					return pinvoke = Module.Read (this, (method, reader) => reader.ReadPInvokeInfo (method));
+					return Module.Read (ref pinvoke, this, (method, reader) => reader.ReadPInvokeInfo (method));
 
 				return null;
 			}
@@ -189,7 +202,7 @@ namespace Mono.Cecil {
 					return overrides;
 
 				if (HasImage)
-					return overrides = Module.Read (this, (method, reader) => reader.ReadOverrides (method));
+					return Module.Read (ref overrides, this, (method, reader) => reader.ReadOverrides (method));
 
 				return overrides = new Collection<MethodReference> ();
 			}
@@ -205,7 +218,7 @@ namespace Mono.Cecil {
 		}
 
 		public override Collection<GenericParameter> GenericParameters {
-			get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); }
+			get { return generic_parameters ?? (this.GetGenericParameters (ref generic_parameters, Module)); }
 		}
 
 		#region MethodAttributes
@@ -454,7 +467,22 @@ namespace Mono.Cecil {
 				index--;
 			}
 
-			return method.Parameters [index];
+			var parameters = method.Parameters;
+
+			if (index < 0 || index >= parameters.size)
+				return null;
+
+			return parameters [index];
+		}
+
+		public static VariableDefinition GetVariable (this MethodBody self, int index)
+		{
+			var variables = self.Variables;
+
+			if (index < 0 || index >= variables.size)
+				return null;
+
+			return variables [index];
 		}
 
 		public static bool GetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics)
diff --git a/vbnc/cecil/Mono.Cecil/MethodImplAttributes.cs b/vbnc/cecil/Mono.Cecil/MethodImplAttributes.cs
index 8a2b422..b24fcf7 100644
--- a/vbnc/cecil/Mono.Cecil/MethodImplAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodImplAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -49,6 +49,5 @@ namespace Mono.Cecil {
 		Synchronized		= 0x0020,	// Method is single threaded through the body
 		NoOptimization		= 0x0040,	// Method is not optimized by the JIT.
 		NoInlining			= 0x0008,	// Method may not be inlined
-		MaxMethodImplVal	= 0xffff	 // Range check value
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/MethodReference.cs b/vbnc/cecil/Mono.Cecil/MethodReference.cs
index c02ae09..1381854 100755
--- a/vbnc/cecil/Mono.Cecil/MethodReference.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -115,7 +115,7 @@ namespace Mono.Cecil {
 				if (generic_parameters != null)
 					return generic_parameters;
 
-				return generic_parameters = new Collection<GenericParameter> ();
+				return generic_parameters = new GenericParameterCollection (this);
 			}
 		}
 
@@ -139,9 +139,9 @@ namespace Mono.Cecil {
 		public override string FullName {
 			get {
 				var builder = new StringBuilder ();
-				builder.Append (ReturnType.FullName);
-				builder.Append (" ");
-				builder.Append (MemberFullName ());
+				builder.Append (ReturnType.FullName)
+					.Append (" ")
+					.Append (MemberFullName ());
 				this.MethodSignatureFullName (builder);
 				return builder.ToString ();
 			}
@@ -151,7 +151,7 @@ namespace Mono.Cecil {
 			get { return false; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get {
 				if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter)
 					return true;
diff --git a/vbnc/cecil/Mono.Cecil/MethodReturnType.cs b/vbnc/cecil/Mono.Cecil/MethodReturnType.cs
index 591b652..d18523a 100755
--- a/vbnc/cecil/Mono.Cecil/MethodReturnType.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodReturnType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -26,6 +26,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Threading;
+
 using Mono.Collections.Generic;
 
 namespace Mono.Cecil {
@@ -65,8 +67,12 @@ namespace Mono.Cecil {
 		}
 
 		internal ParameterDefinition Parameter {
-			get { return parameter ?? (parameter = new ParameterDefinition (return_type)); }
-			set { parameter = value; }
+			get {
+				if (parameter == null)
+					Interlocked.CompareExchange (ref parameter, new ParameterDefinition (return_type, method), null);
+
+				return parameter;
+			}
 		}
 
 		public MetadataToken MetadataToken {
@@ -74,6 +80,11 @@ namespace Mono.Cecil {
 			set { Parameter.MetadataToken = value; }
 		}
 
+		public ParameterAttributes Attributes {
+			get { return Parameter.Attributes; }
+			set { Parameter.Attributes = value; }
+		}
+
 		public bool HasCustomAttributes {
 			get { return parameter != null && parameter.HasCustomAttributes; }
 		}
@@ -82,8 +93,14 @@ namespace Mono.Cecil {
 			get { return Parameter.CustomAttributes; }
 		}
 
+		public bool HasDefault {
+			get { return parameter != null && parameter.HasDefault; }
+			set { Parameter.HasDefault = value; }
+		}
+
 		public bool HasConstant {
 			get { return parameter != null && parameter.HasConstant; }
+			set { Parameter.HasConstant = value; }
 		}
 
 		public object Constant {
@@ -91,6 +108,11 @@ namespace Mono.Cecil {
 			set { Parameter.Constant = value; }
 		}
 
+		public bool HasFieldMarshal {
+			get { return parameter != null && parameter.HasFieldMarshal; }
+			set { Parameter.HasFieldMarshal = value; }
+		}
+
 		public bool HasMarshalInfo {
 			get { return parameter != null && parameter.HasMarshalInfo; }
 		}
diff --git a/vbnc/cecil/Mono.Cecil/MethodSemanticsAttributes.cs b/vbnc/cecil/Mono.Cecil/MethodSemanticsAttributes.cs
index f44a3fa..dd0f474 100644
--- a/vbnc/cecil/Mono.Cecil/MethodSemanticsAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodSemanticsAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/MethodSpecification.cs b/vbnc/cecil/Mono.Cecil/MethodSpecification.cs
index e907d6c..172c2d5 100644
--- a/vbnc/cecil/Mono.Cecil/MethodSpecification.cs
+++ b/vbnc/cecil/Mono.Cecil/MethodSpecification.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -82,7 +82,7 @@ namespace Mono.Cecil {
 			get { return method.Parameters; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return method.ContainsGenericParameter; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/Modifiers.cs b/vbnc/cecil/Mono.Cecil/Modifiers.cs
index f7ff611..91cadb1 100644
--- a/vbnc/cecil/Mono.Cecil/Modifiers.cs
+++ b/vbnc/cecil/Mono.Cecil/Modifiers.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -67,7 +67,7 @@ namespace Mono.Cecil {
 			get { return true; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; }
 		}
 
@@ -110,7 +110,7 @@ namespace Mono.Cecil {
 			get { return true; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; }
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/ModuleDefinition.cs b/vbnc/cecil/Mono.Cecil/ModuleDefinition.cs
index cc4f48f..5cdce8e 100755
--- a/vbnc/cecil/Mono.Cecil/ModuleDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/ModuleDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -29,6 +29,7 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Threading;
 using SR = System.Reflection;
 
 using Mono.Cecil.Cil;
@@ -47,6 +48,7 @@ namespace Mono.Cecil {
 
 		ReadingMode reading_mode;
 		IAssemblyResolver assembly_resolver;
+		IMetadataResolver metadata_resolver;
 		Stream symbol_stream;
 		ISymbolReaderProvider symbol_reader_provider;
 		bool read_symbols;
@@ -61,6 +63,11 @@ namespace Mono.Cecil {
 			set { assembly_resolver = value; }
 		}
 
+		public IMetadataResolver MetadataResolver {
+			get { return metadata_resolver; }
+			set { metadata_resolver = value; }
+		}
+
 		public Stream SymbolStream {
 			get { return symbol_stream; }
 			set { symbol_stream = value; }
@@ -95,6 +102,7 @@ namespace Mono.Cecil {
 		TargetRuntime runtime;
 		TargetArchitecture architecture;
 		IAssemblyResolver assembly_resolver;
+		IMetadataResolver metadata_resolver;
 
 		public ModuleKind Kind {
 			get { return kind; }
@@ -116,10 +124,15 @@ namespace Mono.Cecil {
 			set { assembly_resolver = value; }
 		}
 
+		public IMetadataResolver MetadataResolver {
+			get { return metadata_resolver; }
+			set { metadata_resolver = value; }
+		}
+
 		public ModuleParameters ()
 		{
 			this.kind = ModuleKind.Dll;
-			this.runtime = GetCurrentRuntime ();
+			this.Runtime = GetCurrentRuntime ();
 			this.architecture = TargetArchitecture.I386;
 		}
 
@@ -183,19 +196,23 @@ namespace Mono.Cecil {
 		public byte [] Win32Resources;
 		internal MetadataSystem MetadataSystem;
 		internal ReadingMode ReadingMode;
-		public IAssemblyResolver AssemblyResolver;
+
 		internal ISymbolReaderProvider SymbolReaderProvider;
-		internal ISymbolReader SymbolReader;
 
-		TypeSystem type_system;
+		internal ISymbolReader symbol_reader;
+		internal IAssemblyResolver assembly_resolver;
+		internal IMetadataResolver metadata_resolver;
+		internal TypeSystem type_system;
 
 		readonly MetadataReader reader;
 		readonly string fq_name;
 
+		internal string runtime_version;
 		internal ModuleKind kind;
 		TargetRuntime runtime;
 		TargetArchitecture architecture;
 		ModuleAttributes attributes;
+		ModuleCharacteristics characteristics;
 		Guid mvid;
 
 		internal AssemblyDefinition assembly;
@@ -217,11 +234,23 @@ namespace Mono.Cecil {
 
 		public ModuleKind Kind {
 			get { return kind; }
+			set { kind = value; }
 		}
 
 		public TargetRuntime Runtime {
 			get { return runtime; }
-			set { runtime = value; }
+			set {
+				runtime = value;
+				runtime_version = runtime.RuntimeVersionString ();
+			}
+		}
+
+		public string RuntimeVersion {
+			get { return runtime_version; }
+			set {
+				runtime_version = value;
+				runtime = runtime_version.ParseRuntime ();
+			}
 		}
 
 		public TargetArchitecture Architecture {
@@ -234,6 +263,11 @@ namespace Mono.Cecil {
 			set { attributes = value; }
 		}
 
+		public ModuleCharacteristics Characteristics {
+			get { return characteristics; }
+			set { characteristics = value; }
+		}
+
 		public string FullyQualifiedName {
 			get { return fq_name; }
 		}
@@ -248,7 +282,11 @@ namespace Mono.Cecil {
 		}
 
 		public bool HasSymbols {
-			get { return SymbolReader != null; }
+			get { return symbol_reader != null; }
+		}
+
+		public ISymbolReader SymbolReader {
+			get { return symbol_reader; }
 		}
 
 		public override MetadataScopeType MetadataScopeType {
@@ -261,12 +299,40 @@ namespace Mono.Cecil {
 
 #if !READ_ONLY
 		internal MetadataImporter MetadataImporter {
-			get { return importer ?? (importer = new MetadataImporter (this)); }
+			get {
+				if (importer == null)
+					Interlocked.CompareExchange (ref importer, new MetadataImporter (this), null);
+
+				return importer;
+			}
 		}
 #endif
 
-		internal TypeSystem TypeSystem {
-			get { return type_system ?? (type_system = TypeSystem.CreateTypeSystem (this)); }
+		public IAssemblyResolver AssemblyResolver {
+			get {
+				if (assembly_resolver == null)
+					Interlocked.CompareExchange (ref assembly_resolver, new DefaultAssemblyResolver (), null);
+
+				return assembly_resolver;
+			}
+		}
+
+		public IMetadataResolver MetadataResolver {
+			get {
+				if (metadata_resolver == null)
+					Interlocked.CompareExchange (ref metadata_resolver, new MetadataResolver (this.AssemblyResolver), null);
+
+				return metadata_resolver;
+			}
+		}
+
+		public TypeSystem TypeSystem {
+			get {
+				if (type_system == null)
+					Interlocked.CompareExchange (ref type_system, TypeSystem.CreateTypeSystem (this), null);
+
+				return type_system;
+			}
 		}
 
 		public bool HasAssemblyReferences {
@@ -284,7 +350,7 @@ namespace Mono.Cecil {
 					return references;
 
 				if (HasImage)
-					return references = Read (this, (_, reader) => reader.ReadAssemblyReferences ());
+					return Read (ref references, this, (_, reader) => reader.ReadAssemblyReferences ());
 
 				return references = new Collection<AssemblyNameReference> ();
 			}
@@ -305,7 +371,7 @@ namespace Mono.Cecil {
 					return modules;
 
 				if (HasImage)
-					return modules = Read (this, (_, reader) => reader.ReadModuleReferences ());
+					return Read (ref modules, this, (_, reader) => reader.ReadModuleReferences ());
 
 				return modules = new Collection<ModuleReference> ();
 			}
@@ -329,7 +395,7 @@ namespace Mono.Cecil {
 					return resources;
 
 				if (HasImage)
-					return resources = Read (this, (_, reader) => reader.ReadResources ());
+					return Read (ref resources, this, (_, reader) => reader.ReadResources ());
 
 				return resources = new Collection<Resource> ();
 			}
@@ -345,7 +411,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (this)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, this)); }
 		}
 
 		public bool HasTypes {
@@ -363,7 +429,7 @@ namespace Mono.Cecil {
 					return types;
 
 				if (HasImage)
-					return types = Read (this, (_, reader) => reader.ReadTypes ());
+					return Read (ref types, this, (_, reader) => reader.ReadTypes ());
 
 				return types = new TypeDefinitionCollection (this);
 			}
@@ -384,7 +450,7 @@ namespace Mono.Cecil {
 					return exported_types;
 
 				if (HasImage)
-					return exported_types = Read (this, (_, reader) => reader.ReadExportedTypes ());
+					return Read (ref exported_types, this, (_, reader) => reader.ReadExportedTypes ());
 
 				return exported_types = new Collection<ExportedType> ();
 			}
@@ -396,7 +462,7 @@ namespace Mono.Cecil {
 					return entry_point;
 
 				if (HasImage)
-					return entry_point = Read (this, (_, reader) => reader.ReadEntryPoint ());
+					return Read (ref entry_point, this, (_, reader) => reader.ReadEntryPoint ());
 
 				return entry_point = null;
 			}
@@ -407,7 +473,6 @@ namespace Mono.Cecil {
 		{
 			this.MetadataSystem = new MetadataSystem ();
 			this.token = new MetadataToken (TokenType.Module, 1);
-			this.AssemblyResolver = GlobalAssemblyResolver.Instance;
 		}
 
 		internal ModuleDefinition (Image image)
@@ -415,9 +480,10 @@ namespace Mono.Cecil {
 		{
 			this.Image = image;
 			this.kind = image.Kind;
-			this.runtime = image.Runtime;
+			this.RuntimeVersion = image.RuntimeVersion;
 			this.architecture = image.Architecture;
 			this.attributes = image.Attributes;
+			this.characteristics = image.Characteristics;
 			this.fq_name = image.FileName;
 
 			this.reader = new MetadataReader (this);
@@ -432,7 +498,10 @@ namespace Mono.Cecil {
 		{
 			CheckFullName (fullName);
 
-			return Read (this, (_, reader) => reader.GetTypeReference (scope, fullName) != null);
+			if (!HasImage)
+				return false;
+
+			return GetTypeReference (scope, fullName) != null;
 		}
 
 		public bool TryGetTypeReference (string fullName, out TypeReference type)
@@ -444,19 +513,42 @@ namespace Mono.Cecil {
 		{
 			CheckFullName (fullName);
 
-			return (type = Read (this, (_, reader) => reader.GetTypeReference (scope, fullName))) != null;
+			if (!HasImage) {
+				type = null;
+				return false;
+			}
+
+			return (type = GetTypeReference (scope, fullName)) != null;
+		}
+
+		TypeReference GetTypeReference (string scope, string fullname)
+		{
+			return Read (new Row<string, string> (scope, fullname), (row, reader) => reader.GetTypeReference (row.Col1, row.Col2));
 		}
 
 		public IEnumerable<TypeReference> GetTypeReferences ()
 		{
+			if (!HasImage)
+				return Empty<TypeReference>.Array;
+
 			return Read (this, (_, reader) => reader.GetTypeReferences ());
 		}
 
 		public IEnumerable<MemberReference> GetMemberReferences ()
 		{
+			if (!HasImage)
+				return Empty<MemberReference>.Array;
+
 			return Read (this, (_, reader) => reader.GetMemberReferences ());
 		}
 
+		public TypeReference GetType (string fullName, bool runtimeName)
+		{
+			return runtimeName
+				? TypeParser.ParseType (this, fullName)
+				: GetType (fullName);
+		}
+
 		public TypeDefinition GetType (string fullName)
 		{
 			CheckFullName (fullName);
@@ -475,6 +567,26 @@ namespace Mono.Cecil {
 			return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name);
 		}
 
+		public IEnumerable<TypeDefinition> GetTypes ()
+		{
+			return GetTypes (Types);
+		}
+
+		static IEnumerable<TypeDefinition> GetTypes (Collection<TypeDefinition> types)
+		{
+			for (int i = 0; i < types.Count; i++) {
+				var type = types [i];
+
+				yield return type;
+
+				if (!type.HasNestedTypes)
+					continue;
+
+				foreach (var nested in GetTypes (type.NestedTypes))
+					yield return nested;
+			}
+		}
+
 		static void CheckFullName (string fullName)
 		{
 			if (fullName == null)
@@ -504,17 +616,17 @@ namespace Mono.Cecil {
 
 		internal FieldDefinition Resolve (FieldReference field)
 		{
-			return MetadataResolver.Resolve (AssemblyResolver, field);
+			return MetadataResolver.Resolve (field);
 		}
 
 		internal MethodDefinition Resolve (MethodReference method)
 		{
-			return MetadataResolver.Resolve (AssemblyResolver, method);
+			return MetadataResolver.Resolve (method);
 		}
 
 		internal TypeDefinition Resolve (TypeReference type)
 		{
-			return MetadataResolver.Resolve (AssemblyResolver, type);
+			return MetadataResolver.Resolve (type);
 		}
 
 #if !READ_ONLY
@@ -546,89 +658,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);
+			return Import (field, null);
 		}
 
-		public FieldReference Import (SR.FieldInfo field, MethodReference context)
-		{
-			return Import (field, (IGenericParameterProvider) context);
-		}
-
-		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);
+			return MetadataImporter.ImportMethod (method, default (ImportGenericContext), ImportGenericKind.Definition);
 		}
 
-		public MethodReference Import (SR.MethodBase method, MethodReference context)
-		{
-			return Import (method, (IGenericParameterProvider) context);
-		}
-
-		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
 
@@ -639,20 +719,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);
 
@@ -661,7 +731,7 @@ namespace Mono.Cecil {
 
 			CheckContext (context, this);
 
-			return MetadataImporter.ImportType (type, (IGenericContext) context);
+			return MetadataImporter.ImportType (type, GenericContextFor (context));
 		}
 
 		public FieldReference Import (FieldReference field)
@@ -671,20 +741,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);
 
@@ -693,30 +753,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);
+			return Import (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);
-		}
-
-		MethodReference Import (MethodReference method, IGenericParameterProvider context)
+		public MethodReference Import (MethodReference method, IGenericParameterProvider context)
 		{
 			CheckMethod (method);
 
@@ -725,7 +770,7 @@ namespace Mono.Cecil {
 
 			CheckContext (context, this);
 
-			return MetadataImporter.ImportMethod (method, (IGenericContext) context);
+			return MetadataImporter.ImportMethod (method, GenericContextFor (context));
 		}
 
 #endif
@@ -737,31 +782,69 @@ namespace Mono.Cecil {
 
 		public IMetadataTokenProvider LookupToken (MetadataToken token)
 		{
-			return Read (this, (_, reader) => reader.LookupToken (token));
+			return Read (token, (t, reader) => reader.LookupToken (t));
+		}
+
+		readonly object module_lock = new object();
+
+		internal object SyncRoot {
+			get { return module_lock; }
 		}
 
 		internal TRet Read<TItem, TRet> (TItem item, Func<TItem, MetadataReader, TRet> read)
 		{
-			var position = reader.position;
-			var context = reader.context;
+			lock (module_lock) {
+				var position = reader.position;
+				var context = reader.context;
 
-			var ret = read (item, reader);
+				var ret = read (item, reader);
 
-			reader.position = position;
-			reader.context = context;
+				reader.position = position;
+				reader.context = context;
 
-			return ret;
+				return ret;
+			}
+		}
+
+		internal TRet Read<TItem, TRet> (ref TRet variable, TItem item, Func<TItem, MetadataReader, TRet> read) where TRet : class
+		{
+			lock (module_lock) {
+				if (variable != null)
+					return variable;
+
+				var position = reader.position;
+				var context = reader.context;
+
+				var ret = read (item, reader);
+
+				reader.position = position;
+				reader.context = context;
+
+				return variable = ret;
+			}
+		}
+
+		public bool HasDebugHeader {
+			get { return Image != null && !Image.Debug.IsZero; }
+		}
+
+		public ImageDebugDirectory GetDebugHeader (out byte [] header)
+		{
+			if (!HasDebugHeader)
+				throw new InvalidOperationException ();
+
+			return Image.GetDebugHeader (out header);
 		}
 
 		void ProcessDebugHeader ()
 		{
-			if (Image == null || Image.Debug.IsZero)
+			if (!HasDebugHeader)
 				return;
 
 			byte [] header;
-			var directory = Image.GetDebugHeader (out header);
+			var directory = GetDebugHeader (out header);
 
-			if (!SymbolReader.ProcessDebugHeader (directory, header))
+			if (!symbol_reader.ProcessDebugHeader (directory, header))
 				throw new InvalidOperationException ();
 		}
 
@@ -780,19 +863,23 @@ namespace Mono.Cecil {
 			var module = new ModuleDefinition {
 				Name = name,
 				kind = parameters.Kind,
-				runtime = parameters.Runtime,
+				Runtime = parameters.Runtime,
 				architecture = parameters.Architecture,
 				mvid = Guid.NewGuid (),
 				Attributes = ModuleAttributes.ILOnly,
+				Characteristics = (ModuleCharacteristics) 0x8540,
 			};
 
 			if (parameters.AssemblyResolver != null)
-				module.AssemblyResolver = parameters.AssemblyResolver;
+				module.assembly_resolver = parameters.AssemblyResolver;
+
+			if (parameters.MetadataResolver != null)
+				module.metadata_resolver = parameters.MetadataResolver;
 
 			if (parameters.Kind != ModuleKind.NetModule) {
 				var assembly = new AssemblyDefinition ();
 				module.assembly = assembly;
-				module.assembly.Name = new AssemblyNameDefinition (name, new Version (0, 0));
+				module.assembly.Name = CreateAssemblyName (name);
 				assembly.main_module = module;
 			}
 
@@ -801,6 +888,14 @@ namespace Mono.Cecil {
 			return module;
 		}
 
+		static AssemblyNameDefinition CreateAssemblyName (string name)
+		{
+			if (name.EndsWith (".dll") || name.EndsWith (".exe"))
+				name = name.Substring (0, name.Length - 4);
+
+			return new AssemblyNameDefinition (name, new Version (0, 0, 0, 0));
+		}
+
 #endif
 
 		public void ReadSymbols ()
@@ -809,10 +904,10 @@ namespace Mono.Cecil {
 				throw new InvalidOperationException ();
 
 			var provider = SymbolProvider.GetPlatformReaderProvider ();
+			if (provider == null)
+				throw new InvalidOperationException ();
 
-			SymbolReader = provider.GetSymbolReader (this, fq_name);
-
-			ProcessDebugHeader ();
+			ReadSymbols (provider.GetSymbolReader (this, fq_name));
 		}
 
 		public void ReadSymbols (ISymbolReader reader)
@@ -820,7 +915,7 @@ namespace Mono.Cecil {
 			if (reader == null)
 				throw new ArgumentNullException ("reader");
 
-			SymbolReader = reader;
+			symbol_reader = reader;
 
 			ProcessDebugHeader ();
 		}
@@ -916,6 +1011,14 @@ namespace Mono.Cecil {
 			return self != null && self.HasImage;
 		}
 
+		public static bool IsCorlib (this ModuleDefinition module)
+		{
+			if (module.Assembly == null)
+				return false;
+
+			return module.Assembly.Name.Name == "mscorlib";
+		}
+
 		public static string GetFullyQualifiedName (this Stream self)
 		{
 #if !SILVERLIGHT
@@ -943,5 +1046,20 @@ namespace Mono.Cecil {
 				return TargetRuntime.Net_4_0;
 			}
 		}
+
+		public static string RuntimeVersionString (this TargetRuntime runtime)
+		{
+			switch (runtime) {
+			case TargetRuntime.Net_1_0:
+				return "v1.0.3705";
+			case TargetRuntime.Net_1_1:
+				return "v1.1.4322";
+			case TargetRuntime.Net_2_0:
+				return "v2.0.50727";
+			case TargetRuntime.Net_4_0:
+			default:
+				return "v4.0.30319";
+			}
+		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/ModuleKind.cs b/vbnc/cecil/Mono.Cecil/ModuleKind.cs
index eb57890..c29da88 100644
--- a/vbnc/cecil/Mono.Cecil/ModuleKind.cs
+++ b/vbnc/cecil/Mono.Cecil/ModuleKind.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -41,6 +41,7 @@ namespace Mono.Cecil {
 		I386,
 		AMD64,
 		IA64,
+		ARMv7,
 	}
 
 	[Flags]
@@ -48,5 +49,16 @@ namespace Mono.Cecil {
 		ILOnly = 1,
 		Required32Bit = 2,
 		StrongNameSigned = 8,
+		Preferred32Bit = 0x00020000,
+	}
+
+	[Flags]
+	public enum ModuleCharacteristics {
+		HighEntropyVA = 0x0020,
+		DynamicBase = 0x0040,
+		NoSEH = 0x0400,
+		NXCompat = 0x0100,
+		AppContainer = 0x1000,
+		TerminalServerAware = 0x8000,
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/ModuleReference.cs b/vbnc/cecil/Mono.Cecil/ModuleReference.cs
index 11d98b7..3934b3c 100644
--- a/vbnc/cecil/Mono.Cecil/ModuleReference.cs
+++ b/vbnc/cecil/Mono.Cecil/ModuleReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -56,7 +56,6 @@ namespace Mono.Cecil {
 		public ModuleReference (string name)
 			: this ()
 		{
-			Mixin.CheckName (name);
 			this.name = name;
 		}
 
diff --git a/vbnc/cecil/Mono.Cecil/NativeType.cs b/vbnc/cecil/Mono.Cecil/NativeType.cs
index afa107f..88da980 100644
--- a/vbnc/cecil/Mono.Cecil/NativeType.cs
+++ b/vbnc/cecil/Mono.Cecil/NativeType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/PInvokeAttributes.cs b/vbnc/cecil/Mono.Cecil/PInvokeAttributes.cs
index fc94692..bb36838 100644
--- a/vbnc/cecil/Mono.Cecil/PInvokeAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/PInvokeAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -53,7 +53,7 @@ namespace Mono.Cecil {
 
 		BestFitMask			= 0x0030,
 		BestFitEnabled		= 0x0010,
-		BestFidDisabled		= 0x0020,
+		BestFitDisabled		= 0x0020,
 
 		ThrowOnUnmappableCharMask = 0x3000,
 		ThrowOnUnmappableCharEnabled = 0x1000,
diff --git a/vbnc/cecil/Mono.Cecil/PInvokeInfo.cs b/vbnc/cecil/Mono.Cecil/PInvokeInfo.cs
index 53aae2c..cfd817c 100644
--- a/vbnc/cecil/Mono.Cecil/PInvokeInfo.cs
+++ b/vbnc/cecil/Mono.Cecil/PInvokeInfo.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -106,14 +106,14 @@ namespace Mono.Cecil {
 			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); }
 		}
 
-		public bool IsBestFistEnabled {
+		public bool IsBestFitEnabled {
 			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); }
 			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); }
 		}
 
-		public bool IsBestFistDisabled {
-			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled); }
-			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled, value); }
+		public bool IsBestFitDisabled {
+			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled); }
+			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled, value); }
 		}
 
 		public bool IsThrowOnUnmappableCharEnabled {
diff --git a/vbnc/cecil/Mono.Cecil/ParameterAttributes.cs b/vbnc/cecil/Mono.Cecil/ParameterAttributes.cs
index 8f8d1d5..e0bc825 100644
--- a/vbnc/cecil/Mono.Cecil/ParameterAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/ParameterAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -35,6 +35,8 @@ namespace Mono.Cecil {
 		None				= 0x0000,
 		In					= 0x0001,	// Param is [In]
 		Out					= 0x0002,	// Param is [Out]
+		Lcid				= 0x0004,
+		Retval				= 0x0008,
 		Optional			= 0x0010,	// Param is optional
 		HasDefault			= 0x1000,	// Param has default value
 		HasFieldMarshal		= 0x2000,	// Param has field marshal
diff --git a/vbnc/cecil/Mono.Cecil/ParameterDefinition.cs b/vbnc/cecil/Mono.Cecil/ParameterDefinition.cs
index 5af416d..9c4496d 100755
--- a/vbnc/cecil/Mono.Cecil/ParameterDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/ParameterDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -60,9 +60,18 @@ namespace Mono.Cecil {
 			get { return method; }
 		}
 
+		public int Sequence {
+			get {
+				if (method == null)
+					return -1;
+
+				return method.HasImplicitThis () ? index + 1 : index;
+			}
+		}
+
 		public bool HasConstant {
 			get {
-				ResolveConstant ();
+				this.ResolveConstant (ref constant, parameter_type.Module);
 
 				return constant != Mixin.NoValue;
 			}
@@ -74,14 +83,6 @@ namespace Mono.Cecil {
 			set { constant = value; }
 		}
 
-		void ResolveConstant ()
-		{
-			if (constant != Mixin.NotResolved)
-				return;
-
-			this.ResolveConstant (ref constant, parameter_type.Module);
-		}
-
 		public bool HasCustomAttributes {
 			get {
 				if (custom_attributes != null)
@@ -92,7 +93,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (parameter_type.Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, parameter_type.Module)); }
 		}
 
 		public bool HasMarshalInfo {
@@ -105,7 +106,7 @@ namespace Mono.Cecil {
 		}
 
 		public MarshalInfo MarshalInfo {
-			get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (parameter_type.Module)); }
+			get { return marshal_info ?? (this.GetMarshalInfo (ref marshal_info, parameter_type.Module)); }
 			set { marshal_info = value; }
 		}
 
@@ -121,6 +122,16 @@ namespace Mono.Cecil {
 			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Out, value); }
 		}
 
+		public bool IsLcid {
+			get { return attributes.GetAttributes ((ushort) ParameterAttributes.Lcid); }
+			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Lcid, value); }
+		}
+
+		public bool IsReturnValue {
+			get { return attributes.GetAttributes ((ushort) ParameterAttributes.Retval); }
+			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Retval, value); }
+		}
+
 		public bool IsOptional {
 			get { return attributes.GetAttributes ((ushort) ParameterAttributes.Optional); }
 			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Optional, value); }
@@ -131,8 +142,19 @@ namespace Mono.Cecil {
 			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasDefault, value); }
 		}
 
+		public bool HasFieldMarshal {
+			get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasFieldMarshal); }
+			set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasFieldMarshal, value); }
+		}
+
 		#endregion
 
+		internal ParameterDefinition (TypeReference parameterType, IMethodSignature method)
+			: this (string.Empty, ParameterAttributes.None, parameterType)
+		{
+			this.method = method;
+		}
+
 		public ParameterDefinition (TypeReference parameterType)
 			: this (string.Empty, ParameterAttributes.None, parameterType)
 		{
diff --git a/vbnc/cecil/Mono.Cecil/ParameterDefinitionCollection.cs b/vbnc/cecil/Mono.Cecil/ParameterDefinitionCollection.cs
index 1b07904..41296e1 100755
--- a/vbnc/cecil/Mono.Cecil/ParameterDefinitionCollection.cs
+++ b/vbnc/cecil/Mono.Cecil/ParameterDefinitionCollection.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/ParameterReference.cs b/vbnc/cecil/Mono.Cecil/ParameterReference.cs
index 0d9cf39..dd6148b 100755
--- a/vbnc/cecil/Mono.Cecil/ParameterReference.cs
+++ b/vbnc/cecil/Mono.Cecil/ParameterReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/PinnedType.cs b/vbnc/cecil/Mono.Cecil/PinnedType.cs
index d5e7a80..ff59cfb 100644
--- a/vbnc/cecil/Mono.Cecil/PinnedType.cs
+++ b/vbnc/cecil/Mono.Cecil/PinnedType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/PointerType.cs b/vbnc/cecil/Mono.Cecil/PointerType.cs
index 54ab775..a142e14 100644
--- a/vbnc/cecil/Mono.Cecil/PointerType.cs
+++ b/vbnc/cecil/Mono.Cecil/PointerType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/PropertyAttributes.cs b/vbnc/cecil/Mono.Cecil/PropertyAttributes.cs
index ad6fd9e..1be0413 100644
--- a/vbnc/cecil/Mono.Cecil/PropertyAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/PropertyAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/PropertyDefinition.cs b/vbnc/cecil/Mono.Cecil/PropertyDefinition.cs
index 3cae6f0..7a183c9 100755
--- a/vbnc/cecil/Mono.Cecil/PropertyDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/PropertyDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -76,7 +76,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		public MethodReference GetMethod {
@@ -127,6 +127,8 @@ namespace Mono.Cecil {
 
 		public bool HasParameters {
 			get {
+				InitializeMethods ();
+
 				if (get_method != null)
 					return get_method.HasParameters;
 
@@ -168,7 +170,7 @@ namespace Mono.Cecil {
 
 		public bool HasConstant {
 			get {
-				ResolveConstant ();
+				this.ResolveConstant (ref constant, Module);
 
 				return constant != Mixin.NoValue;
 			}
@@ -180,14 +182,6 @@ namespace Mono.Cecil {
 			set { constant = value; }
 		}
 
-		void ResolveConstant ()
-		{
-			if (constant != Mixin.NotResolved)
-				return;
-
-			this.ResolveConstant (ref constant, Module);
-		}
-
 		#region PropertyAttributes
 
 		public bool IsSpecialName {
@@ -251,14 +245,24 @@ namespace Mono.Cecil {
 
 		void InitializeMethods ()
 		{
-			if (get_method != null || set_method != null)
-				return;
-
 			var module = this.Module;
-			if (!module.HasImage ())
+			if (module == null)
 				return;
 
-			module.Read (this, (property, reader) => reader.ReadMethods (property));
+			lock (module.SyncRoot) {
+				if (get_method != null || set_method != null)
+					return;
+
+				if (!module.HasImage ())
+					return;
+
+				module.Read (this, (property, reader) => reader.ReadMethods (property));
+			}
+		}
+
+		public override PropertyDefinition Resolve ()
+		{
+			return this;
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/PropertyReference.cs b/vbnc/cecil/Mono.Cecil/PropertyReference.cs
index 31570a5..aae0fe0 100755
--- a/vbnc/cecil/Mono.Cecil/PropertyReference.cs
+++ b/vbnc/cecil/Mono.Cecil/PropertyReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -50,5 +50,7 @@ namespace Mono.Cecil {
 		{
 			property_type = propertyType;
 		}
+
+		public abstract PropertyDefinition Resolve ();
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/ReferenceType.cs b/vbnc/cecil/Mono.Cecil/ReferenceType.cs
index 3a6b326..7940c61 100644
--- a/vbnc/cecil/Mono.Cecil/ReferenceType.cs
+++ b/vbnc/cecil/Mono.Cecil/ReferenceType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/Resource.cs b/vbnc/cecil/Mono.Cecil/Resource.cs
index 0432ae7..eff7f41 100644
--- a/vbnc/cecil/Mono.Cecil/Resource.cs
+++ b/vbnc/cecil/Mono.Cecil/Resource.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/SecurityDeclaration.cs b/vbnc/cecil/Mono.Cecil/SecurityDeclaration.cs
index 4e57ada..a23a39d 100644
--- a/vbnc/cecil/Mono.Cecil/SecurityDeclaration.cs
+++ b/vbnc/cecil/Mono.Cecil/SecurityDeclaration.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -93,6 +93,7 @@ namespace Mono.Cecil {
 	public sealed class SecurityDeclaration {
 
 		readonly internal uint signature;
+		byte [] blob;
 		readonly ModuleDefinition module;
 
 		internal bool resolved;
@@ -137,12 +138,22 @@ namespace Mono.Cecil {
 			this.resolved = true;
 		}
 
+		public SecurityDeclaration (SecurityAction action, byte [] blob)
+		{
+			this.action = action;
+			this.resolved = false;
+			this.blob = blob;
+		}
+
 		public byte [] GetBlob ()
 		{
+			if (blob != null)
+				return blob;
+
 			if (!HasImage || signature == 0)
 				throw new NotSupportedException ();
 
-			return module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature)); ;
+			return blob = module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature));
 		}
 
 		void Resolve ()
@@ -165,18 +176,17 @@ namespace Mono.Cecil {
 			this ISecurityDeclarationProvider self,
 			ModuleDefinition module)
 		{
-			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.HasSecurityDeclarations (provider))
-				: false;
+			return module.HasImage () && module.Read (self, (provider, reader) => reader.HasSecurityDeclarations (provider));
 		}
 
 		public static Collection<SecurityDeclaration> GetSecurityDeclarations (
 			this ISecurityDeclarationProvider self,
+			ref Collection<SecurityDeclaration> variable,
 			ModuleDefinition module)
 		{
 			return module.HasImage ()
-				? module.Read (self, (provider, reader) => reader.ReadSecurityDeclarations (provider))
-				: new Collection<SecurityDeclaration> ();
+				? module.Read (ref variable, self, (provider, reader) => reader.ReadSecurityDeclarations (provider))
+				: variable = new Collection<SecurityDeclaration>();
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/SentinelType.cs b/vbnc/cecil/Mono.Cecil/SentinelType.cs
index d0d5a1d..664d75b 100644
--- a/vbnc/cecil/Mono.Cecil/SentinelType.cs
+++ b/vbnc/cecil/Mono.Cecil/SentinelType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/TargetRuntime.cs b/vbnc/cecil/Mono.Cecil/TargetRuntime.cs
index 9931fc6..9b49a5f 100644
--- a/vbnc/cecil/Mono.Cecil/TargetRuntime.cs
+++ b/vbnc/cecil/Mono.Cecil/TargetRuntime.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/TypeAttributes.cs b/vbnc/cecil/Mono.Cecil/TypeAttributes.cs
index 6e263e8..86fbc4d 100644
--- a/vbnc/cecil/Mono.Cecil/TypeAttributes.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeAttributes.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -62,6 +62,7 @@ namespace Mono.Cecil {
 		// Implementation attributes
 		Import				= 0x00001000,	// Class/Interface is imported
 		Serializable		= 0x00002000,	// Class is serializable
+		WindowsRuntime		= 0x00004000,	// Windows Runtime type
 
 		// String formatting attributes
 		StringFormatMask	= 0x00030000,	// Use this mask to retrieve string information for native interop
diff --git a/vbnc/cecil/Mono.Cecil/TypeDefinition.cs b/vbnc/cecil/Mono.Cecil/TypeDefinition.cs
index c83531a..db5a065 100644
--- a/vbnc/cecil/Mono.Cecil/TypeDefinition.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeDefinition.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -28,6 +28,7 @@
 
 using System;
 
+using Mono.Cecil.Metadata;
 using Mono.Collections.Generic;
 
 namespace Mono.Cecil {
@@ -131,7 +132,7 @@ namespace Mono.Cecil {
 					return interfaces;
 
 				if (HasImage)
-					return interfaces = Module.Read (this, (type, reader) => reader.ReadInterfaces (type));
+					return Module.Read (ref interfaces, this, (type, reader) => reader.ReadInterfaces (type));
 
 				return interfaces = new Collection<TypeReference> ();
 			}
@@ -155,16 +156,12 @@ namespace Mono.Cecil {
 					return nested_types;
 
 				if (HasImage)
-					return nested_types = Module.Read (this, (type, reader) => reader.ReadNestedTypes (type));
+					return Module.Read (ref nested_types, this, (type, reader) => reader.ReadNestedTypes (type));
 
 				return nested_types = new MemberDefinitionCollection<TypeDefinition> (this);
 			}
 		}
 
-		internal new bool HasImage {
-			get { return Module != null && Module.HasImage; }
-		}
-
 		public bool HasMethods {
 			get {
 				if (methods != null)
@@ -183,7 +180,7 @@ namespace Mono.Cecil {
 					return methods;
 
 				if (HasImage)
-					return methods = Module.Read (this, (type, reader) => reader.ReadMethods (type));
+					return Module.Read (ref methods, this, (type, reader) => reader.ReadMethods (type));
 
 				return methods = new MemberDefinitionCollection<MethodDefinition> (this);
 			}
@@ -207,7 +204,7 @@ namespace Mono.Cecil {
 					return fields;
 
 				if (HasImage)
-					return fields = Module.Read (this, (type, reader) => reader.ReadFields (type));
+					return Module.Read (ref fields, this, (type, reader) => reader.ReadFields (type));
 
 				return fields = new MemberDefinitionCollection<FieldDefinition> (this);
 			}
@@ -231,7 +228,7 @@ namespace Mono.Cecil {
 					return events;
 
 				if (HasImage)
-					return events = Module.Read (this, (type, reader) => reader.ReadEvents (type));
+					return Module.Read (ref events, this, (type, reader) => reader.ReadEvents (type));
 
 				return events = new MemberDefinitionCollection<EventDefinition> (this);
 			}
@@ -255,7 +252,7 @@ namespace Mono.Cecil {
 					return properties;
 
 				if (HasImage)
-					return properties = Module.Read (this, (type, reader) => reader.ReadProperties (type));
+					return Module.Read (ref properties, this, (type, reader) => reader.ReadProperties (type));
 
 				return properties = new MemberDefinitionCollection<PropertyDefinition> (this);
 			}
@@ -271,7 +268,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<SecurityDeclaration> SecurityDeclarations {
-			get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); }
+			get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, Module)); }
 		}
 
 		public bool HasCustomAttributes {
@@ -284,7 +281,7 @@ namespace Mono.Cecil {
 		}
 
 		public Collection<CustomAttribute> CustomAttributes {
-			get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+			get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); }
 		}
 
 		public override bool HasGenericParameters {
@@ -297,7 +294,7 @@ namespace Mono.Cecil {
 		}
 
 		public override Collection<GenericParameter> GenericParameters {
-			get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); }
+			get { return generic_parameters ?? (this.GetGenericParameters (ref generic_parameters, Module)); }
 		}
 
 		#region TypeAttributes
@@ -392,6 +389,11 @@ namespace Mono.Cecil {
 			set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
 		}
 
+		public bool IsWindowsRuntime {
+			get { return attributes.GetAttributes ((uint) TypeAttributes.WindowsRuntime); }
+			set { attributes = attributes.SetAttributes ((uint) TypeAttributes.WindowsRuntime, value); }
+		}
+
 		public bool IsAnsiClass {
 			get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
 			set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
@@ -437,6 +439,23 @@ namespace Mono.Cecil {
 			}
 		}
 
+		public override bool IsPrimitive {
+			get {
+				ElementType primitive_etype;
+				return MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype);
+			}
+		}
+
+		public override MetadataType MetadataType {
+			get {
+				ElementType primitive_etype;
+				if (MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype))
+					return (MetadataType) primitive_etype;
+
+				return base.MetadataType;
+			}
+		}
+
 		public override bool IsDefinition {
 			get { return true; }
 		}
@@ -480,7 +499,7 @@ namespace Mono.Cecil {
 			throw new ArgumentException ();
 		}
 
-		public static TypeDefinition GetNestedType (this TypeDefinition self, string name)
+		public static TypeDefinition GetNestedType (this TypeDefinition self, string fullname)
 		{
 			if (!self.HasNestedTypes)
 				return null;
@@ -489,7 +508,8 @@ namespace Mono.Cecil {
 
 			for (int i = 0; i < nested_types.Count; i++) {
 				var nested_type = nested_types [i];
-				if (nested_type.Name == name)
+
+				if (nested_type.TypeFullName () == fullname)
 					return nested_type;
 			}
 
diff --git a/vbnc/cecil/Mono.Cecil/TypeDefinitionCollection.cs b/vbnc/cecil/Mono.Cecil/TypeDefinitionCollection.cs
index 702fe27..eae7122 100644
--- a/vbnc/cecil/Mono.Cecil/TypeDefinitionCollection.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeDefinitionCollection.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Cecil/TypeParser.cs b/vbnc/cecil/Mono.Cecil/TypeParser.cs
index cd3d11a..1af4934 100644
--- a/vbnc/cecil/Mono.Cecil/TypeParser.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeParser.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -129,11 +129,15 @@ namespace Mono.Cecil {
 
 		string ParsePart ()
 		{
-			int start = position;
-			while (position < length && !IsDelimiter (fullname [position]))
-				position++;
+			var part = new StringBuilder ();
+			while (position < length && !IsDelimiter (fullname [position])) {
+				if (fullname [position] == '\\')
+					position++;
 
-			return fullname.Substring (start, position - start);
+				part.Append (fullname [position++]);
+			}
+
+			return part.ToString ();
 		}
 
 		static bool IsDelimiter (char chr)
@@ -173,13 +177,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 +270,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);
@@ -355,9 +353,8 @@ namespace Mono.Cecil {
 			string @namespace, name;
 			SplitFullName (type_info.type_fullname, out @namespace, out name);
 
-			var type = new TypeReference (@namespace, name, scope) {
-				module = module,
-			};
+			var type = new TypeReference (@namespace, name, module, scope);
+			MetadataSystem.TryProcessPrimitiveTypeReference (type);
 
 			AdjustGenericParameters (type);
 
@@ -366,9 +363,8 @@ namespace Mono.Cecil {
 				return type;
 
 			for (int i = 0; i < nested_names.Length; i++) {
-				type = new TypeReference (string.Empty, nested_names [i], null) {
+				type = new TypeReference (string.Empty, nested_names [i], module, null) {
 					DeclaringType = type,
-					module = module,
 				};
 
 				AdjustGenericParameters (type);
@@ -449,6 +445,16 @@ namespace Mono.Cecil {
 			return name.ToString ();
 		}
 
+		static void AppendNamePart (string part, StringBuilder name)
+		{
+			foreach (var c in part) {
+				if (IsDelimiter (c))
+					name.Append ('\\');
+
+				name.Append (c);
+			}
+		}
+
 		static void AppendType (TypeReference type, StringBuilder name, bool fq_name, bool top_level)
 		{
 			var declaring_type = type.DeclaringType;
@@ -459,11 +465,11 @@ namespace Mono.Cecil {
 
 			var @namespace = type.Namespace;
 			if (!string.IsNullOrEmpty (@namespace)) {
-				name.Append (@namespace);
+				AppendNamePart (@namespace, name);
 				name.Append ('.');
 			}
 
-			name.Append (type.GetElementType ().Name);
+			AppendNamePart (type.GetElementType ().Name, name);
 
 			if (!fq_name)
 				return;
diff --git a/vbnc/cecil/Mono.Cecil/TypeReference.cs b/vbnc/cecil/Mono.Cecil/TypeReference.cs
index f36810e..9e8aa5c 100644
--- a/vbnc/cecil/Mono.Cecil/TypeReference.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeReference.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -33,6 +33,40 @@ using Mono.Collections.Generic;
 
 namespace Mono.Cecil {
 
+	public enum MetadataType : byte {
+		Void = ElementType.Void,
+		Boolean = ElementType.Boolean,
+		Char = ElementType.Char,
+		SByte = ElementType.I1,
+		Byte = ElementType.U1,
+		Int16 = ElementType.I2,
+		UInt16 = ElementType.U2,
+		Int32 = ElementType.I4,
+		UInt32 = ElementType.U4,
+		Int64 = ElementType.I8,
+		UInt64 = ElementType.U8,
+		Single = ElementType.R4,
+		Double = ElementType.R8,
+		String = ElementType.String,
+		Pointer = ElementType.Ptr,
+		ByReference = ElementType.ByRef,
+		ValueType = ElementType.ValueType,
+		Class = ElementType.Class,
+		Var = ElementType.Var,
+		Array = ElementType.Array,
+		GenericInstance = ElementType.GenericInst,
+		TypedByReference = ElementType.TypedByRef,
+		IntPtr = ElementType.I,
+		UIntPtr = ElementType.U,
+		FunctionPointer = ElementType.FnPtr,
+		Object = ElementType.Object,
+		MVar = ElementType.MVar,
+		RequiredModifier = ElementType.CModReqD,
+		OptionalModifier = ElementType.CModOpt,
+		Sentinel = ElementType.Sentinel,
+		Pinned = ElementType.Pinned,
+	}
+
 	public class TypeReference : MemberReference, IGenericParameterProvider, IGenericContext {
 
 		string @namespace;
@@ -101,7 +135,7 @@ namespace Mono.Cecil {
 				if (generic_parameters != null)
 					return generic_parameters;
 
-				return generic_parameters = new Collection<GenericParameter> ();
+				return generic_parameters = new GenericParameterCollection (this);
 			}
 		}
 
@@ -113,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 {
@@ -132,13 +175,12 @@ namespace Mono.Cecil {
 				if (fullname != null)
 					return fullname;
 
-				if (IsNested)
-					return fullname = DeclaringType.FullName + "/" + Name;
+				fullname = this.TypeFullName ();
 
-				if (string.IsNullOrEmpty (@namespace))
-					return fullname = Name;
+				if (IsNested)
+					fullname = DeclaringType.FullName + "/" + fullname;
 
-				return fullname = @namespace + "." + Name;
+				return fullname;
 			}
 		}
 
@@ -182,26 +224,17 @@ namespace Mono.Cecil {
 			get { return false; }
 		}
 
-		public bool IsPrimitive {
+		public virtual bool IsPrimitive {
+			get { return etype.IsPrimitive (); }
+		}
+
+		public virtual MetadataType MetadataType {
 			get {
 				switch (etype) {
-				case ElementType.Boolean:
-				case ElementType.Char:
-				case ElementType.I:
-				case ElementType.U:
-				case ElementType.I1:
-				case ElementType.U1:
-				case ElementType.I2:
-				case ElementType.U2:
-				case ElementType.I4:
-				case ElementType.U4:
-				case ElementType.I8:
-				case ElementType.U8:
-				case ElementType.R4:
-				case ElementType.R8:
-					return true;
+				case ElementType.None:
+					return IsValueType ? MetadataType.ValueType : MetadataType.Class;
 				default:
-					return false;
+					return (MetadataType) etype;
 				}
 			}
 		}
@@ -213,14 +246,15 @@ namespace Mono.Cecil {
 			this.token = new MetadataToken (TokenType.TypeRef, 0);
 		}
 
-		public TypeReference (string @namespace, string name, IMetadataScope scope)
+		public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
 			: this (@namespace, name)
 		{
+			this.module = module;
 			this.scope = scope;
 		}
 
-		public TypeReference (string @namespace, string name, IMetadataScope scope, bool valueType) :
-			this (@namespace, name, scope)
+		public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope, bool valueType) :
+			this (@namespace, name, module, scope)
 		{
 			value_type = valueType;
 		}
@@ -242,6 +276,36 @@ namespace Mono.Cecil {
 
 	static partial class Mixin {
 
+		public static bool IsPrimitive (this ElementType self)
+		{
+			switch (self) {
+			case ElementType.Boolean:
+			case ElementType.Char:
+			case ElementType.I:
+			case ElementType.U:
+			case ElementType.I1:
+			case ElementType.U1:
+			case ElementType.I2:
+			case ElementType.U2:
+			case ElementType.I4:
+			case ElementType.U4:
+			case ElementType.I8:
+			case ElementType.U8:
+			case ElementType.R4:
+			case ElementType.R8:
+				return true;
+			default:
+				return false;
+			}
+		}
+
+		public static string TypeFullName (this TypeReference self)
+		{
+			return string.IsNullOrEmpty (self.Namespace)
+				? self.Name
+				: self.Namespace + '.' + self.Name;
+		}
+
 		public static bool IsTypeOf (this TypeReference self, string @namespace, string name)
 		{
 			return self.Name == name
@@ -261,6 +325,7 @@ namespace Mono.Cecil {
 			case ElementType.Pinned:
 			case ElementType.Ptr:
 			case ElementType.SzArray:
+			case ElementType.Sentinel:
 			case ElementType.Var:
 				return true;
 			}
@@ -272,7 +337,7 @@ namespace Mono.Cecil {
 		{
 			var type = self.Resolve ();
 			if (type == null)
-				throw new InvalidOperationException (string.Format ("Failed to resolve type: {0}", self.FullName));
+				throw new ResolutionException (self);
 
 			return type;
 		}
diff --git a/vbnc/cecil/Mono.Cecil/TypeSpecification.cs b/vbnc/cecil/Mono.Cecil/TypeSpecification.cs
index 35e2530..d3f62f9 100644
--- a/vbnc/cecil/Mono.Cecil/TypeSpecification.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeSpecification.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -28,6 +28,8 @@
 
 using System;
 
+using Mono.Cecil.Metadata;
+
 namespace Mono.Cecil {
 
 	public abstract class TypeSpecification : TypeReference {
@@ -40,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 {
@@ -60,10 +63,14 @@ namespace Mono.Cecil {
 			get { return element_type.FullName; }
 		}
 
-		internal override bool ContainsGenericParameter {
+		public override bool ContainsGenericParameter {
 			get { return element_type.ContainsGenericParameter; }
 		}
 
+		public override MetadataType MetadataType {
+			get { return (MetadataType) etype; }
+		}
+
 		internal TypeSpecification (TypeReference type)
 			: base (null, null)
 		{
@@ -71,7 +78,7 @@ namespace Mono.Cecil {
 			this.token = new MetadataToken (TokenType.TypeSpec);
 		}
 
-		public sealed override TypeReference GetElementType ()
+		public override TypeReference GetElementType ()
 		{
 			return element_type.GetElementType ();
 		}
diff --git a/vbnc/cecil/Mono.Cecil/TypeSystem.cs b/vbnc/cecil/Mono.Cecil/TypeSystem.cs
index f7eedc5..9eb2635 100644
--- a/vbnc/cecil/Mono.Cecil/TypeSystem.cs
+++ b/vbnc/cecil/Mono.Cecil/TypeSystem.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,30 +32,66 @@ using Mono.Cecil.Metadata;
 
 namespace Mono.Cecil {
 
-	abstract class TypeSystem {
+	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 types = module.MetadataSystem.Types;
+				var type = LookupTypeDefinition (@namespace, name) ?? LookupTypeForwarded (@namespace, name);
+				if (type != null)
+					return type;
 
-				for (int i = 0; i < types.Length; i++) {
-					var type = types [i];
-					if (type == null)
-						continue;
+				throw new NotSupportedException ();
+			}
+
+			TypeReference LookupTypeDefinition (string @namespace, string name)
+			{
+				var metadata = module.MetadataSystem;
+				if (metadata.Types == null)
+					Initialize (module.Types);
+
+				return module.Read (new Row<string, string> (@namespace, name), (row, reader) => {
+					var types = reader.metadata.Types;
+
+					for (int i = 0; i < types.Length; i++) {
+						if (types [i] == null)
+							types [i] = reader.GetTypeDefinition ((uint) i + 1);
+
+						var type = types [i];
+
+						if (type.Name == row.Col2 && type.Namespace == row.Col1)
+							return type;
+					}
+
+					return null;
+				});
+			}
+
+			TypeReference LookupTypeForwarded (string @namespace, string name)
+			{
+				if (!module.HasExportedTypes)
+					return null;
 
-					if (type.Name == name && type.Namespace == @namespace)
-						return type;
+				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)
+			{
+			}
 		}
 
 		sealed class CommonTypeSystem : TypeSystem {
@@ -115,9 +151,7 @@ namespace Mono.Cecil {
 
 			TypeReference CreateTypeReference (string @namespace, string name)
 			{
-				var type = new TypeReference (@namespace, name, GetCorlibReference ());
-				type.module = module;
-				return type;
+				return new TypeReference (@namespace, name, module, GetCorlibReference ());
 			}
 		}
 
@@ -149,34 +183,35 @@ namespace Mono.Cecil {
 
 		internal static TypeSystem CreateTypeSystem (ModuleDefinition module)
 		{
-			if (IsCorlib (module))
-				return new CorlibTypeSystem (module);
+			if (module.IsCorlib ())
+				return new CoreTypeSystem (module);
 
 			return new CommonTypeSystem (module);
 		}
 
-		static bool IsCorlib (ModuleDefinition module)
-		{
-			if (module.Assembly == null)
-				return false;
-
-			return module.Assembly.Name.Name == "mscorlib";
-		}
-
 		internal abstract TypeReference LookupType (string @namespace, string name);
 
-		TypeReference LookupSystemType (string name, ElementType element_type)
+		TypeReference LookupSystemType (ref TypeReference reference, string name, ElementType element_type)
 		{
-			var type = LookupType ("System", name);
-			type.etype = element_type;
-			return type;
+			lock (module.SyncRoot) {
+				if (reference != null)
+					return reference;
+				var type = LookupType ("System", name);
+				type.etype = element_type;
+				return reference = type;
+			}
 		}
 
-		TypeReference LookupSystemValueType (string name, ElementType element_type)
+		TypeReference LookupSystemValueType (ref TypeReference typeRef, string name, ElementType element_type)
 		{
-			var type = LookupSystemType (name, element_type);
-			type.IsValueType = true;
-			return type;
+			lock (module.SyncRoot) {
+				if (typeRef != null)
+					return typeRef;
+				var type = LookupType ("System", name);
+				type.etype = element_type;
+				type.IsValueType = true;
+				return typeRef = type;
+			}
 		}
 
 		public IMetadataScope Corlib {
@@ -190,75 +225,75 @@ namespace Mono.Cecil {
 		}
 
 		public TypeReference Object {
-			get { return type_object ?? (type_object = LookupSystemType ("Object", ElementType.Object)); }
+			get { return type_object ?? (LookupSystemType (ref type_object, "Object", ElementType.Object)); }
 		}
 
 		public TypeReference Void {
-			get { return type_void ?? (type_void = LookupSystemType ("Void", ElementType.Void)); }
+			get { return type_void ?? (LookupSystemType (ref type_void, "Void", ElementType.Void)); }
 		}
 
 		public TypeReference Boolean {
-			get { return type_bool ?? (type_bool = LookupSystemValueType ("Boolean", ElementType.Boolean)); }
+			get { return type_bool ?? (LookupSystemValueType (ref type_bool, "Boolean", ElementType.Boolean)); }
 		}
 
 		public TypeReference Char {
-			get { return type_char ?? (type_char = LookupSystemValueType ("Char", ElementType.Char)); }
+			get { return type_char ?? (LookupSystemValueType (ref type_char, "Char", ElementType.Char)); }
 		}
 
 		public TypeReference SByte {
-			get { return type_sbyte ?? (type_sbyte = LookupSystemValueType ("SByte", ElementType.I1)); }
+			get { return type_sbyte ?? (LookupSystemValueType (ref type_sbyte, "SByte", ElementType.I1)); }
 		}
 
 		public TypeReference Byte {
-			get { return type_byte ?? (type_byte = LookupSystemValueType ("Byte", ElementType.U1)); }
+			get { return type_byte ?? (LookupSystemValueType (ref type_byte, "Byte", ElementType.U1)); }
 		}
 
 		public TypeReference Int16 {
-			get { return type_int16 ?? (type_int16 = LookupSystemValueType ("Int16", ElementType.I2)); }
+			get { return type_int16 ?? (LookupSystemValueType (ref type_int16, "Int16", ElementType.I2)); }
 		}
 
 		public TypeReference UInt16 {
-			get { return type_uint16 ?? (type_uint16 = LookupSystemValueType ("UInt16", ElementType.U2)); }
+			get { return type_uint16 ?? (LookupSystemValueType (ref type_uint16, "UInt16", ElementType.U2)); }
 		}
 
 		public TypeReference Int32 {
-			get { return type_int32 ?? (type_int32 = LookupSystemValueType ("Int32", ElementType.I4)); }
+			get { return type_int32 ?? (LookupSystemValueType (ref type_int32, "Int32", ElementType.I4)); }
 		}
 
 		public TypeReference UInt32 {
-			get { return type_uint32 ?? (type_uint32 = LookupSystemValueType ("UInt32", ElementType.U4)); }
+			get { return type_uint32 ?? (LookupSystemValueType (ref type_uint32, "UInt32", ElementType.U4)); }
 		}
 
 		public TypeReference Int64 {
-			get { return type_int64 ?? (type_int64 = LookupSystemValueType ("Int64", ElementType.I8)); }
+			get { return type_int64 ?? (LookupSystemValueType (ref type_int64, "Int64", ElementType.I8)); }
 		}
 
 		public TypeReference UInt64 {
-			get { return type_uint64 ?? (type_uint64 = LookupSystemValueType ("UInt64", ElementType.U8)); }
+			get { return type_uint64 ?? (LookupSystemValueType (ref type_uint64, "UInt64", ElementType.U8)); }
 		}
 
 		public TypeReference Single {
-			get { return type_single ?? (type_single = LookupSystemValueType ("Single", ElementType.R4)); }
+			get { return type_single ?? (LookupSystemValueType (ref type_single, "Single", ElementType.R4)); }
 		}
 
 		public TypeReference Double {
-			get { return type_double ?? (type_double = LookupSystemValueType ("Double", ElementType.R8)); }
+			get { return type_double ?? (LookupSystemValueType (ref type_double, "Double", ElementType.R8)); }
 		}
 
 		public TypeReference IntPtr {
-			get { return type_intptr ?? (type_intptr = LookupSystemValueType ("IntPtr", ElementType.I)); }
+			get { return type_intptr ?? (LookupSystemValueType (ref type_intptr, "IntPtr", ElementType.I)); }
 		}
 
 		public TypeReference UIntPtr {
-			get { return type_uintptr ?? (type_uintptr = LookupSystemValueType ("UIntPtr", ElementType.U)); }
+			get { return type_uintptr ?? (LookupSystemValueType (ref type_uintptr, "UIntPtr", ElementType.U)); }
 		}
 
 		public TypeReference String {
-			get { return type_string ?? (type_string = LookupSystemType ("String", ElementType.String)); }
+			get { return type_string ?? (LookupSystemType (ref type_string, "String", ElementType.String)); }
 		}
 
 		public TypeReference TypedReference {
-			get { return type_typedref ?? (type_typedref = LookupSystemValueType ("TypedReference", ElementType.TypedByRef)); }
+			get { return type_typedref ?? (LookupSystemValueType (ref type_typedref, "TypedReference", ElementType.TypedByRef)); }
 		}
 	}
 }
diff --git a/vbnc/cecil/Mono.Cecil/VariantType.cs b/vbnc/cecil/Mono.Cecil/VariantType.cs
index 86d6daa..76562f6 100644
--- a/vbnc/cecil/Mono.Cecil/VariantType.cs
+++ b/vbnc/cecil/Mono.Cecil/VariantType.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/Mono.Collections.Generic/Collection.cs b/vbnc/cecil/Mono.Collections.Generic/Collection.cs
index 5a8752c..5709fbe 100755
--- a/vbnc/cecil/Mono.Collections.Generic/Collection.cs
+++ b/vbnc/cecil/Mono.Collections.Generic/Collection.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,6 +30,8 @@ using System;
 using System.Collections;
 using System.Collections.Generic;
 
+using Mono.Cecil;
+
 namespace Mono.Collections.Generic {
 
 	public class Collection<T> : IList<T>, IList {
@@ -60,6 +62,16 @@ namespace Mono.Collections.Generic {
 			}
 		}
 
+		public int Capacity {
+			get { return items.Length; }
+			set {
+				if (value < 0 || value < size)
+					throw new ArgumentOutOfRangeException ();
+
+				Resize (value);
+			}
+		}
+
 		bool ICollection<T>.IsReadOnly {
 			get { return false; }
 		}
@@ -113,6 +125,16 @@ namespace Mono.Collections.Generic {
 			items = new T [capacity];
 		}
 
+		public Collection (ICollection<T> items)
+		{
+			if (items == null)
+				throw new ArgumentNullException ("items");
+
+			this.items = new T [items.Count];
+			items.CopyTo (this.items, 0);
+			this.size = this.items.Length;
+		}
+
 		public void Add (T item)
 		{
 			if (size == items.Length)
@@ -255,7 +277,7 @@ namespace Mono.Collections.Generic {
 		{
 		}
 
-		void Grow (int desired)
+		internal virtual void Grow (int desired)
 		{
 			int new_size = size + desired;
 			if (new_size <= items.Length)
@@ -267,13 +289,17 @@ namespace Mono.Collections.Generic {
 				System.Math.Max (items.Length * 2, default_capacity),
 				new_size);
 
-#if !CF
-			Array.Resize (ref items, new_size);
-#else
-			var array = new T [new_size];
-			Array.Copy (items, array, size);
-			items = array;
-#endif
+			Resize (new_size);
+		}
+
+		protected void Resize (int new_size)
+		{
+			if (new_size == size)
+				return;
+			if (new_size < size)
+				throw new ArgumentOutOfRangeException ();
+
+			items = items.Resize (new_size);
 		}
 
 		int IList.Add (object value)
diff --git a/vbnc/cecil/Mono.Security.Cryptography/CryptoConvert.cs b/vbnc/cecil/Mono.Security.Cryptography/CryptoConvert.cs
index 26a4ba2..bd38900 100644
--- a/vbnc/cecil/Mono.Security.Cryptography/CryptoConvert.cs
+++ b/vbnc/cecil/Mono.Security.Cryptography/CryptoConvert.cs
@@ -139,10 +139,11 @@ namespace Mono.Security.Cryptography {
 				rsa = RSA.Create ();
 				rsa.ImportParameters (rsap);
 			}
-			catch (CryptographicException ce) {
+			catch (CryptographicException) {
 				// this may cause problem when this code is run under
 				// the SYSTEM identity on Windows (e.g. ASP.NET). See
 				// http://bugzilla.ximian.com/show_bug.cgi?id=77559
+				bool throws = false;
 				try {
 					CspParameters csp = new CspParameters ();
 					csp.Flags = CspProviderFlags.UseMachineKeyStore;
@@ -150,8 +151,12 @@ namespace Mono.Security.Cryptography {
 					rsa.ImportParameters (rsap);
 				}
 				catch {
-					// rethrow original, not the later, exception if this fails
-					throw ce;
+					throws = true;
+				}
+
+				if (throws) {
+					// rethrow original, not the latter, exception if this fails
+					throw;
 				}
 			}
 			return rsa;
diff --git a/vbnc/cecil/Mono.Security.Cryptography/CryptoService.cs b/vbnc/cecil/Mono.Security.Cryptography/CryptoService.cs
index df903a3..58b6cfa 100644
--- a/vbnc/cecil/Mono.Security.Cryptography/CryptoService.cs
+++ b/vbnc/cecil/Mono.Security.Cryptography/CryptoService.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -33,7 +33,7 @@ using System.Security.Cryptography;
 
 #if !READ_ONLY
 
-#if !SILVERLIGHT && !CF
+#if !SILVERLIGHT && !CF
 using System.Runtime.Serialization;
 using Mono.Security.Cryptography;
 #endif
@@ -55,8 +55,6 @@ namespace Mono.Cecil {
 
 			var strong_name = CreateStrongName (key_pair, HashStream (stream, writer, out strong_name_pointer));
 			PatchStrongName (stream, strong_name_pointer, strong_name);
-
-			PatchChecksum (stream, ComputeChecksum (stream));
 		}
 
 		static void PatchStrongName (Stream stream, int strong_name_pointer, byte [] strong_name)
@@ -112,35 +110,6 @@ namespace Mono.Cecil {
 
 			return sha1.Hash;
 		}
-
-		static void PatchChecksum (Stream stream, int checksum)
-		{
-			stream.Seek (0xd8, SeekOrigin.Begin);
-			var buffer = new ByteBuffer (4);
-			buffer.WriteInt32 (checksum);
-
-			stream.Write (buffer.buffer, 0, 4);
-		}
-
-		static int ComputeChecksum (Stream stream)
-		{
-			stream.Seek (0, SeekOrigin.Begin);
-			int count = (int) stream.Length / 4;
-
-			var reader = new BinaryReader (stream);
-			long sum = 0;
-			for (int i = 0; i < count; i++) {
-				sum += reader.ReadUInt32 ();
-				int carry = (int) (sum >> 32);
-				sum &= 0xFFFFFFFFU;
-				sum += carry;
-			}
-
-			while ((sum >> 16) != 0)
-				sum = (sum & 0xFFFF) + (sum >> 16);
-
-			return (int) (sum + stream.Length);
-		}
 #endif
 		static void CopyStreamChunk (Stream stream, Stream dest_stream, byte [] buffer, int length)
 		{
diff --git a/vbnc/cecil/Mono/Actions.cs b/vbnc/cecil/Mono/Actions.cs
index 071b149..756438f 100644
--- a/vbnc/cecil/Mono/Actions.cs
+++ b/vbnc/cecil/Mono/Actions.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@
 
 namespace Mono {
 	//delegate void Action ();
-	//delegate void Action<T1, T2> (T1 arg1, T2 arg2);
+	delegate void Action<T1, T2> (T1 arg1, T2 arg2);
 	//delegate void Action<T1, T2, T3> (T1 arg1, T2 arg2, T3 arg3);
 	//delegate void Action<T1, T2, T3, T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
 }
diff --git a/vbnc/cecil/Mono/Empty.cs b/vbnc/cecil/Mono/Empty.cs
index 70739af..c9e5d7d 100644
--- a/vbnc/cecil/Mono/Empty.cs
+++ b/vbnc/cecil/Mono/Empty.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,8 +27,7 @@
 //
 
 using System;
-using System.Collections;
-using System.Collections.Generic;
+using Mono.Collections.Generic;
 
 namespace Mono {
 
@@ -47,9 +46,22 @@ namespace Mono.Cecil {
 			return self == null || self.Length == 0;
 		}
 
-		public static bool IsNullOrEmpty<T> (this ICollection<T> self)
+		public static bool IsNullOrEmpty<T> (this Collection<T> self)
 		{
-			return self == null || self.Count == 0;
+			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/vbnc/cecil/Mono/Funcs.cs b/vbnc/cecil/Mono/Funcs.cs
index 40f2225..87bc6e9 100644
--- a/vbnc/cecil/Mono/Funcs.cs
+++ b/vbnc/cecil/Mono/Funcs.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/NOTES.txt b/vbnc/cecil/NOTES.txt
deleted file mode 100644
index 6f3618b..0000000
--- a/vbnc/cecil/NOTES.txt
+++ /dev/null
@@ -1,189 +0,0 @@
-namespaces:
-
-	Mono.Cecil.Binary: deleted,
-	Mono.Cecil.Metadata: metadata table/rows: deleted.
-
-collections:
-
-	* Cecil now only exposes Collection of T as a public collection API.
-
-types:
-
-Mono.Cecil
-
-	- AssemblyFactory:
-		Use static Read methods on ModuleDefinition and AssemblyDefinition
-		to get them.
-
-	+ ReadingMode:
-		specifies if the assembly is either loaded in a deffered
-		or immediate fashion.
-
-	+ ReaderParameters
-		+ ReadingMode
-		+ ISymbolReaderProvider
-
-	+ WriterParameters
-		+ ISymbolWriterProvider
-
-	* AssemblyDefinition:
-
-			* Runtime, Kind: moved to ModuleDefiniton
-
-	* ModuleDefinition:
-
-		properties:
-
-			- Image
-			- MemberReferences
-			- TypeReferences
-			- ExternTypes
-
-			* Main -> IsMain. (set removed) : bool
-			+ FullyQualifiedName : string
-			+ Kind : ModuleKind
-			+ Runtime : TargetRuntime
-			+ Architecture : TargetArchitecture
-			+ Attributes : ModuleAttributes
-			+ HasSymbols : bool
-			+ HasExportedTypes : bool
-			+ ExportedTypes : ExportedTypeCollection
-
-			* Types: doesn't contain NestedTypes anymore.
-
-	- AssemblyKind:
-		renamed to ModuleKind.
-
-	+ ModuleKind:
-		+ NetModule
-
-	+ TargetArchitecture:
-		+ I386
-		+ AMD64
-		+ IA64
-
-	+ ModuleAttributes:
-		+ ILOnly
-		+ Required32Bit
-		+ StrongNameSigned
-
-	* FieldDefinition:
-
-		* RVA : int
-
-	* IMethodSignature:
-		* ReturnType : TypeReference
-		+ MethodReturnType : MethodReturnType
-
-	* TypeDefinition:
-		- HasConstructors
-		- Constructors
-		* ctor: swapped namespace and name parameter.
-
-	* ParameterDefinition:
-		* Method : IMethodSignature
-		* Sequence -> Index : int (0 based instead of 1)
-
-	* ArrayType:
-		* IsSizedArray -> IsVector : bool
-
-	* IHasConstant -> IConstantProvider
-	* IHasSecurity -> ISecurityDeclarationProvider
-	* IHasMarshal -> IMarshalInfoProvider
-
-	* MemberReference
-		+ Module : ModuleDefinition
-
-	* MethodDefinition:
-		- This: moved to MethodBody
-		+ HasPInvokeInfo : bool
-
-	* PInvokeInfo:
-		- Method
-
-	* MarshalSpec -> MarshalInfo
-
-	- ModType
-
-	* ModifierRequiredType -> RequiredModifierType
-	* ModifierOptionalType -> OptionalModifierType
-	* ReferenceType -> ByReferenceType
-
-	* TypeReference
-		+ IsArray : bool
-		+ IsPointer : bool
-		+ IsByReference : bool
-		+ IsRequiredModifier : bool
-		+ IsOptionalModifier : bool
-		+ IsSentinel : bool
-		+ IsGenericInstance : bool
-		+ IsGenericParameter : bool
-		+ IsPinned : bool
-		+ IsFunctionPointer : bool
-		+ IsDefinition : bool
-
-		* GetOriginalType -> GetElementType
-		* ctor: swapped namespace and name parameter.
-
-	* MethodReference
-		+ IsGenericInstance : bool
-		+ IsDefinition : bool
-
-		* GetOriginalMethod -> GetElementMethod
-
-	* FieldReference
-		+ IsDefinition : bool
-
-	+ CustomAttributeArgument
-		+ Type : TypeReference
-		+ Value : object
-
-	* CustomAttribute
-		* ConstructorParameters -> ConstructorArguments : CustomAttributeArgumentCollection
-		* Properties : CustomAttributeNamedArgumentCollection
-		* Fields : CustomAttributeNamedArgumentCollection
-
-	* SecurityDeclaration
-		- PermissionSet
-		+ SecurityAttributes : SecurityAttributeCollection
-
-	+ SecurityAttribute
-		+ AttributeType : TypeReference
-		+ Fields : CustomAttributeNamedArgumentCollection
-		+ Properties : CustomAttributeNamedArgumentCollection
-
-	* IMetadataScope
-		+ MetadataScopeType
-
-	+ MetadataScopeType
-		+ AssemblyNameReference
-		+ ModuleDefinition
-		+ ModuleReference
-
-Mono.Cecil.Cil:
-
-	* ExceptionHandler
-		* Type -> HandlerType : TypeReference
-
-	* VariableDefinition
-		- Method
-
-	* Document* : from Guid to enums, the reader/writers are responsible for assigning them.
-
-	* MethodBody
-		* LocalVarToken : MetadataToken
-		* MaxStack -> MaxStackSize : int
-		+ ThisParameter: from MethodDefinition
-
-	* OperandType
-		* ShortInlineParam : ShortInlineArg
-		* InlineParam : InlineArg
-
-	* CilWorker -> ILProcessor
-
-TODO:
-
-	* Mono.Cecil.Rocks
-		* ILGenerator
-
-	* HOWTOs
diff --git a/vbnc/cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs b/vbnc/cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
index ae79cda..bb24f98 100644
--- a/vbnc/cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
+++ b/vbnc/cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/symbols/mdb/Makefile b/vbnc/cecil/symbols/mdb/Makefile
index c29301c..56b5635 100644
--- a/vbnc/cecil/symbols/mdb/Makefile
+++ b/vbnc/cecil/symbols/mdb/Makefile
@@ -4,7 +4,7 @@ SUBDIRS :=
 include ../../../../build/rules.make
 
 LIBRARY = Mono.Cecil.VB.Mdb.dll
-LIBRARY_COMPILE = dmcs -keyfile:$(topdir)/vbnc/cecil/mono.snk -r:$(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll -d:CECIL -debug
+LIBRARY_COMPILE = mcs -keyfile:$(topdir)/vbnc/cecil/mono.snk -r:$(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll -d:CECIL -debug -r:System.dll
 BUILT_FILES = $(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll
 
 include ../../../../build/library.make
diff --git a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.VB.csproj b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.VB.csproj
index 82c54ae..7203d14 100755
--- a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.VB.csproj
+++ b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.VB.csproj
@@ -1,99 +1,99 @@
-<?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)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Mono.Cecil.Mdb</RootNamespace>
-    <AssemblyName>Mono.Cecil.VB.Mdb</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
-    <FileUpgradeFlags>
-    </FileUpgradeFlags>
-    <OldToolsVersion>3.5</OldToolsVersion>
-    <UpgradeBackupLocation />
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;CECIL</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE;CECIL</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Mono.Cecil.Mdb\AssemblyInfo.cs" />
-    <Compile Include="Mono.Cecil.Mdb\MdbReader.cs" />
-    <Compile Include="Mono.Cecil.Mdb\MdbWriter.cs" />
-    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs" />
-    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs" />
-    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs" />
-    <Compile Include="Mono.CompilerServices.SymbolWriter\SymbolWriterImpl.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\Mono.Cecil.VB.csproj">
-      <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
-      <Name>Mono.Cecil.VB</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
-      <Visible>False</Visible>
-      <ProductName>Windows Installer 3.1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
+<?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)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Mono.Cecil.Mdb</RootNamespace>
+    <AssemblyName>Mono.Cecil.VB.Mdb</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <OldToolsVersion>3.5</OldToolsVersion>
+    <UpgradeBackupLocation />
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;CECIL</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;CECIL</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Mono.Cecil.Mdb\AssemblyInfo.cs" />
+    <Compile Include="Mono.Cecil.Mdb\MdbReader.cs" />
+    <Compile Include="Mono.Cecil.Mdb\MdbWriter.cs" />
+    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs" />
+    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs" />
+    <Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs" />
+    <Compile Include="Mono.CompilerServices.SymbolWriter\SymbolWriterImpl.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Mono.Cecil.VB.csproj">
+      <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
+      <Name>Mono.Cecil.VB</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file
diff --git a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj
index 42e68fe..e18be06 100644
--- a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj
+++ b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj
@@ -1,39 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\..\Mono.Cecil.settings" />
   <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Mono.Cecil.Mdb</RootNamespace>
     <AssemblyName>Mono.Cecil.Mdb</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;CECIL</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE;CECIL</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+    <DefineConstants>$(DefineConstants);CECIL</DefineConstants>
   </PropertyGroup>
+  <ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
+    <Reference Include="System.Core" />
+  </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
   </ItemGroup>
@@ -53,11 +29,4 @@
     <Compile Include="Mono.CompilerServices.SymbolWriter\SymbolWriterImpl.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
 </Project>
\ No newline at end of file
diff --git a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
index b416964..8186b50 100644
--- a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,10 +32,10 @@ using System.Runtime.InteropServices;
 
 [assembly: AssemblyTitle ("Mono.Cecil.Mdb")]
 [assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("Copyright � 2008 - 2010 Jb Evain")]
+[assembly: AssemblyCopyright ("Copyright � 2008 - 2011 Jb Evain")]
 
 [assembly: CLSCompliant (false)]
 [assembly: ComVisible (false)]
 
-[assembly: AssemblyVersion ("0.9.3.0")]
-[assembly: AssemblyFileVersion ("0.9.3.0")]
+[assembly: AssemblyVersion ("0.9.5.0")]
+[assembly: AssemblyFileVersion ("0.9.5.0")]
diff --git a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
index 0198a71..2440a66 100644
--- a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -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/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
index 54362ec..6f4aa20 100644
--- a/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
diff --git a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
index 0d614ca..6ad39d2 100644
--- a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
@@ -31,7 +31,7 @@
 using System;
 using System.Reflection;
 using SRE = System.Reflection.Emit;
-using System.Collections;
+using System.Collections.Generic;
 using System.Text;
 using System.Threading;
 using System.IO;
@@ -163,11 +163,11 @@ namespace Mono.CompilerServices.SymbolWriter
 
 	public class MonoSymbolFile : IDisposable
 	{
-		ArrayList methods = new ArrayList ();
-		ArrayList sources = new ArrayList ();
-		ArrayList comp_units = new ArrayList ();
-		Hashtable type_hash = new Hashtable ();
-		Hashtable anonymous_scopes;
+		List<MethodEntry> methods = new List<MethodEntry> ();
+		List<SourceFileEntry> sources = new List<SourceFileEntry> ();
+		List<CompileUnitEntry> comp_units = new List<CompileUnitEntry> ();
+		Dictionary<Type, int> type_hash = new Dictionary<Type, int> ();
+		Dictionary<int, AnonymousScopeEntry> anonymous_scopes;
 
 		OffsetTable ot;
 		int last_type_index;
@@ -199,10 +199,11 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		internal int DefineType (Type type)
 		{
-			if (type_hash.Contains (type))
-				return (int) type_hash [type];
+			int index;
+			if (type_hash.TryGetValue (type, out index))
+				return index;
 
-			int index = ++last_type_index;
+			index = ++last_type_index;
 			type_hash.Add (type, index);
 			return index;
 		}
@@ -234,7 +235,7 @@ namespace Mono.CompilerServices.SymbolWriter
 				throw new InvalidOperationException ();
 
 			if (anonymous_scopes == null)
-				anonymous_scopes = new Hashtable ();
+				anonymous_scopes = new Dictionary<int, AnonymousScopeEntry>  ();
 
 			anonymous_scopes.Add (id, new AnonymousScopeEntry (id));
 		}
@@ -245,7 +246,7 @@ namespace Mono.CompilerServices.SymbolWriter
 			if (reader != null)
 				throw new InvalidOperationException ();
 
-			AnonymousScopeEntry scope = (AnonymousScopeEntry) anonymous_scopes [scope_id];
+			AnonymousScopeEntry scope = anonymous_scopes [scope_id];
 			scope.AddCapturedVariable (name, captured_name, kind);
 		}
 
@@ -254,7 +255,7 @@ namespace Mono.CompilerServices.SymbolWriter
 			if (reader != null)
 				throw new InvalidOperationException ();
 
-			AnonymousScopeEntry scope = (AnonymousScopeEntry) anonymous_scopes [scope_id];
+			AnonymousScopeEntry scope = anonymous_scopes [scope_id];
 			scope.AddCapturedScope (id, captured_name);
 		}
 
@@ -381,12 +382,12 @@ namespace Mono.CompilerServices.SymbolWriter
 		}
 
 		MyBinaryReader reader;
-		Hashtable source_file_hash;
-		Hashtable compile_unit_hash;
+		Dictionary<int, SourceFileEntry> source_file_hash;
+		Dictionary<int, CompileUnitEntry> compile_unit_hash;
 
-		ArrayList method_list;
-		Hashtable method_token_hash;
-		Hashtable source_name_hash;
+		List<MethodEntry> method_list;
+		Dictionary<int, MethodEntry> method_token_hash;
+		Dictionary<string, int> source_name_hash;
 
 		Guid guid;
 
@@ -427,8 +428,8 @@ namespace Mono.CompilerServices.SymbolWriter
 					"Cannot read symbol file `{0}'", filename);
 			}
 
-			source_file_hash = new Hashtable ();
-			compile_unit_hash = new Hashtable ();
+			source_file_hash = new Dictionary<int, SourceFileEntry> ();
+			compile_unit_hash = new Dictionary<int, CompileUnitEntry> ();
 		}
 
 		void CheckGuidMatch (Guid other, string filename, string assembly)
@@ -445,6 +446,11 @@ namespace Mono.CompilerServices.SymbolWriter
 		protected MonoSymbolFile (string filename, Mono.Cecil.ModuleDefinition module)
 			: this (filename)
 		{
+			// Check that the MDB file matches the module, if we have been
+			// passed a module.
+			if (module == null)
+				return;
+
 			CheckGuidMatch (module.Mvid, filename, module.FullyQualifiedName);
 		}
 
@@ -484,7 +490,7 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		public static MonoSymbolFile ReadSymbolFile (string mdbFilename)
 		{
-			return new MonoSymbolFile (mdbFilename, null);
+			return new MonoSymbolFile (mdbFilename);
 		}
 
 		public int CompileUnitCount {
@@ -534,8 +540,8 @@ namespace Mono.CompilerServices.SymbolWriter
 				throw new InvalidOperationException ();
 
 			lock (this) {
-				SourceFileEntry source = (SourceFileEntry) source_file_hash [index];
-				if (source != null)
+				SourceFileEntry source;
+				if (source_file_hash.TryGetValue (index, out source))
 					return source;
 
 				long old_pos = reader.BaseStream.Position;
@@ -570,8 +576,8 @@ namespace Mono.CompilerServices.SymbolWriter
 				throw new InvalidOperationException ();
 
 			lock (this) {
-				CompileUnitEntry unit = (CompileUnitEntry) compile_unit_hash [index];
-				if (unit != null)
+				CompileUnitEntry unit;
+				if (compile_unit_hash.TryGetValue (index, out unit))
 					return unit;
 
 				long old_pos = reader.BaseStream.Position;
@@ -604,8 +610,8 @@ namespace Mono.CompilerServices.SymbolWriter
 				if (method_token_hash != null)
 					return;
 
-				method_token_hash = new Hashtable ();
-				method_list = new ArrayList ();
+				method_token_hash = new Dictionary<int, MethodEntry> ();
+				method_list = new List<MethodEntry> ();
 
 				long old_pos = reader.BaseStream.Position;
 				reader.BaseStream.Position = ot.MethodTableOffset;
@@ -627,7 +633,9 @@ namespace Mono.CompilerServices.SymbolWriter
 
 			lock (this) {
 				read_methods ();
-				return (MethodEntry) method_token_hash [token];
+				MethodEntry me;
+				method_token_hash.TryGetValue (token, out me);
+				return me;
 			}
 		}
 
@@ -665,7 +673,7 @@ namespace Mono.CompilerServices.SymbolWriter
 
 			lock (this) {
 				if (source_name_hash == null) {
-					source_name_hash = new Hashtable ();
+					source_name_hash = new Dictionary<string, int> ();
 
 					for (int i = 0; i < ot.SourceCount; i++) {
 						SourceFileEntry source = GetSourceFile (i + 1);
@@ -673,10 +681,10 @@ namespace Mono.CompilerServices.SymbolWriter
 					}
 				}
 
-				object value = source_name_hash [file_name];
-				if (value == null)
+				int value;
+				if (!source_name_hash.TryGetValue (file_name, out value))
 					return -1;
-				return (int) value;
+				return value;
 			}
 		}
 
@@ -685,18 +693,21 @@ namespace Mono.CompilerServices.SymbolWriter
 			if (reader == null)
 				throw new InvalidOperationException ();
 
+			AnonymousScopeEntry scope;
 			lock (this) {
-				if (anonymous_scopes != null)
-					return (AnonymousScopeEntry) anonymous_scopes [id];
+				if (anonymous_scopes != null) {
+					anonymous_scopes.TryGetValue (id, out scope);
+					return scope;
+				}
 
-				anonymous_scopes = new Hashtable ();
+				anonymous_scopes = new Dictionary<int, AnonymousScopeEntry> ();
 				reader.BaseStream.Position = ot.AnonymousScopeTableOffset;
 				for (int i = 0; i < ot.AnonymousScopeCount; i++) {
-					AnonymousScopeEntry scope = new AnonymousScopeEntry (reader);
+					scope = new AnonymousScopeEntry (reader);
 					anonymous_scopes.Add (scope.ID, scope);
 				}
 
-				return (AnonymousScopeEntry) anonymous_scopes [id];
+				return anonymous_scopes [id];
 			}
 		}
 
diff --git a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
index 2bf6592..c170150 100644
--- a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
@@ -30,7 +30,7 @@
 
 using System;
 using System.Security.Cryptography;
-using System.Collections;
+using System.Collections.Generic;
 using System.Text;
 using System.IO;
 
@@ -202,13 +202,10 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
 
-		private class OffsetComparerClass : IComparer
+		private class OffsetComparerClass : IComparer<LineNumberEntry>
 		{
-			public int Compare (object a, object b)
+			public int Compare (LineNumberEntry l1, LineNumberEntry l2)
 			{
-				LineNumberEntry l1 = (LineNumberEntry) a;
-				LineNumberEntry l2 = (LineNumberEntry) b;
-
 				if (l1.Offset < l2.Offset)
 					return -1;
 				else if (l1.Offset > l2.Offset)
@@ -218,13 +215,10 @@ namespace Mono.CompilerServices.SymbolWriter
 			}
 		}
 
-		private class RowComparerClass : IComparer
+		private class RowComparerClass : IComparer<LineNumberEntry>
 		{
-			public int Compare (object a, object b)
+			public int Compare (LineNumberEntry l1, LineNumberEntry l2)
 			{
-				LineNumberEntry l1 = (LineNumberEntry) a;
-				LineNumberEntry l2 = (LineNumberEntry) b;
-
 				if (l1.Row < l2.Row)
 					return -1;
 				else if (l1.Row > l2.Row)
@@ -234,8 +228,8 @@ namespace Mono.CompilerServices.SymbolWriter
 			}
 		}
 
-		public static readonly IComparer OffsetComparer = new OffsetComparerClass ();
-		public static readonly IComparer RowComparer = new RowComparerClass ();
+		public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
+		public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
 
 		public override string ToString ()
 		{
@@ -453,8 +447,8 @@ namespace Mono.CompilerServices.SymbolWriter
 		public readonly int ID;
 		#endregion
 
-		ArrayList captured_vars = new ArrayList ();
-		ArrayList captured_scopes = new ArrayList ();
+		List<CapturedVariable> captured_vars = new List<CapturedVariable> ();
+		List<CapturedScope> captured_scopes = new List<CapturedScope> ();
 
 		public AnonymousScopeEntry (int id)
 		{
@@ -529,8 +523,8 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		MonoSymbolFile file;
 		SourceFileEntry source;
-		ArrayList include_files;
-		ArrayList namespaces;
+		List<SourceFileEntry> include_files;
+		List<NamespaceEntry> namespaces;
 
 		bool creating;
 
@@ -550,7 +544,7 @@ namespace Mono.CompilerServices.SymbolWriter
 			this.Index = file.AddCompileUnit (this);
 
 			creating = true;
-			namespaces = new ArrayList ();
+			namespaces = new List<NamespaceEntry> ();
 		}
 
 		public void AddFile (SourceFileEntry file)
@@ -559,7 +553,7 @@ namespace Mono.CompilerServices.SymbolWriter
 				throw new InvalidOperationException ();
 
 			if (include_files == null)
-				include_files = new ArrayList ();
+				include_files = new List<SourceFileEntry> ();
 
 			include_files.Add (file);
 		}
@@ -635,13 +629,13 @@ namespace Mono.CompilerServices.SymbolWriter
 
 				int count_includes = reader.ReadLeb128 ();
 				if (count_includes > 0) {
-					include_files = new ArrayList ();
+					include_files = new List<SourceFileEntry> ();
 					for (int i = 0; i < count_includes; i++)
 						include_files.Add (file.GetSourceFile (reader.ReadLeb128 ()));
 				}
 
 				int count_ns = reader.ReadLeb128 ();
-				namespaces = new ArrayList ();
+				namespaces = new List<NamespaceEntry> ();
 				for (int i = 0; i < count_ns; i ++)
 					namespaces.Add (new NamespaceEntry (file, reader));
 
@@ -913,7 +907,7 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		void DoRead (MonoSymbolFile file, MyBinaryReader br)
 		{
-			ArrayList lines = new ArrayList ();
+			var lines = new List<LineNumberEntry> ();
 
 			bool is_hidden = false, modified = false;
 			int stm_line = 1, stm_offset = 0, stm_file = 1;
@@ -1118,9 +1112,9 @@ namespace Mono.CompilerServices.SymbolWriter
 			locals_check_done :
 				;
 			} else {
-				Hashtable local_names = new Hashtable ();
+				var local_names = new Dictionary<string, LocalVariableEntry> ();
 				foreach (LocalVariableEntry local in locals) {
-					if (local_names.Contains (local.Name)) {
+					if (local_names.ContainsKey (local.Name)) {
 						flags |= Flags.LocalNamesAmbiguous;
 						break;
 					}
diff --git a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
index 3f43dd6..db77c25 100644
--- a/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
+++ b/vbnc/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
@@ -33,28 +33,31 @@
 
 using System;
 using System.Runtime.CompilerServices;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 namespace Mono.CompilerServices.SymbolWriter
 {
 	public class MonoSymbolWriter
 	{
-		ArrayList methods = null;
-		ArrayList sources = null;
-		ArrayList comp_units = null;
+		List<SourceMethodBuilder> methods;
+		List<SourceFileEntry> sources;
+		List<CompileUnitEntry> comp_units;
 		protected readonly MonoSymbolFile file;
-		string filename = null;
+		string filename;
 
-		private SourceMethodBuilder current_method = null;
-		private Stack current_method_stack;
+		private SourceMethodBuilder current_method;
+#if NET_2_1
+		System.Collections.Stack current_method_stack = new System.Collections.Stack ();
+#else
+		Stack<SourceMethodBuilder> current_method_stack = new Stack<SourceMethodBuilder> ();
+#endif
 
 		public MonoSymbolWriter (string filename)
 		{
-			this.methods = new ArrayList ();
-			this.sources = new ArrayList ();
-			this.comp_units = new ArrayList ();
-			this.current_method_stack = new Stack ();
+			this.methods = new List<SourceMethodBuilder> ();
+			this.sources = new List<SourceFileEntry> ();
+			this.comp_units = new List<CompileUnitEntry> ();
 			this.file = new MonoSymbolFile ();
 
 			this.filename = filename + ".mdb";
@@ -239,10 +242,14 @@ namespace Mono.CompilerServices.SymbolWriter
 
 	public class SourceMethodBuilder
 	{
-		ArrayList _locals;
-		ArrayList _blocks;
-		ArrayList _scope_vars;
-		Stack _block_stack;
+		List<LocalVariableEntry> _locals;
+		List<CodeBlockEntry> _blocks;
+		List<ScopeVariable> _scope_vars;
+#if NET_2_1
+		System.Collections.Stack _block_stack;
+#else
+		Stack<CodeBlockEntry> _block_stack;
+#endif
 		string _real_name;
 		IMethodDef _method;
 		ICompileUnit _comp_unit;
@@ -277,10 +284,16 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		public void StartBlock (CodeBlockEntry.Type type, int start_offset)
 		{
-			if (_block_stack == null)
-				_block_stack = new Stack ();
+			if (_block_stack == null) {
+#if NET_2_1
+				_block_stack = new System.Collections.Stack ();
+#else
+				_block_stack = new Stack<CodeBlockEntry> ();
+#endif
+			}
+
 			if (_blocks == null)
-				_blocks = new ArrayList ();
+				_blocks = new List<CodeBlockEntry> ();
 
 			int parent = CurrentBlock != null ? CurrentBlock.Index : -1;
 
@@ -333,7 +346,7 @@ namespace Mono.CompilerServices.SymbolWriter
 		public void AddLocal (int index, string name)
 		{
 			if (_locals == null)
-				_locals = new ArrayList ();
+				_locals = new List<LocalVariableEntry> ();
 			int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
 			_locals.Add (new LocalVariableEntry (index, name, block_idx));
 		}
@@ -352,7 +365,7 @@ namespace Mono.CompilerServices.SymbolWriter
 		public void AddScopeVariable (int scope, int index)
 		{
 			if (_scope_vars == null)
-				_scope_vars = new ArrayList ();
+				_scope_vars = new List<ScopeVariable> ();
 			_scope_vars.Add (
 				new ScopeVariable (scope, index));
 		}
diff --git a/vbnc/cecil/symbols/pdb/Makefile b/vbnc/cecil/symbols/pdb/Makefile
index 6aa7fae..27cdb78 100644
--- a/vbnc/cecil/symbols/pdb/Makefile
+++ b/vbnc/cecil/symbols/pdb/Makefile
@@ -4,7 +4,7 @@ SUBDIRS :=
 include ../../../../build/rules.make
 
 LIBRARY = Mono.Cecil.VB.Pdb.dll
-LIBRARY_COMPILE = dmcs -keyfile:$(topdir)/vbnc/cecil/mono.snk -r:$(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll -d:CECIL -debug
+LIBRARY_COMPILE = mcs -keyfile:$(topdir)/vbnc/cecil/mono.snk -r:$(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll -d:CECIL -debug
 
 BUILT_FILES = $(topdir)/class/lib/$(PROFILE)/Mono.Cecil.VB.dll
 
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
index 852f797..d92a5b7 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -12,7 +17,6 @@ namespace Microsoft.Cci.Pdb {
 
     internal BitAccess(int capacity) {
       this.buffer = new byte[capacity];
-      this.offset = 0;
     }
 
     internal byte[] Buffer {
@@ -26,15 +30,26 @@ namespace Microsoft.Cci.Pdb {
       offset = 0;
     }
 
+    internal void Append(Stream stream, int count) {
+      int newCapacity = offset + count;
+      if (buffer.Length < newCapacity) {
+        byte[] newBuffer = new byte[newCapacity];
+        Array.Copy(buffer, newBuffer, buffer.Length);
+        buffer = newBuffer;
+      }
+      stream.Read(buffer, offset, count);
+      offset += count;
+    }
+
     internal int Position {
       get { return offset; }
       set { offset = value; }
     }
     private int offset;
 
-    internal void WriteBuffer(Stream stream, int count) {
-      stream.Write(buffer, 0, count);
-    }
+    //internal void WriteBuffer(Stream stream, int count) {
+    //  stream.Write(buffer, 0, count);
+    //}
 
     internal void MinCapacity(int capacity) {
       if (buffer.Length < capacity) {
@@ -49,25 +64,25 @@ namespace Microsoft.Cci.Pdb {
       }
     }
 
-    internal void WriteInt32(int value) {
-      buffer[offset + 0] = (byte)value;
-      buffer[offset + 1] = (byte)(value >> 8);
-      buffer[offset + 2] = (byte)(value >> 16);
-      buffer[offset + 3] = (byte)(value >> 24);
-      offset += 4;
-    }
+    //internal void WriteInt32(int value) {
+    //  buffer[offset + 0] = (byte)value;
+    //  buffer[offset + 1] = (byte)(value >> 8);
+    //  buffer[offset + 2] = (byte)(value >> 16);
+    //  buffer[offset + 3] = (byte)(value >> 24);
+    //  offset += 4;
+    //}
 
-    internal void WriteInt32(int[] values) {
-      for (int i = 0; i < values.Length; i++) {
-        WriteInt32(values[i]);
-      }
-    }
+    //internal void WriteInt32(int[] values) {
+    //  for (int i = 0; i < values.Length; i++) {
+    //    WriteInt32(values[i]);
+    //  }
+    //}
 
-    internal void WriteBytes(byte[] bytes) {
-      for (int i = 0; i < bytes.Length; i++) {
-        buffer[offset++] = bytes[i];
-      }
-    }
+    //internal void WriteBytes(byte[] bytes) {
+    //  for (int i = 0; i < bytes.Length; i++) {
+    //    buffer[offset++] = bytes[i];
+    //  }
+    //}
 
     internal void ReadInt16(out short value) {
       value = (short)((buffer[offset + 0] & 0xFF) |
@@ -75,6 +90,11 @@ namespace Microsoft.Cci.Pdb {
       offset += 2;
     }
 
+    internal void ReadInt8(out sbyte value) {
+      value = (sbyte)buffer[offset];
+      offset += 1;
+    }
+
     internal void ReadInt32(out int value) {
       value = (int)((buffer[offset + 0] & 0xFF) |
                           (buffer[offset + 1] << 8) |
@@ -84,14 +104,14 @@ namespace Microsoft.Cci.Pdb {
     }
 
     internal void ReadInt64(out long value) {
-      value = (long)((buffer[offset + 0] & 0xFF) |
-                           (buffer[offset + 1] << 8) |
-                           (buffer[offset + 2] << 16) |
-                           (buffer[offset + 3] << 24) |
-                           (buffer[offset + 4] << 32) |
-                           (buffer[offset + 5] << 40) |
-                           (buffer[offset + 6] << 48) |
-                           (buffer[offset + 7] << 56));
+      value = (long)(((ulong)buffer[offset + 0] & 0xFF) |
+                           ((ulong)buffer[offset + 1] << 8) |
+                           ((ulong)buffer[offset + 2] << 16) |
+                           ((ulong)buffer[offset + 3] << 24) |
+                           ((ulong)buffer[offset + 4] << 32) |
+                           ((ulong)buffer[offset + 5] << 40) |
+                           ((ulong)buffer[offset + 6] << 48) |
+                           ((ulong)buffer[offset + 7] << 56));
       offset += 8;
     }
 
@@ -115,14 +135,14 @@ namespace Microsoft.Cci.Pdb {
     }
 
     internal void ReadUInt64(out ulong value) {
-      value = (ulong)((buffer[offset + 0] & 0xFF) |
-                           (buffer[offset + 1] << 8) |
-                           (buffer[offset + 2] << 16) |
-                           (buffer[offset + 3] << 24) |
-                           (buffer[offset + 4] << 32) |
-                           (buffer[offset + 5] << 40) |
-                           (buffer[offset + 6] << 48) |
-                           (buffer[offset + 7] << 56));
+      value = (ulong)(((ulong)buffer[offset + 0] & 0xFF) |
+                           ((ulong)buffer[offset + 1] << 8) |
+                           ((ulong)buffer[offset + 2] << 16) |
+                           ((ulong)buffer[offset + 3] << 24) |
+                           ((ulong)buffer[offset + 4] << 32) |
+                           ((ulong)buffer[offset + 5] << 40) |
+                           ((ulong)buffer[offset + 6] << 48) |
+                           ((ulong)buffer[offset + 7] << 56));
       offset += 8;
     }
 
@@ -159,7 +179,7 @@ namespace Microsoft.Cci.Pdb {
     internal decimal ReadDecimal() {
       int[] bits = new int[4];
       this.ReadInt32(bits);
-      return new decimal(bits);
+      return new decimal(bits[2], bits[3], bits[1], bits[0] < 0, (byte)((bits[0] & 0x00FF0000) >> 16));
     }
 
     internal void ReadBString(out string value) {
@@ -169,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/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
index a9ed7f7..6719131 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -13,10 +18,10 @@ namespace Microsoft.Cci.Pdb {
       bits.ReadUInt32(words);
     }
 
-    internal BitSet(int size) {
-      this.size = size;
-      words = new uint[size];
-    }
+    //internal BitSet(int size) {
+    //  this.size = size;
+    //  words = new uint[size];
+    //}
 
     internal bool IsSet(int index) {
       int word = index / 32;
@@ -24,43 +29,43 @@ namespace Microsoft.Cci.Pdb {
       return ((words[word] & GetBit(index)) != 0);
     }
 
-    internal void Set(int index) {
-      int word = index / 32;
-      if (word >= this.size) return;
-      words[word] |= GetBit(index);
-    }
+    //internal void Set(int index) {
+    //  int word = index / 32;
+    //  if (word >= this.size) return;
+    //  words[word] |= GetBit(index);
+    //}
 
-    internal void Clear(int index) {
-      int word = index / 32;
-      if (word >= this.size) return;
-      words[word] &= ~GetBit(index);
-    }
+    //internal void Clear(int index) {
+    //  int word = index / 32;
+    //  if (word >= this.size) return;
+    //  words[word] &= ~GetBit(index);
+    //}
 
-    private uint GetBit(int index) {
+    private static uint GetBit(int index) {
       return ((uint)1 << (index % 32));
     }
 
-    private uint ReverseBits(uint value) {
-      uint o = 0;
-      for (int i = 0; i < 32; i++) {
-        o = (o << 1) | (value & 1);
-        value >>= 1;
-      }
-      return o;
-    }
+    //private static uint ReverseBits(uint value) {
+    //  uint o = 0;
+    //  for (int i = 0; i < 32; i++) {
+    //    o = (o << 1) | (value & 1);
+    //    value >>= 1;
+    //  }
+    //  return o;
+    //}
 
     internal bool IsEmpty {
       get { return size == 0; }
     }
 
-    internal bool GetWord(int index, out uint word) {
-      if (index < size) {
-        word = ReverseBits(words[index]);
-        return true;
-      }
-      word = 0;
-      return false;
-    }
+    //internal bool GetWord(int index, out uint word) {
+    //  if (index < size) {
+    //    word = ReverseBits(words[index]);
+    //    return true;
+    //  }
+    //  word = 0;
+    //  return false;
+    //}
 
     private int size;
     private uint[] words;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
index bef3086..49c51ce 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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.
 //
 //-----------------------------------------------------------------------------
 //
@@ -163,67 +168,67 @@ namespace Microsoft.Cci.Pdb {
 
     // function to extract primitive mode, type and size
 
-    internal static CV_prmode CV_MODE(TYPE_ENUM typ) {
-      return (CV_prmode)((((uint)typ) & CV_MMASK) >> CV_MSHIFT);
-    }
+    //internal static CV_prmode CV_MODE(TYPE_ENUM typ) {
+    //  return (CV_prmode)((((uint)typ) & CV_MMASK) >> CV_MSHIFT);
+    //}
 
-    internal static CV_type CV_TYPE(TYPE_ENUM typ) {
-      return (CV_type)((((uint)typ) & CV_TMASK) >> CV_TSHIFT);
-    }
+    //internal static CV_type CV_TYPE(TYPE_ENUM typ) {
+    //  return (CV_type)((((uint)typ) & CV_TMASK) >> CV_TSHIFT);
+    //}
 
-    internal static uint CV_SUBT(TYPE_ENUM typ) {
-      return ((((uint)typ) & CV_SMASK) >> CV_SSHIFT);
-    }
+    //internal static uint CV_SUBT(TYPE_ENUM typ) {
+    //  return ((((uint)typ) & CV_SMASK) >> CV_SSHIFT);
+    //}
 
     // functions to check the type of a primitive
 
-    internal static bool CV_TYP_IS_DIRECT(TYPE_ENUM typ) {
-      return (CV_MODE(typ) == CV_prmode.CV_TM_DIRECT);
-    }
-
-    internal static bool CV_TYP_IS_PTR(TYPE_ENUM typ) {
-      return (CV_MODE(typ) != CV_prmode.CV_TM_DIRECT);
-    }
-
-    internal static bool CV_TYP_IS_SIGNED(TYPE_ENUM typ) {
-      return
-          (((CV_TYPE(typ) == CV_type.CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) ||
-                 (typ == TYPE_ENUM.T_INT1)  ||
-                 (typ == TYPE_ENUM.T_INT2)  ||
-                 (typ == TYPE_ENUM.T_INT4)  ||
-                 (typ == TYPE_ENUM.T_INT8)  ||
-                 (typ == TYPE_ENUM.T_INT16) ||
-                 (typ == TYPE_ENUM.T_RCHAR));
-    }
-
-    internal static bool CV_TYP_IS_UNSIGNED(TYPE_ENUM typ) {
-      return (((CV_TYPE(typ) == CV_type.CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) ||
-                    (typ == TYPE_ENUM.T_UINT1) ||
-                    (typ == TYPE_ENUM.T_UINT2) ||
-                    (typ == TYPE_ENUM.T_UINT4) ||
-                    (typ == TYPE_ENUM.T_UINT8) ||
-                    (typ == TYPE_ENUM.T_UINT16));
-    }
-
-    internal static bool CV_TYP_IS_REAL(TYPE_ENUM typ) {
-      return ((CV_TYPE(typ) == CV_type.CV_REAL)  && CV_TYP_IS_DIRECT(typ));
-    }
+    //internal static bool CV_TYP_IS_DIRECT(TYPE_ENUM typ) {
+    //  return (CV_MODE(typ) == CV_prmode.CV_TM_DIRECT);
+    //}
+
+    //internal static bool CV_TYP_IS_PTR(TYPE_ENUM typ) {
+    //  return (CV_MODE(typ) != CV_prmode.CV_TM_DIRECT);
+    //}
+
+    //internal static bool CV_TYP_IS_SIGNED(TYPE_ENUM typ) {
+    //  return
+    //      (((CV_TYPE(typ) == CV_type.CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) ||
+    //             (typ == TYPE_ENUM.T_INT1)  ||
+    //             (typ == TYPE_ENUM.T_INT2)  ||
+    //             (typ == TYPE_ENUM.T_INT4)  ||
+    //             (typ == TYPE_ENUM.T_INT8)  ||
+    //             (typ == TYPE_ENUM.T_INT16) ||
+    //             (typ == TYPE_ENUM.T_RCHAR));
+    //}
+
+    //internal static bool CV_TYP_IS_UNSIGNED(TYPE_ENUM typ) {
+    //  return (((CV_TYPE(typ) == CV_type.CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) ||
+    //                (typ == TYPE_ENUM.T_UINT1) ||
+    //                (typ == TYPE_ENUM.T_UINT2) ||
+    //                (typ == TYPE_ENUM.T_UINT4) ||
+    //                (typ == TYPE_ENUM.T_UINT8) ||
+    //                (typ == TYPE_ENUM.T_UINT16));
+    //}
+
+    //internal static bool CV_TYP_IS_REAL(TYPE_ENUM typ) {
+    //  return ((CV_TYPE(typ) == CV_type.CV_REAL)  && CV_TYP_IS_DIRECT(typ));
+    //}
 
     const uint CV_FIRST_NONPRIM = 0x1000;
 
-    internal static bool CV_IS_PRIMITIVE(TYPE_ENUM typ) {
-      return ((uint)(typ) < CV_FIRST_NONPRIM);
-    }
+    //internal static bool CV_IS_PRIMITIVE(TYPE_ENUM typ) {
+    //  return ((uint)(typ) < CV_FIRST_NONPRIM);
+    //}
 
-    internal static bool CV_TYP_IS_COMPLEX(TYPE_ENUM typ) {
-      return ((CV_TYPE(typ) == CV_type.CV_COMPLEX) && CV_TYP_IS_DIRECT(typ));
-    }
+    //internal static bool CV_TYP_IS_COMPLEX(TYPE_ENUM typ) {
+    //  return ((CV_TYPE(typ) == CV_type.CV_COMPLEX) && CV_TYP_IS_DIRECT(typ));
+    //}
 
-    internal static bool CV_IS_INTERNAL_PTR(TYPE_ENUM typ) {
-      return (CV_IS_PRIMITIVE(typ) &&
-                    CV_TYPE(typ) == CV_type.CV_CVRESERVED &&
-                    CV_TYP_IS_PTR(typ));
-    }
+    //internal static bool CV_IS_INTERNAL_PTR(TYPE_ENUM typ) {
+    //  return (CV_IS_PRIMITIVE(typ) &&
+    //                CV_TYPE(typ) == CV_type.CV_CVRESERVED &&
+    //                CV_TYP_IS_PTR(typ));
+    //}
   }
 
   // selected values for type_index - for a more complete definition, see
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
index 99929d9..48a1851 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -9,8 +14,6 @@ using System.IO;
 namespace Microsoft.Cci.Pdb {
   internal class DataStream {
     internal DataStream() {
-      this.contentSize = 0;
-      this.pages = null;
     }
 
     internal DataStream(int contentSize, BitAccess bits, int count) {
@@ -72,73 +75,35 @@ namespace Microsoft.Cci.Pdb {
       }
     }
 
-    internal void Write(PdbWriter writer, byte[] bytes) {
-      Write(writer, bytes, bytes.Length);
-    }
-
-    internal void Write(PdbWriter writer, byte[] bytes, int data) {
-      if (bytes == null || data == 0) {
-        return;
-      }
-
-      int left = data;
-      int used = 0;
-      int rema = contentSize % writer.pageSize;
-      if (rema != 0) {
-        int todo = writer.pageSize - rema;
-        if (todo > left) {
-          todo = left;
-        }
-
-        int lastPage = pages[pages.Length - 1];
-        writer.Seek(lastPage, rema);
-        writer.Write(bytes, used, todo);
-        used += todo;
-        left -= todo;
-      }
-
-      if (left > 0) {
-        int count = (left + writer.pageSize - 1) / writer.pageSize;
-        int page0 = writer.AllocatePages(count);
-
-        writer.Seek(page0, 0);
-        writer.Write(bytes, used, left);
-
-        AddPages(page0, count);
-      }
-
-      contentSize += data;
-    }
-
-    private void AddPages(int page0, int count) {
-      if (pages == null) {
-        pages = new int[count];
-        for (int i = 0; i < count; i++) {
-          pages[i] = page0 + i;
-        }
-      } else {
-        int[] old = pages;
-        int used = old.Length;
-
-        pages = new int[used + count];
-        Array.Copy(old, pages, used);
-        for (int i = 0; i < count; i++) {
-          pages[used + i] = page0 + i;
-        }
-      }
-    }
-
-    internal int Pages {
-      get { return pages == null ? 0 : pages.Length; }
-    }
+    //private void AddPages(int page0, int count) {
+    //  if (pages == null) {
+    //    pages = new int[count];
+    //    for (int i = 0; i < count; i++) {
+    //      pages[i] = page0 + i;
+    //    }
+    //  } else {
+    //    int[] old = pages;
+    //    int used = old.Length;
+
+    //    pages = new int[used + count];
+    //    Array.Copy(old, pages, used);
+    //    for (int i = 0; i < count; i++) {
+    //      pages[used + i] = page0 + i;
+    //    }
+    //  }
+    //}
+
+    //internal int Pages {
+    //  get { return pages == null ? 0 : pages.Length; }
+    //}
 
     internal int Length {
       get { return contentSize; }
     }
 
-    internal int GetPage(int index) {
-      return pages[index];
-    }
+    //internal int GetPage(int index) {
+    //  return pages[index];
+    //}
 
     internal int contentSize;
     internal int[] pages;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
index b6159ab..588f3c1 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
index 29fb9fd..0ca7915 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
index a9a5b2a..8ab3717 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -9,7 +14,7 @@ namespace Microsoft.Cci.Pdb {
   internal class DbiModuleInfo {
     internal DbiModuleInfo(BitAccess bits, bool readStrings) {
       bits.ReadInt32(out opened);
-      section = new DbiSecCon(bits);
+      new DbiSecCon(bits);
       bits.ReadUInt16(out flags);
       bits.ReadInt16(out stream);
       bits.ReadInt32(out cbSyms);
@@ -35,7 +40,7 @@ namespace Microsoft.Cci.Pdb {
     }
 
     internal int opened;                 //  0..3
-    internal DbiSecCon section;                //  4..31
+    //internal DbiSecCon section;                //  4..31
     internal ushort flags;                  // 32..33
     internal short stream;                 // 34..35
     internal int cbSyms;                 // 36..39
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
index 1e2b60d..de9fde9 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
index a092b1c..db0e41b 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -54,7 +59,7 @@ namespace Microsoft.Cci.Pdb {
   // By Brian Grunkemeyer, algorithm by Patrick Dussud.
   // Version 1.30 2/20/2000
   //| <include path='docs/doc[@for="IntHashTable"]/*' />
-  internal class IntHashTable : IEnumerable {
+  internal class IntHashTable {//: IEnumerable {
     /*
       Implementation Notes:
 
@@ -125,7 +130,7 @@ namespace Microsoft.Cci.Pdb {
             187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
             1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369};
 
-    private int GetPrime(int minSize) {
+    private static int GetPrime(int minSize) {
       if (minSize < 0) {
         throw new ArgumentException("Arg_HTCapacityOverflow");
       }
@@ -168,17 +173,17 @@ namespace Microsoft.Cci.Pdb {
       : this(0, 100) {
     }
 
-    // Constructs a new hashtable with the given initial capacity and a load
-    // factor of 1.0. The capacity argument serves as an indication of
-    // the number of entries the hashtable will contain. When this number (or
-    // an approximation) is known, specifying it in the constructor can
-    // eliminate a number of resizing operations that would otherwise be
-    // performed when elements are added to the hashtable.
-    //
-    //| <include path='docs/doc[@for="IntHashTable.IntHashTable1"]/*' />
-    internal IntHashTable(int capacity)
-      : this(capacity, 100) {
-    }
+    //// Constructs a new hashtable with the given initial capacity and a load
+    //// factor of 1.0. The capacity argument serves as an indication of
+    //// the number of entries the hashtable will contain. When this number (or
+    //// an approximation) is known, specifying it in the constructor can
+    //// eliminate a number of resizing operations that would otherwise be
+    //// performed when elements are added to the hashtable.
+    ////
+    ////| <include path='docs/doc[@for="IntHashTable.IntHashTable1"]/*' />
+    //internal IntHashTable(int capacity)
+    //  : this(capacity, 100) {
+    //}
 
     // Constructs a new hashtable with the given initial capacity and load
     // factor. The capacity argument serves as an indication of the
@@ -213,7 +218,7 @@ namespace Microsoft.Cci.Pdb {
     // The out parameter seed is h1(key), while the out parameter
     // incr is h2(key, hashSize).  Callers of this function should
     // add incr each time through a loop.
-    private uint InitHash(int key, int hashsize, out uint seed, out uint incr) {
+    private static uint InitHash(int key, int hashsize, out uint seed, out uint incr) {
       // Hashcode must be positive.  Also, we must not use the sign bit, since
       // that is used for the collision bit.
       uint hashcode = (uint)key & 0x7FFFFFFF;
@@ -236,52 +241,52 @@ namespace Microsoft.Cci.Pdb {
       Insert(key, value, true);
     }
 
-    // Removes all entries from this hashtable.
-    //| <include path='docs/doc[@for="IntHashTable.Clear"]/*' />
-    internal void Clear() {
-      if (count == 0)
-        return;
+    //// Removes all entries from this hashtable.
+    ////| <include path='docs/doc[@for="IntHashTable.Clear"]/*' />
+    //internal void Clear() {
+    //  if (count == 0)
+    //    return;
 
-      for (int i = 0; i < buckets.Length; i++) {
-        buckets[i].hash_coll = 0;
-        buckets[i].key = -1;
-        buckets[i].val = null;
-      }
+    //  for (int i = 0; i < buckets.Length; i++) {
+    //    buckets[i].hash_coll = 0;
+    //    buckets[i].key = -1;
+    //    buckets[i].val = null;
+    //  }
 
-      count = 0;
-      occupancy = 0;
-    }
+    //  count = 0;
+    //  occupancy = 0;
+    //}
 
     // Checks if this hashtable contains an entry with the given key.  This is
     // an O(1) operation.
     //
     //| <include path='docs/doc[@for="IntHashTable.Contains"]/*' />
-    internal bool Contains(int key) {
-      if (key < 0) {
-        throw new ArgumentException("Argument_KeyLessThanZero");
-      }
-
-      uint seed;
-      uint incr;
-      // Take a snapshot of buckets, in case another thread resizes table
-      bucket[] lbuckets = buckets;
-      uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr);
-      int ntry = 0;
-
-      bucket b;
-      do {
-        int bucketNumber = (int)(seed % (uint)lbuckets.Length);
-        b = lbuckets[bucketNumber];
-        if (b.val == null) {
-          return false;
-        }
-        if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && b.key == key) {
-          return true;
-        }
-        seed += incr;
-      } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
-      return false;
-    }
+    //internal bool Contains(int key) {
+    //  if (key < 0) {
+    //    throw new ArgumentException("Argument_KeyLessThanZero");
+    //  }
+
+    //  uint seed;
+    //  uint incr;
+    //  // Take a snapshot of buckets, in case another thread resizes table
+    //  bucket[] lbuckets = buckets;
+    //  uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr);
+    //  int ntry = 0;
+
+    //  bucket b;
+    //  do {
+    //    int bucketNumber = (int)(seed % (uint)lbuckets.Length);
+    //    b = lbuckets[bucketNumber];
+    //    if (b.val == null) {
+    //      return false;
+    //    }
+    //    if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && b.key == key) {
+    //      return true;
+    //    }
+    //    seed += incr;
+    //  } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
+    //  return false;
+    //}
 
     // Returns the value associated with the given key. If an entry with the
     // given key is not found, the returned value is null.
@@ -313,9 +318,9 @@ namespace Microsoft.Cci.Pdb {
         } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
         return null;
       }
-      set {
-        Insert(key, value, false);
-      }
+      //set {
+      //  Insert(key, value, false);
+      //}
     }
 
     // Increases the bucket count of this hashtable. This method is called from
@@ -374,9 +379,9 @@ namespace Microsoft.Cci.Pdb {
     // enumerator will throw an exception.
     //
     //| <include path='docs/doc[@for="IntHashTable.IEnumerable.GetEnumerator"]/*' />
-    IEnumerator IEnumerable.GetEnumerator() {
-      return new IntHashTableEnumerator(this);
-    }
+    //IEnumerator IEnumerable.GetEnumerator() {
+    //  return new IntHashTableEnumerator(this);
+    //}
 
     // Internal method to compare two keys.
     //
@@ -502,78 +507,77 @@ namespace Microsoft.Cci.Pdb {
     // Returns the number of associations in this hashtable.
     //
     //| <include path='docs/doc[@for="IntHashTable.Count"]/*' />
-    internal int Count {
-      get { return count; }
-    }
+    //internal int Count {
+    //  get { return count; }
+    //}
 
     // Implements an enumerator for a hashtable. The enumerator uses the
     // internal version number of the hashtabke to ensure that no modifications
     // are made to the hashtable while an enumeration is in progress.
-    private class IntHashTableEnumerator : IEnumerator {
-      private IntHashTable hashtable;
-      private int bucket;
-      private int version;
-      private bool current;
-      private int currentKey;
-      private Object currentValue;
-
-      internal IntHashTableEnumerator(IntHashTable hashtable) {
-        this.hashtable = hashtable;
-        bucket = hashtable.buckets.Length;
-        version = hashtable.version;
-        current = false;
-      }
-
-      public bool MoveNext() {
-        if (version != hashtable.version)
-          throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
-        while (bucket > 0) {
-          bucket--;
-          Object val = hashtable.buckets[bucket].val;
-          if (val != null) {
-            currentKey = hashtable.buckets[bucket].key;
-            currentValue = val;
-            current = true;
-            return true;
-          }
-        }
-        current = false;
-        return false;
-      }
-
-      internal int Key {
-        get {
-          if (current == false)
-            throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
-          return currentKey;
-        }
-      }
-
-      public Object Current {
-        get {
-          if (current == false)
-            throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
-          return currentValue;
-        }
-      }
-
-      public Object Value {
-        get {
-          if (version != hashtable.version)
-            throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
-          if (current == false)
-            throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
-          return currentValue;
-        }
-      }
-
-      public void Reset() {
-        if (version != hashtable.version) throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
-        current = false;
-        bucket = hashtable.buckets.Length;
-        currentKey = -1;
-        currentValue = null;
-      }
-    }
+    //private class IntHashTableEnumerator : IEnumerator {
+    //  private IntHashTable hashtable;
+    //  private int bucket;
+    //  private int version;
+    //  private bool current;
+    //  //private int currentKey;
+    //  private Object currentValue;
+
+    //  internal IntHashTableEnumerator(IntHashTable hashtable) {
+    //    this.hashtable = hashtable;
+    //    bucket = hashtable.buckets.Length;
+    //    version = hashtable.version;
+    //  }
+
+    //  public bool MoveNext() {
+    //    if (version != hashtable.version)
+    //      throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+    //    while (bucket > 0) {
+    //      bucket--;
+    //      Object val = hashtable.buckets[bucket].val;
+    //      if (val != null) {
+    //        //currentKey = hashtable.buckets[bucket].key;
+    //        currentValue = val;
+    //        current = true;
+    //        return true;
+    //      }
+    //    }
+    //    current = false;
+    //    return false;
+    //  }
+
+    //  //internal int Key {
+    //  //  get {
+    //  //    if (current == false)
+    //  //      throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+    //  //    return currentKey;
+    //  //  }
+    //  //}
+
+    //  public Object Current {
+    //    get {
+    //      if (current == false)
+    //        throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+    //      return currentValue;
+    //    }
+    //  }
+
+    //  //public Object Value {
+    //  //  get {
+    //  //    if (version != hashtable.version)
+    //  //      throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+    //  //    if (current == false)
+    //  //      throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+    //  //    return currentValue;
+    //  //  }
+    //  //}
+
+    //  public void Reset() {
+    //    if (version != hashtable.version) throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+    //    current = false;
+    //    bucket = hashtable.buckets.Length;
+    //    //currentKey = -1;
+    //    currentValue = null;
+    //  }
+    //}
   }
 }
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
index 3a7910d..a6669b5 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -8,12 +13,20 @@ using System;
 namespace Microsoft.Cci.Pdb {
   internal class MsfDirectory {
     internal MsfDirectory(PdbReader reader, PdbFileHeader head, BitAccess bits) {
-      bits.MinCapacity(head.directorySize);
       int pages = reader.PagesFromSize(head.directorySize);
 
       // 0..n in page of directory pages.
-      reader.Seek(head.directoryRoot, 0);
-      bits.FillBuffer(reader.reader, pages * 4);
+      bits.MinCapacity(head.directorySize);
+      int directoryRootPages = head.directoryRoot.Length;
+      int pagesPerPage = head.pageSize / 4;
+      int pagesToGo = pages;
+      for (int i = 0; i < directoryRootPages; i++) {
+        int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
+        reader.Seek(head.directoryRoot[i], 0);
+        bits.Append(reader.reader, pagesInThisPage * 4);
+        pagesToGo -= pagesInThisPage;
+      }
+      bits.Position = 0;
 
       DataStream stream = new DataStream(head.directorySize, bits, pages);
       bits.MinCapacity(head.directorySize);
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
index 1f1aec1..434841b 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -22,6 +27,11 @@ namespace Microsoft.Cci.Pdb {
         this.value = tag1;
       } else if (tag2 == 0x80) {
         switch (tag1) {
+          case 0x00: //sbyte
+            sbyte sb;
+            bits.ReadInt8(out sb);
+            this.value = sb;
+            break;
           case 0x01: //short
             short s;
             bits.ReadInt16(out s);
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
index 515dc37..d7f8f0f 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
index 0dd7f93..38d1d56 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
index d6d493c..47191ef 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -21,7 +26,7 @@ namespace Microsoft.Cci.Pdb {
       bits.ReadGuid(out doctype);
     }
 
-    static Dictionary<string,int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
+    static Dictionary<string, int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
       Dictionary<string, int> result = new Dictionary<string, int>();
       int ver;
       int sig;
@@ -30,9 +35,9 @@ namespace Microsoft.Cci.Pdb {
       bits.ReadInt32(out age);    //  8..11 Age
       bits.ReadGuid(out guid);       // 12..27 GUID
 
-      if (ver != 20000404) {
-        throw new PdbDebugException("Unsupported PDB Stream version {0}", ver);
-      }
+      //if (ver != 20000404) {
+      //  throw new PdbDebugException("Unsupported PDB Stream version {0}", ver);
+      //}
 
       // Read string buffer.
       int buf;
@@ -70,7 +75,7 @@ namespace Microsoft.Cci.Pdb {
           bits.ReadCString(out name);
           bits.Position = saved;
 
-          result.Add(name, ni);
+          result.Add(name.ToUpperInvariant(), ni);
           j++;
         }
       }
@@ -126,17 +131,13 @@ namespace Microsoft.Cci.Pdb {
       return ht;
     }
 
-    private static PdbFunction match = new PdbFunction();
-
-    private static PdbFunction FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
-      match.segment = sec;
-      match.address = off;
+    private static int FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
+      var match = new PdbFunction {
+        segment = sec,
+        address = off,
+      };
 
-      int item = Array.BinarySearch(funcs, match, PdbFunction.byAddress);
-      if (item >= 0) {
-        return funcs[item];
-      }
-      return null;
+      return Array.BinarySearch(funcs, match, PdbFunction.byAddress);
     }
 
     static void LoadManagedLines(PdbFunction[] funcs,
@@ -146,53 +147,10 @@ namespace Microsoft.Cci.Pdb {
                                  Dictionary<string, int> nameIndex,
                                  PdbReader reader,
                                  uint limit) {
-      Array.Sort(funcs, PdbFunction.byAddress);
-      IntHashTable checks = new IntHashTable();
+      Array.Sort(funcs, PdbFunction.byAddressAndToken);
 
-      // 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 = SymLanguageType.CSharp;
-              Guid vendorGuid = SymLanguageVendor.Microsoft;
-              if (nameIndex.TryGetValue("/src/files/"+name, 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;
@@ -211,8 +169,25 @@ namespace Microsoft.Cci.Pdb {
               bits.ReadUInt16(out sec.sec);
               bits.ReadUInt16(out sec.flags);
               bits.ReadUInt32(out sec.cod);
-              PdbFunction func = FindFunction(funcs, sec.sec, sec.off);
-              if (func == null) break;
+              int funcIndex = FindFunction(funcs, sec.sec, sec.off);
+              if (funcIndex < 0) break;
+              var func = funcs[funcIndex];
+              if (func.lines == null) {
+                while (funcIndex > 0) {
+                  var f = funcs[funcIndex-1];
+                  if (f.lines != null || f.segment != sec.sec || f.address != sec.off) break;
+                  func = f;
+                  funcIndex--;
+                }
+              } else {
+                while (funcIndex < funcs.Length-1 && func.lines != null) {
+                  var f = funcs[funcIndex+1];
+                  if (f.segment != sec.sec || f.address != sec.off) break;
+                  func = f;
+                  funcIndex++;
+                }
+              }
+              if (func.lines != null) break;
 
               // Count the line blocks.
               int begSym = bits.Position;
@@ -255,7 +230,7 @@ namespace Microsoft.Cci.Pdb {
 
                   uint lineBegin = line.flags & (uint)CV_Line_Flags.linenumStart;
                   uint delta = (line.flags & (uint)CV_Line_Flags.deltaLineEnd) >> 24;
-                  bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
+                  //bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
                   if ((sec.flags & 1) != 0) {
                     bits.Position = pcol + 4 * i;
                     bits.ReadUInt16(out column.offColumnStart);
@@ -295,7 +270,7 @@ namespace Microsoft.Cci.Pdb {
 
       bits.Position = 4;
       // Console.WriteLine("{0}:", info.moduleName);
-      funcs = PdbFunction.LoadManagedFunctions(info.moduleName,
+      funcs = PdbFunction.LoadManagedFunctions(/*info.moduleName,*/
                                                bits, (uint)info.cbSyms,
                                                readStrings);
       if (funcs != null) {
@@ -316,10 +291,10 @@ namespace Microsoft.Cci.Pdb {
       DbiHeader dh = new DbiHeader(bits);
       header = new DbiDbgHdr();
 
-      if (dh.sig != -1 || dh.ver != 19990903) {
-        throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}",
-                               dh.sig, dh.ver);
-      }
+      //if (dh.sig != -1 || dh.ver != 19990903) {
+      //  throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}",
+      //                         dh.sig, dh.ver);
+      //}
 
       // Read gpmod section.
       ArrayList modList = new ArrayList();
@@ -362,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);
@@ -377,24 +349,37 @@ namespace Microsoft.Cci.Pdb {
       dir.streams[1].Read(reader, bits);
       Dictionary<string, int> nameIndex = LoadNameIndex(bits, out age, out guid);
       int nameStream;
-      if (!nameIndex.TryGetValue("/names", out nameStream)) {
+      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);
           }
         }
       }
@@ -413,9 +398,140 @@ namespace Microsoft.Cci.Pdb {
       }
 
       //
-      Array.Sort(funcs, PdbFunction.byAddress);
+      Array.Sort(funcs, PdbFunction.byAddressAndToken);
       //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/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
index c351076..e1f56db 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -9,21 +14,20 @@ using System.Text;
 
 namespace Microsoft.Cci.Pdb {
   internal class PdbFileHeader {
-    internal PdbFileHeader(int pageSize) {
-      this.magic = new byte[32] {
-                0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
-                0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
-                0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
-                0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00  // "^^^DS^^^"
-            };
-      this.pageSize = pageSize;
-      this.zero = 0;
-    }
+    //internal PdbFileHeader(int pageSize) {
+    //  this.magic = new byte[32] {
+    //            0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
+    //            0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
+    //            0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
+    //            0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00  // "^^^DS^^^"
+    //        };
+    //  this.pageSize = pageSize;
+    //}
 
     internal PdbFileHeader(Stream reader, BitAccess bits) {
       bits.MinCapacity(56);
       reader.Seek(0, SeekOrigin.Begin);
-      bits.FillBuffer(reader, 56);
+      bits.FillBuffer(reader, 52);
 
       this.magic = new byte[32];
       bits.ReadBytes(this.magic);                 //   0..31
@@ -32,41 +36,45 @@ namespace Microsoft.Cci.Pdb {
       bits.ReadInt32(out this.pagesUsed);         //  40..43
       bits.ReadInt32(out this.directorySize);     //  44..47
       bits.ReadInt32(out this.zero);              //  48..51
-      bits.ReadInt32(out this.directoryRoot);     //  52..55
-    }
 
-    internal string Magic {
-      get { return StringFromBytesUTF8(magic); }
+      int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize;
+      this.directoryRoot = new int[directoryPages];
+      bits.FillBuffer(reader, directoryPages * 4);
+      bits.ReadInt32(this.directoryRoot);
     }
 
-    internal void Write(Stream writer, BitAccess bits) {
-      bits.MinCapacity(56);
-      bits.WriteBytes(magic);                     //   0..31
-      bits.WriteInt32(pageSize);                  //  32..35
-      bits.WriteInt32(freePageMap);               //  36..39
-      bits.WriteInt32(pagesUsed);                 //  40..43
-      bits.WriteInt32(directorySize);             //  44..47
-      bits.WriteInt32(zero);                      //  48..51
-      bits.WriteInt32(directoryRoot);             //  52..55
+    //internal string Magic {
+    //  get { return StringFromBytesUTF8(magic); }
+    //}
 
-      writer.Seek(0, SeekOrigin.Begin);
-      bits.WriteBuffer(writer, 56);
-    }
+    //internal void Write(Stream writer, BitAccess bits) {
+    //  bits.MinCapacity(pageSize);
+    //  bits.WriteBytes(magic);                     //   0..31
+    //  bits.WriteInt32(pageSize);                  //  32..35
+    //  bits.WriteInt32(freePageMap);               //  36..39
+    //  bits.WriteInt32(pagesUsed);                 //  40..43
+    //  bits.WriteInt32(directorySize);             //  44..47
+    //  bits.WriteInt32(zero);                      //  48..51
+    //  bits.WriteInt32(directoryRoot);             //  52..55
+
+    //  writer.Seek(0, SeekOrigin.Begin);
+    //  bits.WriteBuffer(writer, pageSize);
+    //}
 
     //////////////////////////////////////////////////// Helper Functions.
     //
-    internal string StringFromBytesUTF8(byte[] bytes) {
-      return StringFromBytesUTF8(bytes, 0, bytes.Length);
-    }
+    //internal static string StringFromBytesUTF8(byte[] bytes) {
+    //  return StringFromBytesUTF8(bytes, 0, bytes.Length);
+    //}
 
-    internal string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
-      for (int i = 0; i < length; i++) {
-        if (bytes[offset + i] < ' ') {
-          length = i;
-        }
-      }
-      return Encoding.UTF8.GetString(bytes, offset, length);
-    }
+    //internal static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
+    //  for (int i = 0; i < length; i++) {
+    //    if (bytes[offset + i] < ' ') {
+    //      length = i;
+    //    }
+    //  }
+    //  return Encoding.UTF8.GetString(bytes, offset, length);
+    //}
 
     ////////////////////////////////////////////////////////////// Fields.
     //
@@ -76,7 +84,7 @@ namespace Microsoft.Cci.Pdb {
     internal int pagesUsed;
     internal int directorySize;
     internal readonly int zero;
-    internal int directoryRoot;
+    internal int[] directoryRoot;
   }
 
 }
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
index be28420..2ef733f 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -12,25 +17,31 @@ namespace Microsoft.Cci.Pdb {
     static internal readonly Guid msilMetaData = new Guid(0xc6ea3fc9, 0x59b3, 0x49d6, 0xbc, 0x25,
                                                         0x09, 0x02, 0xbb, 0xab, 0xb4, 0x60);
     static internal readonly IComparer byAddress = new PdbFunctionsByAddress();
-    static internal readonly IComparer byToken = new PdbFunctionsByToken();
+    static internal readonly IComparer byAddressAndToken = new PdbFunctionsByAddressAndToken();
+    //static internal readonly IComparer byToken = new PdbFunctionsByToken();
 
     internal uint token;
     internal uint slotToken;
-    internal string name;
-    internal string module;
-    internal ushort flags;
+    internal uint tokenOfMethodWhoseUsingInfoAppliesToThisMethod;
+    //internal string name;
+    //internal string module;
+    //internal ushort flags;
 
     internal uint segment;
     internal uint address;
-    internal uint length;
+    //internal uint length;
 
     //internal byte[] metadata;
     internal PdbScope[] scopes;
+    internal PdbSlot[] slots;
+    internal PdbConstant[] constants;
+    internal string[] usedNamespaces;
     internal PdbLines[] lines;
     internal ushort[]/*?*/ usingCounts;
     internal IEnumerable<INamespaceScope>/*?*/ namespaceScopes;
     internal string/*?*/ iteratorClass;
     internal List<ILocalScope>/*?*/ iteratorScopes;
+    internal PdbSynchronizationInformation/*?*/ synchronizationInformation;
 
     private static string StripNamespace(string module) {
       int li = module.LastIndexOf('.');
@@ -41,10 +52,10 @@ namespace Microsoft.Cci.Pdb {
     }
 
 
-    internal static PdbFunction[] LoadManagedFunctions(string module,
+    internal static PdbFunction[] LoadManagedFunctions(/*string module,*/
                                                        BitAccess bits, uint limit,
                                                        bool readStrings) {
-      string mod = StripNamespace(module);
+      //string mod = StripNamespace(module);
       int begin = bits.Position;
       int count = 0;
 
@@ -101,7 +112,7 @@ namespace Microsoft.Cci.Pdb {
           case SYM.S_GMANPROC:
           case SYM.S_LMANPROC:
             ManProcSym proc;
-            int offset = bits.Position;
+            //int offset = bits.Position;
 
             bits.ReadUInt32(out proc.parent);
             bits.ReadUInt32(out proc.end);
@@ -122,7 +133,7 @@ namespace Microsoft.Cci.Pdb {
             //Console.WriteLine("token={0:X8} [{1}::{2}]", proc.token, module, proc.name);
 
             bits.Position = stop;
-            funcs[func++] = new PdbFunction(module, proc, bits);
+            funcs[func++] = new PdbFunction(/*module,*/ proc, bits);
             break;
 
           default: {
@@ -190,15 +201,14 @@ namespace Microsoft.Cci.Pdb {
     internal PdbFunction() {
     }
 
-    internal PdbFunction(string module, ManProcSym proc, BitAccess bits) {
+    internal PdbFunction(/*string module, */ManProcSym proc, BitAccess bits) {
       this.token = proc.token;
-      this.module = module;
-      this.name = proc.name;
-      this.flags = proc.flags;
+      //this.module = module;
+      //this.name = proc.name;
+      //this.flags = proc.flags;
       this.segment = proc.seg;
       this.address = proc.off;
-      this.length = proc.len;
-      this.slotToken = 0;
+      //this.length = proc.len;
 
       if (proc.seg != 1) {
         throw new PdbDebugException("Segment is {0}, not 1.", proc.seg);
@@ -207,18 +217,27 @@ namespace Microsoft.Cci.Pdb {
         throw new PdbDebugException("Warning parent={0}, next={1}",
                                     proc.parent, proc.next);
       }
-      if (proc.dbgStart != 0 || proc.dbgEnd != 0) {
-        throw new PdbDebugException("Warning DBG start={0}, end={1}",
-                                    proc.dbgStart, proc.dbgEnd);
-      }
+      //if (proc.dbgStart != 0 || proc.dbgEnd != 0) {
+      //  throw new PdbDebugException("Warning DBG start={0}, end={1}",
+      //                              proc.dbgStart, proc.dbgEnd);
+      //}
 
       int constantCount;
       int scopeCount;
       int slotCount;
       int usedNamespacesCount;
       CountScopesAndSlots(bits, proc.end, out constantCount, out scopeCount, out slotCount, out usedNamespacesCount);
-      scopes = new PdbScope[scopeCount];
-      int scope = 0;
+      int scope = constantCount > 0 || slotCount > 0 || usedNamespacesCount > 0 ? 1 : 0;
+      int slot = 0;
+      int constant = 0;
+      int usedNs = 0;
+      scopes = new PdbScope[scopeCount+scope];
+      slots = new PdbSlot[slotCount];
+      constants = new PdbConstant[constantCount];
+      usedNamespaces = new string[usedNamespacesCount];
+
+      if (scope > 0)
+        scopes[0] = new PdbScope(this.address, proc.len, slots, constants, usedNamespaces);
 
       while (bits.Position < proc.end) {
         ushort siz;
@@ -250,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;
@@ -266,17 +287,28 @@ namespace Microsoft.Cci.Pdb {
               bits.ReadUInt32(out block.parent);
               bits.ReadUInt32(out block.end);
               bits.ReadUInt32(out block.len);
-              bits.ReadUInt32(out this.address);
+              bits.ReadUInt32(out block.off);
               bits.ReadUInt16(out block.seg);
               bits.SkipCString(out block.name);
               bits.Position = stop;
 
-              scopes[scope] = new PdbScope(block, bits, out slotToken);
+              scopes[scope++] = new PdbScope(this.address, block, bits, out slotToken);
               bits.Position = (int)block.end;
               break;
             }
 
+          case SYM.S_MANSLOT:
+            slots[slot++] = new PdbSlot(bits);
+            bits.Position = stop;
+            break;
+
+          case SYM.S_MANCONSTANT:
+            constants[constant++] = new PdbConstant(bits);
+            bits.Position = stop;
+            break;
+
           case SYM.S_UNAMESPACE:
+            bits.ReadCString(out usedNamespaces[usedNs++]);
             bits.Position = stop;
             break;
 
@@ -321,10 +353,10 @@ namespace Microsoft.Cci.Pdb {
       switch (kind) {
         case 0: this.ReadUsingInfo(bits); break;
         case 1: this.ReadForwardInfo(bits); break;
-        case 2: this.ReadForwardedToModuleInfo(bits); break;
+        case 2: break; // this.ReadForwardedToModuleInfo(bits); break;
         case 3: this.ReadIteratorLocals(bits); break;
         case 4: this.ReadForwardIterator(bits); break;
-        default: throw new PdbDebugException("Unknown custom metadata item kind: {0}", kind);
+        // TODO: handle unknown custom metadata, 5 & 6 are new with roslyn, see https://roslyn.codeplex.com/workitem/54
       }
       bits.Position = savedPosition+(int)numberOfBytesInItem;
     }
@@ -346,10 +378,11 @@ namespace Microsoft.Cci.Pdb {
       }
     }
 
-    private void ReadForwardedToModuleInfo(BitAccess bits) {
-    }
+    //private void ReadForwardedToModuleInfo(BitAccess bits) {
+    //}
 
     private void ReadForwardInfo(BitAccess bits) {
+      bits.ReadUInt32(out this.tokenOfMethodWhoseUsingInfoAppliesToThisMethod);
     }
 
     private void ReadUsingInfo(BitAccess bits) {
@@ -380,20 +413,86 @@ namespace Microsoft.Cci.Pdb {
       }
     }
 
-    internal class PdbFunctionsByToken : IComparer {
+    internal class PdbFunctionsByAddressAndToken : IComparer {
       public int Compare(Object x, Object y) {
         PdbFunction fx = (PdbFunction)x;
         PdbFunction fy = (PdbFunction)y;
 
-        if (fx.token < fy.token) {
+        if (fx.segment < fy.segment) {
+          return -1;
+        } else if (fx.segment > fy.segment) {
+          return 1;
+        } else if (fx.address < fy.address) {
           return -1;
-        } else if (fx.token > fy.token) {
+        } else if (fx.address > fy.address) {
           return 1;
         } else {
-          return 0;
+          if (fx.token < fy.token)
+            return -1;
+          else if (fx.token > fy.token)
+            return 1;
+          else
+            return 0;
         }
       }
+    }
+
+    //internal class PdbFunctionsByToken : IComparer {
+    //  public int Compare(Object x, Object y) {
+    //    PdbFunction fx = (PdbFunction)x;
+    //    PdbFunction fy = (PdbFunction)y;
+
+    //    if (fx.token < fy.token) {
+    //      return -1;
+    //    } else if (fx.token > fy.token) {
+    //      return 1;
+    //    } else {
+    //      return 0;
+    //    }
+    //  }
+
+    //}
+  }
+
+  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/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
index 78eb9d6..f6fe3a9 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
index 9e989cd..382638b 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
index 52a8f2a..edfd926 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -25,9 +30,9 @@ namespace Microsoft.Cci.Pdb {
       return (size + pageSize - 1) / (pageSize);
     }
 
-    internal int PageSize {
-      get { return pageSize; }
-    }
+    //internal int PageSize {
+    //  get { return pageSize; }
+    //}
 
     internal readonly int pageSize;
     internal readonly Stream reader;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
index 72a68d7..92ac385 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -12,13 +17,25 @@ namespace Microsoft.Cci.Pdb {
     internal PdbScope[] scopes;
     internal string[] usedNamespaces;
 
-    internal uint segment;
+    //internal uint segment;
     internal uint address;
+    internal uint offset;
     internal uint length;
 
-    internal PdbScope(BlockSym32 block, BitAccess bits, out uint typind) {
-      this.segment = block.seg;
+    internal PdbScope(uint address, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces) {
+      this.constants = constants;
+      this.slots = slots;
+      this.scopes = new PdbScope[0];
+      this.usedNamespaces = usedNamespaces;
+      this.address = address;
+      this.offset = 0;
+      this.length = length;
+    }
+
+    internal PdbScope(uint funcOffset, BlockSym32 block, BitAccess bits, out uint typind) {
+      //this.segment = block.seg;
       this.address = block.off;
+      this.offset = block.off - funcOffset;
       this.length = block.len;
       typind = 0;
 
@@ -58,12 +75,12 @@ namespace Microsoft.Cci.Pdb {
               bits.SkipCString(out sub.name);
 
               bits.Position = stop;
-              scopes[scope++] = new PdbScope(sub, bits, out typind);
+              scopes[scope++] = new PdbScope(funcOffset, sub, bits, out typind);
               break;
             }
 
           case SYM.S_MANSLOT:
-            slots[slot++] = new PdbSlot(bits, out typind);
+            slots[slot++] = new PdbSlot(bits);
             bits.Position = stop;
             break;
 
@@ -82,8 +99,9 @@ namespace Microsoft.Cci.Pdb {
             break;
 
           default:
-            throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
-          // bits.Position = stop;
+            //throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
+            bits.Position = stop;
+            break;
         }
       }
 
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
index b2cebbe..e2b76d5 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
@@ -1,6 +1,11 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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;
@@ -8,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 uint segment;
+    //internal uint address;
 
-    internal PdbSlot(BitAccess bits, out uint typind) {
+    internal PdbSlot(BitAccess bits) {
       AttrSlotSym slot;
 
       bits.ReadUInt32(out slot.index);
@@ -24,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;
+      //this.segment = slot.segCod;
+      //this.address = slot.offCod;
 
-      typind = slot.typind;
     }
   }
 }
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
index e7b0e34..ac40f85 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
@@ -1,20 +1,25 @@
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
+// 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 PdbSource {
-    internal uint index;
+    //internal uint index;
     internal string name;
     internal Guid doctype;
     internal Guid language;
     internal Guid vendor;
 
-    internal PdbSource(uint index, string name, Guid doctype, Guid language, Guid vendor) {
-      this.index = index;
+    internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor) {
+      //this.index = index;
       this.name = name;
       this.doctype = doctype;
       this.language = language;
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs
new file mode 100644
index 0000000..879339b
--- /dev/null
+++ b/vbnc/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/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs
deleted file mode 100644
index ca4992e..0000000
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation.  All Rights Reserved.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.IO;
-
-namespace Microsoft.Cci.Pdb {
-  internal class PdbWriter {
-    internal PdbWriter(Stream writer, int pageSize) {
-      this.pageSize = pageSize;
-      this.usedBytes = pageSize * 3;
-      this.writer = writer;
-
-      writer.SetLength(usedBytes);
-    }
-
-    internal void WriteMeta(DataStream[] streams, BitAccess bits) {
-      PdbFileHeader head = new PdbFileHeader(pageSize);
-
-      WriteDirectory(streams,
-                     out head.directoryRoot,
-                     out head.directorySize,
-                     bits);
-      WriteFreeMap();
-
-      head.freePageMap = 2;
-      head.pagesUsed = usedBytes / pageSize;
-
-      writer.Seek(0, SeekOrigin.Begin);
-      head.Write(writer, bits);
-    }
-
-    private void WriteDirectory(DataStream[] streams,
-                                out int directoryRoot,
-                                out int directorySize,
-                                BitAccess bits) {
-      DataStream directory = new DataStream();
-
-      int pages = 0;
-      for (int s = 0; s < streams.Length; s++) {
-        if (streams[s].Length > 0) {
-          pages += streams[s].Pages;
-        }
-      }
-
-      int use = 4 * (1 + streams.Length + pages);
-      bits.MinCapacity(use);
-      bits.WriteInt32(streams.Length);
-      for (int s = 0; s < streams.Length; s++) {
-        bits.WriteInt32(streams[s].Length);
-      }
-      for (int s = 0; s < streams.Length; s++) {
-        if (streams[s].Length > 0) {
-          bits.WriteInt32(streams[s].pages);
-        }
-      }
-      directory.Write(this, bits.Buffer, use);
-      directorySize = directory.Length;
-
-      use = 4 * directory.Pages;
-      bits.MinCapacity(use);
-      bits.WriteInt32(directory.pages);
-
-      DataStream ddir = new DataStream();
-      ddir.Write(this, bits.Buffer, use);
-
-      directoryRoot = ddir.pages[0];
-    }
-
-    private void WriteFreeMap() {
-      byte[] buffer = new byte[pageSize];
-
-      // We configure the old free map with only the first 3 pages allocated.
-      buffer[0] = 0xf8;
-      for (int i = 1; i < pageSize; i++) {
-        buffer[i] = 0xff;
-      }
-      Seek(1, 0);
-      Write(buffer, 0, pageSize);
-
-      // We configure the new free map with all of the used pages gone.
-      int count = usedBytes / pageSize;
-      int full = count / 8;
-      for (int i = 0; i < full; i++) {
-        buffer[i] = 0;
-      }
-      int rema = count % 8;
-      buffer[full] = (byte)(0xff << rema);
-
-      Seek(2, 0);
-      Write(buffer, 0, pageSize);
-    }
-
-    internal int AllocatePages(int count) {
-      int begin = usedBytes;
-
-      usedBytes += count * pageSize;
-      writer.SetLength(usedBytes);
-
-      if (usedBytes > pageSize * pageSize * 8) {
-        throw new Exception("PdbWriter does not support multiple free maps.");
-      }
-      return begin / pageSize;
-    }
-
-    internal void Seek(int page, int offset) {
-      writer.Seek(page * pageSize + offset, SeekOrigin.Begin);
-    }
-
-    internal void Write(byte[] bytes, int offset, int count) {
-      writer.Write(bytes, offset, count);
-    }
-
-    //////////////////////////////////////////////////////////////////////
-    //
-    internal int PageSize {
-      get { return pageSize; }
-    }
-
-    //////////////////////////////////////////////////////////////////////
-    //
-    internal readonly int pageSize;
-    private Stream writer;
-    private int usedBytes;
-  }
-
-}
diff --git a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
index 2b28971..db3f291 100644
--- a/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
+++ b/vbnc/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
@@ -13,38 +13,6 @@ using System.Diagnostics.SymbolStore;
 
 namespace Microsoft.Cci {
 
-  internal sealed class UsedNamespace : IUsedNamespace {
-
-    internal UsedNamespace(IName alias, IName namespaceName) {
-      this.alias = alias;
-      this.namespaceName = namespaceName;
-    }
-
-    public IName Alias {
-      get { return this.alias; }
-    }
-    readonly IName alias;
-
-    public IName NamespaceName {
-      get { return this.namespaceName; }
-    }
-    readonly IName namespaceName;
-
-  }
-
-  internal class NamespaceScope : INamespaceScope {
-
-    internal NamespaceScope(IEnumerable<IUsedNamespace> usedNamespaces) {
-      this.usedNamespaces = usedNamespaces;
-    }
-
-    public IEnumerable<IUsedNamespace> UsedNamespaces {
-      get { return this.usedNamespaces; }
-    }
-    readonly IEnumerable<IUsedNamespace> usedNamespaces;
-
-  }
-
   internal sealed class PdbIteratorScope : ILocalScope {
 
     internal PdbIteratorScope(uint offset, uint length) {
@@ -61,6 +29,5 @@ namespace Microsoft.Cci {
       get { return this.length; }
     }
     uint length;
-
   }
 }
\ No newline at end of file
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.VB.csproj b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.VB.csproj
index d000423..4dc04f4 100755
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.VB.csproj
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.VB.csproj
@@ -1,128 +1,128 @@
-<?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)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{63E6915C-7EA4-4D76-AB28-0D7191EEA626}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Mono.Cecil.Pdb</RootNamespace>
-    <AssemblyName>Mono.Cecil.VB.Pdb</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
-    <FileUpgradeFlags>
-    </FileUpgradeFlags>
-    <OldToolsVersion>3.5</OldToolsVersion>
-    <UpgradeBackupLocation />
-    <PublishUrl>publish\</PublishUrl>
-    <Install>true</Install>
-    <InstallFrom>Disk</InstallFrom>
-    <UpdateEnabled>false</UpdateEnabled>
-    <UpdateMode>Foreground</UpdateMode>
-    <UpdateInterval>7</UpdateInterval>
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
-    <UpdatePeriodically>false</UpdatePeriodically>
-    <UpdateRequired>false</UpdateRequired>
-    <MapFileExtensions>true</MapFileExtensions>
-    <ApplicationRevision>0</ApplicationRevision>
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
-    <UseApplicationTrust>false</UseApplicationTrust>
-    <BootstrapperEnabled>true</BootstrapperEnabled>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoWarn>0649</NoWarn>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoWarn>0649</NoWarn>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Microsoft.Cci.Pdb\BitAccess.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\BitSet.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\CvInfo.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\DataStream.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\DbiDbgHdr.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\DbiHeader.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\DbiModuleInfo.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\DbiSecCon.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\Interfaces.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\IntHashTable.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\MsfDirectory.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbConstant.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbDebugException.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbException.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbFile.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbFileHeader.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbFunction.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbLine.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbLines.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\PdbReader.cs" />
-    <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\PdbWriter.cs" />
-    <Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs" />
-    <Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
-    <Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
-    <Compile Include="Mono.Cecil.Pdb\ISymUnmanagedWriter2.cs" />
-    <Compile Include="Mono.Cecil.Pdb\ModuleMetadata.cs" />
-    <Compile Include="Mono.Cecil.Pdb\PdbHelper.cs" />
-    <Compile Include="Mono.Cecil.Pdb\PdbReader.cs" />
-    <Compile Include="Mono.Cecil.Pdb\PdbWriter.cs" />
-    <Compile Include="Mono.Cecil.Pdb\SymDocumentWriter.cs" />
-    <Compile Include="Mono.Cecil.Pdb\SymWriter.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\Mono.Cecil.VB.csproj">
-      <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
-      <Name>Mono.Cecil.VB</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
-      <Visible>False</Visible>
-      <ProductName>Windows Installer 3.1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
+<?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)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{63E6915C-7EA4-4D76-AB28-0D7191EEA626}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Mono.Cecil.Pdb</RootNamespace>
+    <AssemblyName>Mono.Cecil.VB.Pdb</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <OldToolsVersion>3.5</OldToolsVersion>
+    <UpgradeBackupLocation />
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoWarn>0649</NoWarn>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoWarn>0649</NoWarn>
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Microsoft.Cci.Pdb\BitAccess.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\BitSet.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\CvInfo.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\DataStream.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\DbiDbgHdr.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\DbiHeader.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\DbiModuleInfo.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\DbiSecCon.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\Interfaces.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\IntHashTable.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\MsfDirectory.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbConstant.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbDebugException.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbException.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbFile.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbFileHeader.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbFunction.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbLine.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbLines.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbReader.cs" />
+    <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\PdbTokenLine.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs" />
+    <Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
+    <Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
+    <Compile Include="Mono.Cecil.Pdb\ISymUnmanagedWriter2.cs" />
+    <Compile Include="Mono.Cecil.Pdb\ModuleMetadata.cs" />
+    <Compile Include="Mono.Cecil.Pdb\PdbHelper.cs" />
+    <Compile Include="Mono.Cecil.Pdb\PdbReader.cs" />
+    <Compile Include="Mono.Cecil.Pdb\PdbWriter.cs" />
+    <Compile Include="Mono.Cecil.Pdb\SymDocumentWriter.cs" />
+    <Compile Include="Mono.Cecil.Pdb\SymWriter.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Mono.Cecil.VB.csproj">
+      <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
+      <Name>Mono.Cecil.VB</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
index ed8dc01..c41388e 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
@@ -1,45 +1,13 @@
-<?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">
+  <Import Project="..\..\Mono.Cecil.settings" />
   <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{63E6915C-7EA4-4D76-AB28-0D7191EEA626}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Mono.Cecil.Pdb</RootNamespace>
     <AssemblyName>Mono.Cecil.Pdb</AssemblyName>
-    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <NoWarn>0649</NoWarn>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
     <NoWarn>0649</NoWarn>
-    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="System" />
-  </ItemGroup>
-  <ItemGroup>
     <ProjectReference Include="..\..\Mono.Cecil.csproj">
       <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
       <Name>Mono.Cecil</Name>
@@ -69,7 +37,7 @@
     <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\PdbWriter.cs" />
+    <Compile Include="Microsoft.Cci.Pdb\PdbTokenLine.cs" />
     <Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs" />
     <Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
     <Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
@@ -82,11 +50,4 @@
     <Compile Include="Mono.Cecil.Pdb\SymWriter.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
 </Project>
\ No newline at end of file
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
index 59cd80f..14d2679 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,10 +32,10 @@ using System.Runtime.InteropServices;
 
 [assembly: AssemblyTitle ("Mono.Cecil.Pdb")]
 [assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("Copyright � 2008 - 2010 Jb Evain")]
+[assembly: AssemblyCopyright ("Copyright � 2008 - 2011 Jb Evain")]
 
 [assembly: CLSCompliant (false)]
 [assembly: ComVisible (false)]
 
-[assembly: AssemblyVersion ("0.9.3.0")]
-[assembly: AssemblyFileVersion ("0.9.3.0")]
+[assembly: AssemblyVersion ("0.9.5.0")]
+[assembly: AssemblyFileVersion ("0.9.5.0")]
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
index c9647c4..8f47b2c 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
@@ -27,6 +27,8 @@
 
 using System.Runtime.InteropServices;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb {
 
 	[Guid ("B01FAFEB-C450-3A4D-BEEC-B4CEEC01E006")]
@@ -35,3 +37,5 @@ namespace Mono.Cecil.Pdb {
 	interface ISymUnmanagedDocumentWriter {
 	}
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
index dbc3d65..11466dc 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
@@ -33,6 +33,8 @@ using System.Runtime.InteropServices.ComTypes;
 
 using Mono.Cecil.Cil;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb {
 
 	[Guid ("0B97726E-9E6D-4f05-9A26-424022093CAA")]
@@ -97,3 +99,5 @@ namespace Mono.Cecil.Pdb {
 			[In] int endOffset);
 	}
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
index 13aed34..b175c06 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
@@ -1,7 +1,10 @@
 using System;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Text;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb {
 
 	[ComImport, InterfaceType (ComInterfaceType.InterfaceIsIUnknown), Guid ("BA3FEE4C-ECB9-4e41-83B7-183FA41CD859")]
@@ -73,7 +76,7 @@ namespace Mono.Cecil.Pdb {
 		uint FindTypeDefByName (string szTypeDef, uint tkEnclosingClass);
 		Guid GetScopeProps (StringBuilder szName, uint cchName, out uint pchName);
 		uint GetModuleFromScope ();
-		uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, ref uint pdwTypeDefFlags);
+		uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags);
 		uint GetInterfaceImplProps (uint iiImpl, out uint pClass);
 		uint GetTypeRefProps (uint tr, out uint ptkResolutionScope, StringBuilder szName, uint cchName);
 		uint ResolveTypeRef (uint tr, [In] ref Guid riid, [MarshalAs (UnmanagedType.Interface)] out object ppIScope);
@@ -93,8 +96,7 @@ namespace Mono.Cecil.Pdb {
 		uint FindMethod (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
 		uint FindField (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
 		uint FindMemberRef (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
-		uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr,
-		  IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA);
+		uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA);
 		uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr /* byte* */ ppvSigBlob);
 		uint EnumProperties (ref uint phEnum, uint td, IntPtr /* uint* */ rProperties, uint cMax);
 		uint EnumEvents (ref uint phEnum, uint td, IntPtr /* uint* */ rEvents, uint cMax);
@@ -145,11 +147,47 @@ namespace Mono.Cecil.Pdb {
 
 		readonly ModuleDefinition module;
 
+		Dictionary<uint, TypeDefinition> types;
+		Dictionary<uint, MethodDefinition> methods;
+
 		public ModuleMetadata (ModuleDefinition module)
 		{
 			this.module = module;
 		}
 
+		bool TryGetType (uint token, out TypeDefinition type)
+		{
+			if (types == null)
+				InitializeMetadata (module);
+
+			return types.TryGetValue (token, out type);
+		}
+
+		bool TryGetMethod (uint token, out MethodDefinition method)
+		{
+			if (methods == null)
+				InitializeMetadata (module);
+
+			return methods.TryGetValue (token, out method);
+		}
+
+		void InitializeMetadata (ModuleDefinition module)
+		{
+			types = new Dictionary<uint, TypeDefinition> ();
+			methods = new Dictionary<uint, MethodDefinition> ();
+
+			foreach (var type in module.GetTypes ()) {
+				types.Add (type.MetadataToken.ToUInt32 (), type);
+				InitializeMethods (type);
+			}
+		}
+
+		void InitializeMethods (TypeDefinition type)
+		{
+			foreach (var method in type.Methods)
+				methods.Add (method.MetadataToken.ToUInt32 (), method);
+		}
+
 		public void SetModuleProps (string szName)
 		{
 			throw new NotImplementedException ();
@@ -440,10 +478,40 @@ namespace Mono.Cecil.Pdb {
 			throw new NotImplementedException ();
 		}
 
-		public uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, ref uint pdwTypeDefFlags)
+		public uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags)
+		{
+			TypeDefinition type;
+			if (!TryGetType (td, out type)) {
+				Marshal.WriteInt16 (szTypeDef, 0);
+				pchTypeDef = 1;
+				return 0;
+			}
+
+			WriteString (type.IsNested ? type.Name : type.FullName, szTypeDef, cchTypeDef, out pchTypeDef);
+			WriteIntPtr (pdwTypeDefFlags, (uint) type.Attributes);
+			return type.BaseType != null ? type.BaseType.MetadataToken.ToUInt32 () : 0;
+		}
+
+		static void WriteIntPtr (IntPtr ptr, uint value)
+		{
+			if (ptr == IntPtr.Zero)
+				return;
+
+			Marshal.WriteInt32 (ptr, (int) value);
+		}
+
+		static void WriteString (string str, IntPtr buffer, uint bufferSize, out uint chars)
 		{
-			pchTypeDef = 0;
-			return td;
+			var length = str.Length + 1 >= bufferSize ? bufferSize - 1 : (uint) str.Length;
+			chars = length + 1;
+			var offset = 0;
+
+			for (int i = 0; i < length; i++) {
+				Marshal.WriteInt16 (buffer, offset, str [i]);
+				offset += 2;
+			}
+
+			Marshal.WriteInt16 (buffer, offset, 0);
 		}
 
 		public uint GetInterfaceImplProps (uint iiImpl, out uint pClass)
@@ -533,9 +601,20 @@ namespace Mono.Cecil.Pdb {
 
 		public uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA)
 		{
-			pClass = 0;
-			pchMethod = 0;
-			return mb;
+			MethodDefinition method;
+			if (!TryGetMethod (mb, out method)) {
+				Marshal.WriteInt16 (szMethod, 0);
+				pchMethod = 1;
+				pClass = 0;
+				return 0;
+			}
+
+			pClass = method.DeclaringType.MetadataToken.ToUInt32 ();
+			WriteString (method.Name, szMethod, cchMethod, out pchMethod);
+			WriteIntPtr (pdwAttr, (uint) method.Attributes);
+			WriteIntPtr (pulCodeRVA, (uint) method.RVA);
+
+			return (uint) method.ImplAttributes;
 		}
 
 		public uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr ppvSigBlob)
@@ -695,7 +774,11 @@ namespace Mono.Cecil.Pdb {
 
 		public uint GetNestedClassProps (uint tdNestedClass)
 		{
-			throw new NotImplementedException ();
+			TypeDefinition type;
+			if (!TryGetType (tdNestedClass, out type))
+				return 0;
+
+			return type.IsNested ? type.DeclaringType.MetadataToken.ToUInt32 () : 0;
 		}
 
 		public uint GetNativeCallConvFromSig (IntPtr pvSig, uint cbSig)
@@ -709,3 +792,5 @@ namespace Mono.Cecil.Pdb {
 		}
 	}
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
index dac7019..aa63982 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -36,6 +36,7 @@ namespace Mono.Cecil.Pdb {
 
 	class PdbHelper {
 
+#if !READ_ONLY
 		public static SymWriter CreateWriter (ModuleDefinition module, string pdb)
 		{
 			var writer = new SymWriter ();
@@ -47,6 +48,7 @@ namespace Mono.Cecil.Pdb {
 
 			return writer;
 		}
+#endif
 
 		public static string GetPdbFileName (string assemblyFileName)
 		{
@@ -63,10 +65,12 @@ namespace Mono.Cecil.Pdb {
 
 		public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
 		{
-			throw new NotImplementedException ();
+			return new PdbReader (symbolStream);
 		}
 	}
 
+#if !READ_ONLY
+
 	public class PdbWriterProvider : ISymbolWriterProvider {
 
 		public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
@@ -80,6 +84,8 @@ namespace Mono.Cecil.Pdb {
 		}
 	}
 
+#endif
+
 	static class GuidMapping {
 
 		static readonly Dictionary<Guid, DocumentLanguage> guid_language = new Dictionary<Guid, DocumentLanguage> ();
@@ -98,6 +104,7 @@ namespace Mono.Cecil.Pdb {
 			AddMapping (DocumentLanguage.JScript, new Guid (0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2));
 			AddMapping (DocumentLanguage.Smc, new Guid (0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd));
 			AddMapping (DocumentLanguage.MCpp, new Guid (0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1));
+			AddMapping (DocumentLanguage.FSharp, new Guid (0xab4f38c9, 0xb6e6, 0x43ba, 0xbe, 0x3b, 0x58, 0x08, 0x0b, 0x2c, 0xcc, 0xe3));
 		}
 
 		static void AddMapping (DocumentLanguage language, Guid guid)
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
index 59bfa1b..6d4fd09 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -86,16 +86,15 @@ 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) {
-					if (this.age != age)
-						return false;
-					if (this.guid != guid)
-						return false;
-				}
+
+				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)
 					functions.Add (function.token, function);
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
index fad193c..d07b698 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain at gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -33,9 +33,10 @@ using System.Diagnostics.SymbolStore;
 using Mono.Cecil.Cil;
 using Mono.Collections.Generic;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb {
 
-#if !READ_ONLY
 	public class PdbWriter : Cil.ISymbolWriter {
 
 		readonly ModuleDefinition module;
@@ -216,5 +217,6 @@ namespace Mono.Cecil.Pdb {
 			writer.Close ();
 		}
 	}
-#endif
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
index 3f4cc4a..34918dc 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
@@ -28,6 +28,8 @@
 
 using System;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb
 {
 	internal class SymDocumentWriter
@@ -45,3 +47,5 @@ namespace Mono.Cecil.Pdb
 		}
 	}
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
index 759ca59..678942a 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
@@ -34,6 +34,8 @@ using System.Runtime.InteropServices;
 using Mono.Cecil.Cil;
 using Mono.Collections.Generic;
 
+#if !READ_ONLY
+
 namespace Mono.Cecil.Pdb
 {
 	internal class SymWriter
@@ -164,3 +166,5 @@ namespace Mono.Cecil.Pdb
 		}
 	}
 }
+
+#endif
diff --git a/vbnc/cecil/symbols/pdb/Mono.Cecil.VB.Pdb.dll.sources b/vbnc/cecil/symbols/pdb/Mono.Cecil.VB.Pdb.dll.sources
index 86ef310..66f234f 100644
--- a/vbnc/cecil/symbols/pdb/Mono.Cecil.VB.Pdb.dll.sources
+++ b/vbnc/cecil/symbols/pdb/Mono.Cecil.VB.Pdb.dll.sources
@@ -21,7 +21,7 @@ Microsoft.Cci.Pdb/PdbReader.cs
 Microsoft.Cci.Pdb/PdbScope.cs
 Microsoft.Cci.Pdb/PdbSlot.cs
 Microsoft.Cci.Pdb/PdbSource.cs
-Microsoft.Cci.Pdb/PdbWriter.cs
+Microsoft.Cci.Pdb/PdbTokenLine.cs
 Microsoft.Cci.Pdb/SourceLocationProvider.cs
 Mono.Cecil.Pdb/AssemblyInfo.cs
 Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
diff --git a/vbnc/vbnc/source/Emit/EmitLog.vb b/vbnc/vbnc/source/Emit/EmitLog.vb
index 34ff0e2..690034a 100644
--- a/vbnc/vbnc/source/Emit/EmitLog.vb
+++ b/vbnc/vbnc/source/Emit/EmitLog.vb
@@ -172,8 +172,7 @@ Public Class EmitLog
             Dim block As TryBlock = m_ExceptionBlocks.Peek
             Dim ex As Mono.Cecil.Cil.ExceptionHandler = block.Handlers(block.Handlers.Count - 1)
             CilWorker.Emit(Mono.Cecil.Cil.OpCodes.Endfilter)
-            ex.FilterEnd = CreateAndEmitNop()
-            ex.HandlerStart = ex.FilterEnd
+            ex.HandlerStart = CreateAndEmitNop()
         Else
             Dim ex As New Mono.Cecil.Cil.ExceptionHandler(Mono.Cecil.Cil.ExceptionHandlerType.Catch)
             Dim block As TryBlock = m_ExceptionBlocks.Peek
diff --git a/vbnc/vbnc/source/General/CecilHelper.vb b/vbnc/vbnc/source/General/CecilHelper.vb
index 4258e3c..720d65a 100755
--- a/vbnc/vbnc/source/General/CecilHelper.vb
+++ b/vbnc/vbnc/source/General/CecilHelper.vb
@@ -165,7 +165,7 @@ Public Class CecilHelper
         If genericType Is Nothing Then Return Member
 
         result = New Mono.Cecil.GenericInstanceType(Member)
-        result.DeclaringType = FindDefinition(Type)
+        ' result.DeclaringType = FindDefinition(Type)
 
         Dim tGI As Mono.Cecil.GenericInstanceType = TryCast(Type, Mono.Cecil.GenericInstanceType)
         If Member.DeclaringType IsNot Nothing AndAlso tGI IsNot Nothing AndAlso Helper.CompareType(Member.DeclaringType, tGI.ElementType) Then
@@ -468,6 +468,10 @@ Public Class CecilHelper
             End If
         Next
 
+        For i As Integer = 0 To arguments.Count - 1
+            If arguments(i) Is original Then Return arguments(i)
+        Next
+
         If original.IsNested Then
             Dim parentType As TypeReference = InflateType(original.DeclaringType, parameters, arguments)
             If parentType IsNot original Then
@@ -533,6 +537,24 @@ Public Class CecilHelper
         Throw New NotImplementedException
     End Function
 
+    Shared Function CloneGenericParameter(gp As GenericParameter) As GenericParameter
+        Dim rv As New GenericParameter(gp.Name, gp.Owner)
+        rv.Attributes = gp.Attributes
+        If gp.HasConstraints Then
+            For i As Integer = 0 To gp.Constraints.Count - 1
+                rv.Constraints.Add(gp.Constraints(i))
+            Next
+        End If
+        rv.HasDefaultConstructorConstraint = gp.HasDefaultConstructorConstraint
+        rv.HasNotNullableValueTypeConstraint = gp.HasNotNullableValueTypeConstraint
+        rv.HasReferenceTypeConstraint = gp.HasReferenceTypeConstraint
+        rv.IsContravariant = gp.IsContravariant
+        rv.IsCovariant = gp.IsCovariant
+        rv.IsNonVariant = gp.IsNonVariant
+
+        Return rv
+    End Function
+
     Public Shared Function GetCorrectMember(ByVal Member As MethodDefinition, ByVal Arguments As Mono.Collections.Generic.Collection(Of TypeReference), Optional ByVal Emittable As Boolean = False) As Mono.Cecil.MethodReference
         Dim result As Mono.Cecil.MethodReference
         Dim parameters As Mono.Collections.Generic.Collection(Of GenericParameter) = Member.GenericParameters
@@ -549,8 +571,8 @@ Public Class CecilHelper
         result.OriginalMethod = Member
 
         For i As Integer = 0 To Member.GenericParameters.Count - 1
-            result.GenericParameters.Add(Member.GenericParameters(i))
-            reflectableMember.GenericParameters.Add(Member.GenericParameters(i))
+            result.GenericParameters.Add(CloneGenericParameter(Member.GenericParameters(i)))
+            reflectableMember.GenericParameters.Add(CloneGenericParameter(Member.GenericParameters(i)))
         Next
 
         For i As Integer = 0 To Member.Parameters.Count - 1
diff --git a/vbnc/vbnc/source/General/Compiler.vb b/vbnc/vbnc/source/General/Compiler.vb
index b4e93d4..c89ab4d 100755
--- a/vbnc/vbnc/source/General/Compiler.vb
+++ b/vbnc/vbnc/source/General/Compiler.vb
@@ -316,11 +316,13 @@ Public Class Compiler
         End Select
 
         Dim an As AssemblyNameDefinition = New AssemblyNameDefinition("dummy", New Version())
-        AssemblyBuilderCecil = AssemblyDefinition.CreateAssembly(an, IO.Path.GetFileNameWithoutExtension(OutFileName), kind)
+        Dim moduleParameters As New ModuleParameters()
+        moduleParameters.Kind = kind
+        moduleParameters.AssemblyResolver = AssemblyResolver
+        AssemblyBuilderCecil = AssemblyDefinition.CreateAssembly(an, IO.Path.GetFileNameWithoutExtension(OutFileName), moduleParameters)
         ModuleBuilderCecil = AssemblyBuilderCecil.MainModule
         ModuleBuilderCecil.Name = IO.Path.GetFileName(OutFileName)
         ModuleBuilderCecil.Runtime = TypeManager.Corlib.MainModule.Runtime
-        ModuleBuilderCecil.AssemblyResolver = AssemblyResolver
         If CommandLine.Verbose Then Report.WriteLine(String.Format("Using runtime version: {0}", ModuleBuilderCecil.Runtime))
         Return Compiler.Report.Errors = 0
     End Function
diff --git a/vbnc/vbnc/source/General/Helper.vb b/vbnc/vbnc/source/General/Helper.vb
index e1e9a1b..73585bc 100755
--- a/vbnc/vbnc/source/General/Helper.vb
+++ b/vbnc/vbnc/source/General/Helper.vb
@@ -1528,7 +1528,7 @@ Public Class Helper
             Helper.Assert(result IsNot Nothing)
         ElseIf CecilHelper.IsGenericType(OpenType) Then
             Dim typeParams As Mono.Collections.Generic.Collection(Of TypeReference)
-            Dim typeArgs As New Mono.Collections.Generic.Collection(Of TypeReference)(Nothing)
+            Dim typeArgs As New Mono.Collections.Generic.Collection(Of TypeReference)
 
             typeParams = CecilHelper.GetGenericArguments(OpenType)
 
diff --git a/vbnc/vbnc/source/General/Version.vb b/vbnc/vbnc/source/General/Version.vb
index e8458fc..318cb67 100644
--- a/vbnc/vbnc/source/General/Version.vb
+++ b/vbnc/vbnc/source/General/Version.vb
@@ -16,4 +16,4 @@
 ' License along with this library; if not, write to the Free Software
 ' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 ' 
-<Assembly: AssemblyInformationalVersion ("3.0 - master/9d3ff8a")>
+<Assembly: AssemblyInformationalVersion ("3.8 - master/763ac58")>
diff --git a/vbnc/vbnc/source/Members/Parameter.vb b/vbnc/vbnc/source/Members/Parameter.vb
index 253e81d..302b2ec 100644
--- a/vbnc/vbnc/source/Members/Parameter.vb
+++ b/vbnc/vbnc/source/Members/Parameter.vb
@@ -187,7 +187,7 @@ Public Class Parameter
 
         Helper.Assert(m_ParameterBuilderCecil Is Nothing)
         m_ParameterBuilderCecil = New Mono.Cecil.ParameterDefinition(Nothing)
-        m_ParameterBuilderCecil.Sequence = -1
+        DirectCast(m_ParameterBuilderCecil, ParameterReference).Sequence = -1
         m_ParameterBuilderCecil.Annotations.Add(Compiler, Me)
         m_ParameterBuilderCecil.ParameterType = Helper.GetTypeOrTypeReference(Compiler, Compiler.TypeCache.System_Void)
 
diff --git a/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb b/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb
index db78d48..5ab8feb 100644
--- a/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb
+++ b/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb
@@ -1133,6 +1133,8 @@ Public Class AssemblyDeclaration
                 Return IsDefinedHere(DirectCast(gp.Owner, Mono.Cecil.TypeDefinition))
             ElseIf TypeOf gp.Owner Is Mono.Cecil.MethodDefinition Then
                 Return IsDefinedHere(DirectCast(gp.Owner, Mono.Cecil.MethodDefinition))
+            ElseIf TypeOf gp.Owner Is Mono.Cecil.MethodReference Then
+                Return IsDefinedHere(DirectCast(gp.Owner, Mono.Cecil.MethodReference))
             Else
                 Throw New NotImplementedException
             End If
diff --git a/vbruntime/Microsoft.VisualBasic/AssemblyInfo.vb b/vbruntime/Microsoft.VisualBasic/AssemblyInfo.vb
index 99b2f66..6187026 100644
--- a/vbruntime/Microsoft.VisualBasic/AssemblyInfo.vb
+++ b/vbruntime/Microsoft.VisualBasic/AssemblyInfo.vb
@@ -66,16 +66,16 @@ Imports System.Security
 <Assembly: AssemblyDefaultAlias("Microsoft.VisualBasic.dll")> 
 #Else
 #If NET_VER >= 4.5 Then
-<Assembly: AssemblyVersion("11.0.0.0")> 
+<Assembly: AssemblyVersion("10.0.0.0")> 
 <Assembly: ComVisible(True)> 
 '<Assembly: Guid("aa353322-85a4-4601-a6b7-e3b724e9350c")> 
 <Assembly: CLSCompliant(True)> 
 <Assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default Or DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)> 
 <Assembly: CompilationRelaxations(CompilationRelaxations.NoStringInterning)> 
 <Assembly: RuntimeCompatibility(WrapNonExceptionThrows:=True)> 
-<Assembly: SatelliteContractVersion("11.0.0.0")> 
-<Assembly: AssemblyInformationalVersion("11.0.30319.17020")> 
-<Assembly: AssemblyFileVersion("11.0.30319.17020")> 
+<Assembly: SatelliteContractVersion("10.0.0.0")> 
+<Assembly: AssemblyInformationalVersion("10.0.30319.17020")> 
+<Assembly: AssemblyFileVersion("10.0.30319.17020")> 
 <Assembly: AssemblyDefaultAlias("Microsoft.VisualBasic.dll")> 
 #ElseIf NET_VER >= 4.0 Then
 <Assembly: AssemblyVersion("10.0.0.0")> 
diff --git a/vbruntime/Test/Makefile b/vbruntime/Test/Makefile
index da15d2e..e291590 100644
--- a/vbruntime/Test/Makefile
+++ b/vbruntime/Test/Makefile
@@ -18,6 +18,7 @@ DISTFILES += $(wildcard *.vb) $(wildcard *.cs) $(wildcard */*.vb) $(wildcard */*
 DISTFILES += $(wildcard bin/*config)
 
 MONO_VB_PATH="../../class/lib/bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH"
+CSCOMPILER=mcs
 
 ifeq ("$(FXVERSION)", "")
 NUNIT_VERSION=2
@@ -26,10 +27,8 @@ NUNIT_VERSION=$(FXVERSION)
 endif
 
 ifeq ("$(NUNIT_VERSION)", "1")
-CSCOMPILER=mcs
 CSDEFINES=-define:NET_1_0,NET_1_1
 else
-CSCOMPILER=gmcs
 CSDEFINES=-define:NET_1_0,NET_1_1,NET_2_0
 endif
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mono/packages/mono-basic.git



More information about the Pkg-mono-svn-commits mailing list