222 references to Throw
Microsoft.Extensions.AI.Abstractions (222)
AdditionalPropertiesDictionary{TValue}.cs (2)
205
_ =
Throw
.IfNull(items);
252
private readonly AdditionalPropertiesDictionary<TValue> _properties =
Throw
.IfNull(properties);
ChatCompletion\ChatClientExtensions.cs (14)
27
_ =
Throw
.IfNull(client);
49
_ =
Throw
.IfNull(client);
50
_ =
Throw
.IfNull(serviceType);
54
throw
Throw
.CreateMissingServiceException(serviceType, serviceKey);
73
_ =
Throw
.IfNull(client);
77
throw
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)
24
Value =
Throw
.IfNullOrWhitespace(value);
87
Throw
.IfNull(writer).WriteStringValue(value.Value);
ChatCompletion\ChatResponse.cs (1)
35
_ =
Throw
.IfNull(message);
ChatCompletion\ChatResponseExtensions.cs (10)
32
_ =
Throw
.IfNull(list);
33
_ =
Throw
.IfNull(response);
61
_ =
Throw
.IfNull(list);
62
_ =
Throw
.IfNull(updates);
84
_ =
Throw
.IfNull(list);
85
_ =
Throw
.IfNull(update);
116
_ =
Throw
.IfNull(list);
117
_ =
Throw
.IfNull(updates);
139
_ =
Throw
.IfNull(updates);
167
_ =
Throw
.IfNull(updates);
ChatCompletion\ChatResponseFormat.cs (1)
82
_ =
Throw
.IfNull(schemaType);
ChatCompletion\ChatResponseFormatJson.cs (1)
25
Throw
.ArgumentException(
ChatCompletion\ChatRole.cs (2)
48
Value =
Throw
.IfNullOrWhitespace(value);
100
Throw
.IfNull(writer).WriteStringValue(value.Value);
ChatCompletion\DelegatingChatClient.cs (2)
29
InnerClient =
Throw
.IfNull(innerClient);
55
_ =
Throw
.IfNull(serviceType);
ChatCompletion\RequiredChatToolMode.cs (1)
38
_ =
Throw
.IfNullOrWhitespace(requiredFunctionName);
ChatRouting\RoutingChatClient.cs (4)
45
_ =
Throw
.IfNull(clientSelector);
67
_ =
Throw
.IfNull(messages);
84
_ =
Throw
.IfNull(messages);
102
_ =
Throw
.IfNull(serviceType);
ChatRouting\RoutingContext.cs (1)
33
_ =
Throw
.IfNull(messages);
Contents\DataContent.cs (7)
69
: this(
Throw
.IfNull(uri).ToString(), mediaType)
86
_uri =
Throw
.IfNullOrWhitespace(uri);
89
Throw
.ArgumentException(nameof(uri), "The provided URI is not a data URI.");
99
Throw
.ArgumentNullException(nameof(mediaType), $"{nameof(uri)} did not contain a media type, and {nameof(mediaType)} was not provided.");
147
_ =
Throw
.IfNullOrEmpty(path);
167
_ =
Throw
.IfNull(stream);
214
_ =
Throw
.IfNull(path);
Contents\DataUriParser.cs (2)
85
_ =
Throw
.IfNullOrWhitespace(mediaType, parameterName);
89
Throw
.ArgumentException(parameterName, $"An invalid media type was specified: '{mediaType}'");
Contents\FunctionCallContent.cs (5)
29
Name =
Throw
.IfNull(name);
83
_ =
Throw
.IfNull(encodedArguments);
84
_ =
Throw
.IfNull(callId);
85
_ =
Throw
.IfNull(name);
86
_ =
Throw
.IfNull(argumentParser);
Contents\HostedFileContent.cs (2)
31
FileId =
Throw
.IfNullOrWhitespace(fileId);
42
set => field =
Throw
.IfNullOrWhitespace(value);
Contents\HostedVectorStoreContent.cs (2)
31
_vectorStoreId =
Throw
.IfNullOrWhitespace(vectorStoreId);
42
set => _vectorStoreId =
Throw
.IfNullOrWhitespace(value);
Contents\InputRequestContent.cs (1)
24
RequestId =
Throw
.IfNullOrWhitespace(requestId);
Contents\InputResponseContent.cs (1)
24
RequestId =
Throw
.IfNullOrWhitespace(requestId);
Contents\McpServerToolCallContent.cs (2)
35
: base(
Throw
.IfNullOrWhitespace(callId))
37
Name =
Throw
.IfNullOrWhitespace(name);
Contents\McpServerToolResultContent.cs (1)
26
: base(
Throw
.IfNullOrWhitespace(callId))
Contents\ToolApprovalRequestContent.cs (1)
29
ToolCall =
Throw
.IfNull(toolCall);
Contents\ToolApprovalResponseContent.cs (1)
29
ToolCall =
Throw
.IfNull(toolCall);
Contents\ToolCallContent.cs (1)
27
CallId =
Throw
.IfNull(callId);
Contents\ToolResultContent.cs (1)
27
CallId =
Throw
.IfNull(callId);
Contents\UriContent.cs (3)
42
: this(new Uri(
Throw
.IfNull(uri)), mediaType)
58
_uri =
Throw
.IfNull(uri);
68
set => _uri =
Throw
.IfNull(value);
Contents\UsageContent.cs (2)
30
_details =
Throw
.IfNull(details);
37
set => _details =
Throw
.IfNull(value);
Embeddings\BinaryEmbedding.cs (7)
25
_vector =
Throw
.IfNull(vector);
33
set => _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)
30
InnerGenerator =
Throw
.IfNull(innerGenerator);
50
_ =
Throw
.IfNull(serviceType);
Embeddings\EmbeddingGenerationOptions.cs (1)
40
_ =
Throw
.IfLessThan(value.Value, 1, nameof(value));
Embeddings\EmbeddingGeneratorExtensions.cs (14)
29
_ =
Throw
.IfNull(generator);
52
_ =
Throw
.IfNull(generator);
53
_ =
Throw
.IfNull(serviceType);
57
throw
Throw
.CreateMissingServiceException(serviceType, serviceKey);
77
_ =
Throw
.IfNull(generator);
81
throw
Throw
.CreateMissingServiceException(typeof(TService), serviceKey);
137
_ =
Throw
.IfNull(generator);
138
_ =
Throw
.IfNull(value);
144
Throw
.InvalidOperationException("Embedding generator returned a null collection of embeddings.");
149
Throw
.InvalidOperationException($"Expected the number of embeddings ({embeddings.Count}) to match the number of inputs (1).");
155
Throw
.InvalidOperationException("Embedding generator generated a null embedding.");
182
_ =
Throw
.IfNull(generator);
183
_ =
Throw
.IfNull(values);
196
Throw
.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));
Files\DelegatingHostedFileClient.cs (2)
32
InnerClient =
Throw
.IfNull(innerClient);
77
_ =
Throw
.IfNull(serviceType);
Files\HostedFileClientExtensions.cs (18)
38
_ =
Throw
.IfNull(client);
39
_ =
Throw
.IfNull(content);
65
_ =
Throw
.IfNull(client);
66
_ =
Throw
.IfNullOrEmpty(filePath);
100
_ =
Throw
.IfNull(client);
101
_ =
Throw
.IfNullOrWhitespace(fileId);
102
_ =
Throw
.IfNull(destinationPath);
155
_ =
Throw
.IfNull(client);
156
_ =
Throw
.IfNull(hostedFile);
189
_ =
Throw
.IfNull(client);
190
_ =
Throw
.IfNullOrWhitespace(fileId);
205
_ =
Throw
.IfNull(client);
220
_ =
Throw
.IfNull(client);
242
_ =
Throw
.IfNull(client);
243
_ =
Throw
.IfNull(serviceType);
247
throw
Throw
.CreateMissingServiceException(serviceType, serviceKey);
266
_ =
Throw
.IfNull(client);
270
throw
Throw
.CreateMissingServiceException(typeof(TService), serviceKey);
Functions\AIFunctionFactory.cs (19)
129
_ =
Throw
.IfNull(method);
204
_ =
Throw
.IfNull(method);
301
_ =
Throw
.IfNull(method);
386
_ =
Throw
.IfNull(method);
516
Throw
.IfNullOrEmpty(name),
535
_ =
Throw
.IfNull(method);
539
Throw
.ArgumentException(nameof(method), "Open generic methods are not supported");
544
Throw
.ArgumentNullException(nameof(target), "Target must not be null for an instance method.");
563
_ =
Throw
.IfNull(method);
564
_ =
Throw
.IfNull(createInstanceFunc);
568
Throw
.ArgumentException(nameof(method), "Open generic methods are not supported");
573
Throw
.ArgumentException(nameof(method), "The method must be an instance method.");
624
Throw
.InvalidOperationException("Unable to create an instance of the target type.");
662
Throw
.ArgumentException(
670
Throw
.ArgumentException(
819
Throw
.ArgumentException("method", $"Multiple parameters are mapped to the same name '{effectiveName}'. Ensure that any {nameof(AIParameterNameAttribute)} values do not collide with each other or with other parameter names.");
915
Throw
.ArgumentException(nameof(parameter), "Parameter is missing a name.");
1014
Throw
.ArgumentException(nameof(arguments), $"The arguments dictionary is missing a value for the required parameter '{argumentName}'.");
1023
Throw
.ArgumentNullException($"arguments.{nameof(AIFunctionArguments.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\AIFunctionNameAttribute.cs (1)
26
Name =
Throw
.IfNullOrWhitespace(name);
Functions\AIParameterNameAttribute.cs (1)
26
Name =
Throw
.IfNullOrWhitespace(name);
Functions\DelegatingAIFunction.cs (2)
26
InnerFunction =
Throw
.IfNull(innerFunction);
63
_ =
Throw
.IfNull(serviceType);
Functions\DelegatingAIFunctionDeclaration.cs (2)
23
InnerFunction =
Throw
.IfNull(innerFunction);
50
_ =
Throw
.IfNull(serviceType);
Image\DelegatingImageGenerator.cs (2)
30
InnerGenerator =
Throw
.IfNull(innerGenerator);
53
_ =
Throw
.IfNull(serviceType);
Image\ImageGeneratorExtensions.cs (17)
31
_ =
Throw
.IfNull(generator);
53
_ =
Throw
.IfNull(generator);
54
_ =
Throw
.IfNull(serviceType);
58
throw
Throw
.CreateMissingServiceException(serviceType, serviceKey);
77
_ =
Throw
.IfNull(generator);
81
throw
Throw
.CreateMissingServiceException(typeof(TService), serviceKey);
102
_ =
Throw
.IfNull(generator);
103
_ =
Throw
.IfNull(prompt);
125
_ =
Throw
.IfNull(generator);
126
_ =
Throw
.IfNull(originalImages);
127
_ =
Throw
.IfNull(prompt);
149
_ =
Throw
.IfNull(generator);
150
_ =
Throw
.IfNull(originalImage);
151
_ =
Throw
.IfNull(prompt);
177
_ =
Throw
.IfNull(generator);
178
_ =
Throw
.IfNull(fileName);
179
_ =
Throw
.IfNull(prompt);
Realtime\CreateConversationItemRealtimeClientMessage.cs (2)
26
_item =
Throw
.IfNull(item);
36
set => _item =
Throw
.IfNull(value);
Realtime\DelegatingRealtimeClient.cs (2)
30
InnerClient =
Throw
.IfNull(innerClient);
51
_ =
Throw
.IfNull(serviceType);
Realtime\InputAudioBufferAppendRealtimeClientMessage.cs (2)
26
_content =
Throw
.IfNull(audioContent);
39
set => _content =
Throw
.IfNull(value);
Realtime\RealtimeServerMessageType.cs (2)
109
Value =
Throw
.IfNullOrWhitespace(value);
161
Throw
.IfNull(writer).WriteStringValue(value.Value);
Realtime\RealtimeSessionKind.cs (2)
46
Value =
Throw
.IfNullOrWhitespace(value);
98
Throw
.IfNull(writer).WriteStringValue(value.Value);
Realtime\SessionUpdateRealtimeClientMessage.cs (1)
35
Options =
Throw
.IfNull(options);
ResponseContinuationToken.cs (2)
59
_ =
Throw
.IfNull(writer);
60
_ =
Throw
.IfNull(value);
SpeechToText\DelegatingSpeechToTextClient.cs (2)
31
InnerClient =
Throw
.IfNull(innerClient);
61
_ =
Throw
.IfNull(serviceType);
SpeechToText\SpeechToTextClientExtensions.cs (5)
30
_ =
Throw
.IfNull(client);
47
_ =
Throw
.IfNull(client);
48
_ =
Throw
.IfNull(audioSpeechContent);
69
_ =
Throw
.IfNull(client);
70
_ =
Throw
.IfNull(audioSpeechContent);
SpeechToText\SpeechToTextResponse.cs (1)
30
_contents =
Throw
.IfNull(contents);
SpeechToText\SpeechToTextResponseUpdate.cs (1)
47
_contents =
Throw
.IfNull(contents);
SpeechToText\SpeechToTextResponseUpdateExtensions.cs (2)
25
_ =
Throw
.IfNull(updates);
46
_ =
Throw
.IfNull(updates);
SpeechToText\SpeechToTextResponseUpdateKind.cs (2)
51
Value =
Throw
.IfNullOrWhitespace(value);
103
=>
Throw
.IfNull(writer).WriteStringValue(value.Value);
TextToSpeech\DelegatingTextToSpeechClient.cs (2)
30
InnerClient =
Throw
.IfNull(innerClient);
60
_ =
Throw
.IfNull(serviceType);
TextToSpeech\TextToSpeechClientExtensions.cs (1)
25
_ =
Throw
.IfNull(client);
TextToSpeech\TextToSpeechResponse.cs (1)
26
Contents =
Throw
.IfNull(contents);
TextToSpeech\TextToSpeechResponseUpdate.cs (1)
44
Contents =
Throw
.IfNull(contents);
TextToSpeech\TextToSpeechResponseUpdateExtensions.cs (2)
25
_ =
Throw
.IfNull(updates);
44
_ =
Throw
.IfNull(updates);
TextToSpeech\TextToSpeechResponseUpdateKind.cs (2)
51
Value =
Throw
.IfNullOrWhitespace(value);
103
=>
Throw
.IfNull(writer).WriteStringValue(value.Value);
Tools\AITool.cs (1)
45
_ =
Throw
.IfNull(serviceType);
Tools\HostedMcpServerTool.cs (4)
27
ServerName =
Throw
.IfNullOrWhitespace(serverName);
28
ServerAddress =
Throw
.IfNullOrWhitespace(serverAddress);
75
_ =
Throw
.IfNull(serverAddress);
79
Throw
.ArgumentException(nameof(serverAddress), "The provided URL is not absolute.");
UsageDetails.cs (1)
120
_ =
Throw
.IfNull(usage);
Utilities\AIJsonSchemaTransformCache.cs (4)
38
_ =
Throw
.IfNull(transformOptions);
42
Throw
.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);
59
Throw
.ArgumentException(nameof(contentType), $"The content type must derive from {nameof(AIContent)}.");
197
Throw
.ArgumentException(nameof(contentType), $"Cannot register built-in {nameof(AIContent)} types.");
Utilities\AIJsonUtilities.Schema.Create.cs (4)
82
_ =
Throw
.IfNull(method);
96
Throw
.ArgumentException(nameof(parameter), "Parameter is missing a name.");
135
Throw
.ArgumentException(nameof(method), $"Multiple parameters are mapped to the same name '{parameterSchemaName}'. Ensure that any {nameof(AIParameterNameAttribute)} values do not collide with each other or with other parameter names.");
219
Throw
.ArgumentException(paramName ?? "schema", "The schema document must be an object or a boolean value.");
Utilities\AIJsonUtilities.Schema.Transform.cs (3)
25
_ =
Throw
.IfNull(transformOptions);
29
Throw
.ArgumentException(nameof(transformOptions), "The options instance does not specify any transformations.");
192
Throw
.ArgumentException(nameof(schema), "Schema must be an object or a boolean value.");