10 instantiations of JsonElement
Microsoft.AspNetCore.Components.WebAssembly.Server (1)
Microsoft.Build (1)
System.Text.Json (8)
1622 references to JsonElement
aspire (97)
DotNet\DotNetCliRunner.cs (13)
245var rootElement = jsonDocument.RootElement;
247if (!rootElement.TryGetProperty("Properties", out var properties))
252if (!properties.TryGetProperty("IsAspireHost", out var isAspireHostElement))
262if (rootElement.TryGetProperty("Items", out var items))
265if (items.TryGetProperty("PackageReference", out var packageReferences))
267foreach (var packageRef in packageReferences.EnumerateArray())
269if (packageRef.TryGetProperty("Identity", out var identity) &&
271packageRef.TryGetProperty("Version", out var version))
280if (aspireHostingVersion == null && items.TryGetProperty("AspireProjectOrPackageReference", out var aspireProjectOrPackageReferences))
282foreach (var aspireRef in aspireProjectOrPackageReferences.EnumerateArray())
284if (aspireRef.TryGetProperty("Identity", out var identity) &&
286aspireRef.TryGetProperty("Version", out var version))
296if (aspireHostingVersion == null && properties.TryGetProperty("AspireHostingSDKVersion", out var aspireHostingSdkVersionElement))
Npm\SigstoreNpmProvenanceChecker.cs (10)
268if (predicate.TryGetProperty("buildDefinition", out var buildDefinition) &&
271if (buildDefinition.TryGetProperty("buildType", out var buildTypeElement) &&
277if (buildDefinition.TryGetProperty("externalParameters", out var extParams) &&
279extParams.TryGetProperty("workflow", out var workflow) &&
282if (workflow.TryGetProperty("repository", out var repoEl) &&
288if (workflow.TryGetProperty("path", out var pathEl) &&
294if (workflow.TryGetProperty("ref", out var refEl) &&
302if (predicate.TryGetProperty("runDetails", out var runDetails) &&
304runDetails.TryGetProperty("builder", out var builder) &&
307if (builder.TryGetProperty("id", out var idEl) &&
Aspire.Azure.Npgsql (6)
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL (6)
Aspire.Cli.Tests (32)
Aspire.Dashboard (3)
Aspire.Dashboard.Tests (7)
Aspire.Hosting (15)
Dcp\DcpLogParser.cs (6)
143var root = doc.RootElement;
158("Cmd", root.TryGetProperty("Cmd", out var cmdProp) ? cmdProp.GetString() : null),
159("Args", root.TryGetProperty("Args", out var argsProp) ? argsProp.ToString() : null),
160("ContainerName", root.TryGetProperty("ContainerName", out var containerNameProp) ? containerNameProp.GetString() : null),
161("ContainerId", root.TryGetProperty("ContainerID", out var containerIdProp) ? containerIdProp.GetString() : null),
162("Error", root.TryGetProperty("error", out var errorProp) ? errorProp.GetString() : null)
Aspire.Hosting.JavaScript (2)
Aspire.Hosting.Maui (3)
Aspire.Hosting.OpenAI (3)
Aspire.Hosting.PostgreSQL.Tests (1)
Aspire.Hosting.Seq.Tests (2)
Aspire.Hosting.Tests (39)
Aspire.Templates.Tests (2)
dotnet (17)
dotnet-aot (11)
dotnet-openapi (1)
dotnet-sourcelink (1)
dotnet-user-jwts (8)
ILCompiler.Compiler (1)
ILCompiler.ReadyToRun (4)
Infrastructure.Tests (11)
Microsoft.AspNetCore.Authentication (4)
Microsoft.AspNetCore.Authentication.DeviceBoundSessions (2)
Microsoft.AspNetCore.Authentication.OAuth (24)
Microsoft.AspNetCore.Authentication.OpenIdConnect (1)
Microsoft.AspNetCore.Authentication.Twitter (5)
Microsoft.AspNetCore.Components.Endpoints (46)
_generated\20\BrowserOptionsJsonContext.InteractiveServerBrowserOptions.g.cs (3)
113var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>
128AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions).GetProperty("Extensions", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>), global::System.Array.Empty<global::System.Type>(), null),
131properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>(options, info3);
_generated\25\BrowserOptionsJsonContext.IDictionaryStringJsonElement.g.cs (13)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>? _IDictionaryStringJsonElement;
19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>> IDictionaryStringJsonElement
22get => _IDictionaryStringJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>)Options.GetTypeInfo(typeof(global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>));
25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>> Create_IDictionaryStringJsonElement(global::System.Text.Json.JsonSerializerOptions options)
27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>> jsonTypeInfo))
29var info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>>
31ObjectCreator = () => new global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>(),
37jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateIDictionaryInfo<global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>, string, global::System.Text.Json.JsonElement>(options, info);
47private void IDictionaryStringJsonElementSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>? value)
57foreach (global::System.Collections.Generic.KeyValuePair<string, global::System.Text.Json.JsonElement> entry in value)
src\aspnetcore\src\Components\Shared\src\RenderFragmentSerializer.cs (6)
274builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
301builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
333var value = attr.Value is JsonElement je
361JsonElement je => JsonSerializer.Deserialize<SerializedRenderFragment>(je.GetRawText(), jsonOptions),
368return attr.Value is JsonElement json ? ConvertTypedValue(json, attr.TypeAssembly!, attr.TypeName!, jsonOptions, typeCache) : attr.Value;
372private static object? ConvertTypedValue(JsonElement json, string assemblyName, string typeName, JsonSerializerOptions? jsonOptions, ComponentParametersTypeCache typeCache)
Microsoft.AspNetCore.Components.Server (14)
src\aspnetcore\src\Components\Shared\src\RenderFragmentSerializer.cs (6)
274builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
301builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
333var value = attr.Value is JsonElement je
361JsonElement je => JsonSerializer.Deserialize<SerializedRenderFragment>(je.GetRawText(), jsonOptions),
368return attr.Value is JsonElement json ? ConvertTypedValue(json, attr.TypeAssembly!, attr.TypeName!, jsonOptions, typeCache) : attr.Value;
372private static object? ConvertTypedValue(JsonElement json, string assemblyName, string typeName, JsonSerializerOptions? jsonOptions, ComponentParametersTypeCache typeCache)
Microsoft.AspNetCore.Components.Web (46)
Microsoft.AspNetCore.Components.WebAssembly (22)
src\aspnetcore\src\Components\Shared\src\RenderFragmentSerializer.cs (6)
274builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
301builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
333var value = attr.Value is JsonElement je
361JsonElement je => JsonSerializer.Deserialize<SerializedRenderFragment>(je.GetRawText(), jsonOptions),
368return attr.Value is JsonElement json ? ConvertTypedValue(json, attr.TypeAssembly!, attr.TypeName!, jsonOptions, typeCache) : attr.Value;
372private static object? ConvertTypedValue(JsonElement json, string assemblyName, string typeName, JsonSerializerOptions? jsonOptions, ComponentParametersTypeCache typeCache)
Microsoft.AspNetCore.Components.WebAssembly.Authentication (13)
Microsoft.AspNetCore.Components.WebAssembly.Server (12)
Microsoft.AspNetCore.Components.WebView (6)
IpcCommon.cs (6)
19public static bool TryDeserializeIncoming(string message, out IncomingMessageType messageType, out ArraySegment<JsonElement> args)
22public static bool TryDeserializeOutgoing(string message, out OutgoingMessageType messageType, out ArraySegment<JsonElement> args)
37private static bool TryDeserialize<T>(string message, out T messageType, out ArraySegment<JsonElement> args)
44var parsed = (JsonElement[])JsonSerializer.Deserialize(messageAfterPrefix, typeof(JsonElement[]), JsonSerializerOptionsProvider.Options);
46args = new ArraySegment<JsonElement>(parsed, 1, parsed.Length - 1);
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
Microsoft.AspNetCore.Http.Extensions (10)
Microsoft.AspNetCore.Identity (44)
_generated\31\IdentityJsonSerializerContext.PublicKeyCredentialAuthenticatorAssertionResponse.g.cs (6)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse>(){ Id = (global::Microsoft.AspNetCore.Identity.BufferSource)args[0], Type = (string)args[1], ClientExtensionResults = (global::System.Text.Json.JsonElement)args[2], Response = (global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse)args[3] },
99var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement>
114AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse>).GetProperty("ClientExtensionResults", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement), global::System.Array.Empty<global::System.Type>(), null),
117properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement>(options, info2);
229ParameterType = typeof(global::System.Text.Json.JsonElement),
253public static extern void __set_PublicKeyCredentialAuthenticatorAssertionResponse_ClientExtensionResults(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<TResponse> obj, global::System.Text.Json.JsonElement value);
_generated\32\IdentityJsonSerializerContext.PublicKeyCredentialAuthenticatorAttestationResponse.g.cs (6)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse>(){ Id = (global::Microsoft.AspNetCore.Identity.BufferSource)args[0], Type = (string)args[1], ClientExtensionResults = (global::System.Text.Json.JsonElement)args[2], Response = (global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse)args[3] },
99var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement>
114AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse>).GetProperty("ClientExtensionResults", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement), global::System.Array.Empty<global::System.Type>(), null),
117properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement>(options, info2);
229ParameterType = typeof(global::System.Text.Json.JsonElement),
253public static extern void __set_PublicKeyCredentialAuthenticatorAttestationResponse_ClientExtensionResults(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<TResponse> obj, global::System.Text.Json.JsonElement value);
Microsoft.AspNetCore.JsonPatch.SystemTextJson (7)
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
Microsoft.Build (3)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts (2)
Microsoft.Deployment.DotNet.Releases (34)
Microsoft.Diagnostics.DataContractReader (28)
_generated\0\ContractDescriptorContext.ContractDescriptor.g.cs (3)
175var info6 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
190AttributeProviderFactory = static () => typeof(global::Microsoft.Diagnostics.DataContractReader.ContractDescriptorParser.ContractDescriptor).GetProperty("Extras", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>), global::System.Array.Empty<global::System.Type>(), null),
193properties[6] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, info6);
_generated\7\ContractDescriptorContext.DictionaryStringJsonElement.g.cs (13)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>? _DictionaryStringJsonElement;
21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> DictionaryStringJsonElement
24get => _DictionaryStringJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>)Options.GetTypeInfo(typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>));
27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> Create_DictionaryStringJsonElement(global::System.Text.Json.JsonSerializerOptions options)
29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> jsonTypeInfo))
31var info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
33ObjectCreator = () => new global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>(),
39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateDictionaryInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>, string, global::System.Text.Json.JsonElement>(options, info);
49private void DictionaryStringJsonElementSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>? value)
59foreach (global::System.Collections.Generic.KeyValuePair<string, global::System.Text.Json.JsonElement> entry in value)
Microsoft.DotNet.Arcade.Sdk (3)
Microsoft.DotNet.ProjectTools (6)
Microsoft.Extensions.AI (33)
Microsoft.Extensions.AI.Abstractions (76)
Functions\AIFunctionFactory.cs (24)
96/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
108/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
177/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
189/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="serializerOptions"/> if provided,
267/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
279/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
356/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
368/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="serializerOptions"/> if provided,
415/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
418/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/>. If the argument is a <see cref="JsonElement"/>,
459/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
471/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
513JsonElement jsonSchema,
514JsonElement? returnJsonSchema = null) =>
522string name, string description, JsonElement jsonSchema, JsonElement? returnJsonSchema) :
527public override JsonElement JsonSchema => jsonSchema;
528public override JsonElement? ReturnJsonSchema => returnJsonSchema;
604public override JsonElement JsonSchema => FunctionDescriptor.JsonSchema;
605public override JsonElement? ReturnJsonSchema => FunctionDescriptor.ReturnJsonSchema;
850public JsonElement JsonSchema { get; }
851public JsonElement? ReturnJsonSchema { get; }
973JsonElement element => JsonSerializer.Deserialize(element, typeInfo),
1201return JsonElement.ParseValue(ref reader);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.ChatResponseFormatJson.g.cs (7)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.ChatResponseFormatJson((global::System.Text.Json.JsonElement?)args[0], (string)args[1], (string)args[2]),
37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.Text.Json.JsonElement?), typeof(string), typeof(string)}, modifiers: null),
53var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?>
68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetProperty("Schema", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null),
71properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info0);
128global::System.Text.Json.JsonElement? __value_Schema = ((global::Microsoft.Extensions.AI.ChatResponseFormatJson)value).Schema;
153ParameterType = typeof(global::System.Text.Json.JsonElement?),
Microsoft.Extensions.AI.Abstractions.Tests (173)
Generated\361d1da7f942c932\TestJsonSerializerContext.ChatResponseFormatJson.g.cs (7)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.ChatResponseFormatJson((global::System.Text.Json.JsonElement?)args[0], (string)args[1], (string)args[2]),
35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.Text.Json.JsonElement?), typeof(string), typeof(string)}, modifiers: null),
51var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?>
66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetProperty("Schema", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null),
69properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info0);
126global::System.Text.Json.JsonElement? __value_Schema = ((global::Microsoft.Extensions.AI.ChatResponseFormatJson)value).Schema;
151ParameterType = typeof(global::System.Text.Json.JsonElement?),
Utilities\AIJsonUtilitiesTests.cs (77)
152JsonElement expected = JsonDocument.Parse("""
174JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options);
182JsonElement expected = JsonDocument.Parse("""
189JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(object[]), serializerOptions: JsonContext.Default.Options);
197JsonElement expected = JsonDocument.Parse("""
232JsonElement actual = AIJsonUtilities.CreateJsonSchema(
246JsonElement expected = JsonDocument.Parse("""
282JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options, inferenceOptions: inferenceOptions);
295JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty);
322JsonElement expected = JsonDocument.Parse($$"""
358JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty, description: string.Empty, inferenceOptions: inferenceOptions);
368JsonElement schemaParameters = func.JsonSchema.GetProperty("properties");
388JsonElement expected = JsonDocument.Parse($$"""
394JsonElement actualSchema = property.Value;
434JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: string.Empty);
436Assert.True(schema.TryGetProperty("required", out JsonElement requiredElement));
496JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: string.Empty, serializerOptions: options);
499Assert.True(schema.TryGetProperty("properties", out JsonElement properties));
500Assert.True(properties.TryGetProperty("input", out JsonElement inputSchema));
503Assert.True(inputSchema.TryGetProperty("required", out JsonElement requiredElement));
515JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(TypeWithRequiredMembers), serializerOptions: JsonContext.Default.Options);
517Assert.True(schema.TryGetProperty("required", out JsonElement requiredElement));
557JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method);
560Assert.True(doc.RootElement.TryGetProperty("title", out JsonElement titleElement));
562Assert.True(doc.RootElement.TryGetProperty("description", out JsonElement descElement));
570JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method);
573Assert.True(schema.TryGetProperty("title", out JsonElement titleElement));
595JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: "override_title");
598Assert.True(doc.RootElement.TryGetProperty("title", out JsonElement titleElement));
611JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method);
613JsonElement properties = schema.GetProperty("properties");
662JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(object));
681JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
706JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options);
716JsonElement expectedSchema = JsonDocument.Parse("""
723JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(MyEnumValue?), serializerOptions: JsonContext.Default.Options);
1205JsonElement expectedSchema = JsonDocument.Parse("""
1218JsonElement actualSchema = AIJsonUtilities.CreateJsonSchema(typeof(ClassWithNullableMaxLengthProperty), serializerOptions: JsonContext.Default.Options);
1514JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1542JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1547JsonElement properties = schema.GetProperty("properties");
1559JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1569JsonElement properties = schema.GetProperty("properties");
1583JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1588JsonElement properties = schema.GetProperty("properties");
1602JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1607JsonElement properties = schema.GetProperty("properties");
1620JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1629JsonElement properties = schema.GetProperty("properties");
1638JsonElement schema = JsonDocument.Parse("""
1649JsonElement expectedSchema = JsonDocument.Parse("""
1665JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1672JsonElement schema = JsonDocument.Parse("""
1683JsonElement expectedSchema = JsonDocument.Parse("""
1699JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1706JsonElement schema = JsonDocument.Parse("""
1717JsonElement expectedSchema = JsonDocument.Parse("""
1734JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1741JsonElement schema = JsonDocument.Parse("""
1753JsonElement expectedSchema = JsonDocument.Parse("""
1771JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1778JsonElement schema = JsonDocument.Parse("""
1786JsonElement expectedSchema = JsonDocument.Parse("""
1798JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1817JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
1835JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, transformOptions);
1869JsonElement schema = JsonDocument.Parse("{}").RootElement;
1882JsonElement schema = JsonDocument.Parse(invalidSchema).RootElement;
1894JsonElement schema = JsonDocument.Parse(booleanSchema).RootElement;
1898JsonElement result = AIJsonUtilities.TransformSchema(schema, transformOptions);
1910Assert.True(result.TryGetProperty("not", out JsonElement notValue));
1940[JsonSerializable(typeof(JsonElement))]
1952private static bool DeepEquals(JsonElement element1, JsonElement element2)
1954return JsonElement.DeepEquals(element1, element2);
1957private static void AssertDeepEquals(JsonElement element1, JsonElement element2)
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (3)
Microsoft.Extensions.AI.Evaluation.Safety (4)
Microsoft.Extensions.AI.Integration.Tests (7)
Microsoft.Extensions.AI.OpenAI (44)
Generated\361d1da7f942c932\OpenAIJsonContext.DictionaryStringJsonElement.g.cs (13)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>? _DictionaryStringJsonElement;
19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> DictionaryStringJsonElement
22get => _DictionaryStringJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>)Options.GetTypeInfo(typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>));
25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> Create_DictionaryStringJsonElement(global::System.Text.Json.JsonSerializerOptions options)
27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> jsonTypeInfo))
29var info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
31ObjectCreator = () => new global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>(),
35jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateDictionaryInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>, string, global::System.Text.Json.JsonElement>(options, info);
45private void DictionaryStringJsonElementSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>? value)
55foreach (global::System.Collections.Generic.KeyValuePair<string, global::System.Text.Json.JsonElement> entry in value)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OpenAIJsonContext.ToolJson.g.cs (9)
95var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
110AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.OpenAIClientExtensions.ToolJson).GetProperty("Properties", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>), global::System.Array.Empty<global::System.Type>(), null),
113properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, info2);
117var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement>
132AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.OpenAIClientExtensions.ToolJson).GetProperty("AdditionalProperties", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement), global::System.Array.Empty<global::System.Type>(), null),
135properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement>(options, info3);
137var info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
152AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.OpenAIClientExtensions.ToolJson).GetProperty("ExtensionData", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>), global::System.Array.Empty<global::System.Type>(), null),
155properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, info4);
Microsoft.Extensions.AI.OpenAI.Tests (44)
OpenAIConversionTests.cs (22)
112var schema = JsonDocument.Parse("""
132var root = parsedParams.RootElement;
133Assert.True(root.TryGetProperty("additionalProperties", out var ap), "additionalProperties should be preserved");
142var jsonSchema = JsonDocument.Parse("""
173var root = parsedParams.RootElement;
175Assert.True(root.TryGetProperty("$defs", out var defs), "The $defs property should be preserved in the function parameters");
176Assert.True(defs.TryGetProperty("Person", out var person), "The Person definition should exist in $defs");
177Assert.True(person.TryGetProperty("properties", out var properties), "Person should have properties");
203var schema = JsonDocument.Parse("""
224var root = parsedParams.RootElement;
225Assert.True(root.TryGetProperty("additionalProperties", out var ap), "additionalProperties should be preserved");
708var root = jsonDoc.RootElement;
711Assert.True(root.TryGetProperty("properties", out var properties));
712Assert.True(properties.TryGetProperty("name", out var nameProperty));
772Assert.True(JsonElement.DeepEquals(JsonSerializer.SerializeToElement(new Dictionary<string, object?>
776}), JsonElement.Parse(tc.FunctionArguments.ToMemory().Span)));
828Assert.True(JsonElement.DeepEquals(JsonSerializer.SerializeToElement(new Dictionary<string, object?>
832}), JsonElement.Parse(m3.FunctionArguments.ToMemory().Span)));
1611Assert.Equal(42, ((JsonElement)deserializedArgs["number"]!).GetInt32());
1612Assert.True(((JsonElement)deserializedArgs["boolean"]!).GetBoolean());
1615var nestedObj = (JsonElement)deserializedArgs["nestedObject"]!;
OpenAIResponseClientTests.cs (16)
661JsonElement reasoningItem = secondRequest.RootElement.GetProperty("input").EnumerateArray()
662.Single(item => item.TryGetProperty("type", out var t) && t.GetString() == "reasoning");
1639Assert.Equal("dotnet/extensions", ((JsonElement)call.Arguments["repoName"]!).GetString());
1640Assert.Equal("What is the path to the README.md file for Microsoft.Extensions.AI.Abstractions?", ((JsonElement)call.Arguments["question"]!).GetString());
2016Assert.Equal("dotnet/extensions", ((JsonElement)firstCall.Arguments["repoName"]!).GetString());
2027Assert.Equal("dotnet/extensions", ((JsonElement)secondCall.Arguments["repoName"]!).GetString());
2028Assert.Equal("What is the path to the README.md file for Microsoft.Extensions.AI.Abstractions?", ((JsonElement)secondCall.Arguments["question"]!).GetString());
2427Assert.Equal("dotnet/extensions", ((JsonElement)firstCall.Arguments["repoName"]!).GetString());
2438Assert.Equal("dotnet/extensions", ((JsonElement)secondCall.Arguments["repoName"]!).GetString());
2439Assert.Equal("What is the path to the README.md file for Microsoft.Extensions.AI.Abstractions?", ((JsonElement)secondCall.Arguments["question"]!).GetString());
8844Assert.Equal("my-server", ((JsonElement)call.Arguments["resource_name"]!).GetString());
8845Assert.Equal("production", ((JsonElement)call.Arguments["env"]!).GetString());
8943Assert.Equal("my-server", ((JsonElement)call.Arguments["resource_name"]!).GetString());
8944Assert.Equal("production", ((JsonElement)call.Arguments["env"]!).GetString());
8951Assert.Equal("my-server", ((JsonElement)coalesced.Arguments["resource_name"]!).GetString());
8952Assert.Equal("production", ((JsonElement)coalesced.Arguments["env"]!).GetString());
Microsoft.Extensions.AI.Tests (76)
Functions\AIFunctionFactoryTest.cs (37)
162AIFunction func = AIFunctionFactory.Create((JsonElement param) => param, serializerOptions: options);
163JsonElement expectedResult = JsonDocument.Parse(jsonStringParam, new() { CommentHandling = JsonCommentHandling.Skip }).RootElement;
182AIFunction func = AIFunctionFactory.Create((JsonElement param) => param);
183JsonElement expectedResult = JsonDocument.Parse(JsonSerializer.Serialize(invalidJsonParam, JsonContext.Default.String)).RootElement;
366JsonElement expectedSchema = JsonDocument.Parse("""
473JsonElement valueParam = f.JsonSchema.GetProperty("properties").GetProperty("value");
545var result = (JsonElement?)await func.InvokeAsync(new()
577JsonElement schema = AIFunctionFactory.Create(method, target: null, options).JsonSchema;
579bool inRequired = schema.TryGetProperty("required", out JsonElement required) &&
581bool inProperties = schema.TryGetProperty("properties", out JsonElement properties) &&
582properties.TryGetProperty("service", out JsonElement _);
1234JsonElement expectedSchema = JsonDocument.Parse("""
1267JsonElement expectedSchema = JsonDocument.Parse("""
1304JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(int), serializerOptions: AIJsonUtilities.DefaultOptions);
1556JsonElement schema = func.JsonSchema;
1557JsonElement properties = schema.GetProperty("properties");
1560JsonElement nullableIntSchema = properties.GetProperty("nullableInt");
1562nullableIntSchema.TryGetProperty("type", out JsonElement nullableIntType),
1569JsonElement nullableIntWithDefaultSchema = properties.GetProperty("nullableIntWithDefault");
1571nullableIntWithDefaultSchema.TryGetProperty("type", out JsonElement nullableIntWithDefaultType),
1577nullableIntWithDefaultSchema.TryGetProperty("default", out JsonElement nullableIntWithDefaultDefault),
1582JsonElement required = schema.GetProperty("required");
1596JsonElement schema = func.JsonSchema;
1597JsonElement properties = schema.GetProperty("properties");
1600JsonElement nullableStringSchema = properties.GetProperty("nullableString");
1602nullableStringSchema.TryGetProperty("type", out JsonElement nullableStringType),
1609JsonElement nullableIntSchema = properties.GetProperty("nullableInt");
1611nullableIntSchema.TryGetProperty("type", out JsonElement nullableIntType),
1618JsonElement nullableStringWithDefaultSchema = properties.GetProperty("nullableStringWithDefault");
1620nullableStringWithDefaultSchema.TryGetProperty("type", out JsonElement nullableStringWithDefaultType),
1626nullableStringWithDefaultSchema.TryGetProperty("default", out JsonElement nullableStringWithDefaultDefault),
1631JsonElement nullableIntWithDefaultSchema = properties.GetProperty("nullableIntWithDefault");
1633nullableIntWithDefaultSchema.TryGetProperty("type", out JsonElement nullableIntWithDefaultType),
1639nullableIntWithDefaultSchema.TryGetProperty("default", out JsonElement nullableIntWithDefaultDefault),
1644JsonElement required = schema.GetProperty("required");
1676JsonElement schema = func.JsonSchema;
1677JsonElement properties = schema.GetProperty("properties");
Generated\361d1da7f942c932\TestJsonSerializerContext.ChatResponseFormatJson.g.cs (6)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.ChatResponseFormatJson((global::System.Text.Json.JsonElement?)args[0], (string)args[1], (string)args[2]),
35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.Text.Json.JsonElement?), typeof(string), typeof(string)}, modifiers: null),
51var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?>
66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.ChatResponseFormatJson).GetProperty("Schema", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null),
69properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info0);
139ParameterType = typeof(global::System.Text.Json.JsonElement?),
Microsoft.Extensions.Configuration.Json (4)
Microsoft.ML.GenAI.Phi (4)
Microsoft.ML.Tokenizers (79)
Model\SentencePieceTokenizer.cs (59)
574JsonElement root = doc.RootElement;
577if (!root.TryGetProperty("model", out JsonElement modelElement))
590if (modelElement.TryGetProperty("type", out JsonElement modelTypeElement) &&
603if (!modelElement.TryGetProperty("unk_id", out JsonElement unkIdElement))
618bool byteFallback = modelElement.TryGetProperty("byte_fallback", out JsonElement byteFallbackElement) &&
621if (!modelElement.TryGetProperty("vocab", out JsonElement vocabElement) ||
628foreach (JsonElement entry in vocabElement.EnumerateArray())
675if (root.TryGetProperty("normalizer", out JsonElement normalizerElement) &&
697if (root.TryGetProperty("pre_tokenizer", out JsonElement preTokenizerElement) &&
761private static Dictionary<string, int> ParseAddedTokens(JsonElement root)
764if (!root.TryGetProperty("added_tokens", out JsonElement addedTokens) || addedTokens.ValueKind != JsonValueKind.Array)
769foreach (JsonElement entry in addedTokens.EnumerateArray())
776if (!entry.TryGetProperty("special", out JsonElement specialElement) || specialElement.ValueKind != JsonValueKind.True)
781if (entry.TryGetProperty("content", out JsonElement contentElement) &&
782entry.TryGetProperty("id", out JsonElement idElement))
798JsonElement root,
807if (root.TryGetProperty("post_processor", out JsonElement postProcessor) &&
820JsonElement postProcessor,
845if (postProcessor.TryGetProperty("processors", out JsonElement processors) && processors.ValueKind == JsonValueKind.Array)
847foreach (JsonElement inner in processors.EnumerateArray())
865JsonElement postProcessor,
871if (!postProcessor.TryGetProperty("single", out JsonElement single) || single.ValueKind != JsonValueKind.Array)
876JsonElement? ppSpecialTokens = postProcessor.TryGetProperty("special_tokens", out JsonElement st) && st.ValueKind == JsonValueKind.Object
877? st : (JsonElement?)null;
880foreach (JsonElement item in single.EnumerateArray())
896else if (item.TryGetProperty("SpecialToken", out JsonElement specialToken) &&
897specialToken.TryGetProperty("id", out JsonElement idElement))
918JsonElement? ppSpecialTokens,
922if (ppSpecialTokens is JsonElement st &&
923st.TryGetProperty(tokenName, out JsonElement entry) &&
924entry.TryGetProperty("ids", out JsonElement ids) &&
962JsonElement postProcessor,
969if (postProcessor.TryGetProperty(property, out JsonElement el) && el.ValueKind == JsonValueKind.Array && el.GetArrayLength() >= 2 &&
1021private static string? GetStringOrNull(JsonElement element, string propertyName) =>
1022element.TryGetProperty(propertyName, out JsonElement value) && value.ValueKind == JsonValueKind.String
1026private static byte[]? ExtractPrecompiledCharsMap(JsonElement normalizer)
1036if (normalizer.TryGetProperty("precompiled_charsmap", out JsonElement mapElement) &&
1048normalizer.TryGetProperty("normalizers", out JsonElement normalizersElement) &&
1055foreach (JsonElement inner in normalizersElement.EnumerateArray())
1077private static bool NormalizerCollapsesWhitespace(JsonElement normalizer)
1089return !normalizer.TryGetProperty("strip_right", out JsonElement stripRight) || stripRight.ValueKind != JsonValueKind.False;
1098normalizer.TryGetProperty("normalizers", out JsonElement normalizersElement) &&
1101foreach (JsonElement inner in normalizersElement.EnumerateArray())
1114private static bool ReplaceCollapsesSpaces(JsonElement replace)
1116if (!replace.TryGetProperty("pattern", out JsonElement patternElement) ||
1118!patternElement.TryGetProperty("Regex", out JsonElement regexElement) ||
1147private static bool PreTokenizerSplitsWhitespace(JsonElement preTokenizer)
1162preTokenizer.TryGetProperty("pretokenizers", out JsonElement preTokenizersElement) &&
1165foreach (JsonElement inner in preTokenizersElement.EnumerateArray())
1181private static void ValidatePreTokenizer(JsonElement preTokenizer)
1198if (preTokenizer.TryGetProperty("pretokenizers", out JsonElement pretokenizers) &&
1201foreach (JsonElement inner in pretokenizers.EnumerateArray())
1213private static void ExtractMetaspaceSettings(JsonElement preTokenizer, ref bool addDummyPrefix, ref bool escapeWhiteSpaces)
1223if (preTokenizer.TryGetProperty("add_prefix_space", out JsonElement addPrefixElement))
1233if (preTokenizer.TryGetProperty("replacement", out JsonElement replacementElement))
1252if (preTokenizer.TryGetProperty("prepend_scheme", out JsonElement prependSchemeElement))
1263preTokenizer.TryGetProperty("pretokenizers", out JsonElement preTokenizersElement) &&
1266foreach (JsonElement inner in preTokenizersElement.EnumerateArray())
Normalizer\SentencePieceNormalizationStep.cs (20)
83public static bool HasRichSteps(JsonElement normalizer)
85if (normalizer.ValueKind != JsonValueKind.Object || !normalizer.TryGetProperty("type", out JsonElement typeElement) ||
95if (normalizer.TryGetProperty("normalizers", out JsonElement steps) && steps.ValueKind == JsonValueKind.Array)
97foreach (JsonElement step in steps.EnumerateArray())
127public static SentencePieceNormalizationStep Build(JsonElement normalizer)
134string? type = normalizer.TryGetProperty("type", out JsonElement typeElement) && typeElement.ValueKind == JsonValueKind.String
140if (normalizer.TryGetProperty("normalizers", out JsonElement steps) && steps.ValueKind == JsonValueKind.Array)
142foreach (JsonElement step in steps.EnumerateArray())
152if (normalizer.TryGetProperty("precompiled_charsmap", out JsonElement mapElement))
170stripLeft: !normalizer.TryGetProperty("strip_left", out JsonElement left) || left.ValueKind != JsonValueKind.False,
171stripRight: !normalizer.TryGetProperty("strip_right", out JsonElement right) || right.ValueKind != JsonValueKind.False);
190if (normalizer.TryGetProperty("prepend", out JsonElement prependElement) &&
224private static bool ReplaceIsWhitespaceCollapse(JsonElement replace)
226if (!replace.TryGetProperty("pattern", out JsonElement patternElement) ||
228!patternElement.TryGetProperty("Regex", out JsonElement regexElement) ||
415public static ReplaceStep Create(JsonElement normalizer)
417string content = normalizer.TryGetProperty("content", out JsonElement contentElement) && contentElement.ValueKind == JsonValueKind.String
419if (!normalizer.TryGetProperty("pattern", out JsonElement pattern) || pattern.ValueKind != JsonValueKind.Object)
424if (pattern.TryGetProperty("String", out JsonElement literal))
434if (pattern.TryGetProperty("Regex", out JsonElement regex))
Microsoft.ML.Tokenizers.Tests (29)
BpeTests.cs (25)
956JsonElement root = doc.RootElement;
957if (!root.TryGetProperty("model", out JsonElement modelElement) ||
959!modelElement.TryGetProperty("type", out JsonElement typeElement) ||
961!modelElement.TryGetProperty("vocab", out JsonElement vocabElement) ||
969if (modelElement.TryGetProperty("unk_token", out JsonElement unKnownElement))
974if (modelElement.TryGetProperty("continuing_subword_prefix", out JsonElement continuingSubwordPrefixElement))
979if (modelElement.TryGetProperty("end_of_word_suffix", out JsonElement endOfWordSuffixElement))
984if (modelElement.TryGetProperty("fuse_unknown_tokens", out JsonElement fuseUnknownTokensElement))
1004private static IEnumerable<KeyValuePair<string, int>> GetVocabulary(JsonElement vocabElement)
1012private static IEnumerable<string> GetMerges(JsonElement modelElement)
1014if (modelElement.TryGetProperty("merges", out JsonElement mergesElement) && mergesElement.ValueKind == JsonValueKind.Array)
1016foreach (JsonElement merge in mergesElement.EnumerateArray())
1028private static IReadOnlyList<PreTokenizer>? GetPreTokenizer(JsonElement root, out bool byteLevel)
1033if (root.TryGetProperty("pre_tokenizer", out JsonElement preTokenizerElement) &&
1035preTokenizerElement.TryGetProperty("type", out JsonElement typeElement) &&
1038preTokenizerElement.TryGetProperty("pretokenizers", out JsonElement preTokenizersElement) &&
1041foreach (JsonElement preTokenizer in preTokenizersElement.EnumerateArray())
1044preTokenizer.TryGetProperty("type", out JsonElement preTokenizerTypeElement) &&
1050if (preTokenizer.TryGetProperty("pattern", out JsonElement patternElement) &&
1052patternElement.TryGetProperty("Regex", out JsonElement regexElement) &&
1073private static Dictionary<string, int>? GetSpecialTokens(JsonElement root)
1075if (root.TryGetProperty("added_tokens", out JsonElement modelElement) && modelElement.ValueKind == JsonValueKind.Array)
1078foreach (JsonElement token in modelElement.EnumerateArray())
1080if (token.TryGetProperty("content", out JsonElement contentElement) &&
1082token.TryGetProperty("id", out JsonElement idElement) && idElement.ValueKind == JsonValueKind.Number)
Microsoft.NET.Build.Containers (27)
LocalDaemons\ContainerRuntimes.cs (14)
82if (!config.RootElement.TryGetProperty("ServerErrors", out JsonElement errorProperty) ||
122JsonElement dockerInfo = GetDockerConfig().RootElement;
124dockerInfo.TryGetProperty("DockerRootDir", out JsonElement dockerRootDir) &&
127dockerInfo.TryGetProperty("host", out JsonElement host) &&
128host.TryGetProperty("buildahVersion", out JsonElement buildahVersion) &&
173JsonElement rootElement = GetDockerConfig().RootElement;
174if (rootElement.TryGetProperty("RegistryConfig", out JsonElement registryConfig) &&
176registryConfig.TryGetProperty("IndexConfigs", out JsonElement indexConfigs) &&
182property.Value.TryGetProperty("Secure", out JsonElement secure) &&
191if (rootElement.TryGetProperty("registries", out JsonElement registries) &&
197property.Value.TryGetProperty("Insecure", out JsonElement insecure) &&
217if (!GetDockerConfig().RootElement.TryGetProperty("DriverStatus", out JsonElement driverStatus) ||
223foreach (JsonElement item in driverStatus.EnumerateArray())
230JsonElement[] values = item.EnumerateArray().ToArray();
LocalDaemons\DockerCli.cs (13)
158if (!config.RootElement.TryGetProperty("ServerErrors", out JsonElement errorProperty))
241var rootElement = GetDockerConfig().RootElement;
244if (rootElement.TryGetProperty("RegistryConfig", out var registryConfig) && registryConfig.ValueKind == JsonValueKind.Object)
246if (registryConfig.TryGetProperty("IndexConfigs", out var indexConfigs) && indexConfigs.ValueKind == JsonValueKind.Object)
251&& property.Value.TryGetProperty("Secure", out var secure)
262if (rootElement.TryGetProperty("registries", out var registries) && registries.ValueKind == JsonValueKind.Object)
267&& property.Value.TryGetProperty("Insecure", out var insecure)
614var dockerinfo = GetDockerConfig().RootElement;
618dockerinfo.TryGetProperty("DockerRootDir", out var dockerRootDir) && dockerRootDir.GetString() is not null;
619var hasPodmanProperty = dockerinfo.TryGetProperty("host", out var host) && host.TryGetProperty("buildahVersion", out var buildahVersion) && buildahVersion.GetString() is not null;
633if (!GetDockerConfig().RootElement.TryGetProperty("DriverStatus", out var driverStatus) || driverStatus.ValueKind != JsonValueKind.Array)
638foreach (var item in driverStatus.EnumerateArray())
Microsoft.NET.HostModel (2)
Microsoft.SourceLink.Tools.Package (1)
Microsoft.TemplateEngine.Edge (1)
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (1)
Microsoft.TemplateEngine.Utils (1)
Microsoft.TemplateSearch.Common (1)
Microsoft.TestPlatform.CommunicationUtilities (144)
Microsoft.TestPlatform.TestHostRuntimeProvider (3)
NuGet.Protocol (6)
RepoTasks (4)
rzc (6)
Shared.Tests (23)
System.Text.Json (211)
System\Text\Json\Document\JsonElement.cs (27)
63public JsonElement this[int index]
108/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
119/// A <see cref="JsonElement"/> representing the value of the requested property.
134public JsonElement GetProperty(string propertyName)
138if (TryGetProperty(propertyName, out JsonElement property))
147/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
162/// A <see cref="JsonElement"/> representing the value of the requested property.
174public JsonElement GetProperty(ReadOnlySpan<char> propertyName)
176if (TryGetProperty(propertyName, out JsonElement property))
185/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
202/// A <see cref="JsonElement"/> representing the value of the requested property.
214public JsonElement GetProperty(ReadOnlySpan<byte> utf8PropertyName)
216if (TryGetProperty(utf8PropertyName, out JsonElement property))
254public bool TryGetProperty(string propertyName, out JsonElement value)
288public bool TryGetProperty(ReadOnlySpan<char> propertyName, out JsonElement value)
324public bool TryGetProperty(ReadOnlySpan<byte> utf8PropertyName, out JsonElement value)
1238/// Compares the values of two <see cref="JsonElement"/> values for equality, including the values of all descendant elements.
1240/// <param name="element1">The first <see cref="JsonElement"/> to compare.</param>
1241/// <param name="element2">The second <see cref="JsonElement"/> to compare.</param>
1258public static bool DeepEquals(JsonElement element1, JsonElement element2)
1304foreach (JsonElement e1 in element1.EnumerateArray())
1368Dictionary<string, ValueQueue<JsonElement>> properties2 = new(capacity: remainingProps, StringComparer.Ordinal);
1373ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop2.Name, out bool _);
1388ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop.Name, out bool exists);
1392if (!exists || !values.TryDequeue(out JsonElement value) || !DeepEquals(prop.Value, value))
1693public JsonElement Clone()
System\Text\Json\Serialization\JsonSerializer.Write.Element.cs (19)
14/// Converts the provided value into a <see cref="JsonElement"/>.
17/// <returns>A <see cref="JsonElement"/> representation of the JSON value.</returns>
26public static JsonElement SerializeToElement<TValue>(TValue value, JsonSerializerOptions? options = null)
33/// Converts the provided value into a <see cref="JsonElement"/>.
35/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
51public static JsonElement SerializeToElement(object? value, Type inputType, JsonSerializerOptions? options = null)
59/// Converts the provided value into a <see cref="JsonElement"/>.
62/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
68public static JsonElement SerializeToElement<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
77/// Converts the provided value into a <see cref="JsonElement"/>.
79/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
88public static JsonElement SerializeToElement(object? value, JsonTypeInfo jsonTypeInfo)
97/// Converts the provided value into a <see cref="JsonElement"/>.
99/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
114public static JsonElement SerializeToElement(object? value, Type inputType, JsonSerializerContext context)
123private static JsonElement WriteElement<TValue>(in TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
133return JsonElement.Parse(output.WrittenSpan, options.GetDocumentOptions());
141private static JsonElement WriteElementAsObject(object? value, JsonTypeInfo jsonTypeInfo)
151return JsonElement.Parse(output.WrittenSpan, options.GetDocumentOptions());