175 references to Throw
Microsoft.Extensions.AI.Abstractions (175)
AdditionalPropertiesDictionary{TValue}.cs (2)
205_ = Throw.IfNull(items); 252private readonly AdditionalPropertiesDictionary<TValue> _properties = Throw.IfNull(properties);
ChatCompletion\ChatClientExtensions.cs (14)
27_ = Throw.IfNull(client); 49_ = Throw.IfNull(client); 50_ = Throw.IfNull(serviceType); 54throw Throw.CreateMissingServiceException(serviceType, serviceKey); 73_ = Throw.IfNull(client); 77throw Throw.CreateMissingServiceException(typeof(TService), serviceKey); 97_ = Throw.IfNull(client); 98_ = Throw.IfNull(chatMessage); 117_ = Throw.IfNull(client); 118_ = Throw.IfNull(chatMessage); 137_ = Throw.IfNull(client); 138_ = Throw.IfNull(chatMessage); 157_ = Throw.IfNull(client); 158_ = Throw.IfNull(chatMessage);
ChatCompletion\ChatFinishReason.cs (2)
27_value = Throw.IfNullOrWhitespace(value); 90Throw.IfNull(writer).WriteStringValue(value.Value);
ChatCompletion\ChatResponse.cs (1)
35_ = Throw.IfNull(message);
ChatCompletion\ChatResponseExtensions.cs (10)
28_ = Throw.IfNull(list); 29_ = Throw.IfNull(response); 57_ = Throw.IfNull(list); 58_ = Throw.IfNull(updates); 80_ = Throw.IfNull(list); 81_ = Throw.IfNull(update); 112_ = Throw.IfNull(list); 113_ = Throw.IfNull(updates); 135_ = Throw.IfNull(updates); 163_ = Throw.IfNull(updates);
ChatCompletion\ChatResponseFormat.cs (1)
82_ = Throw.IfNull(schemaType);
ChatCompletion\ChatResponseFormatJson.cs (1)
25Throw.ArgumentException(
ChatCompletion\ChatRole.cs (2)
48Value = Throw.IfNullOrWhitespace(value); 100Throw.IfNull(writer).WriteStringValue(value.Value);
ChatCompletion\DelegatingChatClient.cs (2)
29InnerClient = Throw.IfNull(innerClient); 55_ = Throw.IfNull(serviceType);
ChatCompletion\RequiredChatToolMode.cs (1)
38_ = Throw.IfNullOrWhitespace(requiredFunctionName);
Contents\DataContent.cs (4)
63: this(Throw.IfNull(uri).ToString(), mediaType) 80_uri = Throw.IfNullOrWhitespace(uri); 83Throw.ArgumentException(nameof(uri), "The provided URI is not a data URI."); 93Throw.ArgumentNullException(nameof(mediaType), $"{nameof(uri)} did not contain a media type, and {nameof(mediaType)} was not provided.");
Contents\DataUriParser.cs (2)
75_ = Throw.IfNullOrWhitespace(mediaType, parameterName); 79Throw.ArgumentException(parameterName, $"An invalid media type was specified: '{mediaType}'");
Contents\FunctionApprovalRequestContent.cs (1)
27FunctionCall = Throw.IfNull(functionCall);
Contents\FunctionApprovalResponseContent.cs (1)
29FunctionCall = Throw.IfNull(functionCall);
Contents\FunctionCallContent.cs (6)
28CallId = Throw.IfNull(callId); 29Name = Throw.IfNull(name); 78_ = Throw.IfNull(encodedArguments); 79_ = Throw.IfNull(callId); 80_ = Throw.IfNull(name); 81_ = Throw.IfNull(argumentParser);
Contents\FunctionResultContent.cs (1)
30CallId = Throw.IfNull(callId);
Contents\HostedFileContent.cs (2)
30_fileId = Throw.IfNullOrWhitespace(fileId); 41set => _fileId = Throw.IfNullOrWhitespace(value);
Contents\HostedVectorStoreContent.cs (2)
31_vectorStoreId = Throw.IfNullOrWhitespace(vectorStoreId); 42set => _vectorStoreId = Throw.IfNullOrWhitespace(value);
Contents\McpServerToolApprovalRequestContent.cs (1)
27ToolCall = Throw.IfNull(toolCall);
Contents\McpServerToolCallContent.cs (3)
31CallId = Throw.IfNullOrWhitespace(callId); 32ToolName = Throw.IfNullOrWhitespace(toolName); 33ServerName = Throw.IfNullOrWhitespace(serverName);
Contents\McpServerToolResultContent.cs (1)
29CallId = Throw.IfNullOrWhitespace(callId);
Contents\UriContent.cs (3)
40: this(new Uri(Throw.IfNull(uri)), mediaType) 58_uri = Throw.IfNull(uri); 66set => _uri = Throw.IfNull(value);
Contents\UsageContent.cs (2)
30_details = Throw.IfNull(details); 37set => _details = Throw.IfNull(value);
Contents\UserInputRequestContent.cs (1)
24Id = Throw.IfNullOrWhitespace(id);
Contents\UserInputResponseContent.cs (1)
24Id = Throw.IfNullOrWhitespace(id);
Embeddings\BinaryEmbedding.cs (7)
25_vector = Throw.IfNull(vector); 33set => _vector = Throw.IfNull(value); 47_ = Throw.IfNull(typeToConvert); 48_ = Throw.IfNull(options); 92_ = Throw.IfNull(writer); 93_ = Throw.IfNull(value); 94_ = Throw.IfNull(options);
Embeddings\DelegatingEmbeddingGenerator.cs (2)
30InnerGenerator = Throw.IfNull(innerGenerator); 50_ = Throw.IfNull(serviceType);
Embeddings\EmbeddingGenerationOptions.cs (1)
23_ = Throw.IfLessThan(value.Value, 1, nameof(value));
Embeddings\EmbeddingGeneratorExtensions.cs (14)
29_ = Throw.IfNull(generator); 52_ = Throw.IfNull(generator); 53_ = Throw.IfNull(serviceType); 57throw Throw.CreateMissingServiceException(serviceType, serviceKey); 77_ = Throw.IfNull(generator); 81throw Throw.CreateMissingServiceException(typeof(TService), serviceKey); 137_ = Throw.IfNull(generator); 138_ = Throw.IfNull(value); 144Throw.InvalidOperationException("Embedding generator returned a null collection of embeddings."); 149Throw.InvalidOperationException($"Expected the number of embeddings ({embeddings.Count}) to match the number of inputs (1)."); 155Throw.InvalidOperationException("Embedding generator generated a null embedding."); 182_ = Throw.IfNull(generator); 183_ = Throw.IfNull(values); 196Throw.InvalidOperationException($"Expected the number of embeddings ({embeddings.Count}) to match the number of inputs ({inputsCount}).");
Embeddings\GeneratedEmbeddings.cs (2)
30_embeddings = new List<TEmbedding>(Throw.IfLessThan(capacity, 0)); 39_embeddings = new List<TEmbedding>(Throw.IfNull(embeddings));
Functions\AIFunctionFactory.cs (16)
109_ = Throw.IfNull(method); 182_ = Throw.IfNull(method); 275_ = Throw.IfNull(method); 358_ = Throw.IfNull(method); 484Throw.IfNullOrEmpty(name), 503_ = Throw.IfNull(method); 507Throw.ArgumentException(nameof(method), "Open generic methods are not supported"); 512Throw.ArgumentNullException(nameof(target), "Target must not be null for an instance method."); 531_ = Throw.IfNull(method); 532_ = Throw.IfNull(createInstanceFunc); 536Throw.ArgumentException(nameof(method), "Open generic methods are not supported"); 541Throw.ArgumentException(nameof(method), "The method must be an instance method."); 592Throw.InvalidOperationException("Unable to create an instance of the target type."); 793Throw.ArgumentException(nameof(parameter), "Parameter is missing a name."); 889Throw.ArgumentException(nameof(arguments), $"The arguments dictionary is missing a value for the required parameter '{parameter.Name}'."); 898Throw.ArgumentNullException($"arguments.{nameof(AIFunctionArguments.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\DelegatingAIFunction.cs (2)
26InnerFunction = Throw.IfNull(innerFunction); 63_ = Throw.IfNull(serviceType);
Functions\DelegatingAIFunctionDeclaration.cs (2)
23InnerFunction = Throw.IfNull(innerFunction); 50_ = Throw.IfNull(serviceType);
Image\DelegatingImageGenerator.cs (2)
29InnerGenerator = Throw.IfNull(innerGenerator); 52_ = Throw.IfNull(serviceType);
Image\ImageGeneratorExtensions.cs (17)
42_ = Throw.IfNull(generator); 64_ = Throw.IfNull(generator); 65_ = Throw.IfNull(serviceType); 69throw Throw.CreateMissingServiceException(serviceType, serviceKey); 88_ = Throw.IfNull(generator); 92throw Throw.CreateMissingServiceException(typeof(TService), serviceKey); 113_ = Throw.IfNull(generator); 114_ = Throw.IfNull(prompt); 136_ = Throw.IfNull(generator); 137_ = Throw.IfNull(originalImages); 138_ = Throw.IfNull(prompt); 160_ = Throw.IfNull(generator); 161_ = Throw.IfNull(originalImage); 162_ = Throw.IfNull(prompt); 188_ = Throw.IfNull(generator); 189_ = Throw.IfNull(fileName); 190_ = Throw.IfNull(prompt);
SpeechToText\DelegatingSpeechToTextClient.cs (2)
30InnerClient = Throw.IfNull(innerClient); 60_ = Throw.IfNull(serviceType);
SpeechToText\SpeechToTextClientExtensions.cs (5)
29_ = Throw.IfNull(client); 46_ = Throw.IfNull(client); 47_ = Throw.IfNull(audioSpeechContent); 68_ = Throw.IfNull(client); 69_ = Throw.IfNull(audioSpeechContent);
SpeechToText\SpeechToTextResponse.cs (1)
29_contents = Throw.IfNull(contents);
SpeechToText\SpeechToTextResponseUpdate.cs (1)
46_contents = Throw.IfNull(contents);
SpeechToText\SpeechToTextResponseUpdateExtensions.cs (2)
24_ = Throw.IfNull(updates); 45_ = Throw.IfNull(updates);
SpeechToText\SpeechToTextResponseUpdateKind.cs (2)
50Value = Throw.IfNullOrWhitespace(value); 102=> Throw.IfNull(writer).WriteStringValue(value.Value);
src\Shared\JsonSchemaExporter\JsonSchemaExporter.cs (3)
52_ = Throw.IfNull(options); 53_ = Throw.IfNull(type); 72_ = Throw.IfNull(typeInfo);
src\Shared\JsonSchemaExporter\JsonSchemaExporter.ReflectionHelpers.cs (5)
42_jsonTypeInfo_ElementType = Throw.IfNull(elementTypeProperty); 54_jsonPropertyInfo_MemberName = Throw.IfNull(memberName); 69_nullableConverter_ElementConverter_Generic = Throw.IfNull(genericFieldInfo); 86_enumConverter_Options_Generic = Throw.IfNull(genericFieldInfo); 95_enumConverter_NamingPolicy_Generic = Throw.IfNull(genericFieldInfo);
Tools\AITool.cs (1)
45_ = Throw.IfNull(serviceType);
Tools\HostedMcpServerTool.cs (3)
25: this(serverName, new Uri(Throw.IfNull(url))) 38ServerName = Throw.IfNullOrWhitespace(serverName); 39Url = Throw.IfNull(url);
UsageDetails.cs (1)
36_ = Throw.IfNull(usage);
Utilities\AIJsonSchemaTransformCache.cs (4)
38_ = Throw.IfNull(transformOptions); 42Throw.ArgumentException(nameof(transformOptions), "The options instance does not specify any transformations."); 71_ = Throw.IfNull(function); 82_ = Throw.IfNull(responseFormat);
Utilities\AIJsonUtilities.cs (7)
36_ = Throw.IfNull(options); 37_ = Throw.IfNull(typeDiscriminatorId); 53_ = Throw.IfNull(options); 54_ = Throw.IfNull(contentType); 55_ = Throw.IfNull(typeDiscriminatorId); 59Throw.ArgumentException(nameof(contentType), "The content type must derive from AIContent."); 193Throw.ArgumentException(nameof(contentType), "Cannot register built-in AI content types.");
Utilities\AIJsonUtilities.Schema.Create.cs (3)
79_ = Throw.IfNull(method); 92Throw.ArgumentException(nameof(parameter), "Parameter is missing a name."); 197Throw.ArgumentException(paramName ?? "schema", "The schema document must be an object or a boolean value.");
Utilities\AIJsonUtilities.Schema.Transform.cs (3)
25_ = Throw.IfNull(transformOptions); 29Throw.ArgumentException(nameof(transformOptions), "The options instance does not specify any transformations."); 192Throw.ArgumentException(nameof(schema), "Schema must be an object or a boolean value.");