7 types derived from JsonNode
System.Text.Json (7)
3593 references to JsonNode
AnalyzeCiFailure (79)
AnalysisPublisher.cs (11)
92var runId = JsonNode.Parse(analysis.Evidence.Context.RunId!.Value.GetRawText())!;
124private List<PreparedCause> PrepareCauses(ValidatedAnalysis analysis, JsonNode runId, CauseHistoryStore store)
224JsonNode runId,
247JsonNode runId,
351JsonNode runId,
354var occurrence = ((JsonArray)history["occurrences"]!).First(o => ReadNormalizedNumber(Field(o, "run_id")) == ReadNormalizedNumber(runId))!;
430internal static JsonObject CreateOccurrence(ValidatedAnalysis analysis, FailureCause cause, JsonNode runId, string observedAt)
441? JsonNode.Parse(analysis.Run.PrNumbers) : JsonValue.Create(value: 0)),
596JsonNode? request,
601var response = await _github.SendJsonAsync(method, endpoint, request, expectedStatus);
tools\Aspire.TestTools\GitHubApiClient.cs (7)
91public Task<JsonNode?> GetJsonAsync(string endpoint, CancellationToken cancellationToken)
141public async Task<JsonNode?> SendJsonAsync(HttpMethod method, string endpoint, JsonNode? body, HttpStatusCode expectedStatusCode, CancellationToken cancellationToken)
157public async Task SendAsync(HttpMethod method, string endpoint, JsonNode? body, HttpStatusCode expectedStatusCode, CancellationToken cancellationToken)
263private async Task<HttpResponseMessage> OpenAsync(HttpMethod method, Uri uri, Uri original, JsonNode? body, HttpStatusCode expectedStatus, bool allowExternalRedirect, CancellationToken cancellationToken)
452private static async Task<(JsonNode? Node, long Bytes)> ReadJsonAsync(HttpResponseMessage response, long maximumBytes, HttpMethod method, Uri original, CancellationToken cancellationToken)
463return (JsonNode.Parse(output.GetBuffer().AsSpan(start: 0, (int)output.Length)), output.Length);
AnalyzeCiFailure.TestHost (4)
AnalyzeCiFailure.Tests (432)
AnalyzeCiFailureCollectionTests.cs (60)
24var evidence = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "evidence.json")))!;
25var job = Assert.Single(evidence["jobs"]!.AsArray(), job => job!["id"]!.GetValue<string>() == "77")!;
43var evidence = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "evidence.json")))!;
59Assert.Equal("The hosted runner lost communication with the server.", JsonNode.Parse(json)!["jobs"]![0]!["runner_failure"]!.GetValue<string>());
77var outcome = JsonNode.Parse(await File.ReadAllTextAsync(
114var summary = JsonNode.Parse(await File.ReadAllTextAsync(
182var evidence = JsonNode.Parse(await File.ReadAllTextAsync(
207var summary = JsonNode.Parse(await File.ReadAllTextAsync(
359var job = Assert.Single(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "diagnostics/failed-jobs.json")))!.AsArray())!;
369Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
370var state = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!;
374var annotations = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "diagnostics/annotations-77.json")))!.AsArray();
397Assert.False(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
406var jobs = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "diagnostics/failed-jobs.json")))!.AsArray();
409Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
420var job = Assert.Single(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "diagnostics/failed-jobs.json")))!.AsArray())!;
423Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
424Assert.Equal("not-applicable", JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!["state"]!.GetValue<string>());
425Assert.Empty(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!["failures"]!.AsArray());
436var job = Assert.Single(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "diagnostics/failed-jobs.json")))!.AsArray())!;
439Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
440Assert.Equal("not-applicable", JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!["state"]!.GetValue<string>());
441Assert.Empty(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!["failures"]!.AsArray());
452var bundle = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!;
454var failure = Assert.Single(failures);
462var jobs = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "diagnostics/failed-jobs.json")))!.AsArray();
469Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
486Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "collection-outcome.json")))!["has_work"]!.GetValue<bool>());
510var state = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!;
526var state = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!["test_evidence"]!;
573var bundle = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "evidence.json")))!;
579var history = bundle["main_context"]!["candidate_history"]!;
614var bundle = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "evidence.json")))!;
631var index = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "history/cause-index.json")))!.AsArray();
682var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "jobs.json")))!;
702var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "jobs.json")))!;
703var job = pages[0]!["jobs"]![0]!;
734foreach (var step in job["steps"]!.AsArray())
744var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "jobs.json")))!.AsArray();
745foreach (var page in pages)
839var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "jobs.json")))!;
847var duplicate = pages[0]!["jobs"]![0]!.DeepClone();
AnalyzeCiFailureMigrationTests.cs (21)
112var index = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root, "history/cause-index.json")))!.AsArray();
113var entry = Assert.Single(index, entry => entry!["file"]!.GetValue<string>() == "history/causes/" + name)!;
129var regeneratedIndex = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root, "history/cause-index.json")))!.AsArray();
249Assert.Equal(1000, JsonNode.Parse(annotation)![0]!["message"]!.GetValue<string>().Length);
329["number"] = JsonNode.Parse(id),
339var history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
354["number"] = JsonNode.Parse(id),
427var before = JsonNode.Parse(durable.Output)!;
440var stored = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
442Assert.True(JsonNode.DeepEquals(before["occurrences"], stored["occurrences"]));
443var occurrence = Assert.Single(stored["occurrences"]!.AsArray())!;
451var summary = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "runs", "123.json")))!;
572var stored = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(memory, "causes", "transferred-timeout.json")))!;
573var test = Assert.Single(stored["occurrences"]![0]!["tests"]!.AsArray())!;
685var outcome = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root, "collection-outcome.json")))!;
AnalyzeCiFailurePreparationTests.cs (54)
28var artifacts = JsonNode.Parse(await File.ReadAllTextAsync(paths.SelectedTestArtifacts))!;
48? JsonNode.Parse(await File.ReadAllTextAsync(paths.PriorCauseIndex))![0]!["read_error"]!.GetValue<string>()
88var document = JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(evidence))!;
89var failure = document["test_evidence"]!["failures"]![0]!;
112var selected = JsonNode.Parse(await File.ReadAllTextAsync(paths.SelectedTestArtifacts))!.AsArray();
164Assert.Equal("unavailable", JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(paths.RootDirectory, "test-evidence.json")))!["state"]!.GetValue<string>());
177var document = JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(evidence))!;
180document["jobs"] = JsonNode.Parse(json);
184document["test_evidence"]!["failures"]![0]!["sources"] = JsonNode.Parse(json);
208var index = JsonNode.Parse(await File.ReadAllTextAsync(paths.PriorCauseIndex))!.AsArray();
209var entry = Assert.Single(index)!;
233new AnalyzeCiFailure.WorkflowArtifact(JsonNode.Parse(artifact.Id!.Value.GetRawText()), artifact.Name, SizeInBytes: null, Expired: false, CreatedAt: null),
336var index = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "history/cause-index.json")))!.AsArray();
338foreach (var item in index)
342var original = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, item["file"]!.GetValue<string>())))!;
367var entry = Assert.Single(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "history/cause-index.json")))!.AsArray())!;
414var index = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "history/cause-index.json")))!.AsArray();
417var late = Assert.Single(index, cause => cause!["id"]!.GetValue<string>() == "z-late")!;
421var keyless = Assert.Single(index, cause => cause!["id"]!.GetValue<string>() == "z-keyless")!;
464var failures = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "test-failures.json")))!;
508Assert.Equal("unavailable", JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(data, "test-evidence.json")))!["state"]!.GetValue<string>());
529var failures = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "test-failures.json")))!.AsArray();
555var history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
558var summary = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "runs", "123.json")))!;
607var document = JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!;
609var cause = document["causes"]![0]!;
688var jobs = JsonNode.Parse(await File.ReadAllTextAsync(jobsPath))!.AsArray();
693var collected = JsonNode.Parse(await File.ReadAllTextAsync(trustedPath))!.AsArray();
698var analysis = JsonNode.Parse(await File.ReadAllTextAsync(analysisPath))!;
748var failures = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "test-failures.json")))!.AsArray();
775Assert.Equal("unavailable", JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "test-evidence.json")))!["state"]!.GetValue<string>());
799var failures = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(EvidenceDirectory, "test-failures.json")))!.AsArray();
802var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
803summary["failed_tests"] = new JsonArray(failures.Select(test => (JsonNode)new JsonObject
815var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
816cause["tests"] = new JsonArray(failures.Select(test => (JsonNode)new JsonObject
841var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
852var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
867var history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
AnalyzeCiFailurePublicationTests.cs (120)
28var upsert = Assert.Single(
120var analysis = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
142var other = JsonNode.Parse(CreateCause("other-failure", "flaky-test", jobId: 456))!;
146var collected = new JsonArray(tests.Select(test => (JsonNode)new JsonObject
156foreach (var test in tests)
224? JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "ci-analysis-output", "causes", "debugger-timeout.json")))!.AsObject()
278var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
282foreach (var test in summary["failed_tests"]!.AsArray())
307var request = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "published-comment-request.json")))!;
327var posted = Assert.Single(
366Assert.Equal("https://github.com/microsoft/aspire/issues/77", JsonNode.Parse(remote.Output)!["issue_url"]!.GetValue<string>());
391var history = storedLink ? JsonNode.Parse("""
421var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
429var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
462var edit = Assert.Single(
469var addedLabels = Assert.Single(
506var collected = JsonNode.Parse(await File.ReadAllTextAsync(trustedPath))!;
512var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
518var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
536var collected = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
541var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
545var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
565var collected = JsonNode.Parse(await File.ReadAllTextAsync(dataPath))!;
569var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
573var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
581var history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
598var observations = new JsonArray(Enumerable.Range(start: 1, count).Select(index => (JsonNode)new JsonObject
640history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!.AsObject();
673Assert.Equal("https://github.com/microsoft/aspire/issues/77", JsonNode.Parse(remote.Output)!["issue_url"]!.GetValue<string>());
674var original = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "issue.json")))!;
688var collected = JsonNode.Parse(await File.ReadAllTextAsync(data))!;
696var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
703var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
738var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
739var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
740var collected = JsonNode.Parse(await File.ReadAllTextAsync(trustedPath))!;
746foreach (var test in summary["failed_tests"]!.AsArray())
750foreach (var test in collected.AsArray())
784var run = JsonNode.Parse(await File.ReadAllTextAsync(file))!;
827var original = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "issue.json")))!;
874var history = JsonNode.Parse(remote.Output)!;
1095var cause = JsonNode.Parse(await File.ReadAllTextAsync(
1101var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
1120var local = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
1129var stored = JsonNode.Parse(durable.Output)!;
1131var occurrence = Assert.Single(stored["occurrences"]!.AsArray())!;
1175var document = JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!;
1208var cause = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
1209var other = cause.DeepClone();
1218var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
1225var evidence = JsonNode.Parse(await File.ReadAllTextAsync(evidencePath))!;
1241var other = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(directory, "causes", "debugger-timeout.json")))!;
1245var summary = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
1260var summary = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
1263var deterministic = summary["failed_tests"]![0]!.DeepClone();
1269var evidence = JsonNode.Parse(await File.ReadAllTextAsync(evidencePath))!;
1270var failure = evidence[0]!.DeepClone();
1280var history = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "causes", "debugger-timeout.json")))!;
1282var run = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo", "runs", "123.json")))!;
1294var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
1300var cause = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
1308var evidence = JsonNode.Parse(await File.ReadAllTextAsync(evidencePath))!;
1336var definition = JsonNode.Parse("""{"id":"timeout","type":"flaky-test","title":"New title"}""")!.AsObject();
1337var existing = JsonNode.Parse(
1339var occurrence = JsonNode.Parse(
1355var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!;
1359var cause = JsonNode.Parse(await File.ReadAllTextAsync(causePath))!;
1363var evidence = JsonNode.Parse(await File.ReadAllTextAsync(evidencePath))!;
1450var stored = JsonNode.Parse(await File.ReadAllTextAsync(storedPath))!;
1455Assert.True(JsonNode.DeepEquals(stored, JsonNode.Parse(durable.Output)));
1478stored = JsonNode.Parse(await File.ReadAllTextAsync(storedPath))!;
1485Assert.Equal("https://github.com/microsoft/aspire/issues/77", JsonNode.Parse(durable.Output)!["issue_url"]!.GetValue<string>());
aspire (141)
Configuration\ConfigurationService.cs (14)
47: JsonNode.Parse(existingContent, nodeOptions: null, ConfigurationHelper.ParseOptions)?.AsObject() ?? new JsonObject();
92var settings = JsonNode.Parse(existingContent, nodeOptions: null, ConfigurationHelper.ParseOptions)?.AsObject();
215var settings = JsonNode.Parse(content, nodeOptions: null, ConfigurationHelper.ParseOptions)?.AsObject();
239JsonNode current = settings;
244var child = GetChildValue(current, part, key, allowAppend: true);
300private static bool DeleteNestedValue(JsonNode current, KeyPart[] keyParts, string key, int depth)
308var child = GetChildValue(current, part, key, allowAppend: false);
355private static void FlattenJsonValue(JsonNode? value, Dictionary<string, string> result, string key)
497JsonNode? node;
500node = JsonNode.Parse(content, documentOptions: ConfigurationHelper.ParseOptions);
579private static JsonNode? GetChildValue(JsonNode current, KeyPart part, string key, bool allowAppend)
603private static void SetChildValue(JsonNode current, KeyPart part, string key, JsonNode value)
Aspire.Cli.EndToEnd.Tests (67)
Aspire.Cli.Tests (333)
Configuration\ConfigSourceServiceTests.cs (28)
55return Task.FromResult(("version-1", JsonNode.Parse("""
129ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
179ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse(json)!.AsObject()))
344var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
678var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path), documentOptions: ConfigurationHelper.ParseOptions)!;
1297ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
1321ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
1342ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
1364ReadConfiguration = (_, _) => Task.FromResult(("version-2", JsonNode.Parse("""
1376var settings = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject();
1392ReadConfiguration = (_, _) => Task.FromResult(("version-2", JsonNode.Parse("""
1411var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject();
1412configuration["skillSources"] = JsonNode.Parse("""
1415configuration["profiles"] = JsonNode.Parse("""
1422ReadConfiguration = (_, _) => Task.FromResult(("version-2", JsonNode.Parse(flattenedSource
1448var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject();
1449configuration["skillSources"] = JsonNode.Parse("""{"team":{"repository":"example/local","custom:setting":"local"}}""");
1453ReadConfiguration = (_, _) => Task.FromResult(("version-2", JsonNode.Parse("""
1470var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject();
1471configuration["SKILLSOURCES"] = JsonNode.Parse("""
1474configuration["skillSources"] = JsonNode.Parse("""
1480ReadConfiguration = (_, _) => Task.FromResult(("version-2", JsonNode.Parse("""
1581var tracking = JsonNode.Parse(await File.ReadAllTextAsync(checkPath))!.AsObject();
1888var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
2073ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
Mcp\ListResourcesToolTests.cs (13)
399Properties = new Dictionary<string, JsonNode?>
731Properties = new Dictionary<string, JsonNode?>
741Properties = new Dictionary<string, JsonNode?>
769Properties = new Dictionary<string, JsonNode?>
780Properties = new Dictionary<string, JsonNode?>
791Properties = new Dictionary<string, JsonNode?>
820Properties = new Dictionary<string, JsonNode?>
893Properties = new Dictionary<string, JsonNode?>
971Properties = new Dictionary<string, JsonNode?>
982Properties = new Dictionary<string, JsonNode?>
992Properties = new Dictionary<string, JsonNode?>
1002Properties = new Dictionary<string, JsonNode?>
1060Properties = new Dictionary<string, JsonNode?>
Aspire.Dashboard (34)
Aspire.Dashboard.Components.Tests (2)
Aspire.Dashboard.Tests (21)
Aspire.Hosting (103)
Dcp\JsonPatch.cs (22)
17internal static JsonArray Create(JsonNode? current, JsonNode? changed)
25internal static JsonNode? Apply(JsonNode? current, JsonArray patch)
27var result = current?.DeepClone();
29foreach (var operationNode in patch)
41var hasValue = operation.TryGetPropertyValue("value", out var value);
48private static void AddOperations(JsonNode? current, JsonNode? changed, string path, JsonArray operations)
50if (JsonNode.DeepEquals(current, changed))
68if (currentObject.TryGetPropertyValue(property.Key, out var currentValue))
105private static JsonObject CreateOperation(string operation, string path, JsonNode? value = null)
179private static JsonNode? ApplyOperation(JsonNode? current, string operation, string[] segments, bool hasValue, JsonNode? value)
200var parent = GetParent(current, segments);
218private static JsonNode GetParent(JsonNode? current, string[] segments)
220var parent = current ?? throw new JsonException("A JSON Patch path cannot traverse a null value.");
227JsonObject jsonObject when jsonObject.TryGetPropertyValue(segment, out var child) && child is not null => child,
237private static void ApplyToObject(JsonObject target, string operation, string propertyName, JsonNode? value)
260private static void ApplyToArray(JsonArray target, string operation, string indexText, JsonNode? value)
Pipelines\Internal\FileDeploymentStateManager.cs (28)
268protected override JsonNode? GetSectionState(JsonObject? state, string sectionName, bool includeLegacyState)
283var mergedSection = base.GetSectionState(state, sectionName, includeLegacyState)?.DeepClone();
347var legacySectionData = TryGetNestedPropertyValue(GetLegacyFallbackState(), sectionName);
378private static JsonObject? NormalizeSectionData(JsonNode? sectionData) =>
499JsonNode? legacyValue,
500JsonNode? savedValue,
512JsonNode? baseline,
514JsonNode? value,
522var baselinePropertyExists = baselineObject.TryGetPropertyValue(propertyName, out var baselineProperty);
523var savedPropertyExists = valueObject.TryGetPropertyValue(propertyName, out var valueProperty);
535if (baselineExists == savedExists && JsonNode.DeepEquals(baseline, value))
545private static JsonNode? ApplyChanges(JsonNode? latestValue, JsonNode? originalValue, JsonNode? savedValue)
557var originalPropertyExists = originalObject.TryGetPropertyValue(propertyName, out var originalProperty);
558var savedPropertyExists = savedObject.TryGetPropertyValue(propertyName, out var savedProperty);
559var latestPropertyExists = result.TryGetPropertyValue(propertyName, out var latestProperty);
580return JsonNode.DeepEquals(originalValue, savedValue)
584static (bool Exists, JsonNode? Value) ApplyPropertyChanges(
585JsonNode? latestValue,
587JsonNode? originalValue,
589JsonNode? savedValue,
592if (originalExists == savedExists && JsonNode.DeepEquals(originalValue, savedValue))
645if (!current.TryGetPropertyValue(segments[i], out var nextNode) ||
657private static void SetNestedNodeValue(JsonObject root, string path, JsonNode? value, bool valueExists)
664if (!current.TryGetPropertyValue(segment, out var nextNode) || nextNode is not JsonObject nextObject)
761JsonValue stateValue => JsonNode.Parse(stateValue.GetValue<string>())?.AsObject()
Aspire.Hosting.Azure (24)
AzureProvisioningController.cs (8)
1929var outputs = ParseDeploymentStateJson(resource.Name, "Outputs", section.Data["Outputs"]?.GetValue<string>());
2552json["remainingResources"] = new JsonArray([.. result.RemainingResources.Select(resource => (JsonNode)new JsonObject
2617deployment.TryGetPropertyValue("resourceId", out var resourceIdNode) ? resourceIdNode?.GetValue<string>() : null,
2632var outputs = ParseDeploymentStateJson(resource.Name, "Outputs", section.Data["Outputs"]?.GetValue<string>());
2747private JsonNode? ParseDeploymentStateJson(string resourceName, string propertyName, string? json)
2771private static string? TryGetOutputValue(JsonNode? outputs, string outputName)
2777!outputsObject.TryGetPropertyValue(outputName, out var outputNode) ||
2779!outputObject.TryGetPropertyValue("value", out var valueNode))
Aspire.Hosting.Azure.EntraId.Tests (1)
Aspire.Hosting.Azure.EventHubs (5)
Aspire.Hosting.Azure.Kubernetes (1)
Aspire.Hosting.Azure.Sandboxes (3)
Aspire.Hosting.Azure.ServiceBus (5)
Aspire.Hosting.Azure.Tests (54)
Aspire.Hosting.Azure.WebPubSub (1)
Aspire.Hosting.CodeGeneration.Go (10)
Aspire.Hosting.CodeGeneration.Go.Tests (16)
Aspire.Hosting.CodeGeneration.Java (3)
Aspire.Hosting.CodeGeneration.Java.Tests (8)
Aspire.Hosting.CodeGeneration.Python (4)
Aspire.Hosting.CodeGeneration.Rust (1)
Aspire.Hosting.CodeGeneration.Rust.Tests (1)
Aspire.Hosting.CodeGeneration.TypeScript (10)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (2)
Aspire.Hosting.Containers.Tests (10)
Aspire.Hosting.Dotnet.Tests (4)
Aspire.Hosting.DotnetTool.Tests (2)
Aspire.Hosting.Foundry.Tests (5)
Aspire.Hosting.Garnet.Tests (3)
Aspire.Hosting.Go.Tests (25)
Aspire.Hosting.Java.Tests (4)
Aspire.Hosting.JavaScript.Tests (17)
Aspire.Hosting.Kafka.Tests (1)
Aspire.Hosting.Keycloak.Tests (1)
Aspire.Hosting.Kubernetes (5)
Aspire.Hosting.Milvus.Tests (2)
Aspire.Hosting.MongoDB.Tests (3)
Aspire.Hosting.MySql.Tests (4)
Aspire.Hosting.Native.Client (4)
Aspire.Hosting.Native.CodeGeneration (2)
Aspire.Hosting.Native.Core.Tests (238)
ApplicationRevisionTests.cs (51)
26var original = context.Read();
27var revision = context.BeginRevision();
28var resource = context.Author.AddResource(revision, "cache");
30var current = context.Read();
37var resourceId = current["resources"]![0]!["resourceId"];
38var logs = Result(context.Observer.Invoke("readResourceLogs",
41var execution = Result(context.Author.Invoke("getApplicationExecution", Arguments(("context", context.Workspace))));
42var invitation = Result(context.Author.Invoke("inviteResourceExecution",
57var command = Result(context.Observer.Invoke("invokeResourceCommand", Arguments(
59var confirmation = Result(context.Integration.Invoke("requestConfirmation", Arguments(
63var commands = Result(context.Integration.Invoke("readResourceCommands", Arguments(("context", context.Writer))));
64var confirmations = Result(context.Observer.Invoke("readConfirmations", Arguments(("context", context.Reader))));
66var revision = context.BeginRevision();
92var original = context.Read();
93var abandoned = context.BeginRevision();
97var revision = context.BeginRevision();
110var original = context.Read();
111var revision = context.BeginRevision();
112var a = context.Author.AddResource(revision, "a");
113var b = context.Author.AddResource(revision, "b");
129var revision = context.BeginRevision();
156var revision = context.BeginRevision();
157var replacement = Result(context.Author.Invoke("addResource",
163var execution = Result(context.Author.Invoke("getApplicationExecution", Arguments(("context", context.Workspace))));
175var revision = context.BeginRevision();
176var resource = context.Author.AddResource(revision, "cache");
179var change = Result(await waiting);
188var next = context.BeginRevision();
189var nextResource = context.Author.AddResource(next, "cache");
202var revision = context.BeginRevision();
203var cache = context.Author.AddResource(revision, "cache");
204var dependency = context.Author.AddResource(revision, "database");
207var configuration = Result(context.Integration.Invoke("readResourceConfiguration", Arguments(("context", context.Writer))));
208var database = context.Read()["resources"]![1]!;
219var revision = foreign.BeginRevision();
222var invitation = Result(context.Author.Invoke("inviteApplicationWorkspace", Arguments(("context", context.Workspace))));
223var root = Result(context.Integration.Call("getApplicationServer", null));
237var revision = context.BeginRevision();
238var cache = context.Author.AddResource(revision, "cache");
239var dependent = context.Author.AddResource(revision, "tunnel");
242var execution = Result(context.Author.Invoke("getApplicationExecution", Arguments(("context", context.Workspace))));
243var writer = Result(context.Integration.Invoke("joinResourceExecution", Arguments(
262var configuration = Result(context.Integration.Invoke("readResourceConfiguration", Arguments(("context", writer))));
265var dependencies = Result(context.Integration.Invoke("readResourceDependencies", Arguments(("context", writer))));
278var revision = context.BeginRevision();
279var cache = context.Author.AddResource(revision, "cache");
342var revision = context.BeginRevision();
359var revision = context.BeginRevision();
366private static JsonObject RestartArguments(JsonNode writer, long revision) =>
381private static Task<JsonObject> Commit(WorkspaceRpcTestContext context, JsonNode revision) =>
384private static void SetConfiguration(RpcTestClient author, JsonNode resource, string value) =>
NativeComposeCSharpTests.cs (26)
27Assert.True(JsonNode.DeepEquals(first.Compose, second.Compose));
28Assert.True(JsonNode.DeepEquals(first.Inputs, second.Inputs));
31var build = first.Compose["services"]!["web"]!["build"]!;
70var cache = context.Model["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "cache")!;
71var web = context.Model["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "web")!;
72var target = context.Model["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "compose")!;
91var options = JsonNode.Parse(web["configuration"]!["publish.dockerCompose"]!.GetValue<string>())!;
103var other = target.DeepClone();
106var isolated = cache.DeepClone();
135["environment"] = new JsonObject(environment.Select(pair => KeyValuePair.Create(pair.Key, (JsonNode?)JsonValue.Create(pair.Value))))
150var typescript = JsonNode.Parse(await stdout)!.AsObject();
151Assert.True(JsonNode.DeepEquals(plan.Compose, typescript["compose"]), "C# and TypeScript Compose documents differ.");
152Assert.True(JsonNode.DeepEquals(plan.Inputs, typescript["inputs"]), "C# and TypeScript input contracts differ.");
153Assert.True(JsonNode.DeepEquals(JsonSerializer.SerializeToNode(plan.Services, new JsonSerializerOptions(JsonSerializerDefaults.Web)
206var document = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(context.OutputPath, "compose.yaml")))!;
248var state = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(context.OutputPath, "deployment-state.json")))!;
374var model = JsonNode.Parse(await composition.ExportPublishModelAsync())!;
417var resource = context.Model["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "web")!;
438var environment = resources.Single(resource => resource!["name"]!.GetValue<string>() == "compose")!.DeepClone();
441var cache = resources.Single(resource => resource!["name"]!.GetValue<string>() == "cache")!;
465var environment = context.Model["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "compose")!;
531var model = JsonNode.Parse(await composition.ExportPublishModelAsync())!.AsObject();
NativeRpcTests.cs (33)
19var contract = Result(client.Call("getCapabilities", null));
39var session = client.CreateSession();
40var composition = client.StartGeneration(session);
41var web = client.AddResource(composition, "web");
42var cache = client.AddResource(composition, "cache");
46var snapshot = Result(client.Invoke("seal", Arguments(("context", composition))));
68var session = client.CreateSession();
71var composition = client.StartGeneration(session);
72var resource = client.AddResource(composition, "cache");
78var replacement = client.StartGeneration(session);
86var retiredSession = client.CreateSession();
87var liveSession = client.CreateSession();
88var retired = client.StartGeneration(retiredSession);
89var live = client.StartGeneration(liveSession);
90var liveResources = new JsonNode[128];
104var replacement = client.StartGeneration(retiredSession);
105var added = client.AddResource(replacement, "replacement");
115var composition = first.StartGeneration(first.CreateSession());
116var resource = first.AddResource(composition, "cache");
118var forged = resource.DeepClone();
121var retagged = resource.DeepClone();
132var session = first.CreateSession();
133var composition = first.StartGeneration(session);
134var value = Result(first.Invoke("addSecretParameter", Arguments(("context", composition),
136var resource = second.AddResource(second.StartGeneration(second.CreateSession()), "consumer");
149var first = client.CreateSession();
150var second = client.CreateSession();
151var composition = client.StartGeneration(first);
160var composition = client.StartGeneration(client.CreateSession());
181Assert.Equal(classification, Error(JsonNode.Parse(response!)!.AsObject()));
201Assert.Equal("REQUEST_TOO_LARGE", Error(JsonNode.Parse(connection.Process(new byte[Aspire.Hosting.Native.Server.NativeServerOptions.DefaultMaximumRequestBytes + 1])!)!.AsObject()));
203var composition = client.StartGeneration(client.CreateSession());
218var composition = client.StartGeneration(client.CreateSession());
NativeSocketIsolationTests.cs (9)
34var error = (await unauthenticated.CallAsync("getApplicationServer", null, timeout.Token))["error"]!;
136var server = Result(await failing.CallAsync("getApplicationServer", null, timeout.Token));
137var authorServer = Result(context.Author.Call("getApplicationServer", null));
138var session = Result(context.Author.Invoke("openApplication", Arguments(("context", authorServer))));
139var composition = context.Author.StartGeneration(session);
140var resource = context.Author.AddResource(composition, "failure");
141var execution = Result(context.Author.Invoke("createExecution", Arguments(("context", composition))));
142var invitation = Result(context.Author.Invoke("inviteResourceExecution",
144var writer = Result(await failing.CallAsync("invokeCapability", new JsonArray("Aspire.Hosting.Native.Api/joinResourceExecution",
RuntimeRpcTests.cs (20)
23var id = context.Read()["resources"]![0]!["resourceId"];
24var logs = Result(context.Observer.Invoke("readResourceLogs", Arguments(("context", context.Reader),
37var initial = context.Read();
43var updated = Result(await wait.WaitAsync(TimeSpan.FromSeconds(10)));
45var resource = Assert.Single(updated["resources"]!.AsArray())!;
58var root = Result(context.Observer.Call("getApplicationServer", null));
59var invite = Result(context.Author.Invoke("inviteApplicationObserver", Arguments(("context", context.Execution))));
66var stale = Result(context.Author.Invoke("inviteApplicationObserver", Arguments(("context", context.Execution))));
83var id = context.Read()["resources"]![0]!["resourceId"];
84var logs = Result(context.Observer.Invoke("readResourceLogs", Arguments(("context", context.Reader),
90var suffix = Result(context.Observer.Invoke("readResourceLogs", Arguments(("context", context.Reader),
104var command = Result(context.Observer.Invoke("invokeResourceCommand", Arguments(("context", context.Reader),
108var pending = Result(context.Integration.Invoke("readResourceCommands", Arguments(("context", context.Writer))))["commands"]![0]!;
112var result = Result(await completion.WaitAsync(TimeSpan.FromSeconds(10)));
115var confirmation = Result(context.Integration.Invoke("requestConfirmation", Arguments(("context", context.Writer),
118var prompt = Assert.Single(Result(context.Observer.Invoke("readConfirmations", Arguments(("context", context.Reader))))["requests"]!.AsArray())!;
135var command = Result(context.Observer.Invoke("invokeResourceCommand", Arguments(("context", context.Reader),
140var resource = context.Read()["resources"]![0]!;
151var prompt = Result(context.Integration.Invoke("requestConfirmation", Arguments(("context", context.Writer),
170("context", context.Writer), ("observation", JsonNode.Parse(observation))))));
Aspire.Hosting.Native.Server (87)
Rpc\NativeProviderRegistry.cs (19)
22Task<JsonNode?> InvokeAsync(NativeRpcConnection caller, string capability, JsonObject arguments);
23Task<JsonNode?> InvokeCoreAsync(NativeRpcConnection provider, string capability, JsonObject arguments);
24Task<JsonNode?> InvokeCallbackAsync(NativeRpcConnection provider, string callback, JsonObject arguments);
186.Select(pair => (JsonNode?)pair.Value.Capabilities[pair.Key].Metadata.DeepClone()).ToArray())
191public async Task<JsonNode?> InvokeAsync(NativeRpcConnection caller, string capability, JsonObject arguments)
236var result = await registration.Peer.RequestAsync("handleExternalCapability",
240var translated = ToCaller(registration, caller, result, metadata.ReturnType, out var callbackOwner);
281public async Task<JsonNode?> InvokeCoreAsync(NativeRpcConnection provider, string capability, JsonObject arguments)
294JsonNode? Translate(JsonNode? value)
334var result = await origin.InvokeCoreAsync(capability, translated, provider).ConfigureAwait(false);
337JsonNode? DelegateResult(JsonNode? value)
355public async Task<JsonNode?> InvokeCallbackAsync(NativeRpcConnection provider, string callbackId, JsonObject arguments)
376var result = await callback.Owner.RequestAsync("invokeCallback",
381private JsonNode? ToProvider(Registration registration, NativeRpcConnection caller, JsonNode? value, NativeProviderType type,
409private JsonNode? ToCaller(Registration registration, NativeRpcConnection caller, JsonNode? value, NativeProviderType type,
Rpc\NativeRpcConnection.cs (14)
90!JsonNode.DeepEquals(next.Lifetime, previous.Lifetime))
163internal Task<JsonNode?> RequestAsync(string method, JsonArray arguments) =>
199var response = await (callbackConnection._peer ?? throw RpcFault.NotSupported("Bidirectional RPC is not configured."))
205if (response is not null && !JsonNode.DeepEquals(arguments, response))
211internal async Task<JsonNode?> InvokeCoreAsync(string capability, JsonObject arguments, NativeRpcConnection callbackConnection)
213Task<JsonNode?> invocation;
323JsonNode? id;
326Task<JsonNode?> invocation;
363var result = await invocation.WaitAsync(lifetime).ConfigureAwait(false);
435private async Task<JsonNode?> InvokeAsync(string method, JsonNode? parameters)
511private static byte[] EncodeError(JsonNode? id, int code, string classification, string message) => Encode(new NativeRpcResponse
517private static byte[] EncodeFailure(JsonNode? id, string method, int code, string classification, string message)
544return JsonNode.Parse(stream) as JsonObject
Aspire.Hosting.Nats.Tests (3)
Aspire.Hosting.Oracle.Tests (4)
Aspire.Hosting.PostgreSQL.Tests (3)
Aspire.Hosting.Python.Tests (7)
Aspire.Hosting.Qdrant.Tests (2)
Aspire.Hosting.RabbitMQ.Tests (3)
Aspire.Hosting.Radius (1)
Aspire.Hosting.Redis.Tests (17)
Aspire.Hosting.RemoteHost (83)
Ats\AtsCallbackProxyFactory.cs (10)
141var addMethod = jsonObjectType.GetMethod("Add", [typeof(string), typeof(JsonNode)]);
180private JsonNode? MarshalArg(object? value, Type declaredType)
245private Task<JsonNode?> InvokeCallbackAsync(string callbackId, JsonObject? args, CancellationToken cancellationToken)
249return _invoker.InvokeAsync<JsonNode?>(callbackId, args, cancellationToken);
261var result = InvokeCallbackAsync(callbackId, args, cancellationToken).GetAwaiter().GetResult();
268var result = InvokeCallbackAsync(callbackId, args, cancellationToken).GetAwaiter().GetResult();
281var result = await InvokeCallbackAsync(callbackId, args, cancellationToken).ConfigureAwait(false);
288var result = await InvokeCallbackAsync(callbackId, args, cancellationToken).ConfigureAwait(false);
292private T? UnmarshalResult<T>(JsonNode? result, string callbackId)
387private void ApplyDtoWriteback(JsonNode? result, object?[] originalArgs, Type[] argTypes)
Ats\CapabilityDispatcher.cs (19)
21internal delegate Task<JsonNode?> CapabilityHandler(
188if (args == null || !args.TryGetPropertyValue("context", out var contextNode))
235if (args == null || !args.TryGetPropertyValue("context", out var contextNode))
251if (!args.TryGetPropertyValue("value", out var valueNode))
282return Task.FromResult<JsonNode?>(new JsonObject
313if (args == null || !args.TryGetPropertyValue("context", out var contextNode))
336if (args.TryGetPropertyValue(paramName, out var argNode))
433if (args != null && args.TryGetPropertyValue(paramName, out var argNode))
546public async Task<JsonNode?> InvokeAsync(
651public JsonNode? Invoke(string capabilityId, JsonObject? args)
781JsonNode? argNode,
824JsonNode? argNode,
966private static bool IsRejectedEnumString(JsonNode? node, Type unionMemberType)
974private static string DescribeJsonNode(JsonNode? node)
1058if (!args.TryGetPropertyValue(name, out var node) || node is not JsonValue value)
1072if (args.TryGetPropertyValue(name, out var node) && node is JsonValue value)
1084if (args.TryGetPropertyValue(name, out var node) && node is JsonValue value)
1100if (!args.TryGetPropertyValue(name, out var node))
1127if (args.TryGetPropertyValue(name, out var node) && node is JsonObject obj)
Aspire.Hosting.RemoteHost.Tests (180)
CapabilityDispatcherTests.cs (93)
39var result = await dispatcher.InvokeAsync("Aspire.Hosting.Radius/withContainerImage", new JsonObject
129var results = JsonNode.Parse(await output)!.AsArray();
185ResultToReturn = optionsJson is null ? null : new JsonObject { ["p0"] = JsonNode.Parse(optionsJson) }
197var result = dispatcher.Invoke("Aspire.Hosting/withTerminal", args);
237ResultToReturn = new JsonObject { ["p0"] = JsonNode.Parse(optionsJson) }
259CapabilityHandler handler = (args, handles) => Task.FromResult<JsonNode?>(JsonValue.Create("result"));
278dispatcher.Register("test/cap1@1", (_, _) => Task.FromResult<JsonNode?>(null));
279dispatcher.Register("test/cap2@1", (_, _) => Task.FromResult<JsonNode?>(null));
295return Task.FromResult<JsonNode?>(JsonValue.Create("success"));
311return Task.FromResult<JsonNode?>(null);
323dispatcher.Register("test/capability@1", (_, _) => Task.FromResult<JsonNode?>(JsonValue.Create(42)));
325var result = dispatcher.Invoke("test/capability@1", null);
350return Task.FromResult<JsonNode?>(null);
369return Task.FromResult<JsonNode?>(null);
387return Task.FromResult<JsonNode?>(null);
402Task.FromException<JsonNode?>(
427var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/testMethod", args);
439var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/withOptional", args);
451var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/withOptional", args);
506var nameResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestContextType.name", args);
507var countResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestContextType.count", args);
562var tokenResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestCancellationTokenContext.cancellationToken", getArgs);
568var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/canObserveCancellation", invokeArgs);
623var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestParentContextType.nestedContext", args);
640var operationResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestNestedContextType.operation", nestedArgs);
814var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestTypeWithMethods.calculateSum", args);
834var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestTypeWithMethods.processAsync", args);
854var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestTypeWithMethods.processValueTaskAsync", args);
866var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/asyncValueTaskWithResult", args);
911var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/withCallback", args);
977var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/withAsyncCallback", args);
989var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/syncInlineThreadProbe", null);
1001var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/syncBackgroundThreadProbe", null);
1013var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/taskBackgroundThreadProbe", null);
1038var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/valueTaskBackgroundThreadProbe", null);
1203var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/asyncWithResult", args);
1232var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/sumArray", args);
1244var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnArray", args);
1264var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptReadOnlyList", args);
1277var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptUnion", args);
1289var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptUnion", args);
1307var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptDtoUnion", args);
1319var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptEnumStringUnion", args);
1331var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptEnumStringUnion", args);
1372var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptHandleUnion", args);
1424var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableList", null);
1440var listResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableList", null);
1451var result = dispatcher.Invoke("Aspire.Hosting/List.get", args);
1463var listResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnTypedMutableList", null);
1473var result = dispatcher.Invoke("Aspire.Hosting/List.get", args);
1486var listResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableList", null);
1496var removeResult = dispatcher.Invoke("Aspire.Hosting/List.removeAt", removeArgs);
1506var lengthResult = dispatcher.Invoke("Aspire.Hosting/List.length", lengthArgs);
1519var listResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableList", null);
1528var result = dispatcher.Invoke("Aspire.Hosting/List.length", args);
1541var listResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableList", null);
1557var lengthResult = dispatcher.Invoke("Aspire.Hosting/List.length", lengthArgs);
1570var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1586var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1597var result = dispatcher.Invoke("Aspire.Hosting/Dict.get", args);
1609var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnTypedMutableDict", null);
1619var result = dispatcher.Invoke("Aspire.Hosting/Dict.get", args);
1631var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnIntKeyMutableDict", null);
1641var result = dispatcher.Invoke("Aspire.Hosting/Dict.get", args);
1654var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1664var removeResult = dispatcher.Invoke("Aspire.Hosting/Dict.remove", removeArgs);
1674var countResult = dispatcher.Invoke("Aspire.Hosting/Dict.count", countArgs);
1687var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1697var hasResult = dispatcher.Invoke("Aspire.Hosting/Dict.has", hasArgs);
1708var hasResult2 = dispatcher.Invoke("Aspire.Hosting/Dict.has", hasArgs2);
1721var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1730var result = dispatcher.Invoke("Aspire.Hosting/Dict.keys", args);
1746var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnIntKeyMutableDict", null);
1755var result = dispatcher.Invoke("Aspire.Hosting/Dict.keys", args);
1770var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnIntKeyMutableDict", null);
1790var dictResult = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnMutableDict", null);
1799var result = dispatcher.Invoke("Aspire.Hosting/Dict.count", args);
1816var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptEnum", args);
1833var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptEnum", args);
1850var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/returnEnum", args);
1867var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptOptionalEnum", args);
1879var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/acceptOptionalEnum", new JsonObject());
1968var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestResourceWithProperties.color", args);
2009var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestResourceWithMethods.greet", args);
2026var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestResourceWithProperties.color", args);
2043var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/TestResourceWithProperties.name", args);
2386var result = dispatcher.Invoke("Aspire.Hosting.RemoteHost.Tests/findConnectionPropertyKey", args);
2431public async Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
2438public Task InvokeAsync(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
2439=> InvokeAsync<JsonNode?>(callbackId, args, cancellationToken);
2447public List<(string CallbackId, JsonNode? Args)> Invocations { get; } = [];
2451public Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
2459public Task InvokeAsync(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
ExternalCapabilityRegistryTests.cs (25)
30return Task.FromResult<JsonNode?>(null);
60var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
103var payload = JsonNode.Parse(CreateCapabilities("test.external/value").GetRawText())!.AsObject();
109(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("configured")));
148var payload = JsonNode.Parse(CreateCapabilities("test.external/valid", "test.external/invalid").GetRawText())!.AsObject();
189return Task.FromResult<JsonNode?>(null);
194return Task.FromResult<JsonNode?>(JsonValue.Create($"deferred-{args!["p0"]!.GetValue<string>()}"));
201var result = await registry.InvokeGuestCallbackAsync(integration.ServerRpc, relayId,
219var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
246var payload = JsonNode.Parse(CreateCapabilities("test.external/cancel").GetRawText())!.AsObject();
252var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
300return Task.FromResult<JsonNode?>(null);
303var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
322var result = await invocation.WaitAsync(TimeSpan.FromSeconds(10), TestContext.Current.CancellationToken);
357return Task.FromResult<JsonNode?>(null);
360var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
496(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("original")));
498(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("other")));
500(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("replacement")));
554var payload = JsonNode.Parse(CreateCapabilities("test.external/value").GetRawText())!.AsObject();
604(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("first-replacement")));
606(_, _) => Task.FromResult<JsonNode?>(JsonValue.Create("second-replacement")));
628var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
660var firstResponse = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
661var secondResponse = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
TestServices\IntegrationHostTestConnection.cs (4)
22public IntegrationHostTestConnection(JsonElement capabilities, Func<string, JsonObject?, Task<JsonNode?>> handleCapability)
27public IntegrationHostTestConnection(JsonElement capabilities, Func<string, JsonObject?, CancellationToken, Task<JsonNode?>> invokeCallback)
39Func<string, JsonObject?, Task<JsonNode?>>? handleCapability,
40Func<string, JsonObject?, CancellationToken, Task<JsonNode?>>? invokeCallback)
Aspire.Hosting.Seq.Tests (3)
Aspire.Hosting.SqlServer.Tests (3)
Aspire.Hosting.Tests (111)
Dcp\JsonPatchTests.cs (16)
16var current = JsonNode.Parse("""{"unchanged":1,"removed":2,"replaced":"before"}""");
17var changed = JsonNode.Parse("""{"unchanged":1,"replaced":"after","added":true}""");
24Assert.True(JsonNode.DeepEquals(changed, JsonPatch.Apply(current, patch)));
38Assert.True(JsonNode.DeepEquals(changed, JsonPatch.Apply(current, patch)));
56var current = JsonNode.Parse(currentJson);
57var changed = JsonNode.Parse(changedJson);
62Assert.True(JsonNode.DeepEquals(changed, JsonPatch.Apply(current, patch)));
68var current = JsonNode.Parse("""{"a/b":{"m~n":"before"}}""");
69var changed = JsonNode.Parse("""{"a/b":{"m~n":"after"}}""");
76Assert.True(JsonNode.DeepEquals(changed, JsonPatch.Apply(current, patch)));
Aspire.Hosting.TestUtilities (14)
Aspire.Hosting.Valkey.Tests (2)
Aspire.Hosting.Yarp (3)
Aspire.Managed.Tests (1)
Aspire.TestTools (7)
Aspire.TypeSystem (1)
ConfigurationSchemaGenerator (15)
ConfigurationSchemaGenerator.Tests (4)
dotnet-aot (4)
dotnet-user-jwts (1)
GenerateTemplateManifest (1)
Infrastructure.Tests (193)
WorkflowScripts\AutoSecWorkflowTests.cs (167)
26var result = await RunHarnessAsync(new JsonObject
57var alert = Assert.Single(result["alerts"]!.AsArray())!;
73var result = await RunHarnessAsync(new JsonObject { ["mode"] = "collect-alerts", ["failure"] = phase });
106var result = await RunHarnessAsync(request);
122var file = request["changedFiles"]![1]![0]!;
141var result = await RunHarnessAsync(request);
144var pr = Assert.Single(result["output"]!.AsArray())!;
178var result = await RunHarnessAsync(request);
188var result = await RunHarnessAsync(CreateApprovalScenario());
190var decision = Assert.Single(result["value"]!.AsArray());
194var review = Assert.Single(result["reviews"]!.AsArray());
207var result = await RunHarnessAsync(scenario);
238var result = await RunHarnessAsync(scenario);
266var result = await RunHarnessAsync(scenario);
286var result = await RunHarnessAsync(scenario);
315var result = await RunHarnessAsync(scenario);
339var result = await RunHarnessAsync(scenario);
351var decision = Assert.Single(result["value"]!.AsArray());
410var result = await RunHarnessAsync(scenario);
412var decision = Assert.Single(result["value"]!.AsArray());
436var unchanged = await RunHarnessAsync(scenario);
441var result = await RunHarnessAsync(scenario);
443var decision = Assert.Single(result["value"]!.AsArray());
705var result = await RunHarnessAsync(scenario);
707var decision = Assert.Single(result["value"]!.AsArray());
719var result = await RunHarnessAsync(new JsonObject
752var result = await RunHarnessAsync(new JsonObject
773var result = await RunHarnessAsync(new JsonObject
830var result = await RunHarnessAsync(new JsonObject
929var result = await RunHarnessAsync(request);
975var result = await RunHarnessAsync(new JsonObject
1011var result = await RunHarnessAsync(new JsonObject
1053var result = await RunHarnessAsync(request);
1127var result = await RunHarnessAsync(new JsonObject
1154var result = await RunHarnessAsync(new JsonObject
1171var result = await RunHarnessAsync(new JsonObject
1195var result = await RunHarnessAsync(new JsonObject
1290var result = await RunHarnessAsync(new JsonObject
1335var result = await RunHarnessAsync(new JsonObject
1349var result = await RunHarnessAsync(new JsonObject
1379var result = await RunHarnessAsync(new JsonObject
1410var result = await RunHarnessAsync(new JsonObject
1448var result = await RunHarnessAsync(new JsonObject
1475var result = await RunHarnessAsync(new JsonObject
1499var result = await RunHarnessAsync(new JsonObject
1538var result = await RunHarnessAsync(new JsonObject
1601var result = await RunHarnessAsync(new JsonObject
1672var text = JsonNode.Parse(files[path]!.GetValue<string>())!.ToJsonString(new JsonSerializerOptions { WriteIndented = true }).ReplaceLineEndings("\n") + "\n";
1678var head = JsonNode.Parse(heads["extension/package-lock.json"]!.GetValue<string>())!;
1687var result = await RunHarnessAsync(new JsonObject
1729var result = await RunHarnessAsync(new JsonObject
1748var result = await RunHarnessAsync(new JsonObject
1758Assert.Equal([output], result["outputs"]!.AsArray().Select(v => JsonNode.Parse(v!.GetValue<string>())!.ToJsonString()));
1767var result = await RunHarnessAsync(new JsonObject
1795var outputs = result["outputs"]!.AsArray().Select(line => JsonNode.Parse(line!.GetValue<string>())!).ToArray();
1810var result = await RunHarnessAsync(new JsonObject
1845var result = await RunHarnessAsync(new JsonObject
1892var baseline = JsonNode.Parse(baseText)!;
1896var head = JsonNode.Parse(baseText.Replace("4.17.20", "4.17.21", StringComparison.Ordinal).Replace("22.0.0", "22.1.0", StringComparison.Ordinal))!;
1897var package = head["packages"]!["node_modules/lodash"]!;
1950var result = await RunHarnessAsync(new JsonObject
2012baseline["packages"] = JsonNode.Parse(PublicTextBase)!["packages"]!.DeepClone();
2017var result = await RunHarnessAsync(new JsonObject
2054var baseline = JsonNode.Parse(PublicTextBase)!;
2083var head = baseline.DeepClone();
2111var result = await RunHarnessAsync(new JsonObject
2202var result = await RunHarnessAsync(new JsonObject
2238var baseline = JsonNode.Parse(PublicTextBase)!;
2243var result = await RunHarnessAsync(new JsonObject
2270var baseline = JsonNode.Parse(PublicTextBase)!;
2282var head = baseline.DeepClone();
2307var result = await RunHarnessAsync(new JsonObject
2361var result = await RunHarnessAsync(new JsonObject
2430var result = await RunHarnessAsync(new JsonObject
2473var result = await RunHarnessAsync(new JsonObject
2512var result = await RunHarnessAsync(new JsonObject
2542var result = await RunHarnessAsync(new JsonObject
2578var result = await RunHarnessAsync(new JsonObject
2633var result = await RunHarnessAsync(new JsonObject
2661var result = await RunHarnessAsync(new JsonObject
2681var result = await RunHarnessAsync(new JsonObject
2729var result = await RunHarnessAsync(new JsonObject
2761var result = await RunHarnessAsync(new JsonObject
2806var result = await RunHarnessAsync(new JsonObject
2846var result = await RunHarnessAsync(new JsonObject
2866var result = await RunHarnessAsync(new JsonObject
2901var result = await RunHarnessAsync(new JsonObject
2922var result = await RunHarnessAsync(new JsonObject
2948var result = await RunHarnessAsync(new JsonObject
2978var result = await RunHarnessAsync(new JsonObject
3006var result = await RunHarnessAsync(new JsonObject
3038var result = await RunHarnessAsync(request);
3061var result = await RunHarnessAsync(new JsonObject
3071var output = JsonNode.Parse(Assert.Single(result["outputs"]!.AsArray())!.GetValue<string>());
3072Assert.True(JsonNode.DeepEquals(expected, output));
3093var result = await RunHarnessAsync(new JsonObject
3101var output = JsonNode.Parse(Assert.Single(result["outputs"]!.AsArray())!.GetValue<string>());
3102Assert.True(JsonNode.DeepEquals(expected, output));
3129input[field] = JsonNode.Parse(value);
3130var result = await RunHarnessAsync(new JsonObject
3195var result = await RunHarnessAsync(new JsonObject
3232var result = await RunHarnessAsync(new JsonObject
3269var result = await RunHarnessAsync(new JsonObject
3286var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3303var result = await RunHarnessAsync(new JsonObject
3320var unguarded = await RunHarnessAsync(new JsonObject { ["mode"] = "private-shell", ["script"] = script });
3328var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3332var quiet = await RunHarnessAsync(new JsonObject
3348var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = PublicationGuardFixture });
3369var original = await RunHarnessAsync(new JsonObject { ["mode"] = "private-shell", ["script"] = script });
3376var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3379var quiet = await RunHarnessAsync(new JsonObject
3402var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3430var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3446var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3473var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3534var result = await RunHarnessAsync(new JsonObject { ["mode"] = "publication-guard", ["workflow"] = workflow });
3688.Select(step => (JsonNode?)JsonValue.Create(step.Children[new YamlScalarNode("if")].ToString())).ToArray());
3725var result = await RunHarnessAsync(new JsonObject
3748var result = await RunHarnessAsync(new JsonObject
3767var result = await RunHarnessAsync(new JsonObject
3792var result = await RunHarnessAsync(new JsonObject
3829var result = await RunHarnessAsync(new JsonObject
3872var result = await RunHarnessAsync(new JsonObject
3892var result = await RunHarnessAsync(scenario);
3894var decision = Assert.Single(result["value"]!.AsArray());
3915var result = await RunHarnessAsync(scenario);
3917var decision = Assert.Single(result["value"]!.AsArray());
3940var result = await RunHarnessAsync(scenario);
3942var decision = Assert.Single(result["value"]!.AsArray());
3954var result = await RunHarnessAsync(scenario);
3956var decision = Assert.Single(result["value"]!.AsArray());
3985var result = await RunHarnessAsync(scenario);
3987var decision = Assert.Single(result["value"]!.AsArray());
4010var result = await RunHarnessAsync(scenario);
4033var result = await RunHarnessAsync(scenario);
4068var result = await RunHarnessAsync(new JsonObject
4082var result = await RunHarnessAsync(new JsonObject
4129var result = await RunHarnessAsync(new JsonObject
4177var result = await RunHarnessAsync(new JsonObject
4202var result = await RunHarnessAsync(new JsonObject
4216var result = await RunHarnessAsync(new JsonObject
4267var prefixMapped = await RunHarnessAsync(NuGetLookup("Contoso.Build.Engine", config, responses));
4269var exactMapped = await RunHarnessAsync(NuGetLookup("Contoso.Build.Tasks", config, responses.DeepClone().AsObject()));
4308var result = await RunHarnessAsync(new JsonObject
4325var nuget = await RunHarnessAsync(new JsonObject
4338var npm = await RunHarnessAsync(new JsonObject
4362var pip = await RunHarnessAsync(new JsonObject
4388var result = await RunHarnessAsync(CreatePushGateScenario(new JsonObject()));
4393var noPush = await RunHarnessAsync(new JsonObject
4472var result = await RunHarnessAsync(scenario);
4524var result = await RunHarnessAsync(CreatePushGateScenario(pr, item));
4526var failure = Assert.Single(result["failures"]!.AsArray());
4539var result = await RunHarnessAsync(scenario);
4657private static JsonObject Response(JsonNode body) => new() { ["status"] = 200, ["body"] = body };
4720var result = await RunHarnessAsync(new JsonObject
4781private async Task<JsonNode> RunHarnessAsync(JsonObject request)
4804var response = JsonNode.Parse(await File.ReadAllTextAsync(resultPath));
Microsoft.AspNetCore.JsonPatch.SystemTextJson (8)
Microsoft.AspNetCore.OpenApi (67)
Extensions\JsonNodeSchemaExtensions.cs (29)
60/// Note that this method targets <see cref="JsonNode"/> and not <see cref="OpenApiSchema"/> because it is
82/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
84internal static void ApplyValidationAttributes(this JsonNode schema, IEnumerable<Attribute> validationAttributes)
170/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
173internal static void ApplyDefaultValue(this JsonNode schema, object? defaultValue, JsonTypeInfo? jsonTypeInfo)
201/// Note that this method targets <see cref="JsonNode"/> and not <see cref="OpenApiSchema"/> because
205/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
207internal static void ApplyPrimitiveFormats(this JsonNode schema, JsonSchemaExporterContext context)
220/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
222internal static void ApplyRouteConstraints(this JsonNode schema, IEnumerable<IRouteConstraint> constraints)
296/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
299internal static void ApplyParameterInfo(this JsonNode schema, ApiParameterDescription parameterDescription, JsonTypeInfo? jsonTypeInfo)
367enumArray.Add((JsonNode)name);
380&& schema[defaultKey] is JsonNode defaultNode
387var serialized = JsonSerializer.SerializeToNode(enumValue, jsonTypeInfo);
390schema[defaultKey] = (JsonNode)memberName;
425/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
428internal static void MapPolymorphismOptionsToDiscriminator(this JsonNode schema, JsonSchemaExporterContext context, Func<JsonTypeInfo, string?> createSchemaReferenceId)
470/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
473internal static void ApplySchemaReferenceId(this JsonNode schema, JsonSchemaExporterContext context, Func<JsonTypeInfo, string?> createSchemaReferenceId)
504/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
506internal static bool WillBeComponentized(this JsonNode schema)
508return (schema[OpenApiConstants.SchemaId] is JsonNode schemaIdNode
540/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
542internal static void ApplyNullabilityContextInfo(this JsonNode schema, JsonPropertyInfo propertyInfo)
588/// <param name="schema">The <see cref="JsonNode"/> produced by the underlying schema generator.</param>
589internal static void PruneNullTypeForComponentizedTypes(this JsonNode schema)
614private static JsonSchemaType? MapJsonNodeToSchemaType(JsonNode? jsonNode)
630foreach (var node in jsonArray)
Services\Schemas\OpenApiSchemaService.cs (23)
236static JsonArray JsonArray(ReadOnlySpan<JsonNode> values)
240foreach (var value in values)
251var schemaAsJsonObject = CreateSchema(type);
276var rawNode = CreateSchema(type);
300&& refDefault is JsonNode defaultNode)
573private JsonNode CreateSchema(Type type)
578var schema = JsonSchemaExporter.GetJsonSchemaAsNode(_jsonSerializerOptions, underlyingType, _configuration);
582private static JsonNode ResolveReferences(JsonNode node, JsonNode rootSchema)
587private static JsonNode ResolveReferencesRecursive(JsonNode node, JsonNode rootSchema)
591if (jsonObject.TryGetPropertyValue(OpenApiConstants.RefKeyword, out var refNode) &&
600var resolvedNode = ResolveReference(refString, rootSchema);
622var processedValue = ResolveReferencesRecursive(property.Value, rootSchema);
639var processedValue = ResolveReferencesRecursive(jsonArray[i]!, rootSchema);
654private static JsonNode? ResolveReference(string refPath, JsonNode rootSchema)
671var currentNode = rootSchema;
728private static JsonNode EvaluateReferenceToken(string unescapedReferenceToken, JsonNode currentNode, string fullJsonPointer)
741if (!currentObject.TryGetPropertyValue(unescapedReferenceToken, out var referencedValue) ||
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (73)
Functions\AIFunctionFactory.cs (7)
97/// or <see cref="JsonNode"/>, it is deserialized into the parameter type, utilizing <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided,
178/// or <see cref="JsonNode"/>, it is deserialized into the parameter type, utilizing <paramref name="serializerOptions"/> if provided, or else
268/// or <see cref="JsonNode"/>, it is deserialized into the parameter type, utilizing <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided,
357/// or <see cref="JsonNode"/>, it is deserialized into the parameter type, utilizing <paramref name="serializerOptions"/> if provided, or else
419/// <see cref="JsonDocument"/>, or <see cref="JsonNode"/>, it is deserialized directly. If the argument is anything else unknown,
460/// or <see cref="JsonNode"/>, it is deserialized into the parameter type, utilizing <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided,
975JsonNode node => JsonSerializer.Deserialize(node, typeInfo),
Utilities\AIJsonUtilities.Schema.Create.cs (36)
122JsonNode parameterSchema = CreateJsonSchemaCore(
145(requiredProperties ??= []).Add((JsonNode)parameterSchemaName);
149JsonNode schema = new JsonObject();
200JsonNode schema = CreateJsonSchemaCore(type, parameter: null, nullabilityContext: null, description, hasDefaultValue, defaultValue, serializerOptions, inferenceOptions);
223private static JsonNode CreateJsonSchemaCore(
249JsonNode? defaultValueNode = defaultValue is not null
277JsonNode TransformSchemaNode(JsonSchemaExporterContext schemaExporterContext, JsonNode schema)
290if (parameter?.Name is not null && objSchema.TryGetPropertyValue(RefPropertyName, out JsonNode? paramName))
301objSchema[RefPropertyName] = (JsonNode)refUri;
328obj[TypePropertyName] = new JsonArray { (JsonNode)numericType, (JsonNode)"null" };
332obj[TypePropertyName] = (JsonNode)numericType;
343if (objSchema.TryGetPropertyValue(TypePropertyName, out JsonNode? typeKeyWord) &&
349objSchema[TypePropertyName] = new JsonArray { (JsonNode)typeValue, (JsonNode)"null" };
356objSchema.InsertAtStart(TypePropertyName, new JsonArray { (JsonNode)"string", (JsonNode)"null" });
364if (objSchema.TryGetPropertyValue(TypePropertyName, out JsonNode? typeKeyWord) &&
370objSchema[TypePropertyName] = new JsonArray { (JsonNode)typeValue, (JsonNode)"null" };
378JsonNode? defaultValueNode = JsonSerializer.SerializeToNode(defaultValue, ctx.TypeInfo);
385ConvertSchemaToObject(ref schema).InsertAtStart(DescriptionPropertyName, (JsonNode)localDescription);
391ConvertSchemaToObject(ref schema).InsertAtStart(SchemaPropertyName, (JsonNode)SchemaKeywordUri);
404static JsonObject ConvertSchemaToObject(ref JsonNode schema)
424void ApplyDataAnnotations(ref JsonNode schema, AIJsonSchemaCreateContext ctx)
497JsonNode? minNode = null;
498JsonNode? maxNode = null;
567JsonArray? requiredArray = requiredSchemaObj.TryGetPropertyValue(RequiredPropertyName, out JsonNode? existing) ?
580foreach (JsonNode? entry in requiredArray)
591requiredArray.Add((JsonNode)propertyName);
646JsonNode? notNode = obj[NotPropertyName];
716if (!schema.TryGetPropertyValue(TypePropertyName, out JsonNode? typeNode))
729foreach (JsonNode? entry in (JsonArray)typeNode)
786foreach (JsonNode? entry in typeArray)
821private static void InsertAtStart(this JsonObject jsonObject, string key, JsonNode value)
Utilities\AIJsonUtilities.Schema.Transform.cs (21)
32JsonNode? nodeSchema = JsonSerializer.SerializeToNode(schema, JsonContext.Default.JsonElement);
33JsonNode transformedSchema = TransformSchema(nodeSchema, transformOptions);
37private static JsonNode TransformSchema(JsonNode? schema, AIJsonSchemaTransformOptions transformOptions)
43private static JsonNode TransformSchemaCore(JsonNode? schema, AIJsonSchemaTransformOptions transformOptions, List<string>? path)
50schema = new JsonObject { [NotPropertyName] = (JsonNode)true };
68if (schemaObj.TryGetPropertyValue(PropertiesPropertyName, out JsonNode? props) && props is JsonObject propsObj)
82if (schemaObj.TryGetPropertyValue(ItemsPropertyName, out JsonNode? itemsSchema))
89if (schemaObj.TryGetPropertyValue(AdditionalPropertiesPropertyName, out JsonNode? additionalProps) &&
97if (schemaObj.TryGetPropertyValue(NotPropertyName, out JsonNode? notSchema))
108if (schemaObj.TryGetPropertyValue(combinatorKeyword, out JsonNode? combinatorSchema) && combinatorSchema is JsonArray combinatorArray)
114JsonNode element = TransformSchemaCore(combinatorArray[i], transformOptions, path);
130schemaObj[AdditionalPropertiesPropertyName] = (JsonNode)false;
138requiredProps.Add((JsonNode)prop.Key);
145schemaObj.TryGetPropertyValue(TypePropertyName, out JsonNode? typeSchema) &&
151foreach (JsonNode? typeNode in typeArray)
172schemaObj["type"] = (JsonNode)foundType;
173schemaObj["nullable"] = (JsonNode)true;
178schemaObj.TryGetPropertyValue(DefaultPropertyName, out JsonNode? defaultSchema))
180string? description = schemaObj.TryGetPropertyValue(DescriptionPropertyName, out JsonNode? descriptionSchema) ? descriptionSchema?.GetValue<string>() : null;
Microsoft.Extensions.AI.Abstractions.Tests (40)
Utilities\AIJsonUtilitiesTests.cs (10)
100case null when property.PropertyType == typeof(Func<AIJsonSchemaCreateContext, JsonNode, JsonNode>):
101Func<AIJsonSchemaCreateContext, JsonNode, JsonNode> transformer = static (context, schema) => (JsonNode)true;
682JsonNode? schemaAsNode = JsonSerializer.SerializeToNode(schema, options);
695JsonNode? serializedValue = JsonSerializer.SerializeToNode(testData.Value, testData.Type, options);
1830schemaObj.Add("myAwesomeKeyword", (JsonNode)42);
1846if (schemaObj.TryGetPropertyValue("properties", out JsonNode? props))
1853if (schemaObj.TryGetPropertyValue("type", out JsonNode? type) && type is JsonArray typeArray)
Microsoft.Extensions.AI.Evaluation.Quality (5)
Microsoft.Extensions.AI.Evaluation.Safety (4)
Microsoft.Extensions.AI.Integration.Tests (5)
Microsoft.Extensions.AI.OpenAI (1)
Microsoft.Extensions.AI.OpenAI.Tests (1)
Microsoft.Extensions.AI.Tests (3)
Microsoft.ML.AutoML (12)
Microsoft.ML.AutoML.SourceGenerator (5)
Microsoft.NET.Build.Containers (17)
Microsoft.NET.Build.Tasks (9)
Microsoft.NETCore.Platforms (2)
Microsoft.TemplateEngine.Cli (55)
JExtensions.cs (28)
19internal static string? ToString(this JsonNode? token, string? key)
41JsonNode? element = GetPropertyCaseInsensitive(obj, key);
50internal static bool TryGetValue(this JsonNode? token, string? key, out JsonNode? result)
75internal static bool TryParseBool(this JsonNode token, out bool result)
96internal static bool ToBool(this JsonNode? token, string? key = null, bool defaultValue = false)
98if (!token.TryGetValue(key, out JsonNode? checkToken))
111internal static int ToInt32(this JsonNode? token, string? key = null, int defaultValue = 0)
128JsonNode? element = GetPropertyCaseInsensitive(obj, key);
137internal static T ToEnum<T>(this JsonNode token, string? key = null, T defaultValue = default)
149internal static Guid ToGuid(this JsonNode token, string? key = null, Guid defaultValue = default)
160internal static IEnumerable<KeyValuePair<string, JsonNode?>> PropertiesOf(this JsonNode? token, string? key = null)
164return Array.Empty<KeyValuePair<string, JsonNode?>>();
169JsonNode? element = GetPropertyCaseInsensitive(currentJObj, key);
172return Array.Empty<KeyValuePair<string, JsonNode?>>();
180internal static T? Get<T>(this JsonNode? token, string? key)
181where T : JsonNode
188JsonNode? res = GetPropertyCaseInsensitive(obj, key);
192internal static IReadOnlyList<string> ArrayAsStrings(this JsonNode? token, string? propertyName = null)
206foreach (JsonNode? item in arr)
222return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
226internal static void WriteObject(this IPhysicalFileSystem fileSystem, string path, JsonNode obj)
233internal static bool TryParse(this string arg, out JsonNode? token)
237token = JsonNode.Parse(arg, null, DocOptions);
247private static bool TryParseInt(this JsonNode token, out int result)
267private static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key)
269if (obj.TryGetPropertyValue(key, out JsonNode? result))
PostActionProcessors\AddJsonPropertyPostActionProcessor.cs (13)
154JsonNode? newJsonContent = AddElementToJson(
175private static JsonNode? AddElementToJson(IPhysicalFileSystem fileSystem, string targetJsonFile, string? propertyPath, string propertyPathSeparator, string newJsonPropertyName, string newJsonPropertyValue, IPostAction action)
178JsonNode? jsonContent = JsonNode.Parse(fileContent, nodeOptions: null, documentOptions: DeserializerOptions);
204JsonNode? parentProperty = FindJsonNode(jsonContent, propertyPath, propertyPathSeparator, createPath);
212JsonNode? newValue;
215newValue = JsonNode.Parse(newJsonPropertyValue);
223parentProperty.AsObject().TryGetPropertyValue(newJsonPropertyName, out JsonNode? existingValue))
225bool valuesEqual = JsonNode.DeepEquals(existingValue, newValue) ||
249private static JsonNode? FindJsonNode(JsonNode content, string? nodePath, string pathSeparator, bool createPath)
258JsonNode? node = content;
267JsonNode? childNode = node[property];
Microsoft.TemplateEngine.Edge (80)
parent\Shared\JExtensions.cs (57)
27internal static string? ToString(this JsonNode? token, string? key)
49JsonNode? element = GetPropertyCaseInsensitive(obj, key);
63internal static bool TryGetValue(this JsonNode? token, string? key, out JsonNode? result)
88internal static bool TryParseBool(this JsonNode token, out bool result)
109internal static bool ToBool(this JsonNode? token, string? key = null, bool defaultValue = false)
111if (!token.TryGetValue(key, out JsonNode? checkToken))
124internal static bool TryParseInt(this JsonNode token, out int result)
144internal static int ToInt32(this JsonNode? token, string? key = null, int defaultValue = 0)
161JsonNode? element = GetPropertyCaseInsensitive(obj, key);
170internal static T ToEnum<T>(this JsonNode token, string? key = null, T defaultValue = default, bool ignoreCase = false)
182internal static Guid ToGuid(this JsonNode token, string? key = null, Guid defaultValue = default)
200JsonNode? token = jObject.Get<JsonNode>(propertyName);
208internal static IEnumerable<KeyValuePair<string, JsonNode?>> PropertiesOf(this JsonNode? token, string? key = null)
217JsonNode? element = GetPropertyCaseInsensitive(obj, key);
236private static IReadOnlyList<KeyValuePair<string, JsonNode?>> GetObjectProperties(JsonObject obj)
256/// when the internal dictionary has not yet been initialized, so <see cref="JsonNode.ToJsonString"/> is
260private static List<KeyValuePair<string, JsonNode?>> GetObjectPropertiesViaDocument(JsonObject obj)
263var result = new List<KeyValuePair<string, JsonNode?>>();
268var property = new KeyValuePair<string, JsonNode?>(prop.Name, ParseJsonNode(prop.Value.GetRawText()));
282internal static T? Get<T>(this JsonNode? token, string? key)
283where T : JsonNode
290JsonNode? res = GetPropertyCaseInsensitive(obj, key);
294internal static IReadOnlyDictionary<string, string> ToStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
315internal static IReadOnlyDictionary<string, JsonNode> ToJsonNodeDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
317Dictionary<string, JsonNode> result = new(comparer ?? StringComparer.Ordinal);
334internal static IReadOnlyDictionary<string, string> ToJsonNodeStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
349internal static TemplateParameterPrecedence ToTemplateParameterPrecedence(this JsonNode jObject, string? key)
351if (!jObject.TryGetValue(key, out JsonNode? checkToken))
364internal static IReadOnlyList<string> ArrayAsStrings(this JsonNode? token, string? propertyName = null)
378foreach (JsonNode? item in arr)
389internal static IReadOnlyList<Guid> ArrayAsGuids(this JsonNode? token, string? propertyName = null)
403foreach (JsonNode? item in arr)
417internal static IEnumerable<T> Items<T>(this JsonNode? token, string? propertyName = null)
418where T : JsonNode
430foreach (JsonNode? item in arr)
444return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
453return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
469internal static IReadOnlyList<string> JTokenStringOrArrayToCollection(this JsonNode? token, IReadOnlyList<string> defaultSet)
509internal static bool TryGetValueCaseInsensitive(this JsonObject obj, string key, out JsonNode? result)
519internal static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key)
524if (obj.TryGetPropertyValue(key, out JsonNode? result))
552private static JsonNode? GetPropertyCaseInsensitiveViaDocument(JsonObject obj, string key)
557JsonNode? result = null;
558JsonNode? caseInsensitiveResult = null;
582return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
589internal static JsonNode? ParseJsonNode(string json)
591return JsonNode.Parse(json, null, DocOptions);
605return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
614return (JsonObject?)JsonNode.Parse(source.ToJsonString(), null, DocOptions)
630&& target.TryGetPropertyValue(property.Key, out JsonNode? targetNode)
641foreach (var item in sourceArr)
643targetArr.Add(item != null ? JsonNode.Parse(item.ToJsonString()) : null);
650? JsonNode.Parse(property.Value.ToJsonString())
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (87)
ConfigModel\TemplateConfigModel.cs (8)
158JsonNode? globalCustomConfigData = JExtensions.GetPropertyCaseInsensitive(source, nameof(GlobalCustomOperations));
165IReadOnlyDictionary<string, JsonNode> allSpecialOpsConfig = source.ToJsonNodeDictionary(StringComparer.OrdinalIgnoreCase, nameof(SpecialCustomOperations));
168foreach (KeyValuePair<string, JsonNode> globConfigKeyValue in allSpecialOpsConfig)
171JsonNode globData = globConfigKeyValue.Value;
194obj.TryGetValue(nameof(TemplateConstraintInfo.Args), out JsonNode? args);
542IReadOnlyDictionary<string, JsonNode> templateDefinedForms = source.ToJsonNodeDictionary(StringComparer.OrdinalIgnoreCase, nameof(Forms));
544foreach (KeyValuePair<string, JsonNode> form in templateDefinedForms)
554private static IReadOnlyDictionary<string, IBaselineInfo> BaselineInfoFromJObject(IEnumerable<KeyValuePair<string, JsonNode?>> baselineProperties)
parent\Shared\JExtensions.cs (57)
27internal static string? ToString(this JsonNode? token, string? key)
49JsonNode? element = GetPropertyCaseInsensitive(obj, key);
63internal static bool TryGetValue(this JsonNode? token, string? key, out JsonNode? result)
88internal static bool TryParseBool(this JsonNode token, out bool result)
109internal static bool ToBool(this JsonNode? token, string? key = null, bool defaultValue = false)
111if (!token.TryGetValue(key, out JsonNode? checkToken))
124internal static bool TryParseInt(this JsonNode token, out int result)
144internal static int ToInt32(this JsonNode? token, string? key = null, int defaultValue = 0)
161JsonNode? element = GetPropertyCaseInsensitive(obj, key);
170internal static T ToEnum<T>(this JsonNode token, string? key = null, T defaultValue = default, bool ignoreCase = false)
182internal static Guid ToGuid(this JsonNode token, string? key = null, Guid defaultValue = default)
200JsonNode? token = jObject.Get<JsonNode>(propertyName);
208internal static IEnumerable<KeyValuePair<string, JsonNode?>> PropertiesOf(this JsonNode? token, string? key = null)
217JsonNode? element = GetPropertyCaseInsensitive(obj, key);
236private static IReadOnlyList<KeyValuePair<string, JsonNode?>> GetObjectProperties(JsonObject obj)
256/// when the internal dictionary has not yet been initialized, so <see cref="JsonNode.ToJsonString"/> is
260private static List<KeyValuePair<string, JsonNode?>> GetObjectPropertiesViaDocument(JsonObject obj)
263var result = new List<KeyValuePair<string, JsonNode?>>();
268var property = new KeyValuePair<string, JsonNode?>(prop.Name, ParseJsonNode(prop.Value.GetRawText()));
282internal static T? Get<T>(this JsonNode? token, string? key)
283where T : JsonNode
290JsonNode? res = GetPropertyCaseInsensitive(obj, key);
294internal static IReadOnlyDictionary<string, string> ToStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
315internal static IReadOnlyDictionary<string, JsonNode> ToJsonNodeDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
317Dictionary<string, JsonNode> result = new(comparer ?? StringComparer.Ordinal);
334internal static IReadOnlyDictionary<string, string> ToJsonNodeStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
349internal static TemplateParameterPrecedence ToTemplateParameterPrecedence(this JsonNode jObject, string? key)
351if (!jObject.TryGetValue(key, out JsonNode? checkToken))
364internal static IReadOnlyList<string> ArrayAsStrings(this JsonNode? token, string? propertyName = null)
378foreach (JsonNode? item in arr)
389internal static IReadOnlyList<Guid> ArrayAsGuids(this JsonNode? token, string? propertyName = null)
403foreach (JsonNode? item in arr)
417internal static IEnumerable<T> Items<T>(this JsonNode? token, string? propertyName = null)
418where T : JsonNode
430foreach (JsonNode? item in arr)
444return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
453return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
469internal static IReadOnlyList<string> JTokenStringOrArrayToCollection(this JsonNode? token, IReadOnlyList<string> defaultSet)
509internal static bool TryGetValueCaseInsensitive(this JsonObject obj, string key, out JsonNode? result)
519internal static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key)
524if (obj.TryGetPropertyValue(key, out JsonNode? result))
552private static JsonNode? GetPropertyCaseInsensitiveViaDocument(JsonObject obj, string key)
557JsonNode? result = null;
558JsonNode? caseInsensitiveResult = null;
582return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
589internal static JsonNode? ParseJsonNode(string json)
591return JsonNode.Parse(json, null, DocOptions);
605return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
614return (JsonObject?)JsonNode.Parse(source.ToJsonString(), null, DocOptions)
630&& target.TryGetPropertyValue(property.Key, out JsonNode? targetNode)
641foreach (var item in sourceArr)
643targetArr.Add(item != null ? JsonNode.Parse(item.ToJsonString()) : null);
650? JsonNode.Parse(property.Value.ToJsonString())
Microsoft.TemplateEngine.Utils (57)
parent\Shared\JExtensions.cs (57)
27internal static string? ToString(this JsonNode? token, string? key)
49JsonNode? element = GetPropertyCaseInsensitive(obj, key);
63internal static bool TryGetValue(this JsonNode? token, string? key, out JsonNode? result)
88internal static bool TryParseBool(this JsonNode token, out bool result)
109internal static bool ToBool(this JsonNode? token, string? key = null, bool defaultValue = false)
111if (!token.TryGetValue(key, out JsonNode? checkToken))
124internal static bool TryParseInt(this JsonNode token, out int result)
144internal static int ToInt32(this JsonNode? token, string? key = null, int defaultValue = 0)
161JsonNode? element = GetPropertyCaseInsensitive(obj, key);
170internal static T ToEnum<T>(this JsonNode token, string? key = null, T defaultValue = default, bool ignoreCase = false)
182internal static Guid ToGuid(this JsonNode token, string? key = null, Guid defaultValue = default)
200JsonNode? token = jObject.Get<JsonNode>(propertyName);
208internal static IEnumerable<KeyValuePair<string, JsonNode?>> PropertiesOf(this JsonNode? token, string? key = null)
217JsonNode? element = GetPropertyCaseInsensitive(obj, key);
236private static IReadOnlyList<KeyValuePair<string, JsonNode?>> GetObjectProperties(JsonObject obj)
256/// when the internal dictionary has not yet been initialized, so <see cref="JsonNode.ToJsonString"/> is
260private static List<KeyValuePair<string, JsonNode?>> GetObjectPropertiesViaDocument(JsonObject obj)
263var result = new List<KeyValuePair<string, JsonNode?>>();
268var property = new KeyValuePair<string, JsonNode?>(prop.Name, ParseJsonNode(prop.Value.GetRawText()));
282internal static T? Get<T>(this JsonNode? token, string? key)
283where T : JsonNode
290JsonNode? res = GetPropertyCaseInsensitive(obj, key);
294internal static IReadOnlyDictionary<string, string> ToStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
315internal static IReadOnlyDictionary<string, JsonNode> ToJsonNodeDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
317Dictionary<string, JsonNode> result = new(comparer ?? StringComparer.Ordinal);
334internal static IReadOnlyDictionary<string, string> ToJsonNodeStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
349internal static TemplateParameterPrecedence ToTemplateParameterPrecedence(this JsonNode jObject, string? key)
351if (!jObject.TryGetValue(key, out JsonNode? checkToken))
364internal static IReadOnlyList<string> ArrayAsStrings(this JsonNode? token, string? propertyName = null)
378foreach (JsonNode? item in arr)
389internal static IReadOnlyList<Guid> ArrayAsGuids(this JsonNode? token, string? propertyName = null)
403foreach (JsonNode? item in arr)
417internal static IEnumerable<T> Items<T>(this JsonNode? token, string? propertyName = null)
418where T : JsonNode
430foreach (JsonNode? item in arr)
444return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
453return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
469internal static IReadOnlyList<string> JTokenStringOrArrayToCollection(this JsonNode? token, IReadOnlyList<string> defaultSet)
509internal static bool TryGetValueCaseInsensitive(this JsonObject obj, string key, out JsonNode? result)
519internal static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key)
524if (obj.TryGetPropertyValue(key, out JsonNode? result))
552private static JsonNode? GetPropertyCaseInsensitiveViaDocument(JsonObject obj, string key)
557JsonNode? result = null;
558JsonNode? caseInsensitiveResult = null;
582return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
589internal static JsonNode? ParseJsonNode(string json)
591return JsonNode.Parse(json, null, DocOptions);
605return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
614return (JsonObject?)JsonNode.Parse(source.ToJsonString(), null, DocOptions)
630&& target.TryGetPropertyValue(property.Key, out JsonNode? targetNode)
641foreach (var item in sourceArr)
643targetArr.Add(item != null ? JsonNode.Parse(item.ToJsonString()) : null);
650? JsonNode.Parse(property.Value.ToJsonString())
Microsoft.TemplateSearch.Common (76)
parent\Shared\JExtensions.cs (57)
27internal static string? ToString(this JsonNode? token, string? key)
49JsonNode? element = GetPropertyCaseInsensitive(obj, key);
63internal static bool TryGetValue(this JsonNode? token, string? key, out JsonNode? result)
88internal static bool TryParseBool(this JsonNode token, out bool result)
109internal static bool ToBool(this JsonNode? token, string? key = null, bool defaultValue = false)
111if (!token.TryGetValue(key, out JsonNode? checkToken))
124internal static bool TryParseInt(this JsonNode token, out int result)
144internal static int ToInt32(this JsonNode? token, string? key = null, int defaultValue = 0)
161JsonNode? element = GetPropertyCaseInsensitive(obj, key);
170internal static T ToEnum<T>(this JsonNode token, string? key = null, T defaultValue = default, bool ignoreCase = false)
182internal static Guid ToGuid(this JsonNode token, string? key = null, Guid defaultValue = default)
200JsonNode? token = jObject.Get<JsonNode>(propertyName);
208internal static IEnumerable<KeyValuePair<string, JsonNode?>> PropertiesOf(this JsonNode? token, string? key = null)
217JsonNode? element = GetPropertyCaseInsensitive(obj, key);
236private static IReadOnlyList<KeyValuePair<string, JsonNode?>> GetObjectProperties(JsonObject obj)
256/// when the internal dictionary has not yet been initialized, so <see cref="JsonNode.ToJsonString"/> is
260private static List<KeyValuePair<string, JsonNode?>> GetObjectPropertiesViaDocument(JsonObject obj)
263var result = new List<KeyValuePair<string, JsonNode?>>();
268var property = new KeyValuePair<string, JsonNode?>(prop.Name, ParseJsonNode(prop.Value.GetRawText()));
282internal static T? Get<T>(this JsonNode? token, string? key)
283where T : JsonNode
290JsonNode? res = GetPropertyCaseInsensitive(obj, key);
294internal static IReadOnlyDictionary<string, string> ToStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
315internal static IReadOnlyDictionary<string, JsonNode> ToJsonNodeDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
317Dictionary<string, JsonNode> result = new(comparer ?? StringComparer.Ordinal);
334internal static IReadOnlyDictionary<string, string> ToJsonNodeStringDictionary(this JsonNode token, StringComparer? comparer = null, string? propertyName = null)
349internal static TemplateParameterPrecedence ToTemplateParameterPrecedence(this JsonNode jObject, string? key)
351if (!jObject.TryGetValue(key, out JsonNode? checkToken))
364internal static IReadOnlyList<string> ArrayAsStrings(this JsonNode? token, string? propertyName = null)
378foreach (JsonNode? item in arr)
389internal static IReadOnlyList<Guid> ArrayAsGuids(this JsonNode? token, string? propertyName = null)
403foreach (JsonNode? item in arr)
417internal static IEnumerable<T> Items<T>(this JsonNode? token, string? propertyName = null)
418where T : JsonNode
430foreach (JsonNode? item in arr)
444return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
453return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
469internal static IReadOnlyList<string> JTokenStringOrArrayToCollection(this JsonNode? token, IReadOnlyList<string> defaultSet)
509internal static bool TryGetValueCaseInsensitive(this JsonObject obj, string key, out JsonNode? result)
519internal static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key)
524if (obj.TryGetPropertyValue(key, out JsonNode? result))
552private static JsonNode? GetPropertyCaseInsensitiveViaDocument(JsonObject obj, string key)
557JsonNode? result = null;
558JsonNode? caseInsensitiveResult = null;
582return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
589internal static JsonNode? ParseJsonNode(string json)
591return JsonNode.Parse(json, null, DocOptions);
605return (JsonObject?)JsonNode.Parse(json, null, DocOptions)
614return (JsonObject?)JsonNode.Parse(source.ToJsonString(), null, DocOptions)
630&& target.TryGetPropertyValue(property.Key, out JsonNode? targetNode)
641foreach (var item in sourceArr)
643targetArr.Add(item != null ? JsonNode.Parse(item.ToJsonString()) : null);
650? JsonNode.Parse(property.Value.ToJsonString())
MSBuild (3)
NativeIntegrations.DockerCompose (24)
sdk-tasks (14)
Shared.Tests (20)
System.Text.Json (476)
System\Text\Json\Nodes\JsonArray.cs (32)
24private List<JsonNode?>? _list;
39public JsonArray(JsonNodeOptions options, params JsonNode?[] items) : base(options)
49public JsonArray(JsonNodeOptions options, params ReadOnlySpan<JsonNode?> items) : base(options)
58public JsonArray(params JsonNode?[] items) : base()
67public JsonArray(params ReadOnlySpan<JsonNode?> items) : base()
74internal override JsonNode DeepCloneCore()
76GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement);
87_list = new List<JsonNode?>(list.Count)
98internal override bool DeepEqualsCore(JsonNode node)
108List<JsonNode?> currentList = List;
109List<JsonNode?> otherList = array.List;
131internal int GetElementIndex(JsonNode? node)
137/// Returns an enumerable that wraps calls to <see cref="JsonNode.GetValue{T}"/>.
143foreach (JsonNode? item in List)
149private void InitializeFromArray(JsonNode?[] items)
151var list = new List<JsonNode?>(items);
161private void InitializeFromSpan(ReadOnlySpan<JsonNode?> items)
163List<JsonNode?> list = new(items.Length);
213JsonNode? nodeToAdd = ConvertFromValue(value, Options);
220private List<JsonNode?> List => _list ?? InitializeList();
222private protected override JsonNode? GetItem(int index)
227private protected override void SetItem(int index, JsonNode? value)
234internal override unsafe void GetPath(ref ValueStringBuilder path, JsonNode? child)
261GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement);
271foreach (JsonNode? element in List)
287private List<JsonNode?> InitializeList()
289GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement);
298list = new List<JsonNode?>(jElement.GetArrayLength());
302JsonNode? node = JsonNodeConverter.Create(element, Options);
313List<JsonNode?>? exchangedList = Interlocked.CompareExchange(ref _list, list, null);
334private void GetUnderlyingRepresentation(out List<JsonNode?>? list, out JsonElement? jsonElement)
378public JsonNode? Value;
System\Text\Json\Nodes\JsonObject.cs (34)
36public JsonObject(IEnumerable<KeyValuePair<string, JsonNode?>> properties, JsonNodeOptions? options = null) : this(options)
38int capacity = properties is ICollection<KeyValuePair<string, JsonNode?>> propertiesCollection ? propertiesCollection.Count : 0;
39OrderedDictionary<string, JsonNode?> dictionary = CreateDictionary(options, capacity);
41foreach (KeyValuePair<string, JsonNode?> node in properties)
78private OrderedDictionary<string, JsonNode?> Dictionary => _dictionary ?? InitializeDictionary();
80private protected override JsonNode? GetItem(int index) => GetAt(index).Value;
81private protected override void SetItem(int index, JsonNode? value) => SetAt(index, value);
83internal override JsonNode DeepCloneCore()
85GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement);
99foreach (KeyValuePair<string, JsonNode?> item in dictionary)
107internal string GetPropertyName(JsonNode? node)
109KeyValuePair<string, JsonNode?>? item = FindValue(node);
124public bool TryGetPropertyValue(string propertyName, out JsonNode? jsonNode) => TryGetPropertyValue(propertyName, out jsonNode, out _);
141public bool TryGetPropertyValue(string propertyName, out JsonNode? jsonNode, out int index)
153GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement);
175GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement);
187foreach (KeyValuePair<string, JsonNode?> entry in Dictionary)
205internal override bool DeepEqualsCore(JsonNode node)
215OrderedDictionary<string, JsonNode?> currentDict = Dictionary;
216OrderedDictionary<string, JsonNode?> otherDict = jsonObject.Dictionary;
223foreach (KeyValuePair<string, JsonNode?> item in currentDict)
225if (!otherDict.TryGetValue(item.Key, out JsonNode? jsonNode) || !DeepEquals(item.Value, jsonNode))
238internal JsonNode? GetItem(string propertyName)
242if (TryGetPropertyValue(propertyName, out JsonNode? value))
251internal override void GetPath(ref ValueStringBuilder path, JsonNode? child)
272internal void SetItem(string propertyName, JsonNode? value)
276OrderedDictionary<string, JsonNode?> dict = Dictionary;
281JsonNode? replacedValue = dict.GetAt(index).Value;
295private void DetachParent(JsonNode? item)
302private KeyValuePair<string, JsonNode?>? FindValue(JsonNode? value)
304foreach (KeyValuePair<string, JsonNode?> item in Dictionary)
337foreach (KeyValuePair<string, JsonNode?> item in _node)
352public JsonNode? Value;
System\Text\Json\Nodes\JsonObject.IDictionary.cs (31)
13private OrderedDictionary<string, JsonNode?>? _dictionary;
26public void Add(string propertyName, JsonNode? value)
43public bool TryAdd(string propertyName, JsonNode? value) => TryAdd(propertyName, value, out _);
55public bool TryAdd(string propertyName, JsonNode? value, out int index)
79public void Add(KeyValuePair<string, JsonNode?> property) => Add(property.Key, property.Value);
86OrderedDictionary<string, JsonNode?>? dictionary = _dictionary;
94foreach (JsonNode? node in dictionary.Values)
138bool success = Dictionary.Remove(propertyName, out JsonNode? removedNode);
148/// Determines whether the <see cref="JsonObject"/> contains a specific property name and <see cref="JsonNode"/> reference.
154bool ICollection<KeyValuePair<string, JsonNode?>>.Contains(KeyValuePair<string, JsonNode?> item) =>
155((IDictionary<string, JsonNode?>)Dictionary).Contains(item);
174void ICollection<KeyValuePair<string, JsonNode?>>.CopyTo(KeyValuePair<string, JsonNode?>[] array, int index) =>
175((IDictionary<string, JsonNode?>)Dictionary).CopyTo(array, index);
183public IEnumerator<KeyValuePair<string, JsonNode?>> GetEnumerator() => Dictionary.GetEnumerator();
194bool ICollection<KeyValuePair<string, JsonNode?>>.Remove(KeyValuePair<string, JsonNode?> item) => Remove(item.Key);
199ICollection<string> IDictionary<string, JsonNode?>.Keys => Dictionary.Keys;
204ICollection<JsonNode?> IDictionary<string, JsonNode?>.Values => Dictionary.Values;
220bool IDictionary<string, JsonNode?>.TryGetValue(string propertyName, out JsonNode? jsonNode)
230bool ICollection<KeyValuePair<string, JsonNode?>>.IsReadOnly => false;
240private OrderedDictionary<string, JsonNode?> InitializeDictionary()
242GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement);
246OrderedDictionary<string, JsonNode?> newDictionary = CreateDictionary(Options);
252JsonNode? node = JsonNodeConverter.Create(jElementProperty.Value, Options);
260OrderedDictionary<string, JsonNode?>? exchangedDictionary = Interlocked.CompareExchange(ref _dictionary, newDictionary, null);
278private static OrderedDictionary<string, JsonNode?> CreateDictionary(JsonNodeOptions? options, int capacity = 0)
291private void GetUnderlyingRepresentation(out OrderedDictionary<string, JsonNode?>? dictionary, out JsonElement? jsonElement)
System\Text\Json\Nodes\JsonObject.IList.cs (17)
15public KeyValuePair<string, JsonNode?> GetAt(int index) => Dictionary.GetAt(index);
24public void SetAt(int index, string propertyName, JsonNode? value)
28OrderedDictionary<string, JsonNode?> dictionary = Dictionary;
29KeyValuePair<string, JsonNode?> existing = dictionary.GetAt(index);
40public void SetAt(int index, JsonNode? value)
42OrderedDictionary<string, JsonNode?> dictionary = Dictionary;
43KeyValuePair<string, JsonNode?> existing = dictionary.GetAt(index);
67public void Insert(int index, string propertyName, JsonNode? value)
80KeyValuePair<string, JsonNode?> existing = Dictionary.GetAt(index);
86KeyValuePair<string, JsonNode?> IList<KeyValuePair<string, JsonNode?>>.this[int index]
93int IList<KeyValuePair<string, JsonNode?>>.IndexOf(KeyValuePair<string, JsonNode?> item) => ((IList<KeyValuePair<string, JsonNode?>>)Dictionary).IndexOf(item);
96void IList<KeyValuePair<string, JsonNode?>>.Insert(int index, KeyValuePair<string, JsonNode?> item) => Insert(index, item.Key, item.Value);
99void IList<KeyValuePair<string, JsonNode?>>.RemoveAt(int index) => RemoveAt(index);
System\Text\Json\Serialization\JsonSerializer.Write.Node.cs (19)
15/// Converts the provided value into a <see cref="JsonNode"/>.
18/// <returns>A <see cref="JsonNode"/> representation of the JSON value.</returns>
27public static JsonNode? SerializeToNode<TValue>(TValue value, JsonSerializerOptions? options = null)
34/// Converts the provided value into a <see cref="JsonNode"/>.
36/// <returns>A <see cref="JsonNode"/> representation of the value.</returns>
52public static JsonNode? SerializeToNode(object? value, Type inputType, JsonSerializerOptions? options = null)
60/// Converts the provided value into a <see cref="JsonNode"/>.
63/// <returns>A <see cref="JsonNode"/> representation of the value.</returns>
69public static JsonNode? SerializeToNode<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
78/// Converts the provided value into a <see cref="JsonNode"/>.
80/// <returns>A <see cref="JsonNode"/> representation of the value.</returns>
89public static JsonNode? SerializeToNode(object? value, JsonTypeInfo jsonTypeInfo)
98/// Converts the provided value into a <see cref="JsonNode"/>.
100/// <returns>A <see cref="JsonNode"/> representation of the value.</returns>
115public static JsonNode? SerializeToNode(object? value, Type inputType, JsonSerializerContext context)
124private static JsonNode? WriteNode<TValue>(in TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
134return JsonNode.Parse(output.WrittenSpan, options.GetNodeOptions(), options.GetDocumentOptions());
142private static JsonNode? WriteNodeAsObject(object? value, JsonTypeInfo jsonTypeInfo)
152return JsonNode.Parse(output.WrittenSpan, options.GetNodeOptions(), options.GetDocumentOptions());