10 instantiations of JsonElement
Microsoft.AspNetCore.Components.WebAssembly.Server (1)
TargetPickerUi.cs (1)
223JsonElement consoleActor = new();
Microsoft.Build (1)
Construction\Solution\SolutionFile.cs (1)
686solution = new JsonElement();
System.Text.Json (8)
System\Text\Json\Document\JsonDocument.cs (4)
35public JsonElement RootElement => new JsonElement(this, 0); 171return new JsonElement(this, currentIndex + ((arrayIndex + 1) * DbRow.Size)); 181return new JsonElement(this, objectOffset); 1056JsonElement curr = new JsonElement(document, traversalPath.Peek());
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (2)
198value = new JsonElement(this, index + DbRow.Size); 216value = new JsonElement(this, index + DbRow.Size);
System\Text\Json\Document\JsonElement.ArrayEnumerator.cs (1)
42return new JsonElement(_target._parent, _curIdx);
System\Text\Json\Document\JsonElement.ObjectEnumerator.cs (1)
41return new JsonProperty(new JsonElement(_target._parent, _curIdx));
1622 references to JsonElement
aspire (97)
Backchannel\AppHostAuxiliaryBackchannel.cs (4)
386IReadOnlyDictionary<string, JsonElement>? arguments, 644Dictionary<string, JsonElement>? arguments = null; 645if (request.Arguments is JsonElement argsElement && argsElement.ValueKind == JsonValueKind.Object) 647arguments = new Dictionary<string, JsonElement>();
Backchannel\BackchannelJsonSerializerContext.cs (2)
24[JsonSerializable(typeof(JsonElement))] 55[JsonSerializable(typeof(Dictionary<string, JsonElement>))]
Backchannel\IAppHostAuxiliaryBackchannel.cs (1)
100IReadOnlyDictionary<string, JsonElement>? arguments,
Commands\AgentMcpCommand.cs (2)
185? new Dictionary<string, JsonElement>(a) 223? new Dictionary<string, JsonElement>(a)
Commands\InitCommand.cs (5)
657var rootElement = jsonDoc.RootElement; 658if (rootElement.TryGetProperty("Properties", out var properties)) 661if (properties.TryGetProperty("IsAspireHost", out var isAspireHostElement)) 672if (properties.TryGetProperty("OutputType", out var outputTypeElement)) 679if (properties.TryGetProperty("TargetFramework", out var targetFrameworkElement))
Commands\McpCallCommand.cs (2)
87IReadOnlyDictionary<string, JsonElement>? arguments = null; 98var dict = new Dictionary<string, JsonElement>();
Configuration\AspireConfigFile.cs (3)
213if (!doc.RootElement.TryGetProperty("profiles", out var profilesElement)) 223if (prop.Value.TryGetProperty("applicationUrl", out var appUrl) && 229if (prop.Value.TryGetProperty("environmentVariables", out var envVars) &&
Configuration\AspireJsonConfiguration.cs (1)
82public Dictionary<string, JsonElement>? ExtensionData { get; set; }
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))
Mcp\Tools\CallToolContext.cs (1)
27public required IReadOnlyDictionary<string, JsonElement>? Arguments { get; init; }
Mcp\Tools\CliMcpTool.cs (1)
28public abstract JsonElement GetInputSchema();
Mcp\Tools\DoctorTool.cs (1)
19public override JsonElement GetInputSchema()
Mcp\Tools\ExecuteResourceCommandTool.cs (3)
24public override JsonElement GetInputSchema() 48!arguments.TryGetValue("resourceName", out var resourceNameElement) || 49!arguments.TryGetValue("commandName", out var commandNameElement))
Mcp\Tools\GetDocTool.cs (3)
25public override JsonElement GetInputSchema() 51if (arguments is null || !arguments.TryGetValue("slug", out var slugElement)) 71if (arguments.TryGetValue("section", out var sectionElement))
Mcp\Tools\ListAppHostsTool.cs (1)
33public override JsonElement GetInputSchema()
Mcp\Tools\ListConsoleLogsTool.cs (2)
23public override JsonElement GetInputSchema() 45if (arguments is not null && arguments.TryGetValue("resourceName", out var resourceNameElement))
Mcp\Tools\ListDocsTool.cs (1)
28public override JsonElement GetInputSchema()
Mcp\Tools\ListIntegrationsTool.cs (1)
58public override JsonElement GetInputSchema()
Mcp\Tools\ListResourcesTool.cs (1)
52public override JsonElement GetInputSchema()
Mcp\Tools\ListStructuredLogsTool.cs (2)
28public override JsonElement GetInputSchema() 50if (arguments?.TryGetValue("resourceName", out var resourceNameElement) == true &&
Mcp\Tools\ListTracesTool.cs (2)
28public override JsonElement GetInputSchema() 50if (arguments?.TryGetValue("resourceName", out var resourceNameElement) == true &&
Mcp\Tools\ListTraceStructuredLogsTool.cs (2)
28public override JsonElement GetInputSchema() 51if (arguments?.TryGetValue("traceId", out var traceIdElement) == true &&
Mcp\Tools\RefreshToolsTool.cs (1)
15public override JsonElement GetInputSchema()
Mcp\Tools\SearchDocsTool.cs (3)
27public override JsonElement GetInputSchema() 54if (arguments is null || !arguments.TryGetValue("query", out var queryElement)) 74if (arguments.TryGetValue("topK", out var topKElement) && topKElement.TryGetInt32(out var topKValue))
Mcp\Tools\SelectAppHostTool.cs (2)
19public override JsonElement GetInputSchema() 39if (arguments == null || !arguments.TryGetValue("appHostPath", out var appHostPathElement))
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) &&
Projects\DotNetAppHostProject.cs (3)
566var rootElement = jsonDocument.RootElement; 567if (rootElement.TryGetProperty("Properties", out var properties) && 568properties.TryGetProperty("UserSecretsId", out var userSecretsIdElement))
Projects\GuestAppHostProject.cs (5)
642if (!doc.RootElement.TryGetProperty("profiles", out var profiles)) 648JsonElement? profileElement = null; 649if (profiles.TryGetProperty("https", out var httpsProfile)) 671if (profileElement.Value.TryGetProperty("applicationUrl", out var appUrl) && 678if (profileElement.Value.TryGetProperty("environmentVariables", out var envVars))
Projects\ProjectLocator.cs (1)
221if (json.RootElement.TryGetProperty("appHostPath", out var appHostPathProperty) && appHostPathProperty.GetString() is { } appHostPath)
Projects\ProjectUpdater.cs (12)
262var propertiesElement = itemsAndPropertiesDocument.RootElement.GetProperty("Properties"); 263var sdkVersionElement = propertiesElement.GetProperty("AspireHostingSDKVersion"); 612if (itemsAndPropertiesDocument.RootElement.TryGetProperty("Properties", out var propertiesElement)) 614if (propertiesElement.TryGetProperty("ManagePackageVersionsCentrally", out var managePkgVersionsElement)) 630var itemsElement = itemsAndPropertiesDocument.RootElement.GetProperty("Items"); 633if (itemsElement.TryGetProperty("ProjectReference", out var projectReferencesElement)) 635foreach (var projectReference in projectReferencesElement.EnumerateArray()) 644if (itemsElement.TryGetProperty("PackageReference", out var packageReferencesElement)) 646foreach (var packageReference in packageReferencesElement.EnumerateArray()) 662if (!packageReference.TryGetProperty("Version", out var versionElement)) 841var propertiesElement = document.RootElement.GetProperty("Properties"); 842if (propertiesElement.TryGetProperty(propertyName, out var propertyElement))
src\Aspire.Hosting\Backchannel\BackchannelDataTypes.cs (1)
212public JsonElement? Arguments { get; init; }
src\Shared\PackageUpdateHelpers.cs (5)
133if (!document.RootElement.TryGetProperty("searchResult", out var searchResultsArray)) 138foreach (var sourceResult in searchResultsArray.EnumerateArray()) 141var sourcePackagesArray = sourceResult.GetProperty("packages"); 143foreach (var packageResult in sourcePackagesArray.EnumerateArray()) 147var version = packageResult.TryGetProperty("latestVersion", out var latestVersionProp)
Aspire.Azure.Npgsql (6)
src\Components\Common\ManagedIdentityTokenCredentialHelpers.cs (6)
91var payloadJson = JsonElement.ParseValue(ref reader); 94if (payloadJson.TryGetProperty("xms_mirid", out var xms_mirid) && 100else if (payloadJson.TryGetProperty("upn", out var upn)) 104else if (payloadJson.TryGetProperty("preferred_username", out var preferredUsername)) 108else if (payloadJson.TryGetProperty("unique_name", out var uniqueName))
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL (6)
src\Components\Common\ManagedIdentityTokenCredentialHelpers.cs (6)
91var payloadJson = JsonElement.ParseValue(ref reader); 94if (payloadJson.TryGetProperty("xms_mirid", out var xms_mirid) && 100else if (payloadJson.TryGetProperty("upn", out var upn)) 104else if (payloadJson.TryGetProperty("preferred_username", out var preferredUsername)) 108else if (payloadJson.TryGetProperty("unique_name", out var uniqueName))
Aspire.Cli.Tests (32)
Backchannel\BackchannelJsonSerializerContextTests.cs (2)
49var payload = new Dictionary<string, JsonElement>(StringComparer.Ordinal) 56var roundTripped = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(json, options);
Commands\PsCommandTests.cs (1)
323var firstElement = document.RootElement[0];
Mcp\ExecuteResourceCommandToolTests.cs (1)
15private static IReadOnlyDictionary<string, JsonElement> CreateArguments(string resourceName, string commandName)
Mcp\ListConsoleLogsToolTests.cs (6)
22var arguments = new Dictionary<string, JsonElement> 61var arguments = new Dictionary<string, JsonElement> 96var arguments = new Dictionary<string, JsonElement> 130var arguments = new Dictionary<string, JsonElement> 160var arguments = new Dictionary<string, JsonElement> 189var arguments = new Dictionary<string, JsonElement>
Mcp\ListIntegrationsToolTests.cs (9)
34var schema = tool.GetInputSchema(); 37Assert.True(schema.TryGetProperty("type", out var typeElement)); 39Assert.True(schema.TryGetProperty("properties", out var propsElement)); 41Assert.True(schema.TryGetProperty("description", out var descElement)); 43Assert.True(schema.TryGetProperty("additionalProperties", out var additionalPropsElement)); 63Assert.True(json.RootElement.TryGetProperty("integrations", out var integrations)); 88Assert.True(json.RootElement.TryGetProperty("integrations", out var integrations)); 93var firstIntegration = integrations[0]; 122Assert.True(json.RootElement.TryGetProperty("integrations", out var integrations));
Mcp\ListResourcesToolTests.cs (1)
179var resource = jsonDoc.RootElement[0];
Mcp\ListStructuredLogsToolTests.cs (7)
333var arguments = new Dictionary<string, JsonElement> 369var schema = tool.GetInputSchema(); 372Assert.True(schema.TryGetProperty("properties", out var properties)); 373Assert.True(properties.TryGetProperty("resourceName", out var resourceName)); 374Assert.True(resourceName.TryGetProperty("type", out var type)); 383var schema = tool.GetInputSchema(); 386if (schema.TryGetProperty("required", out var required))
Mcp\ListTracesToolTests.cs (2)
315var arguments = new Dictionary<string, JsonElement> 418var arguments = new Dictionary<string, JsonElement>
TestServices\CallToolContextTestHelper.cs (1)
22IReadOnlyDictionary<string, JsonElement>? arguments = null,
TestServices\TestAppHostAuxiliaryBackchannel.cs (2)
47public Func<string, string, IReadOnlyDictionary<string, JsonElement>?, CancellationToken, Task<CallToolResult>>? CallResourceMcpToolHandler { get; set; } 131IReadOnlyDictionary<string, JsonElement>? arguments,
Aspire.Dashboard (3)
Model\GenAI\GenAIItemPartViewModel.cs (1)
138private static JsonObject ToJsonObject(Dictionary<string, JsonElement> dict)
Model\GenAI\GenAIMessages.cs (2)
167public Dictionary<string, JsonElement>? AdditionalProperties { get; set; } 215if (!doc.RootElement.TryGetProperty("type", out var typeProp))
Aspire.Dashboard.Tests (7)
DashboardOptionsTests.cs (5)
318var jsonElement = JsonDocument.Parse(""" 346var jsonElement = JsonDocument.Parse(""" 375var jsonElement = JsonDocument.Parse(""" 411var jsonElement = JsonDocument.Parse(""" 450var jsonElement = JsonDocument.Parse("""
Model\GenAIItemPartViewModelTests.cs (2)
157AdditionalProperties = new Dictionary<string, JsonElement> 178AdditionalProperties = new Dictionary<string, JsonElement>
Aspire.Hosting (15)
Backchannel\AuxiliaryBackchannelRpcTarget.cs (3)
175if (request.Arguments is JsonElement argsElement && argsElement.ValueKind == JsonValueKind.Object) 927private static object? ConvertJsonElementToObject(JsonElement element) 942private static object ConvertJsonNumber(JsonElement element)
Backchannel\BackchannelDataTypes.cs (1)
212public JsonElement? Arguments { get; init; }
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)
src\Shared\PackageUpdateHelpers.cs (5)
133if (!document.RootElement.TryGetProperty("searchResult", out var searchResultsArray)) 138foreach (var sourceResult in searchResultsArray.EnumerateArray()) 141var sourcePackagesArray = sourceResult.GetProperty("packages"); 143foreach (var packageResult in sourcePackagesArray.EnumerateArray()) 147var version = packageResult.TryGetProperty("latestVersion", out var latestVersionProp)
Aspire.Hosting.JavaScript (2)
JavaScriptHostingExtensions.cs (2)
1223if (packageJson.RootElement.TryGetProperty("engines", out var engines) && 1224engines.TryGetProperty("node", out var nodeVersion))
Aspire.Hosting.Maui (3)
Utilities\ProjectFileReader.cs (3)
86var properties = jsonDoc.RootElement.GetProperty("Properties"); 91if (properties.TryGetProperty("TargetFrameworks", out var targetFrameworks)) 97properties.TryGetProperty("TargetFramework", out var targetFramework))
Aspire.Hosting.OpenAI (3)
OpenAIHealthCheck.cs (3)
98if (!doc.RootElement.TryGetProperty("status", out var statusEl)) 103var indicator = statusEl.TryGetProperty("indicator", out var indEl) && indEl.ValueKind == JsonValueKind.String 107var description = statusEl.TryGetProperty("description", out var descEl) && descEl.ValueKind == JsonValueKind.String
Aspire.Hosting.PostgreSQL.Tests (1)
AddPostgresTests.cs (1)
510var servers = document.RootElement.GetProperty("Servers");
Aspire.Hosting.Seq.Tests (2)
SeqFunctionalTests.cs (2)
63var doc = jsonDocument.RootElement.EnumerateArray().FirstOrDefault(); 66var property = doc.GetProperty("Properties").EnumerateArray().FirstOrDefault();
Aspire.Hosting.Tests (39)
Backchannel\AuxiliaryBackchannelTests.cs (2)
332await rpc.InvokeAsync<JsonElement>( 373await rpc.InvokeAsync<JsonElement>(
Backchannel\JsonElementConversionTests.cs (1)
19private static object? ConvertJsonElementToObject(JsonElement element)
Dashboard\DashboardLifecycleHookTests.cs (4)
340var customConfig = JsonSerializer.Deserialize<JsonElement>(customConfigContent); 343var netCoreFramework = frameworks.First(f => f.GetProperty("name").GetString() == "Microsoft.NETCore.App"); 344var aspNetCoreFramework = frameworks.First(f => f.GetProperty("name").GetString() == "Microsoft.AspNetCore.App");
ManifestGenerationTests.cs (32)
32var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 33var x = resources.GetProperty("x"); 34var inputs = x.GetProperty("inputs"); 35var value = inputs.GetProperty("value"); 50var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 51var x = resources.GetProperty("x"); 52var inputs = x.GetProperty("inputs"); 53var value = inputs.GetProperty("value"); 68var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 69var x = resources.GetProperty("x"); 70var inputs = x.GetProperty("inputs"); 71var value = inputs.GetProperty("value"); 72Assert.True(value.TryGetProperty("secret", out var secret)); 86var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 88var workerA = resources.GetProperty("workera"); 129var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 156var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 158var resource = resources.GetProperty("program"); 159var args = resource.GetProperty("args"); 162var verify = new List<Action<JsonElement>>(); 189var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 191var resource = resources.GetProperty("program"); 209var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 211var container = resources.GetProperty("rediscontainer"); 229var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 231var container = resources.GetProperty("rediscontainer"); 251var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 253var server = resources.GetProperty("postgrescontainer"); 256var db = resources.GetProperty("postgresdatabase"); 274var resources = manifestStore.ManifestDocument.RootElement.GetProperty("resources"); 276var container = resources.GetProperty("testresource"); 277Assert.False(container.TryGetProperty("metadata", out var _));
Aspire.Templates.Tests (2)
LocalhostTldHostnameTests.cs (2)
69var profiles = launchSettings.RootElement.GetProperty("profiles"); 74if (profile.Value.TryGetProperty("applicationUrl", out var applicationUrl))
dotnet (17)
Commands\Run\CSharpCompilerCommand.cs (3)
361JsonElement root = jsonDoc.RootElement; 362if (!root.TryGetProperty("runtimeOptions", out JsonElement runtimeOptions) || 363!runtimeOptions.TryGetProperty("framework", out JsonElement framework)) return null;
RuntimeConfig.cs (3)
26JsonElement root = doc.RootElement; 27if (root.TryGetProperty("runtimeOptions", out var runtimeOptionsRoot)) 29if (runtimeOptionsRoot.TryGetProperty("framework", out var framework))
SlnFileFactory.cs (1)
102JsonElement root = JsonDocument.Parse(fileContent, options).RootElement;
ToolManifest\JsonElementExtension.cs (6)
14internal static bool TryGetStringValue(this JsonElement element, string name, out string value) 17if (element.TryGetProperty(name, out JsonElement jsonValue)) 34internal static bool TryGetInt32Value(this JsonElement element, string name, out int value) 37if (element.TryGetProperty(name, out JsonElement jsonValue)) 54internal static bool TryGetBooleanValue(this JsonElement element, string name, out bool value) 57if (element.TryGetProperty(name, out JsonElement jsonValue))
ToolManifest\ToolManifestEditor.cs (4)
141JsonElement root = doc.RootElement; 153if (root.TryGetProperty(JsonPropertyTools, out var tools)) 177if (toolJson.Value.TryGetProperty(JsonPropertyCommands, out var commandsJson)) 187foreach (var command in commandsJson.EnumerateArray())
dotnet-aot (11)
src\sdk\src\Cli\dotnet\SlnFileFactory.cs (1)
102JsonElement root = JsonDocument.Parse(fileContent, options).RootElement;
src\sdk\src\Cli\dotnet\ToolManifest\JsonElementExtension.cs (6)
14internal static bool TryGetStringValue(this JsonElement element, string name, out string value) 17if (element.TryGetProperty(name, out JsonElement jsonValue)) 34internal static bool TryGetInt32Value(this JsonElement element, string name, out int value) 37if (element.TryGetProperty(name, out JsonElement jsonValue)) 54internal static bool TryGetBooleanValue(this JsonElement element, string name, out bool value) 57if (element.TryGetProperty(name, out JsonElement jsonValue))
src\sdk\src\Cli\dotnet\ToolManifest\ToolManifestEditor.cs (4)
141JsonElement root = doc.RootElement; 153if (root.TryGetProperty(JsonPropertyTools, out var tools)) 177if (toolJson.Value.TryGetProperty(JsonPropertyCommands, out var commandsJson)) 187foreach (var command in commandsJson.EnumerateArray())
dotnet-openapi (1)
Commands\BaseCommand.cs (1)
464var packageVersionsElement = packageVersionDocument.RootElement.GetProperty("Packages");
dotnet-sourcelink (1)
dotnet-user-jwts (8)
Helpers\DevJwtCliHelpers.cs (8)
170if (launchSettingsJson.RootElement.TryGetProperty("profiles", out var profiles)) 185static List<string> ExtractIISExpressUrlFromProfile(JsonElement rootElement) 187if (rootElement.TryGetProperty("iisSettings", out var iisSettings)) 189if (iisSettings.TryGetProperty("iisExpress", out var iisExpress)) 192if (iisExpress.TryGetProperty("applicationUrl", out var iisUrl)) 197if (iisExpress.TryGetProperty("sslPort", out var sslPort)) 211if (profile.Value.TryGetProperty("commandName", out var commandName)) 215if (profile.Value.TryGetProperty("applicationUrl", out var applicationUrl))
ILCompiler.Compiler (1)
src\runtime\src\coreclr\tools\Common\Microsoft\SourceLink\Tools\SourceLinkMap.cs (1)
65var root = jsonDocument.RootElement;
ILCompiler.ReadyToRun (4)
Compiler\CallChainProfile.cs (4)
252JsonElement root = document.RootElement; 259foreach (JsonElement methodListArray in methodAndCallees.Value.EnumerateArray()) 264foreach (JsonElement followingMethods in methodListArray.EnumerateArray()) 275foreach (JsonElement methodCount in methodListArray.EnumerateArray())
Infrastructure.Tests (11)
PowerShellScripts\ExpandTestMatrixGitHubTests.cs (7)
152Assert.True(document.RootElement.TryGetProperty("include", out var include)); 179var include = document.RootElement.GetProperty("include"); 181var firstEntry = include.ValueKind == JsonValueKind.Array 210var include = document.RootElement.GetProperty("include"); 212var firstEntry = include.ValueKind == JsonValueKind.Array 216Assert.True(firstEntry.TryGetProperty("runs-on", out var runsOn), 666var include = document.RootElement.GetProperty("include");
PowerShellScripts\SplitTestMatrixByDepsTests.cs (1)
325var include = document.RootElement.GetProperty("include");
PowerShellScripts\SplitTestProjectsTests.cs (1)
121Assert.True(document.RootElement.TryGetProperty("testPartitions", out var partitions));
WorkflowScripts\AutoRerunTransientCiFailuresTests.cs (2)
1209public JsonElement[][] Rows { get; init; } = []; 1236public JsonElement Payload { get; init; }
Microsoft.AspNetCore.Authentication (4)
JsonDocumentAuthExtensions.cs (4)
14/// Gets a string property value from the specified <see cref="JsonElement"/>. 16/// <param name="element">The <see cref="JsonElement"/>.</param> 19public static string? GetString(this JsonElement element, string key) 21if (element.TryGetProperty(key, out var property) && property.ValueKind != JsonValueKind.Null)
Microsoft.AspNetCore.Authentication.DeviceBoundSessions (2)
DeviceBoundSessionJwtValidator.cs (2)
59if (!token.TryGetHeaderValue<JsonElement>("jwk", out var jwkElement))
Microsoft.AspNetCore.Authentication.OAuth (24)
ClaimAction.cs (1)
42public abstract void Run(JsonElement userData, ClaimsIdentity identity, string issuer);
ClaimActionCollectionMapExtensions.cs (2)
82public static void MapCustomJson(this ClaimActionCollection collection, string claimType, Func<JsonElement, string?> resolver) 97public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func<JsonElement, string?> resolver)
CustomJsonClaimAction.cs (3)
20public CustomJsonClaimAction(string claimType, string valueType, Func<JsonElement, string?> resolver) 29public Func<JsonElement, string?> Resolver { get; } 32public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
DeleteClaimAction.cs (1)
25public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
Events\OAuthCreatingTicketContext.cs (4)
36JsonElement user) 51/// <see cref="JsonElement"/> if it is not available. 53public JsonElement User { get; } 113public void RunClaimActions(JsonElement userData)
JsonKeyClaimAction.cs (3)
33public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) 35if (!userData.TryGetProperty(JsonKey, out var value)) 41foreach (var v in value.EnumerateArray())
JsonSubKeyClaimAction.cs (5)
35public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) 37if (!TryGetSubProperty(userData, JsonKey, SubKey, out var value)) 43foreach (var v in value.EnumerateArray()) 55private static bool TryGetSubProperty(JsonElement userData, string propertyName, string subProperty, out JsonElement value)
MapAllClaimsAction.cs (1)
23public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
OAuthTokenResponse.cs (4)
21var root = response.RootElement; 95var root = response.RootElement; 106if (root.TryGetProperty("error_description", out var errorDescription)) 112if (root.TryGetProperty("error_uri", out var errorUri))
Microsoft.AspNetCore.Authentication.OpenIdConnect (1)
UniqueJsonKeyClaimAction.cs (1)
30public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
Microsoft.AspNetCore.Authentication.Twitter (5)
TwitterCreatingTicketContext.cs (3)
38JsonElement user) 72/// <see cref="JsonElement"/> if it is not available. 74public JsonElement User { get; }
TwitterHandler.cs (2)
147/// <param name="user">The <see cref="JsonElement"/> for the user.</param> 150ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token, JsonElement user)
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)
_generated\27\BrowserOptionsJsonContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
_generated\34\BrowserOptionsJsonContext.GetJsonTypeInfo.g.cs (2)
54if (type == typeof(global::System.Collections.Generic.IDictionary<string, global::System.Text.Json.JsonElement>)) 62if (type == typeof(global::System.Text.Json.JsonElement))
BrowserConfiguration\InteractiveServerBrowserOptions.cs (2)
44public IDictionary<string, JsonElement> Extensions { get; } = new Dictionary<string, JsonElement>();
Serialization\IStoredDataSerializer.cs (1)
12IDictionary<string, object?> DeserializeData(IDictionary<string, JsonElement> data);
Serialization\JsonStoredDataSerializer.cs (7)
71public IDictionary<string, object?> DeserializeData(IDictionary<string, JsonElement> data) 82private object? DeserializeEntry(JsonElement element) 90var valueElement = element.GetProperty("value"); 97foreach (var item in valueElement.EnumerateArray()) 225var element = JsonSerializer.Deserialize<JsonElement>(utf8Json, _options); 233var valueElement = element.GetProperty("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)
TempData\CookieTempDataProvider.cs (3)
74Dictionary<string, JsonElement>? dataFromCookie; 80dataFromCookie = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(unprotectBuffer.WrittenSpan); 85dataFromCookie = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(unprotectedBytes);
TempData\SessionStorageTempDataProvider.cs (1)
34var dataFromSession = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(value);
Microsoft.AspNetCore.Components.Server (14)
BlazorPack\BlazorPackHubProtocolWorker.cs (2)
51else if (type == typeof(JsonElement)) 60return JsonElement.ParseValue(ref jsonReader);
Circuits\ComponentParameterDeserializer.cs (4)
58var value = (JsonElement)parameterValues[i]; 98var value = (JsonElement)parameterValues[i];
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)
src\aspnetcore\src\Components\Shared\src\WebRootComponentParameters.cs (2)
51if (value is JsonElement jsonValue && otherValue is JsonElement otherJsonValue)
Microsoft.AspNetCore.Components.Web (46)
_generated\16\WebRendererSerializerContext.GetJsonTypeInfo.g.cs (1)
58if (type == typeof(global::System.Text.Json.JsonElement))
_generated\9\WebRendererSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
JSComponents\JSComponentInterop.cs (2)
81protected internal void SetRootComponentParameters(int componentId, int parameterCount, JsonElement parametersJson, JsonSerializerOptions jsonOptions) 97var parameterJsonValue = jsonProperty.Value;
WebEventData\ChangeEventArgsReader.cs (5)
14internal static ChangeEventArgs Read(JsonElement jsonElement) 21var value = property.Value; 50private static string?[] GetJsonElementStringArrayValue(JsonElement jsonElement) 55foreach (var arrayElement in jsonElement.EnumerateArray()) 60$"Unsupported {nameof(JsonElement)} value kind '{arrayElement.ValueKind}' " +
WebEventData\ClipboardEventArgsReader.cs (1)
14internal static ClipboardEventArgs Read(JsonElement jsonElement)
WebEventData\DragEventArgsReader.cs (7)
21internal static DragEventArgs Read(JsonElement jsonElement) 39private static DataTransfer ReadDataTransfer(JsonElement jsonElement) 58var value = property.Value; 61foreach (var item in value.EnumerateArray()) 80private static DataTransferItem ReadDataTransferItem(JsonElement jsonElement) 102private static string[] ReadStringArray(JsonElement value) 106foreach (var item in value.EnumerateArray())
WebEventData\ErrorEventArgsReader.cs (1)
18internal static ErrorEventArgs Read(JsonElement jsonElement)
WebEventData\FocusEventArgsReader.cs (1)
14internal static FocusEventArgs Read(JsonElement jsonElement)
WebEventData\KeyboardEventArgsReader.cs (1)
23internal static KeyboardEventArgs Read(JsonElement jsonElement)
WebEventData\MouseEventArgsReader.cs (1)
31internal static MouseEventArgs Read(JsonElement jsonElement)
WebEventData\PointerEventArgsReader.cs (1)
21internal static PointerEventArgs Read(JsonElement jsonElement)
WebEventData\ProgressEventArgReader.cs (1)
17internal static ProgressEventArgs Read(JsonElement jsonElement)
WebEventData\TouchEventArgsReader.cs (4)
29internal static TouchEventArgs Read(JsonElement jsonElement) 79private static TouchPoint[] ReadTouchPointArray(JsonElement jsonElement) 83foreach (var item in jsonElement.EnumerateArray()) 91private static TouchPoint ReadTouchPoint(JsonElement jsonElement)
WebEventData\WebEventData.cs (5)
19JsonElement eventDescriptorJson, 20JsonElement eventArgsJson) 39JsonElement eventArgsJson) 66JsonElement eventArgsJson) 93JsonElement eventArgsJson,
WebEventData\WebEventDescriptorReader.cs (2)
19internal static WebEventDescriptor Read(JsonElement jsonElement) 45private static EventFieldInfo? ReadEventFieldInfo(JsonElement jsonElement)
WebEventData\WheelEventArgsReader.cs (1)
17internal static WheelEventArgs Read(JsonElement jsonElement)
WebRenderer.cs (4)
167public Task DispatchEventAsync(JsonElement eventDescriptor, JsonElement eventArgs) 181public void SetRootComponentParameters(int componentId, int parameterCount, JsonElement parametersJson) 196[JsonSerializable(typeof(JsonElement))]
Microsoft.AspNetCore.Components.WebAssembly (22)
_generated\14\WebAssemblyJsonSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
_generated\21\WebAssemblyJsonSerializerContext.GetJsonTypeInfo.g.cs (1)
66if (type == typeof(global::System.Text.Json.JsonElement))
Infrastructure\WebAssemblyJsonSerializerContext.cs (1)
16[JsonSerializable(typeof(JsonElement))]
Prerendering\WebAssemblyComponentParameterDeserializer.cs (4)
59var value = (JsonElement)parameterValues[i]; 96var value = (JsonElement)parameterValues[i];
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)
src\aspnetcore\src\Components\Shared\src\WebRootComponentParameters.cs (2)
51if (value is JsonElement jsonValue && otherValue is JsonElement otherJsonValue)
Microsoft.AspNetCore.Components.WebAssembly.Authentication (13)
_generated\10\InteractiveRequestOptionsSerializerContext.GetJsonTypeInfo.g.cs (1)
42if (type == typeof(global::System.Text.Json.JsonElement))
_generated\6\InteractiveRequestOptionsSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Models\InteractiveRequestOptions.cs (3)
70if (rawValue is JsonElement json) 86static TValue Deserialize(JsonElement element) => element.Deserialize<TValue>()!; 150[JsonSerializable(typeof(JsonElement))]
Services\AccountClaimsPrincipalFactory.cs (1)
51(value is JsonElement element && element.ValueKind != JsonValueKind.Undefined && element.ValueKind != JsonValueKind.Null))
Microsoft.AspNetCore.Components.WebAssembly.Server (12)
TargetPickerUi.cs (12)
149var res = System.Text.Json.JsonDocument.Parse(await ReceiveMessageLoop(browserDebugClientConnect, token)).RootElement; 150var hasTabs = res.TryGetProperty("tabs", out var tabs); 151var hasType = res.TryGetProperty("type", out var type); 160var tabsList = tabs.Deserialize<JsonElement[]>(); 165foreach (var tab in tabsList) 167var hasUrl = tab.TryGetProperty("url", out var urlInTab); 168var hasActor = tab.TryGetProperty("actor", out var actorInTab); 169var hasBrowserId = tab.TryGetProperty("browserId", out var browserIdInTab); 210var hasInput = res.TryGetProperty("input", out var input); 222var hasTarget = res.TryGetProperty("target", out var target); 223JsonElement consoleActor = new(); 225var hasActor = res.TryGetProperty("actor", out var actor);
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)
Internal\Json\AnyConverter.cs (2)
24if (!d.RootElement.TryGetProperty(AnyTypeUrlField, out var urlField)) 45if (!d.RootElement.TryGetProperty(AnyWellKnownTypeValueField, out var valueField))
Microsoft.AspNetCore.Http.Extensions (10)
_generated\12\ProblemDetailsJsonContext.GetJsonTypeInfo.g.cs (1)
38if (type == typeof(global::System.Text.Json.JsonElement))
_generated\5\ProblemDetailsJsonContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
ProblemDetailsJsonContext.cs (1)
14[JsonSerializable(typeof(JsonElement))]
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);
_generated\33\IdentityJsonSerializerContext.PublicKeyCredentialCreationOptions.g.cs (5)
270var info10 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?> 285AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredentialCreationOptions).GetProperty("Extensions", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null), 288properties[10] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info10); 364global::System.Text.Json.JsonElement? __value_Extensions = ((global::Microsoft.AspNetCore.Identity.PublicKeyCredentialCreationOptions)value).Extensions; 425private static extern void __set_PublicKeyCredentialCreationOptions_Extensions(global::Microsoft.AspNetCore.Identity.PublicKeyCredentialCreationOptions obj, global::System.Text.Json.JsonElement? value);
_generated\36\IdentityJsonSerializerContext.PublicKeyCredentialRequestOptions.g.cs (5)
180var info6 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?> 195AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredentialRequestOptions).GetProperty("Extensions", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null), 198properties[6] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info6); 249global::System.Text.Json.JsonElement? __value_Extensions = ((global::Microsoft.AspNetCore.Identity.PublicKeyCredentialRequestOptions)value).Extensions; 284private static extern void __set_PublicKeyCredentialRequestOptions_Extensions(global::Microsoft.AspNetCore.Identity.PublicKeyCredentialRequestOptions obj, global::System.Text.Json.JsonElement? value);
_generated\44\IdentityJsonSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
_generated\45\IdentityJsonSerializerContext.NullableJsonElement.g.cs (9)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 22get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 29global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 30jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
_generated\51\IdentityJsonSerializerContext.GetJsonTypeInfo.g.cs (2)
118if (type == typeof(global::System.Text.Json.JsonElement)) 122if (type == typeof(global::System.Text.Json.JsonElement?))
Passkeys\PublicKeyCredential.cs (1)
33public required JsonElement ClientExtensionResults { get; init; }
Passkeys\PublicKeyCredentialCreationOptions.cs (1)
69public JsonElement? Extensions { get; init; }
Passkeys\PublicKeyCredentialRequestOptions.cs (1)
49public JsonElement? Extensions { get; init; }
Microsoft.AspNetCore.JsonPatch.SystemTextJson (7)
Helpers\JsonUtilities.cs (5)
29using var docA = TryGetJsonElement(a, serializerOptions, out var elementA); 30using var docB = TryGetJsonElement(b, serializerOptions, out var elementB); 32return JsonElement.DeepEquals(elementA, elementB); 35private static IDisposable TryGetJsonElement(object item, JsonSerializerOptions serializerOptions, out JsonElement element) 38if (item is JsonElement jsonElement)
Internal\ConversionResultProvider.cs (2)
49targetType = typeof(JsonElement); 77if (value is JsonElement jsonElement)
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
Infrastructure\DefaultTempDataSerializer.cs (6)
21var rootElement = jsonDocument.RootElement; 25private static IDictionary<string, object> DeserializeDictionary(JsonElement rootElement) 80private static object DeserializeArray(in JsonElement arrayElement) 95foreach (var item in arrayElement.EnumerateArray()) 106foreach (var item in arrayElement.EnumerateArray()) 117private static object DeserializeDictionaryEntry(in JsonElement objectElement)
Microsoft.Build (3)
Construction\Solution\SolutionFile.cs (3)
634_solutionFile = ParseSolutionFromSolutionFilter(solutionFilterFile, out JsonElement solution); 648foreach (JsonElement project in solution.GetProperty("projects").EnumerateArray()) 665internal static string ParseSolutionFromSolutionFilter(string solutionFilterFile, out JsonElement solution)
Microsoft.CodeAnalysis.Features (1)
PdbSourceDocument\SourceLinkMap.cs (1)
72var root = JsonDocument.Parse(json, new JsonDocumentOptions() { AllowTrailingCommas = true }).RootElement;
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
MSBuild\SolutionFileReader.SolutionFilterReader.cs (2)
28var solution = document.RootElement.GetProperty("solution"); 51foreach (var project in solution.GetProperty("projects").EnumerateArray())
Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts (2)
Request.cs (1)
26public required JsonElement[] Parameters { get; init; }
Response.cs (1)
12public JsonElement? Value { get; init; }
Microsoft.Deployment.DotNet.Releases (34)
AspNetCoreReleaseComponent.cs (2)
43internal AspNetCoreReleaseComponent(JsonElement element, ProductRelease release) : base(element, release) 47if (element.TryGetProperty("version-aspnetcoremodule", out JsonElement ancmVersionValue) && ancmVersionValue.ValueKind != JsonValueKind.Null)
Cve.cs (3)
33/// Creates a new <see cref="Cve"/> instance from a <see cref="JsonElement"/>. 35/// <param name="cveElement">The <see cref="JsonElement"/> to deserialize.</param> 36internal Cve(JsonElement cveElement)
JsonExtensions.cs (9)
15/// <param name="value">The <see cref="JsonElement"/> to query.</param> 18internal static ReleaseVersion GetReleaseVersionOrDefault(this JsonElement value, string propertyName) 20if (value.TryGetProperty(propertyName, out JsonElement p) && p.ValueKind != JsonValueKind.Null) 32/// <param name="value">The <see cref="JsonElement"/> to query.</param> 35internal static string GetStringOrDefault(this JsonElement value, string propertyName) 37if (value.TryGetProperty(propertyName, out JsonElement p) && p.ValueKind == JsonValueKind.String) 49/// <param name="value">The <see cref="JsonElement"/> to query.</param> 52internal static Uri GetUriOrDefault(this JsonElement value, string propertyName) 54if (value.TryGetProperty(propertyName, out JsonElement p) && p.ValueKind != JsonValueKind.Null)
Product.cs (3)
148internal Product(JsonElement productElement) 150ReleaseType = productElement.TryGetProperty("release-type", out JsonElement value) ? 239JsonElement root = releasesDocument.RootElement;
ProductCollection.cs (2)
116var root = releasesIndexDocument.RootElement.GetProperty("releases-index"); 119using JsonElement.ArrayEnumerator enumerator = root.EnumerateArray();
ProductRelease.cs (7)
137internal ProductRelease(JsonElement element, Product product) 147if (element.TryGetProperty("cve-list", out JsonElement cveListElement) && cveListElement.ValueKind == JsonValueKind.Array) 161if (element.TryGetProperty("aspnetcore-runtime", out JsonElement aspNetCoreValue) && aspNetCoreValue.ValueKind != JsonValueKind.Null) 167if (element.TryGetProperty("runtime", out JsonElement runtimeValue) && runtimeValue.ValueKind != JsonValueKind.Null) 173if (element.TryGetProperty("windowsdesktop", out JsonElement desktopValue) && desktopValue.ValueKind != JsonValueKind.Null) 183if (element.TryGetProperty("sdks", out JsonElement sdksValue) && sdksValue.ValueKind == JsonValueKind.Array) 192else if (element.TryGetProperty("sdk", out JsonElement sdkValue) && sdkValue.ValueKind != JsonValueKind.Null)
ReleaseComponent.cs (2)
60internal ReleaseComponent(JsonElement element, ProductRelease release) 68if (element.TryGetProperty("files", out JsonElement P) && P.ValueKind == JsonValueKind.Array)
ReleaseFile.cs (3)
68/// Creates a new <see cref="ReleaseFile"/> instance from a <see cref="JsonElement"/>. 70/// <param name="fileElement">The <see cref="JsonElement"/> to deserialize.</param> 71internal ReleaseFile(JsonElement fileElement)
RuntimeReleaseComponent.cs (1)
42internal RuntimeReleaseComponent(JsonElement element, ProductRelease release) : base(element, release)
SdkReleaseComponent.cs (1)
88internal SdkReleaseComponent(JsonElement element, ProductRelease release) : base(element, release)
WindowsDesktopReleaseComponent.cs (1)
23internal WindowsDesktopReleaseComponent(JsonElement element, ProductRelease release) : base(element, release)
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\14\ContractDescriptorContext.GetJsonTypeInfo.g.cs (2)
52if (type == typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>)) 60if (type == typeof(global::System.Text.Json.JsonElement))
_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)
_generated\9\ContractDescriptorContext.JsonElement.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 24get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
ContractDescriptorParser.cs (2)
45[JsonSerializable(typeof(Dictionary<string, JsonElement>))] 73public Dictionary<string, JsonElement>? Extras { get; set; }
Microsoft.DotNet.Arcade.Sdk (3)
src\InstallDotNetCore.cs (3)
64if (jsonDocument.RootElement.TryGetProperty("tools", out JsonElement toolsElement)) 66if (!SkipRuntimesInstall && toolsElement.TryGetProperty("runtimes", out JsonElement dotnetLocalElement)) 260foreach (var version in token.Value.EnumerateArray())
Microsoft.DotNet.ProjectTools (6)
LaunchSettings\LaunchSettings.cs (6)
88var model = document.RootElement; 90if (model.ValueKind != JsonValueKind.Object || !model.TryGetProperty(ProfilesKey, out var profilesObject) || profilesObject.ValueKind != JsonValueKind.Object) 96JsonElement profileObject; 134if (prop.Value.TryGetProperty(CommandNameKey, out var commandNameElement) && commandNameElement.ValueKind == JsonValueKind.String) 151if (!profileObject.TryGetProperty(CommandNameKey, out var finalCommandNameElement) 186|| !profileProperty.Value.TryGetProperty(CommandNameKey, out var commandNameElement)
Microsoft.Extensions.AI (33)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (3)
154var schema = responseFormat.Schema!.Value; 203static bool SchemaRepresentsObject(JsonElement schemaElement) 220static JsonNode? JsonElementToJsonNode(JsonElement element) =>
ChatCompletion\ChatResponse{T}.cs (1)
139if (JsonDocument.Parse(json!).RootElement.TryGetProperty("data", out var data))
ChatCompletion\DistributedCachingChatClient.cs (1)
27/// will deserialize as <see cref="JsonElement"/> rather than as the original type. In general, code using <see cref="DistributedCachingChatClient"/>
ChatCompletion\DistributedCachingChatClientBuilderExtensions.cs (1)
32/// will deserialize as <see cref="JsonElement"/> rather than as the original type. In general, code using <see cref="DistributedCachingChatClient"/>
Common\OtelMessageParts.cs (1)
89public JsonElement? Parameters { get; set; }
Common\OtelMessageSerializer.cs (2)
22private static readonly JsonElement _emptyObject = 225JsonElement element = _emptyObject;
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OtelContext.GetJsonTypeInfo.g.cs (2)
154if (type == typeof(global::System.Text.Json.JsonElement)) 158if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OtelContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OtelContext.NullableJsonElement.g.cs (9)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 22get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 29global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 30jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OtelContext.OtelFunction.g.cs (4)
113var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?> 128AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.OtelFunction).GetProperty("Parameters", InstanceMemberBindingFlags, null, typeof(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.Text.Json.JsonElement?>(options, info3); 163global::System.Text.Json.JsonElement? __value_Parameters = ((global::Microsoft.Extensions.AI.OtelFunction)value).Parameters;
Realtime\OpenTelemetryRealtimeClientSession.cs (1)
622JsonElement element = default;
Microsoft.Extensions.AI.Abstractions (76)
ChatCompletion\ChatResponseFormat.cs (2)
45JsonElement schema, string? schemaName = null, string? schemaDescription = null) => 84var schema = AIJsonUtilities.CreateJsonSchema(
ChatCompletion\ChatResponseFormatJson.cs (2)
21JsonElement? schema, string? schemaName = null, string? schemaDescription = null) 36public JsonElement? Schema { get; }
Functions\AIFunctionDeclaration.cs (2)
50public virtual JsonElement JsonSchema => AIJsonUtilities.DefaultJsonSchema; 67public virtual JsonElement? ReturnJsonSchema => null;
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);
Functions\AIFunctionFactoryOptions.cs (1)
91/// is then JSON serialized, with the resulting <see cref="JsonElement"/> returned from the <see cref="AIFunction.InvokeAsync"/> method.
Functions\DelegatingAIFunction.cs (2)
39public override JsonElement JsonSchema => InnerFunction.JsonSchema; 42public override JsonElement? ReturnJsonSchema => InnerFunction.ReturnJsonSchema;
Functions\DelegatingAIFunctionDeclaration.cs (2)
36public override JsonElement JsonSchema => InnerFunction.JsonSchema; 39public override JsonElement? ReturnJsonSchema => InnerFunction.ReturnJsonSchema;
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?),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.GetJsonTypeInfo.g.cs (2)
488if (type == typeof(global::System.Text.Json.JsonElement)) 492if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.JsonElement.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 24get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.NullableJsonElement.g.cs (9)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 24get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 31global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 32jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
Utilities\AIJsonSchemaTransformCache.cs (5)
61public JsonElement GetOrCreateTransformedSchema(AIFunction function) => 69public JsonElement GetOrCreateTransformedSchema(AIFunctionDeclaration function) 72return (JsonElement)_functionSchemaCache.GetValue(function, _functionSchemaCreateValueCallback); 80public JsonElement? GetOrCreateTransformedSchema(ChatResponseFormatJson responseFormat) 84? (JsonElement?)_responseFormatCache.GetValue(responseFormat, _responseFormatCreateValueCallback)
Utilities\AIJsonUtilities.Defaults.cs (1)
71[JsonSerializable(typeof(JsonElement))]
Utilities\AIJsonUtilities.Schema.Create.cs (7)
73/// <returns>A JSON schema document encoded as a <see cref="JsonElement"/>.</returns> 75public static JsonElement CreateFunctionJsonSchema( 189/// <returns>A <see cref="JsonElement"/> representing the schema.</returns> 190public static JsonElement CreateJsonSchema( 212internal static JsonElement DefaultJsonSchema { get; } = JsonElement.Parse("{}"u8); 215internal static void ValidateSchemaDocument(JsonElement document, [CallerArgumentExpression("document")] string? paramName = null)
Utilities\AIJsonUtilities.Schema.Transform.cs (2)
23public static JsonElement TransformSchema(JsonElement schema, AIJsonSchemaTransformOptions transformOptions)
Microsoft.Extensions.AI.Abstractions.Tests (173)
AssertExtensions.cs (6)
139public static void EqualJsonValues(JsonElement expectedJson, JsonElement actualJson, string? propertyName = null) 156JsonElement expectedElement = NormalizeToElement(expected, options); 157JsonElement actualElement = NormalizeToElement(actual, options); 160static JsonElement NormalizeToElement(object? value, JsonSerializerOptions options) 161=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
ChatCompletion\ChatOptionsTests.cs (2)
226Assert.IsType<JsonElement>(value); 227Assert.Equal("value", ((JsonElement)value!).GetString());
ChatCompletion\ChatResponseFormatTests.cs (3)
17private static JsonElement EmptySchema => JsonDocument.Parse("{}").RootElement; 79ChatResponseFormat.ForJsonSchema(JsonElement.Parse("[1,2,3]"), "name", "description"), 167JsonSerializer.Serialize(format.Schema, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement))));
ChatCompletion\ChatResponseTests.cs (2)
117Assert.IsType<JsonElement>(value); 118Assert.Equal("value", ((JsonElement)value!).GetString());
ChatCompletion\ChatResponseUpdateTests.cs (2)
171Assert.IsType<JsonElement>(value); 172Assert.Equal("value", ((JsonElement)value!).GetString());
Contents\AIAnnotationTests.cs (1)
60Assert.Equal(JsonElement.Parse("\"value\"").ToString(), deserialized.AdditionalProperties["key"]!.ToString());
Contents\CitationAnnotationTests.cs (1)
86Assert.Equal(JsonElement.Parse("\"value\"").ToString(), deserialized.AdditionalProperties["key"]!.ToString());
Contents\FunctionCallContentTests.cs (5)
214Assert.All(arguments.Values, v => Assert.IsType<JsonElement>(v)); 358Assert.True(kvp.Value is JsonElement { ValueKind: JsonValueKind.Object }); 368Assert.True(kvp.Value is JsonElement { ValueKind: JsonValueKind.Array }); 373Assert.True(kvp.Value is JsonElement { ValueKind: JsonValueKind.Number }); 378Assert.True(kvp.Value is JsonElement { ValueKind: JsonValueKind.True });
Embeddings\EmbeddingGenerationOptionsTests.cs (2)
88Assert.IsType<JsonElement>(value); 89Assert.Equal("value", ((JsonElement)value!).GetString());
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?),
Generated\361d1da7f942c932\TestJsonSerializerContext.GetJsonTypeInfo.g.cs (2)
486if (type == typeof(global::System.Text.Json.JsonElement)) 490if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\361d1da7f942c932\TestJsonSerializerContext.NullableJsonElement.g.cs (9)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 22get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 29global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 30jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.GetJsonTypeInfo.g.cs (1)
100if (type == typeof(global::System.Text.Json.JsonElement))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.JsonElement.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 24get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.GetJsonTypeInfo.g.cs (2)
332if (type == typeof(global::System.Text.Json.JsonElement)) 336if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.JsonElement.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 24get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.NullableJsonElement.g.cs (9)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 24get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 31global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 32jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
parent\parent\Shared\JsonSchemaExporter\TestTypes.cs (4)
102yield return new TestData<JsonElement>(JsonDocument.Parse("""[{ "x" : 42 }]""").RootElement, "true"); 118yield return new TestData<JsonElement?>(JsonDocument.Parse("{}").RootElement, "true"); 1246[JsonSerializable(typeof(JsonElement))] 1260[JsonSerializable(typeof(JsonElement?))]
SpeechToText\SpeechToTextOptionsTests.cs (2)
87Assert.IsType<JsonElement>(value); 88Assert.Equal("value", ((JsonElement)value!).GetString());
SpeechToText\SpeechToTextResponseTests.cs (2)
184Assert.IsType<JsonElement>(value); 185Assert.Equal("value", ((JsonElement)value!).GetString());
TextToSpeech\TextToSpeechOptionsTests.cs (2)
115Assert.IsType<JsonElement>(value); 116Assert.Equal("value", ((JsonElement)value!).GetString());
TextToSpeech\TextToSpeechResponseTests.cs (2)
123Assert.IsType<JsonElement>(value); 124Assert.Equal("value", ((JsonElement)value!).GetString());
Utilities\AIJsonSchemaTransformCacheTests.cs (6)
52JsonElement transformedSchema = cache.GetOrCreateTransformedSchema(func); 55JsonElement transformedSchema2 = cache.GetOrCreateTransformedSchema(func); 64JsonElement schema = JsonDocument.Parse("{}").RootElement; 66JsonElement? transformedSchema = cache.GetOrCreateTransformedSchema(responseFormat); 70JsonElement? transformedSchema2 = cache.GetOrCreateTransformedSchema(responseFormat); 78JsonElement? transformedSchema = cache.GetOrCreateTransformedSchema(ChatResponseFormat.Json);
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)
ScenarioRunResultTests.cs (3)
263JsonElement scenario = document.RootElement.GetProperty("scenarioRunResults")[0]; 264JsonElement metrics = scenario.GetProperty("evaluationResult").GetProperty("metrics"); 271JsonElement contents = scenario.GetProperty("messages")[0].GetProperty("contents");
Microsoft.Extensions.AI.Evaluation.Safety (4)
ContentSafetyService.cs (4)
59JsonElement metricElement = annotationResponseDocument.RootElement.EnumerateArray().Last(); 67JsonElement metricDetailsRootElement = metricDetailsDocument.RootElement; 69JsonElement labelElement = metricDetailsRootElement.GetProperty("label"); 277foreach (JsonElement element in document.RootElement.EnumerateArray())
Microsoft.Extensions.AI.Integration.Tests (7)
ChatClientIntegrationTests.cs (2)
515public override JsonElement JsonSchema { get; } = JsonElement.Parse(jsonSchema);
PromptBasedFunctionCallingChatClient.cs (1)
153if (kvp.Value is JsonElement jsonElement)
VerbatimMultiPartHttpHandler.cs (4)
129((List<JsonElement>)parameters[name]).Add(ParseContentToJsonElement(rawValue)); 133parameters.Add(name, new List<JsonElement> { ParseContentToJsonElement(rawValue) }); 142if (parameters[key] is List<JsonElement> list && list.Count == 1) 161private static JsonElement ParseContentToJsonElement(string content)
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.GetJsonTypeInfo.g.cs (2)
30if (type == typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>)) 50if (type == typeof(global::System.Text.Json.JsonElement))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OpenAIJsonContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
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);
MicrosoftExtensionsAIChatExtensions.cs (1)
246return JsonElement.Parse(ms.GetBuffer().AsSpan(0, (int)ms.Position));
OpenAIClientExtensions.cs (6)
243JsonElement jsonSchema = strict is true ? 318private static readonly JsonElement _falseElement = JsonElement.Parse("false"u8); 327public Dictionary<string, JsonElement> Properties { get; set; } = []; 330public JsonElement AdditionalProperties { get; set; } = _falseElement; 333public Dictionary<string, JsonElement>? ExtensionData { get; set; }
OpenAIJsonContext.cs (1)
23[JsonSerializable(typeof(JsonElement))]
OpenAIResponsesChatClient.cs (4)
1563(reasoningItemIdValue is JsonElement { ValueKind: JsonValueKind.String } jsonElement ? jsonElement.GetString() : null); 1941foreach (var fileElement in doc.RootElement.EnumerateArray()) 1944(fileElement.TryGetProperty("file_id", out var idProp) ? idProp.GetString() : null) ?? 1952string? mimeType = fileElement.TryGetProperty("mime_type", out var mimeProp) ? mimeProp.GetString() : null;
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());
parent\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (6)
139public static void EqualJsonValues(JsonElement expectedJson, JsonElement actualJson, string? propertyName = null) 156JsonElement expectedElement = NormalizeToElement(expected, options); 157JsonElement actualElement = NormalizeToElement(actual, options); 160static JsonElement NormalizeToElement(object? value, JsonSerializerOptions options) 161=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Microsoft.Extensions.AI.Tests (76)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (5)
470private static void AssertDeepEquals(JsonElement element1, JsonElement element2) 483private static bool DeepEquals(JsonElement element1, JsonElement element2) 485return JsonElement.DeepEquals(element1, element2);
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
346return result is JsonElement e ?
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?),
Generated\361d1da7f942c932\TestJsonSerializerContext.GetJsonTypeInfo.g.cs (2)
334if (type == typeof(global::System.Text.Json.JsonElement)) 338if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\361d1da7f942c932\TestJsonSerializerContext.NullableJsonElement.g.cs (9)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 22get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 29global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 30jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestJsonSerializerContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
parent\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (6)
139public static void EqualJsonValues(JsonElement expectedJson, JsonElement actualJson, string? propertyName = null) 156JsonElement expectedElement = NormalizeToElement(expected, options); 157JsonElement actualElement = NormalizeToElement(actual, options); 160static JsonElement NormalizeToElement(object? value, JsonSerializerOptions options) 161=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Realtime\FunctionInvokingRealtimeClientTests.cs (1)
593var schema = JsonDocument.Parse("""{"type":"object","properties":{"x":{"type":"string"}}}""").RootElement;
TestJsonSerializerContext.cs (1)
20[JsonSerializable(typeof(JsonElement))]
Microsoft.Extensions.Configuration.Json (4)
JsonConfigurationFileParser.cs (4)
43private void VisitObjectElement(JsonElement element) 58private void VisitArrayElement(JsonElement element) 62foreach (JsonElement arrayElement in element.EnumerateArray()) 89private void VisitValue(JsonElement value)
Microsoft.ML.GenAI.Phi (4)
Module\Phi3SuScaledRotaryEmbedding.cs (4)
28JsonElement shortFactorElement = (JsonElement)config.RopeScaling!["short_factor"]; 29JsonElement longFactorDocument = (JsonElement)config.RopeScaling!["long_factor"];
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)
UnigramTests.cs (4)
30private static IEnumerable<(string Token, float Score)> GetVocabulary(JsonElement root) 32if (root.TryGetProperty("model", out JsonElement modelElement) && 33modelElement.TryGetProperty("vocab", out JsonElement vocabElement) && 36foreach (JsonElement token in vocabElement.EnumerateArray())
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)
ComHost\RegFreeComManifest.cs (2)
57JsonElement clsidMap; 68if (property.Value.TryGetProperty("progid", out JsonElement progIdValue))
Microsoft.SourceLink.Tools.Package (1)
SourceLinkMap.cs (1)
92var root = JsonDocument.Parse(json, new JsonDocumentOptions() { AllowTrailingCommas = true }).RootElement;
Microsoft.TemplateEngine.Edge (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
255/// <see cref="JsonObject.WriteTo"/> falls back to the underlying <see cref="System.Text.Json.JsonElement"/>
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
255/// <see cref="JsonObject.WriteTo"/> falls back to the underlying <see cref="System.Text.Json.JsonElement"/>
Microsoft.TemplateEngine.Utils (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
255/// <see cref="JsonObject.WriteTo"/> falls back to the underlying <see cref="System.Text.Json.JsonElement"/>
Microsoft.TemplateSearch.Common (1)
src\sdk\src\TemplateEngine\Shared\JExtensions.cs (1)
255/// <see cref="JsonObject.WriteTo"/> falls back to the underlying <see cref="System.Text.Json.JsonElement"/>
Microsoft.TestPlatform.CommunicationUtilities (144)
_generated\104\TestPlatformJsonContext.GetJsonTypeInfo.g.cs (2)
402if (type == typeof(global::System.Text.Json.JsonElement)) 406if (type == typeof(global::System.Text.Json.JsonElement?))
_generated\17\TestPlatformJsonContext.VersionedMessageEnvelope.g.cs (4)
93var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?> 108AttributeProviderFactory = static () => typeof(global::Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.JsonDataSerializer.VersionedMessageEnvelope).GetProperty("Payload", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null), 111properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info2); 130global::System.Text.Json.JsonElement? __value_Payload = ((global::Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.JsonDataSerializer.VersionedMessageEnvelope)value).Payload;
_generated\4\TestPlatformJsonContext.MessageEnvelope.g.cs (4)
73var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement?> 88AttributeProviderFactory = static () => typeof(global::Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.JsonDataSerializer.MessageEnvelope).GetProperty("Payload", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement?), global::System.Array.Empty<global::System.Type>(), null), 91properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement?>(options, info1); 109global::System.Text.Json.JsonElement? __value_Payload = ((global::Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.JsonDataSerializer.MessageEnvelope)value).Payload;
_generated\95\TestPlatformJsonContext.JsonElement.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 22get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
_generated\96\TestPlatformJsonContext.NullableJsonElement.g.cs (9)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 22get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 29global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 30jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
JsonDataSerializer.Stj.cs (7)
88var root = doc.RootElement; 89int version = root.TryGetProperty("Version", out var vProp) 92string? messageType = root.TryGetProperty("MessageType", out var mtProp) ? mtProp.GetString() : null; 112if (doc.RootElement.TryGetProperty("Payload", out var payloadElement)) 198var serializedPayload = StjSafe.SerializeToElement(payload, payload.GetType(), payloadOptions); 277public JsonElement? Payload { get; set; } 290public JsonElement? Payload { get; set; }
Serialization\AfterTestRunEndResultConverter.cs (3)
32var root = doc.RootElement; 51private static T? DeserializeProperty<T>(JsonElement element, string name, JsonSerializerOptions options) 53if (element.TryGetProperty(name, out var prop) && prop.ValueKind != JsonValueKind.Null)
Serialization\AttachmentConverters.cs (5)
23var element = doc.RootElement; 29if (element.TryGetProperty("Attachments", out var attachments) && attachments.GetArrayLength() > 0) 31foreach (var attachment in attachments.EnumerateArray()) 63var element = doc.RootElement; 66var description = element.TryGetProperty("Description", out var descProp) && descProp.ValueKind != JsonValueKind.Null
Serialization\DiscoveryCriteriaConverter.cs (6)
31var root = doc.RootElement; 36var runSettings = root.TryGetProperty("RunSettings", out var rs) && rs.ValueKind != JsonValueKind.Null ? rs.GetString() : null; 37var package = root.TryGetProperty("Package", out var pkg) && pkg.ValueKind != JsonValueKind.Null ? pkg.GetString() : null; 38var testCaseFilter = root.TryGetProperty("TestCaseFilter", out var tcf) && tcf.ValueKind != JsonValueKind.Null ? tcf.GetString() : null; 74private static T? DeserializeProperty<T>(JsonElement element, string name, JsonSerializerOptions options) 76if (element.TryGetProperty(name, out var prop) && prop.ValueKind != JsonValueKind.Null)
Serialization\ExceptionConverter.cs (7)
35var root = doc.RootElement; 37string? className = root.TryGetProperty("ClassName", out var clsProp) && clsProp.ValueKind == JsonValueKind.String 41string? message = root.TryGetProperty("Message", out var msgProp) && msgProp.ValueKind != JsonValueKind.Null 45string? stackTrace = root.TryGetProperty("StackTraceString", out var stProp) && stProp.ValueKind == JsonValueKind.String 50if (root.TryGetProperty("InnerException", out var innerProp) && innerProp.ValueKind != JsonValueKind.Null) 57if (root.TryGetProperty("HResult", out var hresultProp) && hresultProp.ValueKind == JsonValueKind.Number) 62if (root.TryGetProperty("Source", out var sourceProp) && sourceProp.ValueKind == JsonValueKind.String)
Serialization\StjSafe.cs (2)
43internal static T? Deserialize<T>(JsonElement element, JsonSerializerOptions options) 67internal static JsonElement SerializeToElement(object value, Type inputType, JsonSerializerOptions options)
Serialization\TestCaseConverter.cs (5)
26var data = doc.RootElement; 28if (!data.TryGetProperty("Properties", out var properties) || properties.GetArrayLength() == 0) 35foreach (var property in properties.EnumerateArray()) 37if (!property.TryGetProperty("Key", out var keyElement)) 50if (!property.TryGetProperty("Value", out var token))
Serialization\TestCaseConverterV2.cs (12)
27var data = doc.RootElement; 29if (data.TryGetProperty("FullyQualifiedName", out var fqn)) 31if (data.TryGetProperty("ExecutorUri", out var uri) && uri.ValueKind != JsonValueKind.Null) 33if (data.TryGetProperty("Source", out var source)) 35if (data.TryGetProperty("Id", out var id) && id.ValueKind != JsonValueKind.Null) 37if (data.TryGetProperty("DisplayName", out var display) && display.ValueKind != JsonValueKind.Null) 39if (data.TryGetProperty("CodeFilePath", out var codePath) && codePath.ValueKind != JsonValueKind.Null) 41if (data.TryGetProperty("LineNumber", out var lineNum)) 45if (data.TryGetProperty("Properties", out var properties) && properties.GetArrayLength() > 0) 47foreach (var prop in properties.EnumerateArray()) 49if (!prop.TryGetProperty("Key", out var keyElement)) 56if (!prop.TryGetProperty("Value", out var valueElement))
Serialization\TestExecutionContextConverter.cs (9)
24var data = doc.RootElement; 28if (data.TryGetProperty("FrequencyOfRunStatsChangeEvent", out var freq)) 30if (data.TryGetProperty("RunStatsChangeEventTimeout", out var timeout)) 32if (data.TryGetProperty("InIsolation", out var isolation)) 34if (data.TryGetProperty("KeepAlive", out var keepAlive)) 36if (data.TryGetProperty("AreTestCaseLevelEventsRequired", out var tcEvents)) 38if (data.TryGetProperty("IsDebug", out var isDebug)) 40if (data.TryGetProperty("TestCaseFilter", out var filter) && filter.ValueKind != JsonValueKind.Null) 42if (data.TryGetProperty("FilterOptions", out var filterOptions) && filterOptions.ValueKind != JsonValueKind.Null)
Serialization\TestObjectBaseConverter.cs (7)
61var data = doc.RootElement; 63if (!data.TryGetProperty("Properties", out var properties) || properties.GetArrayLength() == 0) 68foreach (var prop in properties.EnumerateArray()) 70if (!prop.TryGetProperty("Key", out var keyElement)) 77if (!prop.TryGetProperty("Value", out var valueElement)) 153case JsonElement je: je.WriteTo(writer); break; 198var element = StjSafe.SerializeToElement(value, value.GetType(), options);
Serialization\TestObjectConverter.cs (3)
39var element = doc.RootElement; 41if (!element.TryGetProperty("Key", out var keyElement)) 49if (element.TryGetProperty("Value", out var valueElement) && valueElement.ValueKind != JsonValueKind.Null)
Serialization\TestProcessAttachDebuggerPayloadConverter.cs (3)
29var root = doc.RootElement; 31var processId = root.TryGetProperty("ProcessID", out var pidProp) ? pidProp.GetInt32() : 0; 32var targetFramework = root.TryGetProperty("TargetFramework", out var tf) && tf.ValueKind != JsonValueKind.Null
Serialization\TestPropertyConverter.cs (7)
29var element = doc.RootElement; 31var id = element.TryGetProperty("Id", out var idProp) ? idProp.GetString() : null; 32var label = element.TryGetProperty("Label", out var labelProp) ? labelProp.GetString() : null; 33var category = element.TryGetProperty("Category", out var catProp) ? catProp.GetString() : null; 34var description = element.TryGetProperty("Description", out var descProp) ? descProp.GetString() : null; 35var attributes = element.TryGetProperty("Attributes", out var attrProp) ? (TestPropertyAttributes)attrProp.GetInt32() : default; 36var valueType = element.TryGetProperty("ValueType", out var vtProp) ? vtProp.GetString() : null;
Serialization\TestResultConverter.cs (9)
24var data = doc.RootElement; 26var testCaseElement = data.GetProperty("TestCase"); 31if (data.TryGetProperty("Attachments", out var attachments) && attachments.GetArrayLength() > 0) 33foreach (var attachment in attachments.EnumerateArray()) 43if (data.TryGetProperty("Messages", out var messages) && messages.GetArrayLength() > 0) 45foreach (var message in messages.EnumerateArray()) 54if (!data.TryGetProperty("Properties", out var properties) || properties.GetArrayLength() == 0) 61foreach (var property in properties.EnumerateArray()) 66var token = property.GetProperty("Value");
Serialization\TestResultConverterV2.cs (18)
26var data = doc.RootElement; 29var testCaseElement = data.GetProperty("TestCase"); 34if (data.TryGetProperty("Attachments", out var attachments) && attachments.GetArrayLength() > 0) 36foreach (var attachment in attachments.EnumerateArray()) 46if (data.TryGetProperty("Messages", out var messages) && messages.GetArrayLength() > 0) 48foreach (var message in messages.EnumerateArray()) 58if (data.TryGetProperty("Outcome", out var outcome)) 60if (data.TryGetProperty("ErrorMessage", out var errorMsg) && errorMsg.ValueKind != JsonValueKind.Null) 62if (data.TryGetProperty("ErrorStackTrace", out var errorStack) && errorStack.ValueKind != JsonValueKind.Null) 64if (data.TryGetProperty("DisplayName", out var displayName) && displayName.ValueKind != JsonValueKind.Null) 66if (data.TryGetProperty("ComputerName", out var computerName) && computerName.ValueKind != JsonValueKind.Null) 68if (data.TryGetProperty("Duration", out var duration) && duration.ValueKind != JsonValueKind.Null) 70if (data.TryGetProperty("StartTime", out var startTime) && startTime.ValueKind != JsonValueKind.Null) 72if (data.TryGetProperty("EndTime", out var endTime) && endTime.ValueKind != JsonValueKind.Null) 76if (data.TryGetProperty("Properties", out var properties) && properties.GetArrayLength() > 0) 78foreach (var prop in properties.EnumerateArray()) 80if (!prop.TryGetProperty("Key", out var keyElement)) 85if (!prop.TryGetProperty("Value", out var valueElement))
Serialization\TestRunChangedEventArgsConverter.cs (3)
31var root = doc.RootElement; 50private static T? DeserializeProperty<T>(JsonElement element, string name, JsonSerializerOptions options) 52if (element.TryGetProperty(name, out var prop) && prop.ValueKind != JsonValueKind.Null)
Serialization\TestRunCompleteEventArgsConverter.cs (5)
32var root = doc.RootElement; 35var isCanceled = root.TryGetProperty("IsCanceled", out var ic) && ic.GetBoolean(); 36var isAborted = root.TryGetProperty("IsAborted", out var ia) && ia.GetBoolean(); 65private static T? DeserializeProperty<T>(JsonElement element, string name, JsonSerializerOptions options) 67if (element.TryGetProperty(name, out var prop) && prop.ValueKind != JsonValueKind.Null)
Serialization\TestRunStatisticsConverter.cs (3)
27var root = doc.RootElement; 29long executedTests = root.TryGetProperty("ExecutedTests", out var etProp) ? etProp.GetInt64() : 0; 32if (root.TryGetProperty("Stats", out var statsProp) && statsProp.ValueKind == JsonValueKind.Object)
Serialization\TestSessionInfoConverter.cs (2)
29var root = doc.RootElement; 31var id = root.TryGetProperty("Id", out var idProp) && idProp.ValueKind != JsonValueKind.Null
TestPlatformJsonContext.cs (1)
47[JsonSerializable(typeof(JsonElement))]
Microsoft.TestPlatform.TestHostRuntimeProvider (3)
Hosting\DotnetTestHostManager.cs (3)
1055if (doc.RootElement.TryGetProperty("runtimeOptions", out var runtimeOptions) && 1056runtimeOptions.TryGetProperty("additionalProbingPaths", out var additionalProbingPaths)) 1058foreach (var x in additionalProbingPaths.EnumerateArray())
NuGet.Protocol (6)
Plugins\MessageConverter.cs (6)
14private static readonly Dictionary<(MessageMethod, MessageType), Func<JsonElement, object?>> _read = new() 106var root = doc.RootElement; 108if (!root.TryGetProperty(nameof(Message.RequestId), out var requestIdProp)) 119if (!root.TryGetProperty(nameof(Message.Type), out var typeProp)) 130if (!root.TryGetProperty(nameof(Message.Method), out var methodProp)) 142if (root.TryGetProperty("Payload", out var payloadProp) && payloadProp.ValueKind != JsonValueKind.Null)
RepoTasks (4)
ResolveDotnetToolPackagePaths.cs (4)
40if (!document.RootElement.TryGetProperty("tools", out var tools)) 52var toolsByPackageId = new Dictionary<string, JsonElement>(StringComparer.OrdinalIgnoreCase); 70if (!toolsByPackageId.TryGetValue(packageId, out var tool)) 82if (!tool.TryGetProperty("version", out var versionElement))
rzc (6)
Json\JsonDataReader.cs (6)
15/// <see cref="JsonElement"/> from System.Text.Json, providing 20private readonly JsonElement _element; 21private JsonElement _currentValue; 23public JsonDataReader(JsonElement element) 165foreach (var item in _currentValue.EnumerateArray()) 182foreach (var item in _currentValue.EnumerateArray())
Shared.Tests (23)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.GetJsonTypeInfo.g.cs (2)
344if (type == typeof(global::System.Text.Json.JsonElement)) 348if (type == typeof(global::System.Text.Json.JsonElement?))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.JsonElement.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>? _JsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> JsonElement 24get => _JsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> Create_JsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonElementConverter);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.NullableJsonElement.g.cs (9)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>? _NullableJsonElement; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> NullableJsonElement 24get => _NullableJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?>)Options.GetTypeInfo(typeof(global::System.Text.Json.JsonElement?)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> Create_NullableJsonElement(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.JsonElement?>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.JsonElement?> jsonTypeInfo)) 31global::System.Text.Json.Serialization.JsonConverter converter = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.GetNullableConverter<global::System.Text.Json.JsonElement>(options); 32jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.JsonElement?>(options, converter);
JsonSchemaExporter\TestTypes.cs (4)
102yield return new TestData<JsonElement>(JsonDocument.Parse("""[{ "x" : 42 }]""").RootElement, "true"); 118yield return new TestData<JsonElement?>(JsonDocument.Parse("{}").RootElement, "true"); 1246[JsonSerializable(typeof(JsonElement))] 1260[JsonSerializable(typeof(JsonElement?))]
System.Text.Json (211)
System\Runtime\InteropServices\JsonMarshal.cs (2)
14/// Gets a <see cref="ReadOnlySpan{T}"/> view over the raw JSON data of the given <see cref="JsonElement"/>. 25public static ReadOnlySpan<byte> GetRawUtf8Value(JsonElement element)
System\Text\Json\Document\JsonDocument.cs (8)
33/// The <see cref="JsonElement"/> representing the value of the document. 35public JsonElement RootElement => new JsonElement(this, 0); 99/// This <see cref="RootElement"/>'s <see cref="JsonElement.ValueKind"/> would result in an invalid JSON. 151internal JsonElement GetArrayIndexElement(int currentIndex, int arrayIndex) 712internal JsonElement CloneElement(int index) 1056JsonElement curr = new JsonElement(document, traversalPath.Peek()); 1062JsonElement.ObjectEnumerator enumerator = new(curr, databaseIndexOflastProcessedChild ?? -1); 1089JsonElement.ArrayEnumerator enumerator = new(curr, databaseIndexOflastProcessedChild ?? -1);
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (3)
11internal unsafe bool TryGetNamedPropertyValue(int index, ReadOnlySpan<char> propertyName, out JsonElement value) 111internal bool TryGetNamedPropertyValue(int index, ReadOnlySpan<byte> propertyName, out JsonElement value) 139out JsonElement value)
System\Text\Json\Document\JsonElement.ArrayEnumerator.cs (7)
16public struct ArrayEnumerator : IEnumerable<JsonElement>, IEnumerator<JsonElement> 18private readonly JsonElement _target; 22internal ArrayEnumerator(JsonElement target, int currentIndex = -1) 33public JsonElement Current 64IEnumerator<JsonElement> IEnumerable<JsonElement>.GetEnumerator() => GetEnumerator();
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\Document\JsonElement.ObjectEnumerator.cs (2)
18private readonly JsonElement _target; 22internal ObjectEnumerator(JsonElement target, int currentIndex = -1)
System\Text\Json\Document\JsonElement.Parse.cs (13)
47public static JsonElement ParseValue(ref Utf8JsonReader reader) 56internal static JsonElement ParseValue(ref Utf8JsonReader reader, bool allowDuplicateProperties) 70internal static JsonElement ParseValue(Stream utf8Json, JsonDocumentOptions options) 77/// Parses UTF8-encoded text representing a single JSON value into a <see cref="JsonElement"/>. 81/// <returns>A <see cref="JsonElement"/> representation of the JSON value.</returns> 84public static JsonElement Parse([StringSyntax(StringSyntaxAttribute.Json)] ReadOnlySpan<byte> utf8Json, JsonDocumentOptions options = default) 91/// Parses text representing a single JSON value into a <see cref="JsonElement"/>. 95/// <returns>A <see cref="JsonElement"/> representation of the JSON value.</returns> 98public static JsonElement Parse([StringSyntax(StringSyntaxAttribute.Json)] ReadOnlySpan<char> json, JsonDocumentOptions options = default) 105/// Parses text representing a single JSON value into a <see cref="JsonElement"/>. 109/// <returns>A <see cref="JsonElement"/> representation of the JSON value.</returns> 113public static JsonElement Parse([StringSyntax(StringSyntaxAttribute.Json)] string json, JsonDocumentOptions options = default) 159public static bool TryParseValue(ref Utf8JsonReader reader, [NotNullWhen(true)] out JsonElement? element)
System\Text\Json\Document\JsonProperty.cs (3)
18public JsonElement Value { get; } 20internal JsonProperty(JsonElement value) 110/// This <see cref="Value"/>'s <see cref="JsonElement.ValueKind"/> would result in an invalid JSON.
System\Text\Json\Nodes\JsonArray.cs (13)
23private JsonElement? _jsonElement; 26internal override JsonElement? UnderlyingElement => _jsonElement; 76GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement); 183/// Initializes a new instance of the <see cref="JsonArray"/> class that contains items from the specified <see cref="JsonElement"/>. 186/// The new instance of the <see cref="JsonArray"/> class that contains items from the specified <see cref="JsonElement"/>. 188/// <param name="element">The <see cref="JsonElement"/>.</param> 193public static JsonArray? Create(JsonElement element, JsonNodeOptions? options = null) 203internal JsonArray(JsonElement element, JsonNodeOptions? options = null) : base(options) 268GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement); 296GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement); 302JsonElement jElement = jsonElement.Value; 307foreach (JsonElement element in jElement.EnumerateArray()) 332private void GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement)
System\Text\Json\Nodes\JsonNode.cs (6)
28internal virtual JsonElement? UnderlyingElement => null; 185/// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive 186/// value supported by current <see cref="JsonElement"/>. 188/// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>, 369/// to support arbitrary <see cref="JsonElement"/> and <see cref="JsonNode"/> values. 386if (value is JsonElement element)
System\Text\Json\Nodes\JsonNode.Parse.cs (8)
51JsonElement element = JsonElement.ParseValue(ref reader); 77JsonElement element = JsonElement.Parse(json, documentOptions); 98JsonElement element = JsonElement.Parse(utf8Json, documentOptions); 122JsonElement element = JsonElement.ParseValue(utf8Json, documentOptions);
System\Text\Json\Nodes\JsonObject.cs (10)
21private JsonElement? _jsonElement; 23internal override JsonElement? UnderlyingElement => _jsonElement; 51/// Initializes a new instance of the <see cref="JsonObject"/> class that contains properties from the specified <see cref="JsonElement"/>. 54/// The new instance of the <see cref="JsonObject"/> class that contains properties from the specified <see cref="JsonElement"/>. 56/// <param name="element">The <see cref="JsonElement"/>.</param> 59public static JsonObject? Create(JsonElement element, JsonNodeOptions? options = null) 69internal JsonObject(JsonElement element, JsonNodeOptions? options = null) : this(options) 85GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement); 165GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement); 187GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement);
System\Text\Json\Nodes\JsonObject.IDictionary.cs (2)
249GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement); 298private void GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement)
System\Text\Json\Nodes\JsonValue.CreateOverloads.cs (3)
290public static JsonValue? Create(JsonElement value, JsonNodeOptions? options = null) => JsonValue.CreateFromElement(ref value, options); 298public static JsonValue? Create(JsonElement? value, JsonNodeOptions? options = null) => value is JsonElement element ? JsonValue.CreateFromElement(ref element, options) : null;
System\Text\Json\Nodes\JsonValue.cs (10)
26/// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive 27/// value supported by current <see cref="JsonElement"/>. 29/// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>, 62if (value is JsonElement element) 98if (value is JsonElement element && jsonTypeInfo.EffectiveConverter.IsInternalConverter) 114JsonElement thisElement = ToJsonElement(this, out JsonDocument? thisDocument); 115JsonElement otherElement = ToJsonElement(otherNode, out JsonDocument? otherDocument); 118return JsonElement.DeepEquals(thisElement, otherElement); 126static JsonElement ToJsonElement(JsonNode node, out JsonDocument? backingDocument) 178internal static JsonValue? CreateFromElement(ref readonly JsonElement element, JsonNodeOptions? options = null)
System\Text\Json\Nodes\JsonValueOfElement.cs (6)
10/// Defines a primitive JSON value that is wrapping a <see cref="JsonElement"/>. 12internal sealed class JsonValueOfElement : JsonValue<JsonElement> 14public JsonValueOfElement(JsonElement value, JsonNodeOptions? options) : base(value, options) 19internal override JsonElement? UnderlyingElement => Value; 25if (otherNode.UnderlyingElement is JsonElement otherElement) 27return JsonElement.DeepEquals(Value, otherElement);
System\Text\Json\Nodes\JsonValueOfJsonPrimitive.cs (9)
69if (typeof(T) == typeof(JsonElement) || typeof(T) == typeof(JsonElement?) || typeof(T) == typeof(object)) 71value = (T)(object)JsonWriterHelper.WriteString(_value.Span, static serialized => JsonElement.Parse(serialized)); 153if (typeof(T) == typeof(JsonElement) || typeof(T) == typeof(JsonElement?) || typeof(T) == typeof(object)) 155value = (T)(object)JsonElement.Parse(_value ? JsonConstants.TrueValue : JsonConstants.FalseValue); 200if (typeof(T) == typeof(JsonElement) || typeof(T) == typeof(JsonElement?) || typeof(T) == typeof(object)) 202value = (T)(object)JsonElement.Parse(_value);
System\Text\Json\Nodes\JsonValueOfT.cs (2)
18Debug.Assert(value is not JsonElement or JsonElement { ValueKind: not JsonValueKind.Null });
System\Text\Json\Serialization\Attributes\JsonExtensionDataAttribute.cs (4)
15/// and TValue must be <see cref="JsonElement"/> or <see cref="object"/>. 19/// <see cref="JsonElement"/> depending on the value of <see cref="System.Text.Json.JsonSerializerOptions.UnknownTypeHandling"/>. 21/// If a <see cref="JsonElement"/> is created, a "null" JSON value is treated as a JsonElement with <see cref="JsonElement.ValueKind"/>
System\Text\Json\Serialization\Converters\Node\JsonArrayConverter.cs (2)
40JsonElement jElement = JsonElement.ParseValue(ref reader);
System\Text\Json\Serialization\Converters\Node\JsonNodeConverter.cs (1)
79public static JsonNode? Create(JsonElement element, JsonNodeOptions? options)
System\Text\Json\Serialization\Converters\Node\JsonObjectConverter.cs (2)
78JsonElement jElement = JsonElement.ParseValue(ref reader);
System\Text\Json\Serialization\Converters\Node\JsonValueConverter.cs (2)
38JsonElement element = JsonElement.ParseValue(ref reader, options.AllowDuplicateProperties);
System\Text\Json\Serialization\Converters\Object\ObjectConverter.cs (3)
101return JsonElement.ParseValue(ref reader, options.AllowDuplicateProperties); 114JsonElement element = JsonElement.ParseValue(ref reader, options.AllowDuplicateProperties);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.cs (3)
241if (extDictionary is IDictionary<string, JsonElement> dict) 245dict[dataExtKey] = (JsonElement)propValue!; 247else if (!dict.TryAdd(dataExtKey, (JsonElement)propValue!))
System\Text\Json\Serialization\Converters\Value\JsonElementConverter.cs (4)
9internal sealed class JsonElementConverter : JsonConverter<JsonElement> 11public override JsonElement Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 13return JsonElement.ParseValue(ref reader, options.AllowDuplicateProperties); 16public override void Write(Utf8JsonWriter writer, JsonElement value, JsonSerializerOptions options)
System\Text\Json\Serialization\JsonSerializer.Read.Element.cs (15)
13/// Converts the <see cref="JsonElement"/> representing a single JSON value into a <typeparamref name="TValue"/>. 17/// <param name="element">The <see cref="JsonElement"/> to convert.</param> 28public static TValue? Deserialize<TValue>(this JsonElement element, JsonSerializerOptions? options = null) 36/// Converts the <see cref="JsonElement"/> representing a single JSON value into a <paramref name="returnType"/>. 39/// <param name="element">The <see cref="JsonElement"/> to convert.</param> 54public static object? Deserialize(this JsonElement element, Type returnType, JsonSerializerOptions? options = null) 64/// Converts the <see cref="JsonElement"/> representing a single JSON value into a <typeparamref name="TValue"/>. 68/// <param name="element">The <see cref="JsonElement"/> to convert.</param> 80public static TValue? Deserialize<TValue>(this JsonElement element, JsonTypeInfo<TValue> jsonTypeInfo) 90/// Converts the <see cref="JsonElement"/> representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo"/>. 93/// <param name="element">The <see cref="JsonElement"/> to convert.</param> 98public static object? Deserialize(this JsonElement element, JsonTypeInfo jsonTypeInfo) 108/// Converts the <see cref="JsonElement"/> representing a single JSON value into a <paramref name="returnType"/>. 111/// <param name="element">The <see cref="JsonElement"/> to convert.</param> 139public static object? Deserialize(this JsonElement element, Type returnType, JsonSerializerContext context)
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (1)
398JsonElement element,
System\Text\Json\Serialization\JsonSerializer.Read.HandlePropertyName.cs (7)
117jsonPropertyInfo.PropertyType == typeof(IReadOnlyDictionary<string, JsonElement>); 133genericArgs[1].UnderlyingSystemType == typeof(JsonElement) || 169else if (jsonPropertyInfo.PropertyType == typeof(IReadOnlyDictionary<string, JsonElement>)) 173var existing = (IReadOnlyDictionary<string, JsonElement>)extensionData; 174var newDict = new Dictionary<string, JsonElement>(); 175foreach (KeyValuePair<string, JsonElement> kvp in existing) 183extensionData = new Dictionary<string, JsonElement>();
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());
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Converters.cs (2)
123/// Returns a <see cref="JsonConverter{T}"/> instance that converts <see cref="JsonElement"/> values. 126public static JsonConverter<JsonElement> JsonElementConverter => field ??= new JsonElementConverter();
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (10)
865else if (propValue is IDictionary<string, JsonElement> dictionaryElementValue) 867JsonConverter<JsonElement> converter = GetDictionaryValueConverter<JsonElement>(); 868JsonElement value = converter.Read(ref reader, typeof(JsonElement), Options); 924JsonConverter<JsonElement> converter = (JsonConverter<JsonElement>)Options.GetConverterInternal(typeof(JsonElement)); 925if (!converter.TryRead(ref reader, typeof(JsonElement), Options, ref state, out JsonElement jsonElement, out _))
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (2)
1749typeof(IDictionary<string, JsonElement>).IsAssignableFrom(propertyType) || 1751propertyType == typeof(IReadOnlyDictionary<string, JsonElement>) ||