Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Mono.Cecil')
-rw-r--r--Mono.Cecil/ArrayType.cs24
-rw-r--r--Mono.Cecil/AssemblyDefinition.cs30
-rw-r--r--Mono.Cecil/AssemblyFlags.cs25
-rw-r--r--Mono.Cecil/AssemblyHashAlgorithm.cs24
-rw-r--r--Mono.Cecil/AssemblyInfo.cs33
-rw-r--r--Mono.Cecil/AssemblyLinkedResource.cs24
-rw-r--r--Mono.Cecil/AssemblyNameDefinition.cs24
-rw-r--r--Mono.Cecil/AssemblyNameReference.cs47
-rw-r--r--Mono.Cecil/AssemblyReader.cs244
-rw-r--r--Mono.Cecil/AssemblyWriter.cs62
-rw-r--r--Mono.Cecil/BaseAssemblyResolver.cs33
-rw-r--r--Mono.Cecil/CallSite.cs24
-rw-r--r--Mono.Cecil/CustomAttribute.cs59
-rw-r--r--Mono.Cecil/DefaultAssemblyResolver.cs26
-rw-r--r--Mono.Cecil/EmbeddedResource.cs47
-rw-r--r--Mono.Cecil/EventAttributes.cs24
-rw-r--r--Mono.Cecil/EventDefinition.cs49
-rw-r--r--Mono.Cecil/EventReference.cs24
-rw-r--r--Mono.Cecil/ExportedType.cs35
-rw-r--r--Mono.Cecil/FieldAttributes.cs24
-rw-r--r--Mono.Cecil/FieldDefinition.cs43
-rw-r--r--Mono.Cecil/FieldReference.cs26
-rw-r--r--Mono.Cecil/FileAttributes.cs24
-rw-r--r--Mono.Cecil/FunctionPointerType.cs27
-rw-r--r--Mono.Cecil/GenericInstanceMethod.cs26
-rw-r--r--Mono.Cecil/GenericInstanceType.cs26
-rw-r--r--Mono.Cecil/GenericParameter.cs50
-rw-r--r--Mono.Cecil/GenericParameterAttributes.cs24
-rw-r--r--Mono.Cecil/IConstantProvider.cs40
-rw-r--r--Mono.Cecil/ICustomAttributeProvider.cs30
-rw-r--r--Mono.Cecil/IGenericInstance.cs24
-rw-r--r--Mono.Cecil/IGenericParameterProvider.cs29
-rw-r--r--Mono.Cecil/IMarshalInfoProvider.cs27
-rw-r--r--Mono.Cecil/IMemberDefinition.cs24
-rw-r--r--Mono.Cecil/IMetadataScope.cs24
-rw-r--r--Mono.Cecil/IMetadataTokenProvider.cs24
-rw-r--r--Mono.Cecil/IMethodSignature.cs29
-rw-r--r--Mono.Cecil/Import.cs365
-rw-r--r--Mono.Cecil/LinkedResource.cs24
-rw-r--r--Mono.Cecil/ManifestResourceAttributes.cs24
-rw-r--r--Mono.Cecil/MarshalInfo.cs24
-rw-r--r--Mono.Cecil/MemberDefinitionCollection.cs24
-rw-r--r--Mono.Cecil/MemberReference.cs26
-rw-r--r--Mono.Cecil/MetadataResolver.cs47
-rw-r--r--Mono.Cecil/MetadataSystem.cs83
-rw-r--r--Mono.Cecil/MethodAttributes.cs24
-rw-r--r--Mono.Cecil/MethodCallingConvention.cs24
-rw-r--r--Mono.Cecil/MethodDefinition.cs73
-rw-r--r--Mono.Cecil/MethodImplAttributes.cs24
-rw-r--r--Mono.Cecil/MethodReference.cs26
-rw-r--r--Mono.Cecil/MethodReturnType.cs34
-rw-r--r--Mono.Cecil/MethodSemanticsAttributes.cs24
-rw-r--r--Mono.Cecil/MethodSpecification.cs26
-rw-r--r--Mono.Cecil/Modifiers.cs28
-rw-r--r--Mono.Cecil/ModuleDefinition.cs436
-rw-r--r--Mono.Cecil/ModuleKind.cs36
-rw-r--r--Mono.Cecil/ModuleReference.cs24
-rw-r--r--Mono.Cecil/NativeType.cs24
-rw-r--r--Mono.Cecil/PInvokeAttributes.cs24
-rw-r--r--Mono.Cecil/PInvokeInfo.cs24
-rw-r--r--Mono.Cecil/ParameterAttributes.cs24
-rw-r--r--Mono.Cecil/ParameterDefinition.cs46
-rw-r--r--Mono.Cecil/ParameterDefinitionCollection.cs24
-rw-r--r--Mono.Cecil/ParameterReference.cs24
-rw-r--r--Mono.Cecil/PinnedType.cs24
-rw-r--r--Mono.Cecil/PointerType.cs24
-rw-r--r--Mono.Cecil/PropertyAttributes.cs24
-rw-r--r--Mono.Cecil/PropertyDefinition.cs51
-rw-r--r--Mono.Cecil/PropertyReference.cs24
-rw-r--r--Mono.Cecil/ReferenceType.cs24
-rw-r--r--Mono.Cecil/Resource.cs24
-rw-r--r--Mono.Cecil/SecurityDeclaration.cs29
-rw-r--r--Mono.Cecil/SentinelType.cs24
-rw-r--r--Mono.Cecil/TargetRuntime.cs24
-rw-r--r--Mono.Cecil/TypeAttributes.cs25
-rw-r--r--Mono.Cecil/TypeDefinition.cs100
-rw-r--r--Mono.Cecil/TypeDefinitionCollection.cs24
-rw-r--r--Mono.Cecil/TypeParser.cs62
-rw-r--r--Mono.Cecil/TypeReference.cs96
-rw-r--r--Mono.Cecil/TypeSpecification.cs31
-rw-r--r--Mono.Cecil/TypeSystem.cs126
-rw-r--r--Mono.Cecil/VariantType.cs24
82 files changed, 1433 insertions, 2292 deletions
diff --git a/Mono.Cecil/ArrayType.cs b/Mono.Cecil/ArrayType.cs
index 55c59d8..010049c 100644
--- a/Mono.Cecil/ArrayType.cs
+++ b/Mono.Cecil/ArrayType.cs
@@ -1,29 +1,11 @@
//
-// ArrayType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/AssemblyDefinition.cs b/Mono.Cecil/AssemblyDefinition.cs
index 70929b7..e49f7da 100644
--- a/Mono.Cecil/AssemblyDefinition.cs
+++ b/Mono.Cecil/AssemblyDefinition.cs
@@ -1,29 +1,11 @@
//
-// AssemblyDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -62,7 +44,7 @@ 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> (1) { main_module };
}
@@ -87,7 +69,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 +82,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/Mono.Cecil/AssemblyFlags.cs b/Mono.Cecil/AssemblyFlags.cs
index e466e78..6ca5bc2 100644
--- a/Mono.Cecil/AssemblyFlags.cs
+++ b/Mono.Cecil/AssemblyFlags.cs
@@ -1,29 +1,11 @@
//
-// AssemblyFlags.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -35,6 +17,7 @@ namespace Mono.Cecil {
PublicKey = 0x0001,
SideBySideCompatible = 0x0000,
Retargetable = 0x0100,
+ WindowsRuntime = 0x0200,
DisableJITCompileOptimizer = 0x4000,
EnableJITCompileTracking = 0x8000,
}
diff --git a/Mono.Cecil/AssemblyHashAlgorithm.cs b/Mono.Cecil/AssemblyHashAlgorithm.cs
index 79a5699..66ef4cb 100644
--- a/Mono.Cecil/AssemblyHashAlgorithm.cs
+++ b/Mono.Cecil/AssemblyHashAlgorithm.cs
@@ -1,29 +1,11 @@
//
-// AssemblyHashAlgorithm.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/AssemblyInfo.cs b/Mono.Cecil/AssemblyInfo.cs
index 8a9f809..40cc0d4 100644
--- a/Mono.Cecil/AssemblyInfo.cs
+++ b/Mono.Cecil/AssemblyInfo.cs
@@ -1,29 +1,11 @@
//
-// AssemblyInfo.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System.Reflection;
@@ -31,18 +13,9 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle ("Mono.Cecil")]
-[assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("Copyright © 2008 - 2011 Jb Evain")]
-
-[assembly: ComVisible (false)]
[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
-[assembly: AssemblyVersion ("0.9.5.0")]
-#if !CF
-[assembly: AssemblyFileVersion ("0.9.5.0")]
-#endif
-
[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
diff --git a/Mono.Cecil/AssemblyLinkedResource.cs b/Mono.Cecil/AssemblyLinkedResource.cs
index 4d8bac0..f4896bd 100644
--- a/Mono.Cecil/AssemblyLinkedResource.cs
+++ b/Mono.Cecil/AssemblyLinkedResource.cs
@@ -1,29 +1,11 @@
//
-// AssemblyLinkedResource.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/AssemblyNameDefinition.cs b/Mono.Cecil/AssemblyNameDefinition.cs
index dc6b905..2511d79 100644
--- a/Mono.Cecil/AssemblyNameDefinition.cs
+++ b/Mono.Cecil/AssemblyNameDefinition.cs
@@ -1,29 +1,11 @@
//
-// AssemblyNameDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/AssemblyNameReference.cs b/Mono.Cecil/AssemblyNameReference.cs
index 31b7a30..c61c336 100644
--- a/Mono.Cecil/AssemblyNameReference.cs
+++ b/Mono.Cecil/AssemblyNameReference.cs
@@ -1,29 +1,11 @@
//
-// AssemblyNameReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -92,8 +74,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 +94,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 +158,10 @@ namespace Mono.Cecil {
builder.Append (sep);
builder.Append ("PublicKeyToken=");
- if (this.PublicKeyToken != null && public_key_token.Length > 0) {
- for (int i = 0 ; i < public_key_token.Length ; i++) {
- builder.Append (public_key_token [i].ToString ("x2"));
+ var pk_token = PublicKeyToken;
+ if (!pk_token.IsNullOrEmpty () && pk_token.Length > 0) {
+ for (int i = 0 ; i < pk_token.Length ; i++) {
+ builder.Append (pk_token [i].ToString ("x2"));
}
} else
builder.Append ("null");
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index 9b9669c..ec78a52 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -1,29 +1,11 @@
//
-// AssemblyReader.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -78,15 +60,27 @@ namespace Mono.Cecil {
public static ModuleDefinition CreateModuleFrom (Image image, ReaderParameters parameters)
{
- var module = ReadModule (image, parameters);
+ var reader = CreateModuleReader (image, parameters.ReadingMode);
+ var module = reader.module;
- ReadSymbols (module, parameters);
+ if (parameters.assembly_resolver != null)
+ module.assembly_resolver = parameters.assembly_resolver;
+
+ if (parameters.metadata_resolver != null)
+ module.metadata_resolver = parameters.metadata_resolver;
- if (parameters.AssemblyResolver != null)
- module.assembly_resolver = parameters.AssemblyResolver;
+#if !READ_ONLY
+ if (parameters.metadata_importer_provider != null)
+ module.metadata_importer = parameters.metadata_importer_provider.GetMetadataImporter (module);
+#if !CF
+ if (parameters.reflection_importer_provider != null)
+ module.reflection_importer = parameters.reflection_importer_provider.GetReflectionImporter (module);
+#endif
+#endif
- if (parameters.MetadataResolver != null)
- module.metadata_resolver = parameters.MetadataResolver;
+ reader.ReadModule ();
+
+ ReadSymbols (module, parameters);
return module;
}
@@ -109,13 +103,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) {
@@ -165,7 +152,7 @@ namespace Mono.Cecil {
return;
if (assembly.HasCustomAttributes)
- Read (assembly.CustomAttributes);
+ ReadCustomAttributes (assembly);
if (assembly.HasSecurityDeclarations)
Read (assembly.SecurityDeclarations);
}
@@ -218,21 +205,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)
@@ -550,6 +552,7 @@ namespace Mono.Cecil {
var parameters = new ReaderParameters {
ReadingMode = module.ReadingMode,
SymbolReaderProvider = module.SymbolReaderProvider,
+ AssemblyResolver = module.AssemblyResolver
};
modules.Add (ModuleDefinition.ReadModule (
@@ -768,8 +771,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);
@@ -1023,25 +1030,36 @@ namespace Mono.Cecil {
type.scope = scope;
type.DeclaringType = declaring_type;
- MetadataSystem.TryProcessPrimitiveType (type);
+ MetadataSystem.TryProcessPrimitiveTypeReference (type);
return type;
}
IMetadataScope GetTypeReferenceScope (MetadataToken scope)
{
+ if (scope.TokenType == TokenType.Module)
+ return module;
+
+ IMetadataScope[] scopes;
+
switch (scope.TokenType) {
case TokenType.AssemblyRef:
InitializeAssemblyReferences ();
- return metadata.AssemblyReferences [(int) scope.RID - 1];
+ scopes = metadata.AssemblyReferences;
+ break;
case TokenType.ModuleRef:
InitializeModuleReferences ();
- return metadata.ModuleReferences [(int) scope.RID - 1];
- case TokenType.Module:
- return module;
+ 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 ()
@@ -1243,8 +1261,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;
@@ -1591,10 +1609,11 @@ namespace Mono.Cecil {
var methods = type.Methods;
for (int i = 0; i < methods.Count; i++) {
var method = methods [i];
- if (method.sem_attrs.HasValue)
+ if (method.sem_attrs_ready)
continue;
method.sem_attrs = ReadMethodSemantics (method);
+ method.sem_attrs_ready = true;
}
}
@@ -1768,25 +1787,35 @@ namespace Mono.Cecil {
{
InitializeGenericParameters ();
- Range range;
- if (!metadata.TryGetGenericParameterRange (provider, out range))
+ Range [] ranges;
+ if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
return false;
- return range.Length > 0;
+ return RangesSize (ranges) > 0;
}
public Collection<GenericParameter> ReadGenericParameters (IGenericParameterProvider provider)
{
InitializeGenericParameters ();
- Range range;
- if (!metadata.TryGetGenericParameterRange (provider, out range)
- || !MoveTo (Table.GenericParam, range.Start))
+ Range [] ranges;
+ if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
return new GenericParameterCollection (provider);
metadata.RemoveGenericParameterRange (provider);
- var generic_parameters = new GenericParameterCollection (provider, (int) range.Length);
+ var generic_parameters = new GenericParameterCollection (provider, RangesSize (ranges));
+
+ for (int i = 0; i < ranges.Length; i++)
+ ReadGenericParametersRange (ranges [i], provider, generic_parameters);
+
+ return generic_parameters;
+ }
+
+ void ReadGenericParametersRange (Range range, IGenericParameterProvider provider, GenericParameterCollection generic_parameters)
+ {
+ if (!MoveTo (Table.GenericParam, range.Start))
+ return;
for (uint i = 0; i < range.Length; i++) {
ReadUInt16 (); // index
@@ -1800,8 +1829,6 @@ namespace Mono.Cecil {
generic_parameters.Add (parameter);
}
-
- return generic_parameters;
}
void InitializeGenericParameters ()
@@ -1818,10 +1845,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;
@@ -1836,20 +1863,34 @@ namespace Mono.Cecil {
owner = next;
range.Length++;
} else if (next != owner) {
- if (owner.RID != 0)
- ranges.Add (owner, range);
+ AddRange (ranges, owner, range);
range = new Range (i, 1);
owner = next;
} else
range.Length++;
}
- if (owner != MetadataToken.Zero && !ranges.ContainsKey (owner))
- ranges.Add (owner, range);
+ AddRange (ranges, owner, range);
return ranges;
}
+ static void AddRange (Dictionary<MetadataToken, Range []> ranges, MetadataToken owner, Range range)
+ {
+ if (owner.RID == 0)
+ return;
+
+ Range [] slots;
+ if (!ranges.TryGetValue (owner, out slots)) {
+ ranges.Add (owner, new [] { range });
+ return;
+ }
+
+ slots = slots.Resize (slots.Length + 1);
+ slots [slots.Length - 1] = range;
+ ranges [owner] = slots;
+ }
+
public bool HasGenericConstraints (GenericParameter generic_parameter)
{
InitializeGenericConstraints ();
@@ -2313,23 +2354,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);
@@ -2341,10 +2394,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)
@@ -2355,8 +2413,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)
@@ -2432,23 +2494,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 ();
@@ -2457,10 +2531,6 @@ namespace Mono.Cecil {
security_declarations.Add (new SecurityDeclaration (action, signature, module));
}
-
- metadata.RemoveSecurityDeclarationRange (owner);
-
- return security_declarations;
}
public byte [] ReadSecurityDeclarationBlob (uint signature)
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs
index 9e597ca..4b0d919 100644
--- a/Mono.Cecil/AssemblyWriter.cs
+++ b/Mono.Cecil/AssemblyWriter.cs
@@ -1,29 +1,11 @@
//
-// AssemblyWriter.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -82,7 +64,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 +79,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);
@@ -789,7 +769,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;
}
@@ -1180,9 +1160,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),
@@ -1190,6 +1168,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);
@@ -1645,6 +1636,11 @@ namespace Mono.Cecil {
case ElementType.Var:
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:
diff --git a/Mono.Cecil/BaseAssemblyResolver.cs b/Mono.Cecil/BaseAssemblyResolver.cs
index 10ab2c3..8a11182 100644
--- a/Mono.Cecil/BaseAssemblyResolver.cs
+++ b/Mono.Cecil/BaseAssemblyResolver.cs
@@ -1,29 +1,11 @@
//
-// BaseAssemblyResolver.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -150,6 +132,13 @@ namespace Mono.Cecil {
return assembly;
#if !SILVERLIGHT && !CF
+ if (name.IsRetargetable) {
+ // if the reference is retargetable, zero it
+ name = new AssemblyNameReference (name.Name, new Version (0, 0, 0, 0)) {
+ PublicKeyToken = Empty<byte>.Array,
+ };
+ }
+
var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
if (IsZero (name.Version)) {
@@ -328,7 +317,7 @@ namespace Mono.Cecil {
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++) {
diff --git a/Mono.Cecil/CallSite.cs b/Mono.Cecil/CallSite.cs
index 2d4ed41..ebb108f 100644
--- a/Mono.Cecil/CallSite.cs
+++ b/Mono.Cecil/CallSite.cs
@@ -1,29 +1,11 @@
//
-// CallSite.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/CustomAttribute.cs b/Mono.Cecil/CustomAttribute.cs
index 310f725..33c92f5 100644
--- a/Mono.Cecil/CustomAttribute.cs
+++ b/Mono.Cecil/CustomAttribute.cs
@@ -1,29 +1,11 @@
//
-// CustomAttribute.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -188,10 +170,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 ()
@@ -199,23 +181,22 @@ namespace Mono.Cecil {
if (resolved || !HasImage)
return;
- try {
- Module.Read (this, (attribute, reader) => {
+ Module.Read (this, (attribute, reader) => {
+ try {
reader.ReadCustomAttributeSignature (attribute);
- return this;
- });
-
- resolved = true;
- } catch (ResolutionException) {
- if (arguments != null)
- arguments.Clear ();
- if (fields != null)
- fields.Clear ();
- if (properties != null)
- properties.Clear ();
-
- resolved = false;
- }
+ resolved = true;
+ } catch (ResolutionException) {
+ if (arguments != null)
+ arguments.Clear ();
+ if (fields != null)
+ fields.Clear ();
+ if (properties != null)
+ properties.Clear ();
+
+ resolved = false;
+ }
+ return this;
+ });
}
}
diff --git a/Mono.Cecil/DefaultAssemblyResolver.cs b/Mono.Cecil/DefaultAssemblyResolver.cs
index 460ea5c..eb87277 100644
--- a/Mono.Cecil/DefaultAssemblyResolver.cs
+++ b/Mono.Cecil/DefaultAssemblyResolver.cs
@@ -1,29 +1,11 @@
//
-// DefaultAssemblyResolver.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -39,7 +21,7 @@ namespace Mono.Cecil {
public DefaultAssemblyResolver ()
{
- cache = new Dictionary<string, AssemblyDefinition> ();
+ cache = new Dictionary<string, AssemblyDefinition> (StringComparer.Ordinal);
}
public override AssemblyDefinition Resolve (AssemblyNameReference name)
diff --git a/Mono.Cecil/EmbeddedResource.cs b/Mono.Cecil/EmbeddedResource.cs
index e12dd0b..3da8692 100644
--- a/Mono.Cecil/EmbeddedResource.cs
+++ b/Mono.Cecil/EmbeddedResource.cs
@@ -1,29 +1,11 @@
//
-// EmbeddedResource.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -92,14 +74,25 @@ namespace Mono.Cecil {
static byte [] ReadStream (Stream stream)
{
- var length = (int) stream.Length;
- var data = new byte [length];
- int offset = 0, read;
+ 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;
+ }
- while ((read = stream.Read (data, offset, length - offset)) > 0)
- offset += read;
+ 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 data;
+ return memory.ToArray ();
}
}
}
diff --git a/Mono.Cecil/EventAttributes.cs b/Mono.Cecil/EventAttributes.cs
index 815efa5..9f823fd 100644
--- a/Mono.Cecil/EventAttributes.cs
+++ b/Mono.Cecil/EventAttributes.cs
@@ -1,29 +1,11 @@
//
-// EventAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/EventDefinition.cs b/Mono.Cecil/EventDefinition.cs
index 565186c..33bc341 100644
--- a/Mono.Cecil/EventDefinition.cs
+++ b/Mono.Cecil/EventDefinition.cs
@@ -1,29 +1,11 @@
//
-// EventDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using Mono.Collections.Generic;
@@ -113,7 +95,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 +106,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 +130,21 @@ 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 ()
diff --git a/Mono.Cecil/EventReference.cs b/Mono.Cecil/EventReference.cs
index 8952002..3c3fca0 100644
--- a/Mono.Cecil/EventReference.cs
+++ b/Mono.Cecil/EventReference.cs
@@ -1,29 +1,11 @@
//
-// EventReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/ExportedType.cs b/Mono.Cecil/ExportedType.cs
index c25f8d0..c068e8e 100644
--- a/Mono.Cecil/ExportedType.cs
+++ b/Mono.Cecil/ExportedType.cs
@@ -1,29 +1,11 @@
//
-// ExportedType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -211,13 +193,14 @@ 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;
}
}
diff --git a/Mono.Cecil/FieldAttributes.cs b/Mono.Cecil/FieldAttributes.cs
index dd6bf36..7d5bb54 100644
--- a/Mono.Cecil/FieldAttributes.cs
+++ b/Mono.Cecil/FieldAttributes.cs
@@ -1,29 +1,11 @@
//
-// FieldAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/FieldDefinition.cs b/Mono.Cecil/FieldDefinition.cs
index 29a1bc1..4194707 100644
--- a/Mono.Cecil/FieldDefinition.cs
+++ b/Mono.Cecil/FieldDefinition.cs
@@ -1,29 +1,11 @@
//
-// FieldDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using Mono.Collections.Generic;
@@ -114,7 +96,10 @@ namespace Mono.Cecil {
return initial_value;
}
- set { initial_value = value; }
+ set {
+ initial_value = value;
+ rva = 0;
+ }
}
public FieldAttributes Attributes {
@@ -124,7 +109,7 @@ namespace Mono.Cecil {
public bool HasConstant {
get {
- ResolveConstant ();
+ this.ResolveConstant (ref constant, Module);
return constant != Mixin.NoValue;
}
@@ -136,14 +121,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 +131,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 +144,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/Mono.Cecil/FieldReference.cs b/Mono.Cecil/FieldReference.cs
index be58d3d..6fa0f07 100644
--- a/Mono.Cecil/FieldReference.cs
+++ b/Mono.Cecil/FieldReference.cs
@@ -1,29 +1,11 @@
//
-// FieldReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -43,7 +25,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/Mono.Cecil/FileAttributes.cs b/Mono.Cecil/FileAttributes.cs
index 4d3b6ca..171f174 100644
--- a/Mono.Cecil/FileAttributes.cs
+++ b/Mono.Cecil/FileAttributes.cs
@@ -1,29 +1,11 @@
//
-// FileAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/FunctionPointerType.cs b/Mono.Cecil/FunctionPointerType.cs
index db80f76..0602fcb 100644
--- a/Mono.Cecil/FunctionPointerType.cs
+++ b/Mono.Cecil/FunctionPointerType.cs
@@ -1,29 +1,11 @@
//
-// FunctionPointerType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -85,13 +67,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; }
}
diff --git a/Mono.Cecil/GenericInstanceMethod.cs b/Mono.Cecil/GenericInstanceMethod.cs
index dbe720d..00de03a 100644
--- a/Mono.Cecil/GenericInstanceMethod.cs
+++ b/Mono.Cecil/GenericInstanceMethod.cs
@@ -1,29 +1,11 @@
//
-// GenericInstanceMethod.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -57,7 +39,7 @@ namespace Mono.Cecil {
get { return ElementMethod.DeclaringType; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
}
diff --git a/Mono.Cecil/GenericInstanceType.cs b/Mono.Cecil/GenericInstanceType.cs
index 6554ff0..0e683e7 100644
--- a/Mono.Cecil/GenericInstanceType.cs
+++ b/Mono.Cecil/GenericInstanceType.cs
@@ -1,29 +1,11 @@
//
-// GenericInstanceType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -65,7 +47,7 @@ namespace Mono.Cecil {
get { return true; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
}
diff --git a/Mono.Cecil/GenericParameter.cs b/Mono.Cecil/GenericParameter.cs
index d694e29..24024d2 100644
--- a/Mono.Cecil/GenericParameter.cs
+++ b/Mono.Cecil/GenericParameter.cs
@@ -1,29 +1,11 @@
//
-// GenericParameter.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -66,10 +48,7 @@ namespace Mono.Cecil {
if (constraints != null)
return constraints.Count > 0;
- if (HasImage)
- return Module.Read (this, (generic_parameter, reader) => reader.HasGenericConstraints (generic_parameter));
-
- return false;
+ return HasImage && Module.Read (this, (generic_parameter, reader) => reader.HasGenericConstraints (generic_parameter));
}
}
@@ -79,7 +58,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> ();
}
@@ -95,7 +74,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 IMetadataScope Scope {
@@ -107,6 +86,16 @@ namespace Mono.Cecil {
? ((MethodReference) owner).DeclaringType.Scope
: ((TypeReference) owner).Scope;
}
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override TypeReference DeclaringType {
+ get { return owner as TypeReference; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public MethodReference DeclaringMethod {
+ get { return owner as MethodReference; }
}
public override ModuleDefinition Module {
@@ -135,7 +124,7 @@ namespace Mono.Cecil {
get { return true; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return true; }
}
@@ -192,9 +181,11 @@ namespace Mono.Cecil {
this.owner = owner;
this.type = owner.GenericParameterType;
this.etype = ConvertGenericParameterType (this.type);
+ this.token = new MetadataToken (TokenType.GenericParam);
+
}
- public GenericParameter (int position, GenericParameterType type, ModuleDefinition module)
+ internal GenericParameter (int position, GenericParameterType type, ModuleDefinition module)
: base (string.Empty, string.Empty)
{
if (module == null)
@@ -204,6 +195,7 @@ namespace Mono.Cecil {
this.type = type;
this.etype = ConvertGenericParameterType (type);
this.module = module;
+ this.token = new MetadataToken (TokenType.GenericParam);
}
static ElementType ConvertGenericParameterType (GenericParameterType type)
diff --git a/Mono.Cecil/GenericParameterAttributes.cs b/Mono.Cecil/GenericParameterAttributes.cs
index 6d77956..149582c 100644
--- a/Mono.Cecil/GenericParameterAttributes.cs
+++ b/Mono.Cecil/GenericParameterAttributes.cs
@@ -1,29 +1,11 @@
//
-// GenericParameterAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/IConstantProvider.cs b/Mono.Cecil/IConstantProvider.cs
index 8bcd7d7..178b665 100644
--- a/Mono.Cecil/IConstantProvider.cs
+++ b/Mono.Cecil/IConstantProvider.cs
@@ -1,29 +1,11 @@
//
-// IConstantProvider.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
@@ -44,9 +26,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/Mono.Cecil/ICustomAttributeProvider.cs b/Mono.Cecil/ICustomAttributeProvider.cs
index 916ba0f..36d7ed0 100644
--- a/Mono.Cecil/ICustomAttributeProvider.cs
+++ b/Mono.Cecil/ICustomAttributeProvider.cs
@@ -1,33 +1,14 @@
//
-// ICustomAttributeProvider.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
-
using Mono.Collections.Generic;
namespace Mono.Cecil {
@@ -50,11 +31,12 @@ namespace Mono.Cecil {
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/Mono.Cecil/IGenericInstance.cs b/Mono.Cecil/IGenericInstance.cs
index edc406c..e98d818 100644
--- a/Mono.Cecil/IGenericInstance.cs
+++ b/Mono.Cecil/IGenericInstance.cs
@@ -1,29 +1,11 @@
//
-// IGenericInstance.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System.Text;
diff --git a/Mono.Cecil/IGenericParameterProvider.cs b/Mono.Cecil/IGenericParameterProvider.cs
index d41b7f6..4c8dfc4 100644
--- a/Mono.Cecil/IGenericParameterProvider.cs
+++ b/Mono.Cecil/IGenericParameterProvider.cs
@@ -1,29 +1,11 @@
//
-// IGenericParameterProvider.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
@@ -63,11 +45,12 @@ namespace Mono.Cecil {
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 GenericParameterCollection (self);
+ ? module.Read (ref collection, self, (provider, reader) => reader.ReadGenericParameters (provider))
+ : collection = new GenericParameterCollection (self);
}
}
}
diff --git a/Mono.Cecil/IMarshalInfoProvider.cs b/Mono.Cecil/IMarshalInfoProvider.cs
index 67a53a3..a1b9e88 100644
--- a/Mono.Cecil/IMarshalInfoProvider.cs
+++ b/Mono.Cecil/IMarshalInfoProvider.cs
@@ -1,29 +1,11 @@
//
-// IMarshalInfoProvider.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
@@ -45,10 +27,11 @@ namespace Mono.Cecil {
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/Mono.Cecil/IMemberDefinition.cs b/Mono.Cecil/IMemberDefinition.cs
index ee73d9d..ad74700 100644
--- a/Mono.Cecil/IMemberDefinition.cs
+++ b/Mono.Cecil/IMemberDefinition.cs
@@ -1,29 +1,11 @@
//
-// IMemberDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/IMetadataScope.cs b/Mono.Cecil/IMetadataScope.cs
index 04a0228..2e56e75 100644
--- a/Mono.Cecil/IMetadataScope.cs
+++ b/Mono.Cecil/IMetadataScope.cs
@@ -1,29 +1,11 @@
//
-// IMetadataScope.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/IMetadataTokenProvider.cs b/Mono.Cecil/IMetadataTokenProvider.cs
index 6621835..dcd678b 100644
--- a/Mono.Cecil/IMetadataTokenProvider.cs
+++ b/Mono.Cecil/IMetadataTokenProvider.cs
@@ -1,29 +1,11 @@
//
-// IMetadataTokenProvider.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/IMethodSignature.cs b/Mono.Cecil/IMethodSignature.cs
index 491deec..4d7766e 100644
--- a/Mono.Cecil/IMethodSignature.cs
+++ b/Mono.Cecil/IMethodSignature.cs
@@ -1,29 +1,11 @@
//
-// IMethodSignature.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System.Text;
@@ -46,6 +28,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/Mono.Cecil/Import.cs b/Mono.Cecil/Import.cs
index 2a8293c..4ac2180 100644
--- a/Mono.Cecil/Import.cs
+++ b/Mono.Cecil/Import.cs
@@ -1,54 +1,141 @@
//
-// Import.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
using System.Collections.Generic;
+using Mono.Collections.Generic;
using SR = System.Reflection;
using Mono.Cecil.Metadata;
namespace Mono.Cecil {
- enum ImportGenericKind {
- Definition,
- Open,
+#if !READ_ONLY
+
+ public interface IMetadataImporterProvider {
+ IMetadataImporter GetMetadataImporter (ModuleDefinition module);
}
- class MetadataImporter {
+ public interface IMetadataImporter {
+ TypeReference ImportReference (TypeReference type, IGenericParameterProvider context);
+ FieldReference ImportReference (FieldReference field, IGenericParameterProvider context);
+ MethodReference ImportReference (MethodReference method, IGenericParameterProvider context);
+ }
+
+#if !CF
+
+ public interface IReflectionImporterProvider {
+ IReflectionImporter GetReflectionImporter (ModuleDefinition module);
+ }
+
+ public interface IReflectionImporter {
+ TypeReference ImportReference (Type type, IGenericParameterProvider context);
+ FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context);
+ MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context);
+ }
+#endif
+
+ struct ImportGenericContext {
+
+ Collection<IGenericParameterProvider> stack;
+
+ public bool IsEmpty { get { return stack == null; } }
+
+ public ImportGenericContext (IGenericParameterProvider provider)
+ {
+ if (provider == null)
+ throw new ArgumentNullException ("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 ();
+ }
+
+ public static ImportGenericContext For (IGenericParameterProvider context)
+ {
+ return context != null ? new ImportGenericContext (context) : default (ImportGenericContext);
+ }
+ }
+
+
+#if !CF
+ public class ReflectionImporter : IReflectionImporter {
readonly ModuleDefinition module;
- public MetadataImporter (ModuleDefinition module)
+ public ReflectionImporter (ModuleDefinition module)
{
this.module = module;
}
-#if !CF
+ enum ImportGenericKind {
+ Definition,
+ Open,
+ }
+
static readonly Dictionary<Type, ElementType> type_etype_mapping = new Dictionary<Type, ElementType> (18) {
{ typeof (void), ElementType.Void },
{ typeof (bool), ElementType.Boolean },
@@ -70,12 +157,12 @@ namespace Mono.Cecil {
{ typeof (object), ElementType.Object },
};
- public TypeReference ImportType (Type type, IGenericContext context)
+ TypeReference ImportType (Type type, ImportGenericContext context)
{
return ImportType (type, context, ImportGenericKind.Open);
}
- public TypeReference ImportType (Type type, IGenericContext context, ImportGenericKind import_kind)
+ TypeReference ImportType (Type type, ImportGenericContext context, ImportGenericKind import_kind)
{
if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind))
return ImportTypeSpecification (type, context);
@@ -92,7 +179,7 @@ namespace Mono.Cecil {
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 +206,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 +226,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();
+ }
- return owner.GenericParameters [type.GenericParameterPosition];
+ private static string NormalizedFullName (Type type)
+ {
+ if (IsNestedType (type))
+ return NormalizedFullName (type.DeclaringType) + "/" + type.Name;
+
+ 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 +336,23 @@ namespace Mono.Cecil {
}
#endif
- public FieldReference ImportField (SR.FieldInfo field, IGenericContext context)
+ 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 +367,7 @@ namespace Mono.Cecil {
#endif
}
- public MethodReference ImportMethod (SR.MethodBase method, IGenericContext context, ImportGenericKind import_kind)
+ MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind)
{
if (IsMethodSpecification (method) || ImportOpenGenericMethod (method, import_kind))
return ImportMethodSpecification (method, context);
@@ -286,21 +390,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 +425,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,19 +436,58 @@ 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)
{
return (method.CallingConvention & conventions) != 0;
}
+
+ public virtual TypeReference ImportReference (Type type, IGenericParameterProvider context)
+ {
+ Mixin.CheckType (type);
+ return ImportType (
+ type,
+ ImportGenericContext.For (context),
+ context != null ? ImportGenericKind.Open : ImportGenericKind.Definition);
+ }
+
+ public virtual FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context)
+ {
+ Mixin.CheckField (field);
+ return ImportField (field, ImportGenericContext.For (context));
+ }
+
+ public virtual MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context)
+ {
+ Mixin.CheckMethod (method);
+ return ImportMethod (method,
+ ImportGenericContext.For (context),
+ context != null ? ImportGenericKind.Open : ImportGenericKind.Definition);
+ }
+ }
+
#endif
- public TypeReference ImportType (TypeReference type, IGenericContext context)
+ public class MetadataImporter : IMetadataImporter {
+
+ readonly ModuleDefinition module;
+
+ public MetadataImporter (ModuleDefinition module)
+ {
+ this.module = module;
+ }
+
+ TypeReference ImportType (TypeReference type, ImportGenericContext context)
{
if (type.IsTypeSpecification ())
return ImportTypeSpecification (type, context);
@@ -351,7 +499,7 @@ namespace Mono.Cecil {
ImportScope (type.Scope),
type.IsValueType);
- MetadataSystem.TryProcessPrimitiveType (reference);
+ MetadataSystem.TryProcessPrimitiveTypeReference (reference);
if (type.IsNested)
reference.DeclaringType = ImportType (type.DeclaringType, context);
@@ -368,6 +516,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 ();
@@ -385,6 +534,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 ()
@@ -427,7 +577,7 @@ namespace Mono.Cecil {
imported_parameters.Add (new GenericParameter (parameters [i].Name, imported));
}
- TypeReference ImportTypeSpecification (TypeReference type, IGenericContext context)
+ TypeReference ImportTypeSpecification (TypeReference type, ImportGenericContext context)
{
switch (type.etype) {
case ElementType.SzArray:
@@ -486,32 +636,37 @@ namespace Mono.Cecil {
return imported_instance;
case ElementType.Var:
- if (context == null || context.Type == null)
+ var var_parameter = (GenericParameter) type;
+ if (var_parameter.DeclaringType == null)
throw new InvalidOperationException ();
-
- return ((TypeReference) context.Type).GetElementType ().GenericParameters [((GenericParameter) type).Position];
+ return context.TypeParameter (var_parameter.DeclaringType.FullName, var_parameter.Position);
case ElementType.MVar:
- if (context == null || context.Method == null)
+ var mvar_parameter = (GenericParameter) type;
+ if (mvar_parameter.DeclaringMethod == null)
throw new InvalidOperationException ();
-
- return context.Method.GenericParameters [((GenericParameter) type).Position];
+ return context.MethodParameter (mvar_parameter.DeclaringMethod.Name, mvar_parameter.Position);
}
throw new NotSupportedException (type.etype.ToString ());
}
- public FieldReference ImportField (FieldReference field, IGenericContext context)
+ 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)
+ MethodReference ImportMethod (MethodReference method, ImportGenericContext context)
{
if (method.IsGenericInstance)
return ImportMethodSpecification (method, context);
@@ -523,29 +678,33 @@ namespace Mono.Cecil {
HasThis = method.HasThis,
ExplicitThis = method.ExplicitThis,
DeclaringType = declaring_type,
+ CallingConvention = method.CallingConvention,
};
- reference.CallingConvention = method.CallingConvention;
-
if (method.HasGenericParameters)
ImportGenericParameters (reference, method);
- reference.ReturnType = ImportType (method.ReturnType, context ?? reference);
+ context.Push (reference);
+ try {
+ reference.ReturnType = ImportType (method.ReturnType, context);
- if (!method.HasParameters)
- return reference;
+ if (!method.HasParameters)
+ return reference;
- var reference_parameters = reference.Parameters;
+ var reference_parameters = reference.Parameters;
- var parameters = method.Parameters;
- for (int i = 0; i < parameters.Count; i++)
- reference_parameters.Add (
- new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference)));
+ var parameters = method.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
+ reference_parameters.Add (
+ new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
- return reference;
+ return reference;
+ } finally {
+ context.Pop();
+ }
}
- MethodSpecification ImportMethodSpecification (MethodReference method, IGenericContext context)
+ MethodSpecification ImportMethodSpecification (MethodReference method, ImportGenericContext context)
{
if (!method.IsGenericInstance)
throw new NotSupportedException ();
@@ -562,5 +721,25 @@ namespace Mono.Cecil {
return imported_instance;
}
+
+ public virtual TypeReference ImportReference (TypeReference type, IGenericParameterProvider context)
+ {
+ Mixin.CheckType (type);
+ return ImportType (type, ImportGenericContext.For (context));
+ }
+
+ public virtual FieldReference ImportReference (FieldReference field, IGenericParameterProvider context)
+ {
+ Mixin.CheckField (field);
+ return ImportField (field, ImportGenericContext.For (context));
+ }
+
+ public virtual MethodReference ImportReference (MethodReference method, IGenericParameterProvider context)
+ {
+ Mixin.CheckMethod (method);
+ return ImportMethod (method, ImportGenericContext.For (context));
+ }
}
+
+#endif
}
diff --git a/Mono.Cecil/LinkedResource.cs b/Mono.Cecil/LinkedResource.cs
index 16c1d59..e53430e 100644
--- a/Mono.Cecil/LinkedResource.cs
+++ b/Mono.Cecil/LinkedResource.cs
@@ -1,29 +1,11 @@
//
-// LinkedResource.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/ManifestResourceAttributes.cs b/Mono.Cecil/ManifestResourceAttributes.cs
index 7d6bb19..03ccb6b 100644
--- a/Mono.Cecil/ManifestResourceAttributes.cs
+++ b/Mono.Cecil/ManifestResourceAttributes.cs
@@ -1,29 +1,11 @@
//
-// ManifestResourceAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MarshalInfo.cs b/Mono.Cecil/MarshalInfo.cs
index 9d58738..47d935e 100644
--- a/Mono.Cecil/MarshalInfo.cs
+++ b/Mono.Cecil/MarshalInfo.cs
@@ -1,29 +1,11 @@
//
-// MarshalInfo.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MemberDefinitionCollection.cs b/Mono.Cecil/MemberDefinitionCollection.cs
index 707f36f..c88bd7d 100644
--- a/Mono.Cecil/MemberDefinitionCollection.cs
+++ b/Mono.Cecil/MemberDefinitionCollection.cs
@@ -1,29 +1,11 @@
//
-// MemberDefinitionCollection.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MemberReference.cs b/Mono.Cecil/MemberReference.cs
index b658c51..c412811 100644
--- a/Mono.Cecil/MemberReference.cs
+++ b/Mono.Cecil/MemberReference.cs
@@ -1,29 +1,11 @@
//
-// MemberReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
@@ -72,7 +54,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/Mono.Cecil/MetadataResolver.cs b/Mono.Cecil/MetadataResolver.cs
index e69fcd7..97d3c00 100644
--- a/Mono.Cecil/MetadataResolver.cs
+++ b/Mono.Cecil/MetadataResolver.cs
@@ -1,29 +1,11 @@
//
-// MetadataResolver.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -57,9 +39,26 @@ namespace Mono.Cecil {
get { return member; }
}
+ public IMetadataScope Scope {
+ get {
+ var type = member as TypeReference;
+ if (type != null)
+ return type.Scope;
+
+ var declaring_type = member.DeclaringType;
+ if (declaring_type != null)
+ return declaring_type.Scope;
+
+ throw new NotSupportedException ();
+ }
+ }
+
public ResolutionException (MemberReference member)
: base ("Failed to resolve " + member.FullName)
{
+ if (member == null)
+ throw new ArgumentNullException ("member");
+
this.member = member;
}
@@ -97,6 +96,10 @@ namespace Mono.Cecil {
type = type.GetElementType ();
var scope = type.Scope;
+
+ if (scope == null)
+ return null;
+
switch (scope.MetadataScopeType) {
case MetadataScopeType.AssemblyNameReference:
var assembly = assembly_resolver.Resolve ((AssemblyNameReference) scope);
@@ -154,7 +157,7 @@ namespace Mono.Cecil {
if (declaring_type == null)
return null;
- return declaring_type.GetNestedType (type.Name);
+ return declaring_type.GetNestedType (type.TypeFullName ());
}
public virtual FieldDefinition Resolve (FieldReference field)
diff --git a/Mono.Cecil/MetadataSystem.cs b/Mono.Cecil/MetadataSystem.cs
index bfe7fc5..15922b6 100644
--- a/Mono.Cecil/MetadataSystem.cs
+++ b/Mono.Cecil/MetadataSystem.cs
@@ -1,29 +1,11 @@
//
-// MetadataSystem.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -65,20 +47,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) },
@@ -100,30 +82,45 @@ namespace Mono.Cecil {
};
}
- public static void TryProcessPrimitiveType (TypeReference type)
+ public static void TryProcessPrimitiveTypeReference (TypeReference type)
{
- var scope = type.scope;
- if (scope == null)
+ if (type.Namespace != "System")
return;
- if (scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
+ var scope = type.scope;
+ 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 ()
@@ -287,9 +284,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)
@@ -297,9 +294,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)
@@ -307,9 +304,9 @@ namespace Mono.Cecil {
CustomAttributes.Remove (owner.MetadataToken);
}
- public bool TryGetSecurityDeclarationRange (ISecurityDeclarationProvider owner, out Range range)
+ public bool TryGetSecurityDeclarationRanges (ISecurityDeclarationProvider owner, out Range [] ranges)
{
- return SecurityDeclarations.TryGetValue (owner.MetadataToken, out range);
+ return SecurityDeclarations.TryGetValue (owner.MetadataToken, out ranges);
}
public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner)
diff --git a/Mono.Cecil/MethodAttributes.cs b/Mono.Cecil/MethodAttributes.cs
index 626a97b..1bd7d12 100644
--- a/Mono.Cecil/MethodAttributes.cs
+++ b/Mono.Cecil/MethodAttributes.cs
@@ -1,29 +1,11 @@
//
-// MethodAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MethodCallingConvention.cs b/Mono.Cecil/MethodCallingConvention.cs
index bd7188d..f9c0e0c 100644
--- a/Mono.Cecil/MethodCallingConvention.cs
+++ b/Mono.Cecil/MethodCallingConvention.cs
@@ -1,29 +1,11 @@
//
-// MethodCallingConvention.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/MethodDefinition.cs b/Mono.Cecil/MethodDefinition.cs
index cbda745..b2664ad 100644
--- a/Mono.Cecil/MethodDefinition.cs
+++ b/Mono.Cecil/MethodDefinition.cs
@@ -1,29 +1,11 @@
//
-// MethodDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using Mono.Cecil.Cil;
@@ -37,7 +19,8 @@ namespace Mono.Cecil {
ushort attributes;
ushort impl_attributes;
- internal MethodSemanticsAttributes? sem_attrs;
+ internal volatile bool sem_attrs_ready;
+ internal MethodSemanticsAttributes sem_attrs;
Collection<CustomAttribute> custom_attributes;
Collection<SecurityDeclaration> security_declarations;
@@ -59,23 +42,24 @@ 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 ()
{
- if (sem_attrs.HasValue)
+ if (sem_attrs_ready)
return;
var module = this.Module;
@@ -98,7 +82,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 {
@@ -111,7 +95,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 {
@@ -131,18 +115,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 {
@@ -160,7 +156,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;
}
@@ -175,10 +171,7 @@ namespace Mono.Cecil {
if (overrides != null)
return overrides.Count > 0;
- if (HasImage)
- return Module.Read (this, (method, reader) => reader.HasOverrides (method));
-
- return false;
+ return HasImage && Module.Read (this, (method, reader) => reader.HasOverrides (method));
}
}
@@ -188,7 +181,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> ();
}
@@ -204,7 +197,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
diff --git a/Mono.Cecil/MethodImplAttributes.cs b/Mono.Cecil/MethodImplAttributes.cs
index b24fcf7..7d48b33 100644
--- a/Mono.Cecil/MethodImplAttributes.cs
+++ b/Mono.Cecil/MethodImplAttributes.cs
@@ -1,29 +1,11 @@
//
-// MethodImplAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MethodReference.cs b/Mono.Cecil/MethodReference.cs
index 0adab45..4439236 100644
--- a/Mono.Cecil/MethodReference.cs
+++ b/Mono.Cecil/MethodReference.cs
@@ -1,29 +1,11 @@
//
-// MethodReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -135,7 +117,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/Mono.Cecil/MethodReturnType.cs b/Mono.Cecil/MethodReturnType.cs
index f2e2eaa..a6c9ae4 100644
--- a/Mono.Cecil/MethodReturnType.cs
+++ b/Mono.Cecil/MethodReturnType.cs
@@ -1,31 +1,15 @@
//
-// MethodReturnType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
+using System.Threading;
+
using Mono.Collections.Generic;
namespace Mono.Cecil {
@@ -46,8 +30,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 {
diff --git a/Mono.Cecil/MethodSemanticsAttributes.cs b/Mono.Cecil/MethodSemanticsAttributes.cs
index dd0f474..274dfd0 100644
--- a/Mono.Cecil/MethodSemanticsAttributes.cs
+++ b/Mono.Cecil/MethodSemanticsAttributes.cs
@@ -1,29 +1,11 @@
//
-// MethodSemanticsattributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/MethodSpecification.cs b/Mono.Cecil/MethodSpecification.cs
index 73b5c14..c0f3a86 100644
--- a/Mono.Cecil/MethodSpecification.cs
+++ b/Mono.Cecil/MethodSpecification.cs
@@ -1,29 +1,11 @@
//
-// MethodSpecification.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -82,7 +64,7 @@ namespace Mono.Cecil {
get { return method.Parameters; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return method.ContainsGenericParameter; }
}
diff --git a/Mono.Cecil/Modifiers.cs b/Mono.Cecil/Modifiers.cs
index ad31bc0..7575ec1 100644
--- a/Mono.Cecil/Modifiers.cs
+++ b/Mono.Cecil/Modifiers.cs
@@ -1,29 +1,11 @@
//
-// Modifiers.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -67,7 +49,7 @@ namespace Mono.Cecil {
get { return true; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; }
}
@@ -110,7 +92,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/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs
index 805551a..c665d1e 100644
--- a/Mono.Cecil/ModuleDefinition.cs
+++ b/Mono.Cecil/ModuleDefinition.cs
@@ -1,34 +1,17 @@
//
-// ModuleDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
using System.Collections.Generic;
using System.IO;
+using System.Threading;
using SR = System.Reflection;
using Mono.Cecil.Cil;
@@ -46,8 +29,14 @@ namespace Mono.Cecil {
public sealed class ReaderParameters {
ReadingMode reading_mode;
- IAssemblyResolver assembly_resolver;
- IMetadataResolver metadata_resolver;
+ internal IAssemblyResolver assembly_resolver;
+ internal IMetadataResolver metadata_resolver;
+#if !READ_ONLY
+ internal IMetadataImporterProvider metadata_importer_provider;
+#if !CF
+ internal IReflectionImporterProvider reflection_importer_provider;
+#endif
+#endif
Stream symbol_stream;
ISymbolReaderProvider symbol_reader_provider;
bool read_symbols;
@@ -67,6 +56,20 @@ namespace Mono.Cecil {
set { metadata_resolver = value; }
}
+#if !READ_ONLY
+ public IMetadataImporterProvider MetadataImporterProvider {
+ get { return metadata_importer_provider; }
+ set { metadata_importer_provider = value; }
+ }
+
+#if !CF
+ public IReflectionImporterProvider ReflectionImporterProvider {
+ get { return reflection_importer_provider; }
+ set { reflection_importer_provider = value; }
+ }
+#endif
+#endif
+
public Stream SymbolStream {
get { return symbol_stream; }
set { symbol_stream = value; }
@@ -102,6 +105,12 @@ namespace Mono.Cecil {
TargetArchitecture architecture;
IAssemblyResolver assembly_resolver;
IMetadataResolver metadata_resolver;
+#if !READ_ONLY
+ IMetadataImporterProvider metadata_importer_provider;
+#if !CF
+ IReflectionImporterProvider reflection_importer_provider;
+#endif
+#endif
public ModuleKind Kind {
get { return kind; }
@@ -128,10 +137,24 @@ namespace Mono.Cecil {
set { metadata_resolver = value; }
}
+#if !READ_ONLY
+ public IMetadataImporterProvider MetadataImporterProvider {
+ get { return metadata_importer_provider; }
+ set { metadata_importer_provider = value; }
+ }
+
+#if !CF
+ public IReflectionImporterProvider ReflectionImporterProvider {
+ get { return reflection_importer_provider; }
+ set { reflection_importer_provider = value; }
+ }
+#endif
+#endif
+
public ModuleParameters ()
{
this.kind = ModuleKind.Dll;
- this.runtime = GetCurrentRuntime ();
+ this.Runtime = GetCurrentRuntime ();
this.architecture = TargetArchitecture.I386;
}
@@ -195,8 +218,8 @@ namespace Mono.Cecil {
internal MetadataSystem MetadataSystem;
internal ReadingMode ReadingMode;
internal ISymbolReaderProvider SymbolReaderProvider;
- internal ISymbolReader SymbolReader;
+ internal ISymbolReader symbol_reader;
internal IAssemblyResolver assembly_resolver;
internal IMetadataResolver metadata_resolver;
internal TypeSystem type_system;
@@ -204,17 +227,22 @@ namespace Mono.Cecil {
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;
MethodDefinition entry_point;
#if !READ_ONLY
- MetadataImporter importer;
+#if !CF
+ internal IReflectionImporter reflection_importer;
+#endif
+ internal IMetadataImporter metadata_importer;
#endif
Collection<CustomAttribute> custom_attributes;
Collection<AssemblyNameReference> references;
@@ -234,7 +262,18 @@ namespace Mono.Cecil {
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 {
@@ -247,6 +286,11 @@ namespace Mono.Cecil {
set { attributes = value; }
}
+ public ModuleCharacteristics Characteristics {
+ get { return characteristics; }
+ set { characteristics = value; }
+ }
+
public string FullyQualifiedName {
get { return fq_name; }
}
@@ -261,7 +305,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 {
@@ -272,22 +320,50 @@ namespace Mono.Cecil {
get { return assembly; }
}
-#if !READ_ONLY
- internal MetadataImporter MetadataImporter {
- get { return importer ?? (importer = new MetadataImporter (this)); }
+ internal IReflectionImporter ReflectionImporter {
+ get {
+ if (reflection_importer == null)
+ Interlocked.CompareExchange (ref reflection_importer, new ReflectionImporter (this), null);
+
+ return reflection_importer;
+ }
+
+ }
+
+ internal IMetadataImporter MetadataImporter {
+ get {
+ if (metadata_importer == null)
+ Interlocked.CompareExchange (ref metadata_importer, new MetadataImporter (this), null);
+
+ return metadata_importer;
+ }
}
-#endif
public IAssemblyResolver AssemblyResolver {
- get { return assembly_resolver; }
+ get {
+ if (assembly_resolver == null)
+ Interlocked.CompareExchange (ref assembly_resolver, new AssemblyResolver (), null);
+
+ return assembly_resolver;
+ }
}
public IMetadataResolver MetadataResolver {
- get { return metadata_resolver ?? (metadata_resolver = new MetadataResolver (assembly_resolver)); }
+ get {
+ if (metadata_resolver == null)
+ Interlocked.CompareExchange (ref metadata_resolver, new MetadataResolver (this.AssemblyResolver), null);
+
+ return metadata_resolver;
+ }
}
public TypeSystem TypeSystem {
- get { return type_system ?? (type_system = TypeSystem.CreateTypeSystem (this)); }
+ get {
+ if (type_system == null)
+ Interlocked.CompareExchange (ref type_system, TypeSystem.CreateTypeSystem (this), null);
+
+ return type_system;
+ }
}
public bool HasAssemblyReferences {
@@ -305,7 +381,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> ();
}
@@ -326,7 +402,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> ();
}
@@ -350,7 +426,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> ();
}
@@ -366,7 +442,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 {
@@ -384,7 +460,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);
}
@@ -405,7 +481,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> ();
}
@@ -417,7 +493,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;
}
@@ -428,7 +504,6 @@ namespace Mono.Cecil {
{
this.MetadataSystem = new MetadataSystem ();
this.token = new MetadataToken (TokenType.Module, 1);
- this.assembly_resolver = new AssemblyResolver ();
}
internal ModuleDefinition (Image image)
@@ -436,9 +511,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.Stream.GetFullyQualifiedName ();
this.reader = new MetadataReader (this);
@@ -595,24 +671,6 @@ namespace Mono.Cecil {
#if !READ_ONLY
- static void CheckType (object type)
- {
- if (type == null)
- throw new ArgumentNullException ("type");
- }
-
- static void CheckField (object field)
- {
- if (field == null)
- throw new ArgumentNullException ("field");
- }
-
- static void CheckMethod (object method)
- {
- if (method == null)
- throw new ArgumentNullException ("method");
- }
-
static void CheckContext (IGenericParameterProvider context, ModuleDefinition module)
{
if (context == null)
@@ -623,185 +681,168 @@ namespace Mono.Cecil {
}
#if !CF
+
+ [Obsolete ("Use ImportReference", error: false)]
public TypeReference Import (Type type)
{
- CheckType (type);
-
- return MetadataImporter.ImportType (type, null, ImportGenericKind.Definition);
+ return ImportReference (type, null);
}
- public TypeReference Import (Type type, TypeReference context)
+ public TypeReference ImportReference (Type type)
{
- return Import (type, (IGenericParameterProvider) context);
+ return ImportReference (type, null);
}
- public TypeReference Import (Type type, MethodReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public TypeReference Import (Type type, IGenericParameterProvider context)
{
- return Import (type, (IGenericParameterProvider) context);
+ return ImportReference (type, context);
}
- TypeReference Import (Type type, IGenericParameterProvider context)
+ public TypeReference ImportReference (Type type, IGenericParameterProvider context)
{
- CheckType (type);
+ Mixin.CheckType (type);
CheckContext (context, this);
- return MetadataImporter.ImportType (
- type,
- (IGenericContext) context,
- context != null
- ? ImportGenericKind.Open
- : ImportGenericKind.Definition);
+ return ReflectionImporter.ImportReference (type, context);
}
+ [Obsolete ("Use ImportReference", error: false)]
public FieldReference Import (SR.FieldInfo field)
{
- CheckField (field);
-
- return MetadataImporter.ImportField (field, null);
+ return ImportReference (field, null);
}
- public FieldReference Import (SR.FieldInfo field, TypeReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context)
{
- return Import (field, (IGenericParameterProvider) context);
+ return ImportReference (field, context);
}
- public FieldReference Import (SR.FieldInfo field, MethodReference context)
+ public FieldReference ImportReference (SR.FieldInfo field)
{
- return Import (field, (IGenericParameterProvider) context);
+ return ImportReference (field, null);
}
- FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context)
+ public FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context)
{
- CheckField (field);
+ Mixin.CheckField (field);
CheckContext (context, this);
- return MetadataImporter.ImportField (field, (IGenericContext) context);
+ return ReflectionImporter.ImportReference (field, context);
}
+ [Obsolete ("Use ImportReference", error: false)]
public MethodReference Import (SR.MethodBase method)
{
- CheckMethod (method);
-
- return MetadataImporter.ImportMethod (method, null, ImportGenericKind.Definition);
+ return ImportReference (method, null);
}
- public MethodReference Import (SR.MethodBase method, TypeReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public MethodReference Import (SR.MethodBase method, IGenericParameterProvider context)
{
- return Import (method, (IGenericParameterProvider) context);
+ return ImportReference (method, context);
}
- public MethodReference Import (SR.MethodBase method, MethodReference context)
+ public MethodReference ImportReference (SR.MethodBase method)
{
- return Import (method, (IGenericParameterProvider) context);
+ return ImportReference (method, null);
}
- MethodReference Import (SR.MethodBase method, IGenericParameterProvider context)
+ public MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context)
{
- CheckMethod (method);
+ Mixin.CheckMethod (method);
CheckContext (context, this);
- return MetadataImporter.ImportMethod (method,
- (IGenericContext) context,
- context != null
- ? ImportGenericKind.Open
- : ImportGenericKind.Definition);
+ return ReflectionImporter.ImportReference (method, context);
}
#endif
+ [Obsolete ("Use ImportReference", error: false)]
public TypeReference Import (TypeReference type)
{
- CheckType (type);
-
- if (type.Module == this)
- return type;
-
- return MetadataImporter.ImportType (type, null);
+ return ImportReference (type, null);
}
- public TypeReference Import (TypeReference type, TypeReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public TypeReference Import (TypeReference type, IGenericParameterProvider context)
{
- return Import (type, (IGenericParameterProvider) context);
+ return ImportReference (type, context);
}
- public TypeReference Import (TypeReference type, MethodReference context)
+ public TypeReference ImportReference (TypeReference type)
{
- return Import (type, (IGenericParameterProvider) context);
+ return ImportReference (type, null);
}
- TypeReference Import (TypeReference type, IGenericParameterProvider context)
+ public TypeReference ImportReference (TypeReference type, IGenericParameterProvider context)
{
- CheckType (type);
+ Mixin.CheckType (type);
if (type.Module == this)
return type;
CheckContext (context, this);
- return MetadataImporter.ImportType (type, (IGenericContext) context);
+ return MetadataImporter.ImportReference (type, context);
}
+ [Obsolete ("Use ImportReference", error: false)]
public FieldReference Import (FieldReference field)
{
- CheckField (field);
-
- if (field.Module == this)
- return field;
-
- return MetadataImporter.ImportField (field, null);
+ return ImportReference (field, null);
}
- public FieldReference Import (FieldReference field, TypeReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public FieldReference Import (FieldReference field, IGenericParameterProvider context)
{
- return Import (field, (IGenericParameterProvider) context);
+ return ImportReference (field, context);
}
- public FieldReference Import (FieldReference field, MethodReference context)
+ public FieldReference ImportReference (FieldReference field)
{
- return Import (field, (IGenericParameterProvider) context);
+ return ImportReference (field, null);
}
- FieldReference Import (FieldReference field, IGenericParameterProvider context)
+ public FieldReference ImportReference (FieldReference field, IGenericParameterProvider context)
{
- CheckField (field);
+ Mixin.CheckField (field);
if (field.Module == this)
return field;
CheckContext (context, this);
- return MetadataImporter.ImportField (field, (IGenericContext) context);
+ return MetadataImporter.ImportReference (field, context);
}
+ [Obsolete ("Use ImportReference", error: false)]
public MethodReference Import (MethodReference method)
{
- CheckMethod (method);
-
- if (method.Module == this)
- return method;
-
- return MetadataImporter.ImportMethod (method, null);
+ return ImportReference (method, null);
}
- public MethodReference Import (MethodReference method, TypeReference context)
+ [Obsolete ("Use ImportReference", error: false)]
+ public MethodReference Import (MethodReference method, IGenericParameterProvider context)
{
- return Import (method, (IGenericParameterProvider) context);
+ return ImportReference (method, context);
}
- public MethodReference Import (MethodReference method, MethodReference context)
+ public MethodReference ImportReference (MethodReference method)
{
- return Import (method, (IGenericParameterProvider) context);
+ return ImportReference (method, null);
}
- MethodReference Import (MethodReference method, IGenericParameterProvider context)
+ public MethodReference ImportReference (MethodReference method, IGenericParameterProvider context)
{
- CheckMethod (method);
+ Mixin.CheckMethod (method);
if (method.Module == this)
return method;
CheckContext (context, this);
- return MetadataImporter.ImportMethod (method, (IGenericContext) context);
+ return MetadataImporter.ImportReference (method, context);
}
#endif
@@ -816,28 +857,66 @@ namespace Mono.Cecil {
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);
+
+ reader.position = position;
+ reader.context = context;
+
+ 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);
+ var ret = read (item, reader);
- reader.position = position;
- reader.context = context;
+ reader.position = position;
+ reader.context = context;
- return ret;
+ 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 ();
}
@@ -856,10 +935,11 @@ 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)
@@ -868,6 +948,15 @@ namespace Mono.Cecil {
if (parameters.MetadataResolver != null)
module.metadata_resolver = parameters.MetadataResolver;
+#if !READ_ONLY
+ if (parameters.MetadataImporterProvider != null)
+ module.metadata_importer = parameters.MetadataImporterProvider.GetMetadataImporter (module);
+#if !CF
+ if (parameters.ReflectionImporterProvider != null)
+ module.reflection_importer = parameters.ReflectionImporterProvider.GetReflectionImporter (module);
+#endif
+#endif
+
if (parameters.Kind != ModuleKind.NetModule) {
var assembly = new AssemblyDefinition ();
module.assembly = assembly;
@@ -907,7 +996,7 @@ namespace Mono.Cecil {
if (reader == null)
throw new ArgumentNullException ("reader");
- SymbolReader = reader;
+ symbol_reader = reader;
ProcessDebugHeader ();
}
@@ -990,6 +1079,28 @@ namespace Mono.Cecil {
static partial class Mixin {
+#if !READ_ONLY
+
+ public static void CheckType (object type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+ }
+
+ public static void CheckField (object field)
+ {
+ if (field == null)
+ throw new ArgumentNullException ("field");
+ }
+
+ public static void CheckMethod (object method)
+ {
+ if (method == null)
+ throw new ArgumentNullException ("method");
+ }
+
+#endif
+
public static void CheckParameters (object parameters)
{
if (parameters == null)
@@ -1001,6 +1112,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
@@ -1028,5 +1147,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/Mono.Cecil/ModuleKind.cs b/Mono.Cecil/ModuleKind.cs
index e5f7458..ff7abe9 100644
--- a/Mono.Cecil/ModuleKind.cs
+++ b/Mono.Cecil/ModuleKind.cs
@@ -1,29 +1,11 @@
//
-// ModuleKind.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -41,6 +23,7 @@ namespace Mono.Cecil {
I386,
AMD64,
IA64,
+ ARMv7,
}
[Flags]
@@ -48,5 +31,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/Mono.Cecil/ModuleReference.cs b/Mono.Cecil/ModuleReference.cs
index 3934b3c..43c618f 100644
--- a/Mono.Cecil/ModuleReference.cs
+++ b/Mono.Cecil/ModuleReference.cs
@@ -1,29 +1,11 @@
//
-// ModuleReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/NativeType.cs b/Mono.Cecil/NativeType.cs
index 88da980..02174db 100644
--- a/Mono.Cecil/NativeType.cs
+++ b/Mono.Cecil/NativeType.cs
@@ -1,29 +1,11 @@
//
-// NativeType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/PInvokeAttributes.cs b/Mono.Cecil/PInvokeAttributes.cs
index bb36838..11e96d2 100644
--- a/Mono.Cecil/PInvokeAttributes.cs
+++ b/Mono.Cecil/PInvokeAttributes.cs
@@ -1,29 +1,11 @@
//
-// PInvokeAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/PInvokeInfo.cs b/Mono.Cecil/PInvokeInfo.cs
index cfd817c..8efc010 100644
--- a/Mono.Cecil/PInvokeInfo.cs
+++ b/Mono.Cecil/PInvokeInfo.cs
@@ -1,29 +1,11 @@
//
-// PInvokeInfo.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/ParameterAttributes.cs b/Mono.Cecil/ParameterAttributes.cs
index e0bc825..9a0e35e 100644
--- a/Mono.Cecil/ParameterAttributes.cs
+++ b/Mono.Cecil/ParameterAttributes.cs
@@ -1,29 +1,11 @@
//
-// ParameterAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/ParameterDefinition.cs b/Mono.Cecil/ParameterDefinition.cs
index 8902615..59bafe2 100644
--- a/Mono.Cecil/ParameterDefinition.cs
+++ b/Mono.Cecil/ParameterDefinition.cs
@@ -1,29 +1,11 @@
//
-// ParameterDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using Mono.Collections.Generic;
@@ -54,13 +36,13 @@ namespace Mono.Cecil {
if (method == null)
return -1;
- return method.HasThis ? index + 1 : index;
+ return method.HasImplicitThis () ? index + 1 : index;
}
}
public bool HasConstant {
get {
- ResolveConstant ();
+ this.ResolveConstant (ref constant, parameter_type.Module);
return constant != Mixin.NoValue;
}
@@ -72,14 +54,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)
@@ -90,7 +64,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 {
@@ -103,7 +77,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; }
}
@@ -146,6 +120,12 @@ namespace Mono.Cecil {
#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/Mono.Cecil/ParameterDefinitionCollection.cs b/Mono.Cecil/ParameterDefinitionCollection.cs
index bd8b1c1..1a9764c 100644
--- a/Mono.Cecil/ParameterDefinitionCollection.cs
+++ b/Mono.Cecil/ParameterDefinitionCollection.cs
@@ -1,29 +1,11 @@
//
-// ParameterDefinitionCollection.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/ParameterReference.cs b/Mono.Cecil/ParameterReference.cs
index 46b057c..4670a56 100644
--- a/Mono.Cecil/ParameterReference.cs
+++ b/Mono.Cecil/ParameterReference.cs
@@ -1,29 +1,11 @@
//
-// ParameterReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/PinnedType.cs b/Mono.Cecil/PinnedType.cs
index ff59cfb..fa89af5 100644
--- a/Mono.Cecil/PinnedType.cs
+++ b/Mono.Cecil/PinnedType.cs
@@ -1,29 +1,11 @@
//
-// PinnedType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/PointerType.cs b/Mono.Cecil/PointerType.cs
index a142e14..4b21164 100644
--- a/Mono.Cecil/PointerType.cs
+++ b/Mono.Cecil/PointerType.cs
@@ -1,29 +1,11 @@
//
-// PointerType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/PropertyAttributes.cs b/Mono.Cecil/PropertyAttributes.cs
index 1be0413..4d1ce8c 100644
--- a/Mono.Cecil/PropertyAttributes.cs
+++ b/Mono.Cecil/PropertyAttributes.cs
@@ -1,29 +1,11 @@
//
-// PropertyAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/PropertyDefinition.cs b/Mono.Cecil/PropertyDefinition.cs
index 42878a0..87f2947 100644
--- a/Mono.Cecil/PropertyDefinition.cs
+++ b/Mono.Cecil/PropertyDefinition.cs
@@ -1,29 +1,11 @@
//
-// PropertyDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System.Text;
@@ -76,7 +58,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 MethodDefinition GetMethod {
@@ -170,7 +152,7 @@ namespace Mono.Cecil {
public bool HasConstant {
get {
- ResolveConstant ();
+ this.ResolveConstant (ref constant, Module);
return constant != Mixin.NoValue;
}
@@ -182,14 +164,6 @@ namespace Mono.Cecil {
set { constant = value; }
}
- void ResolveConstant ()
- {
- if (constant != Mixin.NotResolved)
- return;
-
- this.ResolveConstant (ref constant, Module);
- }
-
#region PropertyAttributes
public bool IsSpecialName {
@@ -247,14 +221,19 @@ 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 ()
diff --git a/Mono.Cecil/PropertyReference.cs b/Mono.Cecil/PropertyReference.cs
index 0dcfc95..324a841 100644
--- a/Mono.Cecil/PropertyReference.cs
+++ b/Mono.Cecil/PropertyReference.cs
@@ -1,29 +1,11 @@
//
-// PropertyReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/ReferenceType.cs b/Mono.Cecil/ReferenceType.cs
index 7940c61..67686fb 100644
--- a/Mono.Cecil/ReferenceType.cs
+++ b/Mono.Cecil/ReferenceType.cs
@@ -1,29 +1,11 @@
//
-// ByReferenceType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/Resource.cs b/Mono.Cecil/Resource.cs
index eff7f41..cee75f9 100644
--- a/Mono.Cecil/Resource.cs
+++ b/Mono.Cecil/Resource.cs
@@ -1,29 +1,11 @@
//
-// ResourceType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/SecurityDeclaration.cs b/Mono.Cecil/SecurityDeclaration.cs
index 837472a..309f7d2 100644
--- a/Mono.Cecil/SecurityDeclaration.cs
+++ b/Mono.Cecil/SecurityDeclaration.cs
@@ -1,29 +1,11 @@
//
-// SecurityDeclaration.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -181,11 +163,12 @@ namespace Mono.Cecil {
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/Mono.Cecil/SentinelType.cs b/Mono.Cecil/SentinelType.cs
index 664d75b..b603cc3 100644
--- a/Mono.Cecil/SentinelType.cs
+++ b/Mono.Cecil/SentinelType.cs
@@ -1,29 +1,11 @@
//
-// SentinelType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/TargetRuntime.cs b/Mono.Cecil/TargetRuntime.cs
index 9b49a5f..c1cd026 100644
--- a/Mono.Cecil/TargetRuntime.cs
+++ b/Mono.Cecil/TargetRuntime.cs
@@ -1,29 +1,11 @@
//
-// TargetRuntime.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {
diff --git a/Mono.Cecil/TypeAttributes.cs b/Mono.Cecil/TypeAttributes.cs
index bc4e18f..92a71ac 100644
--- a/Mono.Cecil/TypeAttributes.cs
+++ b/Mono.Cecil/TypeAttributes.cs
@@ -1,29 +1,11 @@
//
-// TypeAttributes.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -62,6 +44,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/Mono.Cecil/TypeDefinition.cs b/Mono.Cecil/TypeDefinition.cs
index a1575e1..226d7f3 100644
--- a/Mono.Cecil/TypeDefinition.cs
+++ b/Mono.Cecil/TypeDefinition.cs
@@ -1,33 +1,16 @@
//
-// TypeDefinition.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
+using Mono.Cecil.Metadata;
using Mono.Collections.Generic;
namespace Mono.Cecil {
@@ -118,10 +101,7 @@ namespace Mono.Cecil {
if (interfaces != null)
return interfaces.Count > 0;
- if (HasImage)
- return Module.Read (this, (type, reader) => reader.HasInterfaces (type));
-
- return false;
+ return HasImage && Module.Read (this, (type, reader) => reader.HasInterfaces (type));
}
}
@@ -131,7 +111,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> ();
}
@@ -142,10 +122,7 @@ namespace Mono.Cecil {
if (nested_types != null)
return nested_types.Count > 0;
- if (HasImage)
- return Module.Read (this, (type, reader) => reader.HasNestedTypes (type));
-
- return false;
+ return HasImage && Module.Read (this, (type, reader) => reader.HasNestedTypes (type));
}
}
@@ -155,7 +132,7 @@ 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);
}
@@ -166,10 +143,7 @@ namespace Mono.Cecil {
if (methods != null)
return methods.Count > 0;
- if (HasImage)
- return methods_range.Length > 0;
-
- return false;
+ return HasImage && methods_range.Length > 0;
}
}
@@ -179,7 +153,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);
}
@@ -190,10 +164,7 @@ namespace Mono.Cecil {
if (fields != null)
return fields.Count > 0;
- if (HasImage)
- return fields_range.Length > 0;
-
- return false;
+ return HasImage && fields_range.Length > 0;
}
}
@@ -203,7 +174,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);
}
@@ -214,10 +185,7 @@ namespace Mono.Cecil {
if (events != null)
return events.Count > 0;
- if (HasImage)
- return Module.Read (this, (type, reader) => reader.HasEvents (type));
-
- return false;
+ return HasImage && Module.Read (this, (type, reader) => reader.HasEvents (type));
}
}
@@ -227,7 +195,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);
}
@@ -238,10 +206,7 @@ namespace Mono.Cecil {
if (properties != null)
return properties.Count > 0;
- if (HasImage)
- return Module.Read (this, (type, reader) => reader.HasProperties (type));
-
- return false;
+ return HasImage && Module.Read (this, (type, reader) => reader.HasProperties (type));
}
}
@@ -251,7 +216,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);
}
@@ -267,7 +232,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 {
@@ -280,7 +245,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 {
@@ -293,7 +258,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
@@ -388,6 +353,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); }
@@ -433,6 +403,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; }
}
@@ -476,7 +463,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;
@@ -485,7 +472,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/Mono.Cecil/TypeDefinitionCollection.cs b/Mono.Cecil/TypeDefinitionCollection.cs
index eae7122..95e39b9 100644
--- a/Mono.Cecil/TypeDefinitionCollection.cs
+++ b/Mono.Cecil/TypeDefinitionCollection.cs
@@ -1,29 +1,11 @@
//
-// TypeDefinitionCollection.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
diff --git a/Mono.Cecil/TypeParser.cs b/Mono.Cecil/TypeParser.cs
index 733c422..36bc6c3 100644
--- a/Mono.Cecil/TypeParser.cs
+++ b/Mono.Cecil/TypeParser.cs
@@ -1,29 +1,11 @@
//
-// TypeParser.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -129,11 +111,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 +159,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 +252,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);
@@ -356,7 +336,7 @@ namespace Mono.Cecil {
SplitFullName (type_info.type_fullname, out @namespace, out name);
var type = new TypeReference (@namespace, name, module, scope);
- MetadataSystem.TryProcessPrimitiveType (type);
+ MetadataSystem.TryProcessPrimitiveTypeReference (type);
AdjustGenericParameters (type);
@@ -447,6 +427,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;
@@ -457,11 +447,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/Mono.Cecil/TypeReference.cs b/Mono.Cecil/TypeReference.cs
index 757c83a..fce2023 100644
--- a/Mono.Cecil/TypeReference.cs
+++ b/Mono.Cecil/TypeReference.cs
@@ -1,29 +1,11 @@
//
-// TypeReference.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -147,6 +129,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 {
@@ -166,13 +157,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;
}
}
@@ -216,28 +206,8 @@ namespace Mono.Cecil {
get { return false; }
}
- public bool IsPrimitive {
- 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;
- default:
- return false;
- }
- }
+ public virtual bool IsPrimitive {
+ get { return etype.IsPrimitive (); }
}
public virtual MetadataType MetadataType {
@@ -288,6 +258,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
diff --git a/Mono.Cecil/TypeSpecification.cs b/Mono.Cecil/TypeSpecification.cs
index aa9b653..d26be5b 100644
--- a/Mono.Cecil/TypeSpecification.cs
+++ b/Mono.Cecil/TypeSpecification.cs
@@ -1,29 +1,11 @@
//
-// TypeSpecification.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -42,16 +24,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 {
@@ -62,7 +45,7 @@ namespace Mono.Cecil {
get { return element_type.FullName; }
}
- internal override bool ContainsGenericParameter {
+ public override bool ContainsGenericParameter {
get { return element_type.ContainsGenericParameter; }
}
diff --git a/Mono.Cecil/TypeSystem.cs b/Mono.Cecil/TypeSystem.cs
index dc20b7b..57b611e 100644
--- a/Mono.Cecil/TypeSystem.cs
+++ b/Mono.Cecil/TypeSystem.cs
@@ -1,29 +1,11 @@
//
-// TypeSystem.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -34,15 +16,24 @@ namespace Mono.Cecil {
public abstract class TypeSystem {
- sealed class CorlibTypeSystem : TypeSystem {
+ sealed class CoreTypeSystem : TypeSystem {
- public CorlibTypeSystem (ModuleDefinition module)
+ public CoreTypeSystem (ModuleDefinition module)
: base (module)
{
}
internal override TypeReference LookupType (string @namespace, string name)
{
+ var type = LookupTypeDefinition (@namespace, name) ?? LookupTypeForwarded (@namespace, name);
+ if (type != null)
+ return type;
+
+ throw new NotSupportedException ();
+ }
+
+ TypeReference LookupTypeDefinition (string @namespace, string name)
+ {
var metadata = module.MetadataSystem;
if (metadata.Types == null)
Initialize (module.Types);
@@ -64,6 +55,22 @@ namespace Mono.Cecil {
});
}
+ TypeReference LookupTypeForwarded (string @namespace, string name)
+ {
+ if (!module.HasExportedTypes)
+ return null;
+
+ var exported_types = module.ExportedTypes;
+ for (int i = 0; i < exported_types.Count; i++) {
+ var exported_type = exported_types [i];
+
+ if (exported_type.Name == name && exported_type.Namespace == @namespace)
+ return exported_type.CreateReference ();
+ }
+
+ return null;
+ }
+
static void Initialize (object obj)
{
}
@@ -158,34 +165,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 {
@@ -199,75 +207,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/Mono.Cecil/VariantType.cs b/Mono.Cecil/VariantType.cs
index 76562f6..81aa7fa 100644
--- a/Mono.Cecil/VariantType.cs
+++ b/Mono.Cecil/VariantType.cs
@@ -1,29 +1,11 @@
//
-// VariantType.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// 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
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
namespace Mono.Cecil {