diff --git a/src/AnthropicClient/Models/Tool.cs b/src/AnthropicClient/Models/Tool.cs
index ed61992..9d667ce 100644
--- a/src/AnthropicClient/Models/Tool.cs
+++ b/src/AnthropicClient/Models/Tool.cs
@@ -65,12 +65,16 @@ public class Tool
/// The description of the tool.
/// The type that contains the method.
/// The name of the method.
- /// Thrown when , , , or is null.
+ /// Thrown when is null or empty.
+ /// Thrown when is null.
/// Thrown when the method is not found in the type.
/// The created tool as instance of .
/// The name of the tool will be sanitized to conform to the Anthropic tool naming rules.
public static Tool CreateFromStaticMethod(string name, string description, Type type, string methodName)
{
+ ArgumentValidator.ThrowIfNullOrWhitespace(methodName, nameof(methodName));
+ ArgumentValidator.ThrowIfNull(type, nameof(type));
+
var method = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static);
if (method is null)
@@ -88,12 +92,16 @@ public class Tool
/// The description of the tool.
/// The instance that contains the method.
/// The name of the method.
- /// Thrown when , , , or is null.
- /// Thrown when the method is not found in the type.
+ /// Thrown when is null or empty.
+ /// Thrown when is null.
+ /// Thrown when is not found in the type of .
/// The created tool as instance of .
/// The name of the tool will be sanitized to conform to the Anthropic tool naming rules.
public static Tool CreateFromInstanceMethod(string name, string description, object instance, string methodName)
{
+ ArgumentValidator.ThrowIfNullOrWhitespace(methodName, nameof(methodName));
+ ArgumentValidator.ThrowIfNull(instance, nameof(instance));
+
var method = instance.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance);
if (method is null)
@@ -111,11 +119,13 @@ public class Tool
/// The name of the tool.
/// The description of the tool.
/// The function.
- /// Thrown when , , or is null.
+ /// Thrown when is null.
/// The created tool as instance of .
/// The name of the tool will be sanitized to conform to the Anthropic tool naming rules.
public static Tool CreateFromFunction(string name, string description, Func func)
{
+ ArgumentValidator.ThrowIfNull(func, nameof(func));
+
return new Tool(name, description, new AnthropicFunction(func.Method, func.Target));
}
@@ -127,11 +137,13 @@ public class Tool
/// The name of the tool.
/// The description of the tool.
/// The function.
- /// Thrown when , , or is null.
+ /// Thrown when is null.
/// The created tool as instance of .
/// The name of the tool will be sanitized to conform to the Anthropic tool naming rules.
public static Tool CreateFromFunction(string name, string description, Func func)
{
+ ArgumentValidator.ThrowIfNull(func, nameof(func));
+
return new Tool(name, description, new AnthropicFunction(func.Method, func.Target));
}