89 references to Throw
Microsoft.Extensions.AI.Abstractions (89)
AdditionalPropertiesDictionary{TValue}.cs (2)
208
_ =
Throw
.IfNull(items);
255
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)
27
_value =
Throw
.IfNullOrWhitespace(value);
90
Throw
.IfNull(writer).WriteStringValue(value.Value);
ChatCompletion\ChatResponse.cs (1)
35
_ =
Throw
.IfNull(message);
ChatCompletion\ChatResponseExtensions.cs (8)
28
_ =
Throw
.IfNull(list);
29
_ =
Throw
.IfNull(response);
57
_ =
Throw
.IfNull(list);
58
_ =
Throw
.IfNull(updates);
84
_ =
Throw
.IfNull(list);
85
_ =
Throw
.IfNull(updates);
107
_ =
Throw
.IfNull(updates);
135
_ =
Throw
.IfNull(updates);
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)
27
InnerClient =
Throw
.IfNull(innerClient);
53
_ =
Throw
.IfNull(serviceType);
ChatCompletion\RequiredChatToolMode.cs (1)
38
_ =
Throw
.IfNullOrWhitespace(requiredFunctionName);
Contents\DataContent.cs (4)
57
: this(
Throw
.IfNull(uri).ToString(), mediaType)
73
_uri =
Throw
.IfNullOrWhitespace(uri);
77
Throw
.ArgumentException(nameof(uri), "The provided URI is not a data URI.");
87
Throw
.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);
79
Throw
.ArgumentException(parameterName, $"An invalid media type was specified: '{mediaType}'");
Contents\FunctionCallContent.cs (6)
28
CallId =
Throw
.IfNull(callId);
29
Name =
Throw
.IfNull(name);
78
_ =
Throw
.IfNull(encodedArguments);
79
_ =
Throw
.IfNull(callId);
80
_ =
Throw
.IfNull(name);
81
_ =
Throw
.IfNull(argumentParser);
Contents\FunctionResultContent.cs (1)
30
CallId =
Throw
.IfNull(callId);
Contents\UriContent.cs (3)
40
: this(new Uri(
Throw
.IfNull(uri)), mediaType)
58
_uri =
Throw
.IfNull(uri);
66
set => _uri =
Throw
.IfNull(value);
Contents\UsageContent.cs (2)
30
_details =
Throw
.IfNull(details);
37
set => _details =
Throw
.IfNull(value);
Embeddings\DelegatingEmbeddingGenerator.cs (2)
30
InnerGenerator =
Throw
.IfNull(innerGenerator);
50
_ =
Throw
.IfNull(serviceType);
Embeddings\EmbeddingGenerationOptions.cs (1)
21
_ =
Throw
.IfLessThan(value.Value, 1, nameof(value));
Embeddings\EmbeddingGeneratorExtensions.cs (14)
32
_ =
Throw
.IfNull(generator);
55
_ =
Throw
.IfNull(generator);
56
_ =
Throw
.IfNull(serviceType);
60
throw
Throw
.CreateMissingServiceException(serviceType, serviceKey);
80
_ =
Throw
.IfNull(generator);
84
throw
Throw
.CreateMissingServiceException(typeof(TService), serviceKey);
140
_ =
Throw
.IfNull(generator);
141
_ =
Throw
.IfNull(value);
147
Throw
.InvalidOperationException("Embedding generator returned a null collection of embeddings.");
152
Throw
.InvalidOperationException($"Expected the number of embeddings ({embeddings.Count}) to match the number of inputs (1).");
158
Throw
.InvalidOperationException("Embedding generator generated a null embedding.");
185
_ =
Throw
.IfNull(generator);
186
_ =
Throw
.IfNull(values);
199
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));
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)
44
_jsonTypeInfo_ElementType =
Throw
.IfNull(elementTypeProperty);
56
_jsonPropertyInfo_MemberName =
Throw
.IfNull(memberName);
71
_nullableConverter_ElementConverter_Generic =
Throw
.IfNull(genericFieldInfo);
88
_enumConverter_Options_Generic =
Throw
.IfNull(genericFieldInfo);
97
_enumConverter_NamingPolicy_Generic =
Throw
.IfNull(genericFieldInfo);
UsageDetails.cs (1)
36
_ =
Throw
.IfNull(usage);
Utilities\AIJsonUtilities.cs (7)
37
_ =
Throw
.IfNull(options);
38
_ =
Throw
.IfNull(typeDiscriminatorId);
54
_ =
Throw
.IfNull(options);
55
_ =
Throw
.IfNull(contentType);
56
_ =
Throw
.IfNull(typeDiscriminatorId);
60
Throw
.ArgumentException(nameof(contentType), "The content type must derive from AIContent.");
165
Throw
.ArgumentException(nameof(contentType), "Cannot register built-in AI content types.");
Utilities\AIJsonUtilities.Schema.cs (3)
66
_ =
Throw
.IfNull(method);
79
Throw
.ArgumentException(nameof(parameter), "Parameter is missing a name.");
163
Throw
.ArgumentException(paramName ?? "schema", "The schema document must be an object or a boolean value.");