Catel.Fody.Weaving.Argument.IsNotNullArgumentMethodCallWeaver.SelectMethod C# (CSharp) Method

SelectMethod() protected method

protected SelectMethod ( Mono.Cecil.TypeDefinition argumentTypeDefinition, TypeReference typeToCheck, Mono.Cecil.MethodDefinition &selectedMethod ) : void
argumentTypeDefinition Mono.Cecil.TypeDefinition
typeToCheck Mono.Cecil.TypeReference
selectedMethod Mono.Cecil.MethodDefinition
return void
        protected override void SelectMethod(TypeDefinition argumentTypeDefinition, TypeReference typeToCheck, out MethodDefinition selectedMethod)
        {
            var isValueType = typeToCheck.IsValueType;
            if (isValueType)
            {
                throw new Exception($"'{typeToCheck.FullName}' is a value type or struct, you cannot check for null on value types");
            }

            selectedMethod = argumentTypeDefinition.Methods.FirstOrDefault(definition => definition.Name == "IsNotNull" && definition.Parameters.Count == 2 && string.Equals(definition.Parameters[1].ParameterType.FullName, typeToCheck.FullName));
            if (selectedMethod == null)
            {
                selectedMethod = argumentTypeDefinition.Methods.FirstOrDefault(definition => definition.Name == "IsNotNull" && definition.Parameters.Count == 2);
            }
        }
    }
IsNotNullArgumentMethodCallWeaver