Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Protect now public API against null

  • Loading branch information...
commit 92c7f45243a945886863dc8bfd24d6e52cde1e54 1 parent 23ac06c
@jbevain authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 Mono.Cecil/MetadataResolver.cs
View
13 Mono.Cecil/MetadataResolver.cs
@@ -27,7 +27,6 @@
//
using System;
-using System.Collections.Generic;
using Mono.Collections.Generic;
@@ -84,11 +83,17 @@ public class MetadataResolver : IMetadataResolver {
public MetadataResolver (IAssemblyResolver assemblyResolver)
{
+ if (assemblyResolver == null)
+ throw new ArgumentNullException ("assemblyResolver");
+
assembly_resolver = assemblyResolver;
}
public virtual TypeDefinition Resolve (TypeReference type)
{
+ if (type == null)
+ throw new ArgumentNullException ("type");
+
type = type.GetElementType ();
var scope = type.Scope;
@@ -154,6 +159,9 @@ static TypeDefinition GetTypeDefinition (ModuleDefinition module, TypeReference
public virtual FieldDefinition Resolve (FieldReference field)
{
+ if (field == null)
+ throw new ArgumentNullException ("field");
+
var type = Resolve (field.DeclaringType);
if (type == null)
return null;
@@ -199,6 +207,9 @@ static FieldDefinition GetField (Collection<FieldDefinition> fields, FieldRefere
public virtual MethodDefinition Resolve (MethodReference method)
{
+ if (method == null)
+ throw new ArgumentNullException ("method");
+
var type = Resolve (method.DeclaringType);
if (type == null)
return null;
Please sign in to comment.
Something went wrong with that request. Please try again.