7 types derived from JsonNode
System.Text.Json (7)
System\Text\Json\Nodes\JsonArray.cs (1)
21public sealed partial class JsonArray : JsonNode
System\Text\Json\Nodes\JsonArray.IList.cs (2)
9public sealed partial class JsonArray : JsonNode, IList<JsonNode?>
System\Text\Json\Nodes\JsonObject.cs (1)
19public sealed partial class JsonObject : JsonNode
System\Text\Json\Nodes\JsonObject.IDictionary.cs (1)
11public partial class JsonObject : IDictionary<string, JsonNode?>
System\Text\Json\Nodes\JsonObject.IList.cs (1)
9public partial class JsonObject : IList<KeyValuePair<string, JsonNode?>>
System\Text\Json\Nodes\JsonValue.cs (1)
14public abstract partial class JsonValue : JsonNode
3593 references to JsonNode
AnalyzeCiFailure (79)
AnalysisDiagnostics.cs (3)
146internal JsonNode ReceiptSnapshot() => _receipts.DeepClone(); 173var outcome = DiagnosticTextSanitizer.SanitizeJson(JsonNode.Parse(TransientJson.Write(progress.CreateOutcome(status))), limit: 500, multiline: true)!;
AnalysisPublicationQueries.cs (2)
34JsonNode? response; 63var match = comments.Where(comment => CiFailureJson.Text(CiFailureJson.Field(CiFailureJson.Field(comment, "user"), "login")) == "github-actions[bot]" &&
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);
AnalysisPublisher.Overflow.cs (1)
112var occurrence = ((JsonArray)item.History["occurrences"]!).First(value =>
AnalysisRerunner.cs (1)
95JsonNode? current;
BranchHistoryReader.cs (7)
49async Task<JsonNode?> ReadWorkflowRunsPageAsync(int number) => await github.GetAsync( 53static bool HasValidWorkflowRunRows(JsonNode? page) => page is JsonObject && Field(page, "workflow_runs") is JsonArray rows && 57var first = await ReadWorkflowRunsPageAsync(number: 1); 83var next = await ReadWorkflowRunsPageAsync(page); 98var newest = rows.Where(run => string.CompareOrdinal(Text(run!["created_at"]), Time(start)) >= 0 && 116JsonNode? pages; 143foreach (var commit in commits)
CiFailureJson.cs (16)
38public static JsonNode? Read(string file) => Parse(File.ReadAllText(file)); 42internal static T? ToContract<T>(JsonNode? node) => node.Deserialize<T>(s_contractOptions); 46internal static JsonNode? ToNode<T>(T value) => JsonSerializer.SerializeToNode(value, s_contractOptions); 91public static JsonNode? Parse(string text) 106private static JsonNode? Project(JsonElement node) 130return JsonNode.Parse(node.GetRawText()); 134public static JsonNode? Field(JsonNode? node, string key) => node is JsonObject obj ? obj[key] : null; 135public static string? Text(JsonNode? node) 148public static NormalizedJsonNumber? ReadNormalizedNumber(JsonNode? node) 151public static bool IsPositiveInteger(JsonNode? node) 160public static bool IsFalse(JsonNode? node) => node is JsonValue value && value.TryGetValue<bool>(out var boolean) && !boolean; 164public static string GetValueText(JsonNode? node) 170JsonNode value => value.ToJsonString(), 174public static void Write(string file, JsonNode? node) => File.WriteAllText( 198public static bool Safe(JsonNode? node, int max, bool multiline = false)
CollectionProjection.cs (2)
27internal static CollectedPrMetadata ProjectPullRequest(JsonNode metadata) => new() 76JsonNode run,
DiagnosticTextSanitizer.cs (5)
72internal static JsonNode? SanitizeJson(JsonNode? node, int limit = 500, bool multiline = false) 81internal static JsonNode? SanitizeJson(JsonElement node, int limit, bool multiline) 92internal static JsonNode? SanitizeCause(JsonNode? node)
Infrastructure\AnalysisGitHubClient.cs (7)
15internal Task<JsonNode?> GetAsync(string endpoint) 26foreach (var page in (JsonArray)response!) 29var rows = property is null ? page : CiFailureJson.Field(page, property); 35foreach (var row in (JsonArray)rows!) 50internal Task<JsonNode?> SendJsonAsync(HttpMethod method, string endpoint, JsonNode? body, HttpStatusCode expectedStatus) 53internal async Task SendAsync(HttpMethod method, string endpoint, JsonNode? body, HttpStatusCode expectedStatus)
Infrastructure\GitHubJson.cs (2)
13internal static long ReadRequiredId(JsonNode? node) 21internal static bool TryReadId(JsonNode? node, out long id)
InvocationCapture.cs (1)
11internal Dictionary<string, JsonNode?> Documents { get; } = new(StringComparer.Ordinal);
PriorCauseCatalogue.cs (1)
29var cause = CiFailureJson.ToContract<PriorCauseRecord>(System.Text.Json.Nodes.JsonNode.Parse(pair.Value.Text))
RecoveryCaptureWriter.cs (1)
50var diagnostic = JsonSerializer.SerializeToNode(
TestResultArtifacts.cs (2)
194internal sealed record WorkflowArtifact(JsonNode? Id, string? Name, JsonNode? SizeInBytes, bool? Expired, string? CreatedAt);
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);
WorkflowRunEvidenceCollector.cs (9)
32private readonly Dictionary<string, JsonNode?> _documents; 41private void CaptureDiagnostic(string name, JsonNode? value) => _documents["diagnostics/" + name] = value; 76private static bool IsFailedOrInterrupted(JsonNode? conclusion) => Text(conclusion) is "failure" or "cancelled" or "timed_out"; 104var runMetadata = await gitHub.GetAsync($"repos/{_repository}/actions/runs/{runIdText}" + 339static (long? Number, bool Ambiguous) SelectSinglePullRequestNumber(IEnumerable<JsonNode?> candidates) 423foreach (var job in failedJobs) 581new JsonArray(files.Select(file => (JsonNode)new JsonObject( 592var pullRequest = await gitHub.GetAsync($"repos/{_repository}/pulls/{subjectPrNumber}"); 725var artifactMetadata = artifacts.First(candidate => ReadNormalizedNumber(Field(candidate, "id")) == ReadNormalizedNumber(selection.Artifact.Id));
Workflows\AspireCiWorkflowConventions.cs (1)
25var firstFailure = (job["steps"] as JsonArray ?? [])
AnalyzeCiFailure.TestHost (4)
tests\AnalyzeCiFailure.Tests\TestServices\GitHubFixtureHandler.cs (4)
40var body = request.Content is null ? null : JsonNode.Parse(await request.Content.ReadAsStringAsync(cancellationToken)) as JsonObject; 122foreach (var label in body!["labels"]!.AsArray()) 205var response = new JsonObject { ["html_url"] = url, [createdKind == "issue" ? "number" : "id"] = JsonNode.Parse(digits.Length == 0 ? "0" : digits) }; 212if (paginated && JsonNode.Parse(result.Output) is JsonArray pages && pages.Count > 0)
AnalyzeCiFailure.Tests (432)
AnalyzeCiFailureAlternateWorkflowTests.cs (8)
407var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "artifacts.json")))!; 454var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "artifacts.json")))!; 465var jobs = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "jobs.json")))!; 481var pages = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(responses, "artifacts.json")))!;
AnalyzeCiFailureBranchHistoryTests.cs (1)
59var candidates = JsonNode.Parse("""
AnalyzeCiFailureCohesionTests.cs (1)
72var json = JsonNode.Parse(TransientJson.Write(outcome))!.AsObject();
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();
AnalyzeCiFailureCSharpRerunTests.cs (2)
109var envelope = System.Text.Json.Nodes.JsonNode.Parse(await File.ReadAllTextAsync(output))!;
AnalyzeCiFailureDiagnosticsTests.cs (29)
28var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 29var log = Assert.Single(summary["events"]!.AsArray(), item => item!["action"]!.GetValue<string>() == "job-log")!; 45var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 47var jobs = Assert.Single(summary["events"]!.AsArray(), item => item!["action"]!.GetValue<string>() == "jobs")!; 65var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 83var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 94var recovery = JsonNode.Parse(File.ReadAllText(Path.Combine(RecoveryDirectory("publication"), "manifest.json")))!; 123var summary = JsonNode.Parse(File.ReadAllText(Path.Combine(invocation.RootDirectory, "diagnostics", "summary.json")))!; 137var manifest = JsonNode.Parse(File.ReadAllText(Path.Combine(RecoveryDirectory("replay"), "manifest.json")))!; 139Assert.Equal("failed", JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!["status"]!.GetValue<string>()); 152var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 164var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 195var summary = JsonNode.Parse(text)!; 218var summary = JsonNode.Parse(text)!; 237var summary = JsonNode.Parse(File.ReadAllText(DiagnosticSummary))!; 261var summary = JsonNode.Parse(File.ReadAllText(Path.Combine(invocation.DiagnosticsDirectory, "summary.json")))!;
AnalyzeCiFailureEnumTests.cs (1)
35var value = CiFailureJson.Parse(json);
AnalyzeCiFailureEvidenceTests.cs (22)
55var proposal = JsonNode.Parse(await File.ReadAllTextAsync(file))!; 56var test = proposal["failed_tests"]![0]!; 80Assert.True(JsonNode.DeepEquals(proposal, JsonNode.Parse(await File.ReadAllTextAsync(file)))); 90var node = JsonNode.Parse(TransientJson.Write(proposal))!; 108["job_id"] = JsonNode.Parse("9007199254740993.0"), 152var projection = JsonNode.Parse(await File.ReadAllTextAsync(output))!.AsObject(); 168var document = JsonNode.Parse(TransientJson.Write(evidence))!; 169var test = document["test_evidence"]!["failures"]![0]!; 172test["ref"] = JsonNode.Parse(value); 176test["sources"]![0]![field == "result_format" ? "format" : field] = JsonNode.Parse(value); 270var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!; 274foreach (var test in summary["failed_tests"]!.AsArray()) 318["summary"] = JsonNode.Parse(history.Output), 350var summary = JsonNode.Parse(await File.ReadAllTextAsync(output))!; 437var summary = JsonNode.Parse(await File.ReadAllTextAsync(output))!;
AnalyzeCiFailureFixtures.cs (8)
59var node = File.Exists(path) ? CiFailureJson.Read(path) : null; 66var node = File.Exists(paths.CandidateMerges) ? CiFailureJson.Read(paths.CandidateMerges) : null; 81JsonNode? Read(string name) 89var context = Read("run-context.json")!; 90var metadata = Read("run.json")!; 91var report = CiFailureJson.Read(Path.Combine(output, "analysis-result.json"))!; 133var docs = new Dictionary<string, JsonNode?>(StringComparer.Ordinal); 186var cause = CiFailureJson.Read(path)!;
AnalyzeCiFailureGitHubJsonTests.cs (4)
20var node = JsonNode.Parse(json); 43var node = JsonNode.Parse(json);
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")))!;
AnalyzeCiFailureOccurrenceTests.cs (10)
188var collected = JsonNode.Parse(await File.ReadAllTextAsync(trustedPath))!; 189foreach (var test in collected.AsArray()) 196var summary = JsonNode.Parse(await File.ReadAllTextAsync(summaryPath))!; 197foreach (var test in summary["failed_tests"]!.AsArray()) 224JsonNode.DeepEquals(JsonNode.Parse(firstHistory.Output), JsonNode.Parse(replayHistory.Output)), 230["occurrences"] = JsonNode.Parse(replayHistory.Output)!["occurrences"]!.DeepClone(),
AnalyzeCiFailureOverflowTests.cs (15)
42var record = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_workspace.Path, "memory-repo/runs/123.json")))!; 73var issues = JsonNode.Parse(await File.ReadAllTextAsync(issuePath))!; 77var pages = JsonNode.Parse(await File.ReadAllTextAsync(pagesPath))!.AsArray(); 91var updated = JsonNode.Parse(await File.ReadAllTextAsync(pagesPath))!.AsArray(); 113var issues = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsArray(); 114var issue = issues[0]!; 129var duplicate = issue.DeepClone(); 153var report = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 158var cause = JsonNode.Parse(await File.ReadAllTextAsync(file))!; 191var cause = JsonNode.Parse(CreateCause(id, "infra-failure", jobId: 123))!;
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")))!;
AnalyzeCiFailureProgressTests.cs (8)
72var summary = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(invocation.DiagnosticsDirectory, "summary.json")))!; 97var summary = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(invocation.DiagnosticsDirectory, "summary.json")))!; 111var summary = JsonNode.Parse(await File.ReadAllTextAsync(DiagnosticSummary))!; 132var summary = JsonNode.Parse(await File.ReadAllTextAsync(DiagnosticSummary))!;
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>());
AnalyzeCiFailureRenderingTests.cs (1)
157var cause = CiFailureJson.Read(args[0])!;
AnalyzeCiFailureRuleTests.cs (4)
47var facts = JsonNode.Parse(TransientJson.Write(evidence))!; 48var decisions = JsonNode.Parse(TransientJson.Write(proposal))!;
AnalyzeCiFailureStorageTests.cs (1)
142capture.Documents.Add("diagnostics/run.json", System.Text.Json.Nodes.JsonNode.Parse("""{"message":"password=private-value"}"""));
AnalyzeCiFailureTextTests.cs (5)
140var node = json is null ? null : AnalyzeCiFailure.CiFailureJson.Parse(json); 168var value = json is null ? null : JsonNode.Parse(json); 216var node = JsonNode.Parse("\"bad\\ud800\"");
AnalyzeCiFailureTransientContractTests.cs (3)
38var json = JsonNode.Parse(TransientJson.Write(AnalyzeCiFailureFixtures.CreateInfrastructureProposal(evidence)))!; 40json["tests"] = JsonNode.Parse("""[{"ref":"test-1","classification":"transient-infra","reason":"Runner kernel incompatibility"}]""");
AnalyzeCiFailureWorkflowAdapterTests.cs (3)
56var job = JsonNode.Parse($$""" 131var artifacts = TestResultArtifacts.ReadArtifacts(JsonNode.Parse(""" 157var artifacts = TestResultArtifacts.ReadArtifacts(JsonNode.Parse("""
AnalyzeCiFailureWorkflowTests.cs (44)
89var trusted = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(evidence))!; 90var decision = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 484var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 485node["run"]!["id"] = System.Text.Json.Nodes.JsonNode.Parse(runId); 486node["jobs"]![0]!["job_id"] = System.Text.Json.Nodes.JsonNode.Parse(jobId); 487node["jobs"]![0]!["reason"] = System.Text.Json.Nodes.JsonNode.Parse(reason); 488node["pr"] = System.Text.Json.Nodes.JsonNode.Parse(subjectPr); 633var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 657if (cause == "not-json" || System.Text.Json.Nodes.JsonNode.Parse(cause)?["title"] is null) 664var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1310var input = System.Text.Json.Nodes.JsonNode.Parse(analysis)!; 1311var context = System.Text.Json.Nodes.JsonNode.Parse(runContext)!; 1313var facts = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(evidence))!; 1314var decisions = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1366var facts = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(evidence))!; 1367var decisions = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1368var input = System.Text.Json.Nodes.JsonNode.Parse(analysis)!; 1383var decision = decisions["tests"]![0]!; 1384var collected = facts["test_evidence"]!["failures"]![0]!; 1599var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1700var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1795var node = System.Text.Json.Nodes.JsonNode.Parse(AnalyzeCiFailure.TransientJson.Write(proposal))!; 1796node["causes"]![0]!["job_ids"] = System.Text.Json.Nodes.JsonNode.Parse(jobIds); 3148Assert.Single(System.Text.Json.Nodes.JsonNode.Parse(await File.ReadAllTextAsync(outputPath))!.AsArray()); 4303var definition = System.Text.Json.Nodes.JsonNode.Parse( 4305var existing = System.Text.Json.Nodes.JsonNode.Parse( 4307var occurrence = System.Text.Json.Nodes.JsonNode.Parse("""{"run_id":2,"observed_at":"2026-08-31T12:00:00Z"}""")!.AsObject(); 5239var jobs = AnalyzeCiFailure.CiFailureJson.Read(paths.FailedJobs); 5259.Select(text => System.Text.Json.Nodes.JsonNode.Parse(text)).ToArray());
GitHubApiClientTests.cs (3)
550var json = await client.SendJsonAsync(HttpMethod.Post, "issues", JsonNode.Parse("""{"title":"issue"}"""), HttpStatusCode.Created, default); 552await client.SendAsync(HttpMethod.Post, "rerun", JsonNode.Parse("""{"title":"issue"}"""), HttpStatusCode.Created, default);
TestServices\GitHubFixtureHandler.cs (4)
40var body = request.Content is null ? null : JsonNode.Parse(await request.Content.ReadAsStringAsync(cancellationToken)) as JsonObject; 122foreach (var label in body!["labels"]!.AsArray()) 205var response = new JsonObject { ["html_url"] = url, [createdKind == "issue" ? "number" : "id"] = JsonNode.Parse(digits.Length == 0 ? "0" : digits) }; 212if (paginated && JsonNode.Parse(result.Output) is JsonArray pages && pages.Count > 0)
aspire (141)
Agents\AgentConfiguration.cs (7)
41if (JsonNode.DeepEquals(original ?? new JsonObject(), root)) 72var root = JsonNode.Parse(json, documentOptions: GetParseOptions()); 94var root = JsonNode.Parse(stream, documentOptions: GetParseOptions()); 213var root = JsonNode.Parse(stream, documentOptions: GetParseOptions());
Agents\AspireSkills\AspireSkillsRemoteConfiguration.cs (8)
86target.Add((JsonNode?)preferred); 98if (!root.TryGetPropertyValue("skills", out var skills)) 184if (marketplaces is not null && marketplaces.TryGetPropertyValue(marketplaceName, out var marketplaceNode)) 253if (!parent.TryGetPropertyValue(key, out var node)) 276if (!parent.TryGetPropertyValue(key, out var node)) 287foreach (var value in array) 296public static string? String(JsonNode? node) 301if (!parent.TryGetPropertyValue(key, out var node))
Agents\ClaudeCode\ClaudeCodeAgentClient.cs (7)
118JsonNode? parsed; 121parsed = JsonNode.Parse(content); 148if (settings.TryGetPropertyValue("hooks", out var hooksNode)) 163if (hooks.TryGetPropertyValue("PostToolUse", out var postToolUseNode)) 181JsonNode hookGroup = new JsonObject 188["args"] = new JsonArray(args.Select(arg => (JsonNode?)JsonValue.Create(arg)).ToArray()), 231private static bool IsAspireHook(JsonNode? node)
Agents\Copilot\CopilotAgentClient.cs (1)
138["args"] = new JsonArray(args.Select(arg => (JsonNode?)JsonValue.Create(arg)).ToArray()),
Agents\McpConfigFileHelper.cs (4)
54JsonNode? root; 57root = JsonNode.Parse(text, documentOptions: documentOptions); 104var serverContainer = config[serverContainerKey]; 144private static bool MatchesArgument(JsonNode? argument, string expected)
Agents\OpenCode\OpenCodeAgentClient.cs (4)
97if (!config.TryGetPropertyValue("skills", out var skills)) 109foreach (var node in paths ?? []) 154if (servers is not null && servers.TryGetPropertyValue("aspire", out var server)) 204if (mcp is not null && mcp.TryGetPropertyValue("servers", out var servers))
Backchannel\BackchannelJsonSerializerContext.cs (2)
63[JsonSerializable(typeof(Dictionary<string, JsonNode?>))] 65[JsonSerializable(typeof(JsonNode))]
Backchannel\ResourceSnapshotMapper.cs (3)
177snapshot.Properties.TryGetValue(KnownProperties.Resource.WaitingFor, out var waitingForProperty) && 210private static string? ConvertJsonNodeToString(JsonNode? node) 215private static bool TryConvertJsonNodeToString(JsonNode? node, [System.Diagnostics.CodeAnalysis.NotNullWhen(returnValue: true)] out string? value)
Commands\DescribeCommand.cs (2)
35[JsonSerializable(typeof(JsonNode))] 36[JsonSerializable(typeof(Dictionary<string, JsonNode?>))]
Commands\InitCommand.cs (1)
620settings = JsonNode.Parse(existingContent)?.AsObject() ?? new JsonObject();
Commands\ResourceCommand.cs (3)
151var commandArguments = commandArgumentsResult.Arguments; 189JsonNode? commandArguments, 255private static (JsonNode? Arguments, string? ErrorMessage) CreateCommandArguments(ResourceSnapshotCommand? command, string[] capturedArguments, CommandArgumentParseMode parseMode)
Commands\ResourceCommandHelper.cs (2)
40JsonNode? arguments, 69JsonNode? arguments,
Commands\Sdk\SdkDumpCommand.cs (1)
843public JsonNode? Value { get; set; }
Commands\TerminalResourceResolver.cs (1)
91if (snapshot.Properties.TryGetValue(KnownProperties.Terminal.ReplicaIndex, out var property))
Configuration\ConfigSourceService.cs (2)
520var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path, cancellationToken), 736var configuration = JsonNode.Parse(json, documentOptions: ConfigurationHelper.ParseOptions) as JsonObject
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)
Mcp\Tools\ExecuteResourceCommandTool.cs (1)
83JsonNode? commandArguments = null;
Mcp\Tools\ListResourcesTool.cs (2)
503if (snapshot.Properties.TryGetValue(KnownProperties.Resource.Source, out var explicitSourceNode) && 539if (snapshot.Properties.TryGetValue(propertyName, out var value) &&
Mcp\Tools\McpToolHelpers.cs (1)
372if (snapshot.Properties.TryGetValue(KnownProperties.Resource.ExcludeFromMcp, out var value) && value is not null)
Migrations\TypeScriptAppHostMigration.cs (6)
200if (JsonNode.Parse(File.ReadAllText(configPath)) is not JsonObject root || 242if (JsonNode.Parse( 255foreach (var entry in include) 261rewritten.Add((JsonNode?)JsonValue.Create(LegacyTypeScriptAppHost.RewriteTsConfigIncludeEntry(value.GetValue<string>()))); 288if (JsonNode.Parse(File.ReadAllText(packageJsonPath)) is not JsonObject root || 304scripts[script.Key] = (JsonNode?)JsonValue.Create(rewritten);
Npm\SigstoreNpmProvenanceChecker.cs (6)
187JsonNode? doc; 190doc = JsonNode.Parse(attestationJson); 198var attestationsNode = doc?["attestations"]; 204foreach (var attestation in attestations) 211var predicateTypeNode = attestationObj["predicateType"]; 232var bundleNode = attestationObj["bundle"];
Projects\FallbackProjectParser.cs (2)
199packageRefArray.Add((JsonNode?)packageObj); 210projectRefArray.Add((JsonNode?)projectObj);
Projects\NativeAppHostServerProject.cs (4)
128["providers"] = new JsonArray(providers.Select(provider => (JsonNode)new JsonObject 133new KeyValuePair<string, JsonNode?>(file.Key, JsonValue.Create(file.Value)))), 134["exports"] = new JsonArray(provider.Descriptor.Exports.Select(module => (JsonNode?)JsonValue.Create(module)).ToArray()) 156runtimeProviders.Add((JsonNode)new JsonObject
Projects\NativeProviderDescriptor.cs (2)
20if (JsonNode.Parse(json) is not JsonObject descriptor || 38private static string ReadString(JsonNode? value)
Projects\RepositoryToolUpdater.cs (1)
285var content = JsonNode.Parse(originalContent)?.AsObject() ?? throw new JsonException("Expected a JSON object.");
Projects\TypeScriptAppHostToolchainResolver.cs (1)
363var packageJson = JsonNode.Parse(File.ReadAllText(packageJsonPath), documentOptions: ConfigurationHelper.ParseOptions) as JsonObject;
Scaffolding\PackageJsonMerger.cs (6)
62existingJson = JsonNode.Parse(existingContent, documentOptions: s_jsonDocumentOptions) as JsonObject; 63scaffoldJson = JsonNode.Parse(scaffoldContent, documentOptions: s_jsonDocumentOptions) as JsonObject; 123var targetValue = existing[key]; 237var existingVersionNode = existingDeps[packageName]; 269var existingVersionNode = existingDeps[packageName]; 334var targetValue = target[key];
Scaffolding\ScaffoldingService.cs (4)
330packageJson = JsonNode.Parse(existingContent, documentOptions: s_scaffoldJsonDocumentOptions) as JsonObject 711foreach (var entry in scaffoldArray) 713if (!existingArray.Any(present => JsonNode.DeepEquals(present, entry))) 730return JsonNode.Parse(content, documentOptions: s_scaffoldJsonDocumentOptions) as JsonObject;
src\Aspire.Hosting\Backchannel\BackchannelDataTypes.cs (3)
455public JsonNode? Arguments { get; init; } 494public JsonNode? Arguments { get; init; } 1191public Dictionary<string, JsonNode?> Properties { get; init; } = [];
src\Shared\ConsoleLogs\SharedAIHelpers.cs (6)
45public static int EstimateSerializedJsonTokenSize(JsonNode node) 160var jsonArray = new JsonArray(spans.Select(s => GetSpanDto(s, context, getResourceName, dashboardBaseUrl)).ToArray<JsonNode>()); 174var jsonArray = new JsonArray(logRecords.Select(l => GetLogEntryDto(l, context, getResourceName, dashboardBaseUrl)).ToArray<JsonNode>()); 188var jsonArray = new JsonArray(traces.Select(t => GetTraceDto(t, context, getResourceName, dashboardBaseUrl)).ToArray<JsonNode>()); 233var linkObjects = span.Links.Select(link => (JsonNode)new JsonObject 385var spanObjects = new List<JsonNode>();
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
src\Shared\Json\JsonFlattener.cs (1)
38if (!current.TryGetPropertyValue(key, out var existing) || existing is not JsonObject)
src\Shared\Model\Serialization\ResourceJson.cs (1)
111public Dictionary<string, JsonNode?>? Properties { get; set; }
src\Shared\Otlp\Serialization\OtlpJsonSerializerContext.cs (2)
34[JsonSerializable(typeof(JsonNode))] 35[JsonSerializable(typeof(Dictionary<string, JsonNode?>))]
src\Shared\Telemetry\InternalMicrosoftDetector.cs (5)
760if (!userConfiguration.TryGetPropertyValue("kerberosStatus", out var kerberosStatusNode) || 776foreach (var kerberosStatusNodeEntry in kerberosStatuses) 1707return JsonNode.Parse( 1878return json.TryGetPropertyValue(propertyName, out var node) && 1904return json.TryGetPropertyValue(propertyName, out var value) &&
src\Shared\UserSecrets\SecretsStore.cs (7)
16private readonly Dictionary<string, JsonNode?> _secrets; 194private static Dictionary<string, JsonNode?> Load(string path) 198return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 204return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 207var parsed = JsonNode.Parse(json, documentOptions: new JsonDocumentOptions 214return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 222var result = new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase);
Templating\TemplateSourceStore.cs (3)
27.Select(source => new KeyValuePair<string, JsonNode?>(source.Key, source.Value?.DeepClone()))); 90if (settings.TryGetPropertyValue(key, out var value)) 105var settings = JsonNode.Parse(content, nodeOptions: null, ConfigurationHelper.ParseOptions) as JsonObject
Utils\ConfigurationHelper.cs (6)
240var node = JsonNode.Parse(content, documentOptions: ParseOptions); 637var node = JsonNode.Parse(content, documentOptions: ParseOptions); 678var settings = JsonNode.Parse(content, documentOptions: ParseOptions)?.AsObject(); 772var child = parent[key];
Utils\EnvironmentChecker\DeprecatedAgentConfigCheck.cs (7)
56var config = JsonNode.Parse(content)?.AsObject(); 107if (!config.TryGetPropertyValue(serversKey, out var serversNode) || serversNode is not JsonObject servers) 112if (!servers.TryGetPropertyValue("aspire", out var aspireNode) || aspireNode is not JsonObject aspire) 117if (!aspire.TryGetPropertyValue("args", out var argsNode) || argsNode is not JsonArray args) 139if (!config.TryGetPropertyValue(serversKey, out var mcpNode) || mcpNode is not JsonObject mcp) 144if (!mcp.TryGetPropertyValue("aspire", out var aspireNode) || aspireNode is not JsonObject aspire) 149if (!aspire.TryGetPropertyValue("command", out var commandNode) || commandNode is not JsonArray command)
Utils\EnvironmentChecker\DevCertsCheck.cs (1)
538certificatesArray.Add((JsonNode)certNode);
Aspire.Cli.EndToEnd.Tests (67)
AgentCommandTests.cs (6)
503var expectedClaudeGlobalSettings = JsonNode.Parse(expectedPluginSettings)!; 504expectedClaudeGlobalSettings["hooks"] = JsonNode.Parse($$""" 555Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expected), JsonNode.Parse(bytes)),
CentralPackageManagementTests.cs (1)
416var candidates = Assert.IsType<JsonArray>(JsonNode.Parse(lsOutput));
CSharpInitTests.cs (7)
126var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"))); 141var description = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "resources.json"))); 195var config = JsonNode.Parse(configText); 198var appHostNode = config["appHost"];
CustomTemplateTests.cs (5)
44var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!; 45var greeting = config["symbols"]!["Greeting"]!; 104var listed = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "sources.json")))!.AsObject(); 188Assert.Empty(JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "empty-sources.json")))!.AsObject());
EmulatedLocalReleaseBuildTests.cs (1)
709var config = JsonNode.Parse(File.ReadAllText(configPath))?.AsObject()
GoCodegenValidationTests.cs (2)
73var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath));
GoStarterTemplateTests.cs (2)
104var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(projectRoot, "aspire.config.json")));
Helpers\CliE2ETestHelpers.cs (1)
1195? JsonNode.Parse(File.ReadAllText(configPath))?.AsObject() ?? new JsonObject()
Helpers\ConfigSourceTestContext.cs (11)
107var integrations = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_root, "integrations.json"), _cancellationToken))!.AsArray(); 292Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expected), JsonNode.Parse(actual)), 419return JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(_root, "actual-config.json"), _cancellationToken))!.AsObject(); 478var expectedSources = JsonNode.Parse($$""" 489Assert.True(JsonNode.DeepEquals(expectedSources, config["skillSources"])); 490var expectedIntegrationSources = JsonNode.Parse($$""" 497Assert.True(JsonNode.DeepEquals(expectedIntegrationSources, config["integrationSources"]));
Helpers\IntegrationHostLifetimeTestHelper.cs (2)
102var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 119var manifest = JsonNode.Parse(File.ReadAllText(manifestPath))!.AsObject();
Helpers\TypeScriptAppHostToolchainTestHelpers.cs (1)
37var packageJson = JsonNode.Parse(File.ReadAllText(packageJsonPath))?.AsObject()
IntegrationSourceTests.cs (4)
145var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(projectDirectory, "aspire.config.json"), cancellationToken))!; 176var metadata = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(packageCacheDirectory, ".nupkg.metadata"), cancellationToken))!;
ProjectReferenceTests.cs (2)
77var config = JsonNode.Parse(File.ReadAllText(configPath))?.AsObject() 314var config = JsonNode.Parse(configJson)?.AsObject()
RepositoryToolUpdateTests.cs (8)
197var expectedDotnet = JsonNode.Parse(dotnetManifest)!; 200Assert.True(JsonNode.DeepEquals(expectedDotnet, JsonNode.Parse(actualDotnet)), actualDotnet); 202var expectedNpm = JsonNode.Parse(npmManifest)!; 207Assert.True(JsonNode.DeepEquals(expectedNpm, JsonNode.Parse(actualNpm)), actualNpm);
SelfUpdateChannelPersistenceTests.cs (1)
118return JsonNode.Parse(File.ReadAllText(path))?.AsObject()
SettledNpmReleasesTests.cs (2)
55var installedManifest = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.FullName, "node_modules", PackageName, "package.json")));
SingleFileAppHostInitDotnetRunTests.cs (1)
87var runJson = JsonNode.Parse(File.ReadAllText(appHostRunJson))?.AsObject();
TypeScriptEmptyAppHostTemplateTests.cs (1)
177var config = JsonNode.Parse(File.ReadAllText(configPath))?.AsObject()
TypeScriptLegacyAppHostTests.cs (1)
135var configJson = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject();
TypeScriptMigrateAppHostTests.cs (2)
123var configJson = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 215var tsconfig = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "tsconfig.apphost.json")))!.AsObject();
TypeScriptPolyglotTests.cs (6)
353var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 448var packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); 479packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); 504var appHostPackageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(appHostDirectory, "package.json")))!.AsObject(); 520var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 523var packagesNode = config["packages"];
Aspire.Cli.Tests (333)
Agents\AgentConfigurationTests.cs (16)
40Assert.True(JsonNode.DeepEquals(inline, file)); 41Assert.True(JsonNode.DeepEquals(inline, tracked)); 63Assert.True(JsonNode.DeepEquals(file, tracked)); 289Assert.True(JsonNode.DeepEquals(config, JsonNode.Parse(await File.ReadAllTextAsync(path)))); 314var published = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 386JsonNode.Parse(await File.ReadAllTextAsync(path))!["token"]!.GetValue<string>()); 422Assert.Equal("replacement", JsonNode.Parse(await File.ReadAllTextAsync(path))!["token"]!.GetValue<string>()); 448Assert.Equal("replacement", JsonNode.Parse(await File.ReadAllTextAsync(path))!["token"]!.GetValue<string>()); 658var settings = JsonNode.Parse(await File.ReadAllTextAsync(target))!; 659Assert.True(JsonNode.DeepEquals(JsonNode.Parse(source), settings["extraKnownMarketplaces"]!["aspire-skills"]!["source"])); 691Assert.True(JsonNode.DeepEquals(AgentConfiguration.ReadObject(results[0].TargetPath), results[0].Configuration)); 695Assert.True(JsonNode.DeepEquals(results[0].Configuration, repeated[0].Configuration));
Agents\OpenCodeAgentClientTests.cs (13)
34var config = JsonNode.Parse(await File.ReadAllTextAsync(target))!; 215var original = new JsonObject { ["mcp"] = JsonNode.Parse(mcp) }; 218original["skills"] = JsonNode.Parse("""{"paths":["./team-skills"],"urls":[]}"""); 225var configured = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject(); 229Assert.True(JsonNode.DeepEquals(original["mcp"], configured["mcp"])); 230Assert.True(JsonNode.DeepEquals(original["skills"]?["paths"], skills["paths"])); 278var skills = JsonNode.Parse(await File.ReadAllTextAsync(path))!["skills"]!; 361var selectedSkills = JsonNode.Parse(await File.ReadAllTextAsync(result.TargetPath))!["skills"]; 362Assert.True(JsonNode.DeepEquals(JsonNode.Parse(pinned)!["skills"], selectedSkills));
Agents\TelemetryHookConfiguratorTests.cs (10)
33var root = JsonNode.Parse(await File.ReadAllTextAsync(hookFile).DefaultTimeout())!.AsObject(); 176var root = JsonNode.Parse(await File.ReadAllTextAsync(settingsPath).DefaultTimeout())!.AsObject(); 271Assert.Equal(!shouldReplace, hooks.Any(hook => JsonNode.DeepEquals(hook, existingHook))); 335var root = JsonNode.Parse(await File.ReadAllTextAsync(settingsPath))!.AsObject(); 342private static bool GroupContainsAspireHook(JsonNode? group) 349private static bool HookReferencesTelemetryScript(JsonNode? hook) 354private static bool JsonValueHasTelemetryScript(JsonNode? node) 357private static bool GroupContainsCommand(JsonNode? group, string command) 366foreach (var group in postToolUse) 370foreach (var hook in hooks)
Backchannel\ResourceSnapshotMapperTests.cs (3)
391Properties = new Dictionary<string, JsonNode?> 393["custom.list"] = new JsonArray((JsonNode?)JsonValue.Create("one"), (JsonNode?)JsonValue.Create("two"))
Commands\AgentInitCommandTests.cs (16)
571var openCodeConfig = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "opencode.jsonc"))); 607var openCodeConfig = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "opencode.jsonc"))); 770var config = JsonNode.Parse(await File.ReadAllTextAsync(expectedPath))!.AsObject(); 923var original = JsonNode.Parse(array 934var configured = JsonNode.Parse(content)!; 935Assert.True(JsonNode.DeepEquals(original["mcp"], configured["mcp"])); 981var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!; 1045var config = JsonNode.Parse(await File.ReadAllTextAsync( 1052var server = config["mcp"]!["servers"]!["aspire"]!; 1060var server = config["mcpServers"]!["aspire"]!;
Commands\ConfigCommandTests.cs (20)
145var settings = JsonNode.Parse(json)?.AsObject(); 185var settings = JsonNode.Parse(settingsJson)?.AsObject(); 217var settings = JsonNode.Parse(await File.ReadAllTextAsync(settingsPath))?.AsObject(); 258var settings = JsonNode.Parse(await File.ReadAllTextAsync(configPath))?.AsObject(); 299var settings = JsonNode.Parse(json)?.AsObject(); 324var settings = JsonNode.Parse(json)?.AsObject(); 356var settings = JsonNode.Parse(json)?.AsObject(); 535var settings = JsonNode.Parse(json)?.AsObject(); 795var settings = JsonNode.Parse(json)?.AsObject(); 823var json = JsonNode.Parse(await File.ReadAllTextAsync(configPath))?.AsObject(); 850Assert.True(JsonNode.DeepEquals(JsonNode.Parse("{}"), JsonNode.Parse(await File.ReadAllTextAsync(configPath)))); 875var settings = JsonNode.Parse(json)?.AsObject(); 906var settings = JsonNode.Parse(json)?.AsObject(); 937var settings = JsonNode.Parse(json)?.AsObject(); 967var settings = JsonNode.Parse(json)?.AsObject(); 1000var settings = JsonNode.Parse(json)?.AsObject(); 1026var settings = JsonNode.Parse(json)?.AsObject(); 1056var settings = JsonNode.Parse(json)?.AsObject();
Commands\ConfigSourceCommandTests.cs (11)
236ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse(""" 316git.ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse(""" 444var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject(); 760var configuration = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!; 1134var configuration = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(output, AspireConfigFile.FileName)))!; 1155var configuration = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.Path, AspireConfigFile.FileName)))!; 1182var configuration = JsonNode.Parse(await File.ReadAllTextAsync(path))!;
Commands\DescribeCommandTests.cs (3)
311Properties = new Dictionary<string, JsonNode?> 331Properties = new Dictionary<string, JsonNode?> 865Properties = new Dictionary<string, JsonNode?>
Commands\InitCommandTests.cs (13)
310var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName)))!.AsObject(); 352var config = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 397var runJson = JsonNode.Parse(File.ReadAllText(runJsonPath))!.AsObject(); 421var aspireConfig = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 475var runJson = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "apphost.run.json")))!.AsObject(); 528var aspireConfig = JsonNode.Parse(File.ReadAllText(aspireConfigPath))!.AsObject(); 667var config = JsonNode.Parse(File.ReadAllText(Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json")))!.AsObject(); 1165var merged = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!.AsObject(); 1189Assert.Equal("stable", JsonNode.Parse(await File.ReadAllTextAsync(configPath))!["channel"]!.GetValue<string>()); 1632var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 1671var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!.AsObject(); 1703var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); 1747var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject();
Commands\NewCommandLocalTemplateTests.InitConfig.cs (6)
70ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse(""" 116Assert.True(JsonNode.DeepEquals(JsonNode.Parse(original), 117JsonNode.Parse(await File.ReadAllTextAsync(settings.GetSettingsFilePath(true))))); 141ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse($$""" 230ReadConfiguration = (_, _) => Task.FromResult(("version-1", JsonNode.Parse("""
Commands\NewCommandLocalTemplateTests.NuGetValues.cs (20)
112var metadata = JsonNode.Parse(await File.ReadAllTextAsync(host))!; 274var template = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 304var template = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 310template["sources"] = JsonNode.Parse(""" 350var definition = JsonNode.Parse(await File.ReadAllTextAsync(definitionPath))!; 392var host = JsonNode.Parse(await File.ReadAllTextAsync(hostPath))!; 393var source = host["symbolInfo"]!["IntegrationVersion"]!.DeepClone(); 397var template = JsonNode.Parse(await File.ReadAllTextAsync(templatePath))!; 479var template = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 484template["sources"] = JsonNode.Parse(""" 489var host = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 490host["symbolInfo"]!["KubernetesVersion"] = JsonNode.Parse("""
Commands\NewCommandLocalTemplateTests.PromptDefaults.cs (19)
127var template = JsonNode.Parse(await File.ReadAllTextAsync(templatePath))!; 128var symbols = template["symbols"]!; 130var host = JsonNode.Parse(await File.ReadAllTextAsync(hostPath))!; 137symbols["normalizedName"] = JsonNode.Parse("""{"type":"generated","generator":"random","parameters":{"low":1,"high":10}}"""); 140symbols["normalizedName"] = JsonNode.Parse("""{"type":"bind","binding":"env:HOME"}"""); 173host["symbolInfo"]!["DisplayName"]!["valueSource"] = JsonNode.Parse( 177symbols["nestedName"] = JsonNode.Parse( 182symbols["nestedName"] = JsonNode.Parse( 187symbols["nestedName"] = JsonNode.Parse( 195symbols["nestedName"] = JsonNode.Parse( 200symbols["name"] = JsonNode.Parse( 204symbols["name"] = JsonNode.Parse( 208symbols["name"] = JsonNode.Parse( 260var template = JsonNode.Parse(await File.ReadAllTextAsync(templatePath))!; 261var symbols = template["symbols"]!; 262symbols["nestedName"] = JsonNode.Parse(
Commands\NewCommandLocalTemplateTests.SourceList.cs (1)
218return Task.FromResult(("version-1", JsonNode.Parse("""
Commands\NewCommandLocalTemplateTests.SourceListGit.cs (3)
147Assert.True(JsonNode.DeepEquals(JsonNode.Parse(RealGitTemplateSourceConfiguration), 148JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(snapshot, AspireConfigFile.FileName)))));
Commands\NewCommandLocalTemplateTests.SourceManagement.cs (12)
233var settings = JsonNode.Parse(await File.ReadAllTextAsync(globalPath))!; 245settings = JsonNode.Parse(await File.ReadAllTextAsync(globalPath))!; 355var settings = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject(); 365Assert.Equal(["other"], JsonNode.Parse(await File.ReadAllTextAsync(path))!["TemplateSources"]!.AsObject().Select(entry => entry.Key)); 367Assert.Empty(JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject()); 403var edited = JsonNode.Parse(await File.ReadAllTextAsync(path))!["templateSources"]!["company"]!.AsObject(); 406Assert.True(JsonNode.DeepEquals(settings["templateSources"]!["company"]!["futureFeature"], edited["futureFeature"])); 413var deleted = JsonNode.Parse(await File.ReadAllTextAsync(path))!["templateSources"]!["company"]!.AsObject(); 415Assert.True(JsonNode.DeepEquals(settings["templateSources"]!["company"]!["futureFeature"], deleted["futureFeature"])); 422var renamed = JsonNode.Parse(await File.ReadAllTextAsync(path))!["templateSources"]!["company"]!.AsObject(); 490Assert.False(JsonNode.Parse(await File.ReadAllTextAsync(path))!["templateSources"]!["broken"]!.GetValue<bool>());
Commands\ResourceCommandTests.cs (4)
1805var json = JsonNode.Parse(output.ToString()); 2320private static void AssertJsonObject(JsonNode? actual, params (string Name, string? Value)[] expected) 2328Assert.True(actualObject.TryGetPropertyValue(name, out var actualValue), $"Expected argument '{name}' to exist.");
Commands\SecretCommandTests.cs (4)
234var listed = JsonNode.Parse(string.Join(Environment.NewLine, outputWriter.Logs))!; 915SecretsStore.SaveJson(path, JsonNode.Parse(""" 934var persisted = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject();
Commands\TelemetryTestHelper.cs (2)
133var node = JsonNode.Parse(compactJson);
Commands\TelemetryTracesCommandTests.cs (3)
137var items = JsonNode.Parse(jsonLine)!.AsArray(); 140var item = items[0]!; 225var items = JsonNode.Parse(jsonLine)!.AsArray();
Commands\TemplateSourceStartupTests.cs (7)
118Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expected), JsonNode.Parse(File.ReadAllText(globalPath)))); 146JsonNode.Parse(File.ReadAllText(migratedPath))!["templateSources"]!["company"]!["repository"]!.GetValue<string>()); 258await ConfigurationHelper.WriteSettingsFileAtomicallyAsync(target, JsonNode.Parse(""" 264Assert.True(JsonNode.Parse(await File.ReadAllTextAsync(destination))!["features"]!["defaultWatchEnabled"]!.GetValue<bool>()); 356Assert.Equal("stable", JsonNode.Parse(File.ReadAllText(migratedPath))!["channel"]!.GetValue<string>());
Commands\TerminalResourceResolverTests.cs (2)
252Properties = new() { [KnownProperties.Terminal.ReplicaIndex] = JsonNode.Parse(json) } 349private static Dictionary<string, JsonNode?> Properties(string? replicaIndex)
Commands\UpdateCommandRepositoryToolsTests.cs (15)
53var packageJson = JsonNode.Parse(await File.ReadAllTextAsync(npmManifest, cancellationToken))!; 67Assert.Equal("13.5.4", JsonNode.Parse(await File.ReadAllTextAsync(dotnetManifest))!["tools"]!["aspire.cli"]!["version"]!.GetValue<string>()); 68Assert.Equal("^13.5.4", JsonNode.Parse(await File.ReadAllTextAsync(npmManifest))!["devDependencies"]![RepositoryToolUpdater.NpmPackageId]!.GetValue<string>()); 87var dotnet = JsonNode.Parse(await File.ReadAllTextAsync(dotnetManifest))!; 90var npm = JsonNode.Parse(await File.ReadAllTextAsync(npmManifest))!; 174Assert.Equal("99.0.0", JsonNode.Parse(await File.ReadAllTextAsync(dotnetManifest))!["tools"]!["aspire.cli"]!["version"]!.GetValue<string>()); 175Assert.Equal("^99.0.0", JsonNode.Parse(await File.ReadAllTextAsync(npmManifest))!["devDependencies"]![RepositoryToolUpdater.NpmPackageId]!.GetValue<string>()); 321Assert.Equal("13.5.4", JsonNode.Parse(await File.ReadAllTextAsync(selectedManifest))!["tools"]!["aspire.cli"]!["version"]!.GetValue<string>()); 547Assert.Equal(targetVersion, JsonNode.Parse(await File.ReadAllTextAsync(dotnetManifest))!["tools"]!["aspire.cli"]!["version"]!.GetValue<string>()); 548Assert.Equal("^" + targetVersion, JsonNode.Parse(await File.ReadAllTextAsync(npmManifest))!["devDependencies"]![RepositoryToolUpdater.NpmPackageId]!.GetValue<string>()); 549var config = JsonNode.Parse(await File.ReadAllTextAsync(configPath))!;
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("""
Configuration\ConfigurationHelperTests.cs (19)
117Assert.Equal("updated", JsonNode.Parse(await File.ReadAllTextAsync(targetPath))!["custom"]!.GetValue<string>()); 138Assert.Equal("updated", JsonNode.Parse(await File.ReadAllTextAsync(targetPath))!["custom"]!.GetValue<string>()); 183Assert.Equal("updated", JsonNode.Parse(await File.ReadAllTextAsync(path))!["custom"]!.GetValue<string>()); 209Assert.Equal("updated", JsonNode.Parse(await File.ReadAllTextAsync(file.FullName))!["custom"]!.GetValue<string>()); 388var normalized = JsonNode.Parse(File.ReadAllText(settingsPath))!.AsObject(); 416var json = JsonNode.Parse(File.ReadAllText(settingsPath)); 417var polyglotNode = json!["features"]!["polyglotSupportEnabled"]; 418var templatesNode = json!["features"]!["showAllTemplates"]; 500Assert.Equal("daily", JsonNode.Parse(File.ReadAllText(settingsPath))!["channel"]!.GetValue<string>()); 518Assert.Equal("daily", JsonNode.Parse(File.ReadAllText(settingsPath))!["channel"]!.GetValue<string>()); 542Assert.Equal("daily", JsonNode.Parse(File.ReadAllText(settingsPath))!["channel"]!.GetValue<string>()); 681var settings = JsonNode.Parse(json)!.AsObject(); 698var settings = JsonNode.Parse(""" 721var settings = JsonNode.Parse(""" 741var flatObject = settings["fresh:object"]; 754var settings = JsonNode.Parse(""" 771var retained = settings["keep"]; 772var docs = settings["DOCS"];
Configuration\ConfigurationServiceTests.cs (13)
123var settings = JsonNode.Parse(await File.ReadAllTextAsync(path))!; 178await ConfigurationHelper.WriteSettingsFileAtomicallyAsync(path, JsonNode.Parse(""" 192var settings = JsonNode.Parse(await File.ReadAllTextAsync(path))!.AsObject(); 769var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); 770var node = json!["features"]!["polyglotSupportEnabled"]; 792var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); 793var node = json!["channel"]; 812var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); 813var node = json!["channel"];
DotNet\DotNetRestoreConfigurationTests.cs (2)
35var values = new JsonObject(properties.Select(name => KeyValuePair.Create<string, JsonNode?>(name, JsonValue.Create("")))); 65var values = new JsonObject(properties.Select(name => KeyValuePair.Create<string, JsonNode?>(name, JsonValue.Create(""))));
Mcp\ExcludeFromMcpTests.cs (9)
44Properties = new Dictionary<string, JsonNode?> 59Properties = new Dictionary<string, JsonNode?> 74Properties = new Dictionary<string, JsonNode?> 89Properties = new Dictionary<string, JsonNode?> 129Properties = new Dictionary<string, JsonNode?> 171Properties = new Dictionary<string, JsonNode?> 217Properties = new Dictionary<string, JsonNode?> 289Properties = new Dictionary<string, JsonNode?> 483Properties = new Dictionary<string, JsonNode?>
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?>
Mcp\ListStructuredLogsToolTests.cs (1)
303var logsArray = JsonNode.Parse(jsonText)?.AsArray();
Mcp\ListTracesToolTests.cs (1)
227var tracesArray = JsonNode.Parse(jsonText)?.AsArray();
Migrations\TypeScriptAppHostMigrationTests.cs (7)
189var config = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "aspire.config.json")))!; 192var tsconfig = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "tsconfig.apphost.json")))!; 196var packageJson = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(root.FullName, "package.json")))!; 197var scripts = packageJson["scripts"]!;
Projects\GuestAppHostProjectTests.cs (5)
1289var updatedManifest = JsonNode.Parse(await File.ReadAllTextAsync(manifestPath))!; 1290var expectedManifest = JsonNode.Parse(installedManifest)!; 1292Assert.True(JsonNode.DeepEquals(expectedManifest, updatedManifest));
Projects\NativeAppHostServerProjectTests.cs (4)
96var request = JsonNode.Parse(File.ReadAllText(start.ArgumentList[1]))!; 483var request = JsonNode.Parse(File.ReadAllText(start.ArgumentList[1]))!;
Projects\ProjectUpdaterNuGetConfigurationTests.cs (3)
81var json = JsonNode.Parse(output.RootElement.GetRawText())!.AsObject(); 286var json = JsonNode.Parse(settings.RootElement.GetRawText())!.AsObject(); 672var json = JsonNode.Parse(output.RootElement.GetRawText())!.AsObject();
Scaffolding\PackageJsonMergerTests.cs (5)
19JsonNode.Parse(json)!.AsObject(); 997var weirdPkg = ParseJson(result)["dependencies"]!["weird-pkg"]; 1248var doc = JsonNode.Parse(result)!.AsObject(); 1301var doc = JsonNode.Parse(result)!.AsObject(); 1486var doc = JsonNode.Parse(result)!.AsObject();
Scaffolding\ScaffoldingServiceTests.cs (8)
119var packageJson = JsonNode.Parse("""{ "scripts": { "aspire:start": "npm --prefix aspire-apphost run aspire:start" } }""")!.AsObject(); 129var packageJson = JsonNode.Parse("""{ "scripts": { "aspire:start": "npm --prefix aspire-apphost run aspire:start" } }""")!.AsObject(); 139var packageJson = JsonNode.Parse("""{ "scripts": { "aspire:start": "npm --prefix aspire-apphost run aspire:start" } }""")!.AsObject(); 149var scripts = JsonNode.Parse("""{ "test": "vitest" }""")!.AsObject(); 212var scripts = JsonNode.Parse(""" 351var merged = JsonNode.Parse( 374var merged = JsonNode.Parse( 398var merged = JsonNode.Parse(
Secrets\SecretStoreResolverTests.cs (5)
148SecretsStore.SaveJson(sourcePath, JsonNode.Parse(""" 154SecretsStore.SaveJson(destinationPath, JsonNode.Parse(""" 170var persisted = JsonNode.Parse(await File.ReadAllTextAsync(destinationPath))!.AsObject(); 182Assert.Null(JsonNode.Parse(await File.ReadAllTextAsync(destinationPath))!["Canonical:Missing"]); 484Assert.Equal(42, JsonNode.Parse(File.ReadAllText(path))!["Count"]!.GetValue<int>());
Telemetry\ReportedLogExportTests.cs (4)
70var envelopes = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(workspace.Path, "envelopes.json")))!.AsArray(); 71foreach (var envelope in envelopes) 88var data = envelope["data"]!; 89var baseData = data["baseData"]!;
TestServices\TestAppHostAuxiliaryBackchannel.cs (1)
307public JsonNode? ExecuteResourceCommandArguments { get; private set; }
TestServices\TestConfigSourceServices.cs (1)
24? JsonNode.Parse(await File.ReadAllTextAsync(path, cancellationToken))!.AsObject()
TestServices\TestDotNetCliRunner.cs (1)
174KeyValuePair.Create<string, JsonNode?>(name, JsonValue.Create(string.Empty))));
Aspire.Dashboard (34)
Model\GenAI\GenAIEvents.cs (2)
25public JsonNode? Content { get; set; } 45public JsonNode? Arguments { get; set; }
Model\GenAI\GenAIItemPartViewModel.cs (1)
144jsonObject[kvp.Key] = JsonNode.Parse(kvp.Value.GetRawText());
Model\GenAI\GenAIMessageParsingHelper.cs (4)
145internal static JsonNode? TryParseStringJsonNode(JsonNode? node) 151var parsed = JsonNode.Parse(json);
Model\GenAI\GenAIMessages.cs (4)
56public JsonNode? Arguments { get; set; } 70public JsonNode? Response { get; set; } = default!; 143public JsonNode? ServerToolCall { get; set; } 157public JsonNode? ServerToolCallResponse { get; set; }
Model\GenAI\GenAISchemaHelpers.cs (5)
49foreach (var item in requiredArray) 61schema.Enum = new List<JsonNode>(); 62foreach (var item in enumArray) 74internal static JsonSchemaType? ParseTypeValue(JsonNode? typeNode) 89foreach (var item in typeArray)
Model\GenAI\GenAIVisualizerDialogViewModel.cs (5)
91var jsonNode = JsonNode.Parse(toolDefinitionsJson, documentOptions: documentOptions); 95foreach (var item in array) 520var toolResponse = GenAIMessageParsingHelper.TryParseStringJsonNode(toolEvent.Content); 557var args = GenAIMessageParsingHelper.TryParseStringJsonNode(function.Arguments);
Model\GenAI\ToolDefinitionSchema.cs (1)
15public List<JsonNode>? Enum { get; set; }
Model\Serialization\ResourceJsonSerializerContext.cs (2)
23[JsonSerializable(typeof(JsonNode))] 24[JsonSerializable(typeof(Dictionary<string, JsonNode?>))]
Model\TelemetryExportService.cs (1)
789private static JsonNode? ConvertPropertyValueToJsonNode(Google.Protobuf.WellKnownTypes.Value value)
Otlp\Model\OtlpHelpers.cs (1)
195private static JsonNode? ConvertAnyValue(AnyValue value)
src\Shared\Model\Serialization\ResourceJson.cs (1)
111public Dictionary<string, JsonNode?>? Properties { get; set; }
src\Shared\Otlp\Serialization\OtlpJsonSerializerContext.cs (2)
34[JsonSerializable(typeof(JsonNode))] 35[JsonSerializable(typeof(Dictionary<string, JsonNode?>))]
src\Shared\Telemetry\InternalMicrosoftDetector.cs (5)
760if (!userConfiguration.TryGetPropertyValue("kerberosStatus", out var kerberosStatusNode) || 776foreach (var kerberosStatusNodeEntry in kerberosStatuses) 1707return JsonNode.Parse( 1878return json.TryGetPropertyValue(propertyName, out var node) && 1904return json.TryGetPropertyValue(propertyName, out var value) &&
Aspire.Dashboard.Components.Tests (2)
Controls\GenAIVisualizerDialogTests.cs (2)
98Parts = [new ToolCallRequestPart { Name = "generate_names", Arguments = JsonNode.Parse(@"{""count"":2}") }] 103Parts = [new ToolCallResponsePart { Response = JsonNode.Parse(@"[""Jack"",""Jane""]") }]
Aspire.Dashboard.Tests (21)
Model\DashboardDataSourceTests.cs (4)
248var metadata = JsonNode.Parse(File.ReadAllText(metadataPath))!.AsObject(); 803var metadata = JsonNode.Parse(File.ReadAllText(metadataPath))!.AsObject(); 844var metadata = JsonNode.Parse(File.ReadAllText(metadataPath))!.AsObject(); 888var metadata = JsonNode.Parse(File.ReadAllText(metadataPath))!.AsObject();
Model\GenAIItemPartViewModelTests.cs (4)
64Response = JsonNode.Parse("""["Jack","Jane"]""") 96Response = JsonNode.Parse("""{"name":"Jack","age":30}""") 121Arguments = JsonNode.Parse("""{"location":"東京","unit":"celsius"}""") 138Response = JsonNode.Parse("""{"weather":"晴れ","city":"東京"}""")
Model\GenAISchemaHelpersTests.cs (8)
113var typeAsObject = JsonNode.Parse("""{"description": "This is an object instead of a string"}"""); 122var typeArrayWithObjects = JsonNode.Parse("""["string", {"invalid": "object"}, "number"]""") as JsonArray; 136var typeArrayWithOnlyObjects = JsonNode.Parse("""[{"invalid": "object"}, {"another": "object"}]""") as JsonArray; 151var typeString = JsonNode.Parse("\"string\""); 159var typeArray = JsonNode.Parse("""["string", "null"]""") as JsonArray; 185var schemaObj = JsonNode.Parse(schemaJson) as JsonObject;
Model\GenAIVisualizerDialogViewModelTests.cs (4)
511Parts = [new ToolCallRequestPart { Name = "generate_names", Arguments = JsonNode.Parse(@"{""count"":2}") }] 516Parts = [new ToolCallResponsePart { Response = JsonNode.Parse(@"[""Jack"",""Jane""]") }] 635Parts = [new ToolCallRequestPart { Name = "generate_names", Arguments = JsonNode.Parse(@"{""count"":2}") }] 640Parts = [new ToolCallResponsePart { Response = JsonNode.Parse(@"[""Jack"",""Jane""]") }]
Model\TelemetryExportServiceTests.cs (1)
1434var waitingForPropertyValue = Assert.Single(waitingForProperty);
Aspire.Hosting (103)
ApplicationModel\AppHostLocalStateStore.cs (7)
63public T Read<T>(string key, Func<JsonNode?, T> readValue, T defaultValue) 90public void Update(string key, Func<JsonNode?, JsonNode?> updateValue) 109var currentValue = state[key]; 110var updatedValue = updateValue(currentValue?.DeepClone()); 111if (JsonNode.DeepEquals(currentValue, updatedValue)) 155if (JsonNode.Parse(File.ReadAllText(_statePath)) is not JsonObject root)
Ats\UserSecretsExports.cs (1)
41var state = JsonNode.Parse(json) as JsonObject
Backchannel\AuxiliaryBackchannelRpcTarget.cs (7)
347var arguments = request.Arguments; 409private static string? ConvertArgumentValue(string name, JsonNode? value) 1173var properties = new Dictionary<string, JsonNode?>(); 1410private static JsonNode? ConvertPropertyValueToJsonNode(object? value) 1415JsonNode jsonNode => jsonNode.DeepClone(), 1446private static JsonNode? ConvertPropertyValueToLegacyJsonNode(object? value) 1461JsonNode jsonNode => jsonNode.ToJsonString(),
Backchannel\BackchannelDataTypes.cs (3)
455public JsonNode? Arguments { get; init; } 494public JsonNode? Arguments { get; init; } 1191public Dictionary<string, JsonNode?> Properties { get; init; } = [];
Dcp\DcpExecutor.cs (2)
1058var current = JsonSerializer.SerializeToNode(obj); 1063var changed = JsonSerializer.SerializeToNode(copy);
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)
Dcp\PersistentPortAllocationStore.cs (2)
47JsonNode? value, 106static bool TryGetPort(JsonNode? node, out int port)
Devcontainers\DevcontainerSettingsWriter.cs (2)
123if (!settings.TryGetPropertyValue(PortAttributesFieldName, out var portsAttributesNode)) 167if (!portsAttributes.TryGetPropertyValue(port, out var portAttributeNode))
Pipelines\Internal\DeploymentStateManagerBase.cs (7)
64protected virtual JsonNode? GetSectionState(JsonObject? state, string sectionName, bool includeLegacyState) => 134if (JsonNode.Parse(fileContent, documentOptions: jsonDocumentOptions) is not JsonObject flattenedState) 190var sectionData = GetSectionState(_state, sectionName, includeLegacyState); 222protected static JsonNode? TryGetNestedPropertyValue(JsonObject? node, string path) 230JsonNode? current = node; 234if (current is not JsonObject currentObj || !currentObj.TryGetPropertyValue(segment, out var nextNode)) 332if (!current.TryGetPropertyValue(segment, out var nextNode) || nextNode is not JsonObject nextObj)
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()
Pipelines\Internal\JsonFlattener.cs (1)
44if (!current.TryGetPropertyValue(key, out var existing) || existing is not JsonObject)
Publishing\ContainerImageArchiveRewriter.cs (8)
229foreach (var manifestNode in manifests) 236if (!manifest.TryGetPropertyValue("RepoTags", out var repoTagsNode) || repoTagsNode is null) 354if (!descriptor.TryGetPropertyValue("annotations", out var annotationsNode) || annotationsNode is null) 518private static JsonNode ParseJson(byte[] contents, string entryName) 522return JsonNode.Parse(contents) 539private static byte[] SerializeJson(JsonNode node) 544private static string GetRequiredString(JsonNode? node, string entryName, string location) 562if (!annotations.TryGetPropertyValue(annotationName, out var value))
Publishing\ContainerRuntimeBase.cs (5)
188var root = JsonNode.Parse(output) as JsonObject; 210private static IReadOnlyList<string> ReadStringArray(JsonNode? node) 218foreach (var item in array) 246var root = JsonNode.Parse(output);
src\Shared\Json\JsonFlattener.cs (1)
38if (!current.TryGetPropertyValue(key, out var existing) || existing is not JsonObject)
src\Shared\UserSecrets\SecretsStore.cs (7)
16private readonly Dictionary<string, JsonNode?> _secrets; 194private static Dictionary<string, JsonNode?> Load(string path) 198return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 204return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 207var parsed = JsonNode.Parse(json, documentOptions: new JsonDocumentOptions 214return new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase); 222var result = new Dictionary<string, JsonNode?>(StringComparer.OrdinalIgnoreCase);
Aspire.Hosting.Azure (24)
AzureBicepResource.cs (1)
257if (inputValue is JsonNode || inputValue is IEnumerable<string>)
AzureBicepResourceExtensions.cs (1)
217public static IResourceBuilder<T> WithParameter<T>(this IResourceBuilder<T> builder, string name, JsonNode value)
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))
AzureProvisioningFailureDetails.cs (2)
566if (JsonNode.Parse(content) is not JsonObject responseObj) 624foreach (var detail in detailsArray)
AzureProvisioningJsonHelpers.cs (2)
26internal static JsonNode? ParseDeploymentStateJson(string json) 32return JsonNode.Parse(json, documentOptions: s_deploymentStateJsonDocumentOptions);
Provisioning\BicepUtilities.cs (3)
83JsonNode node => node, 152var parameters = JsonNode.Parse(jsonString)?.AsObject(); 154? JsonNode.Parse(scopeString)?.AsObject()
Provisioning\Internal\RunModeProvisioningContextProvider.cs (1)
274private static bool? TryGetBoolean(JsonNode? value)
Provisioning\JsonExtensions.cs (3)
10internal static JsonNode Prop(this JsonNode obj, string key) 15var node = jsonObj[key];
Provisioning\Provisioners\BicepProvisioner.cs (3)
83JsonNode? outputObj = null; 86outputObj = JsonNode.Parse(outputJson); 1503if (JsonNode.Parse(parametersJson)?[AzureBicepResource.KnownParameters.Location]?["value"]?.GetValue<string>() is { Length: > 0 } configuredLocation)
Aspire.Hosting.Azure.EntraId.Tests (1)
EntraIdProvisioningTests.cs (1)
863var manifest = await ManifestUtils.GetManifest(entra.Resource, workspace.Path);
Aspire.Hosting.Azure.EventHubs (5)
AzureEventHubsExtensions.cs (3)
330var tempConfig = JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource)); 449public static IResourceBuilder<AzureEventHubsEmulatorResource> WithConfiguration(this IResourceBuilder<AzureEventHubsEmulatorResource> builder, Action<JsonNode> configJson)
ConfigJsonAnnotation.cs (2)
14public ConfigJsonAnnotation(Action<JsonNode> configure) 19public Action<JsonNode> Configure { get; }
Aspire.Hosting.Azure.Kubernetes (1)
AzureKubernetesEnvironmentResource.AksPipeline.cs (1)
418return ParseAksResourceId(JsonNode.Parse(outputsJson)?["id"]?["value"]?.GetValue<string>());
Aspire.Hosting.Azure.Sandboxes (3)
AzureSandboxContainerDeployment.cs (3)
2018.Select(static endpoint => (JsonNode)new JsonObject 2031.Select(static identity => (JsonNode)new JsonObject 2045.Select(static rule => (JsonNode)new JsonObject
Aspire.Hosting.Azure.ServiceBus (5)
AzureServiceBusExtensions.cs (3)
516var tempConfig = JsonNode.Parse(CreateEmulatorConfigJson(builder.Resource)); 595public static IResourceBuilder<AzureServiceBusEmulatorResource> WithConfiguration(this IResourceBuilder<AzureServiceBusEmulatorResource> builder, Action<JsonNode> configJson)
ConfigJsonAnnotation.cs (2)
14public ConfigJsonAnnotation(Action<JsonNode> configure) 19public Action<JsonNode> Configure { get; }
Aspire.Hosting.Azure.Tests (54)
AzureAppServiceTests.cs (1)
1467private static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource) =>
AzureBicepProvisionerTests.cs (1)
1666var outputs = JsonNode.Parse(section.Data[BicepUtilities.DeploymentStateOutputsKey]!.GetValue<string>())!.AsObject();
AzureBicepResourceTests.cs (1)
188var manifest = await ManifestUtils.GetManifest(bicepResource.Resource);
AzureContainerAppsTests.cs (1)
1889private static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource) =>
AzureDeployerTests.cs (6)
720var parameters = JsonNode.Parse(resourceGroup.Deployments.Content!.Properties.Parameters.ToString())!; 1917var stateJson = JsonNode.Parse(stateContent); 2042var stateJson = JsonNode.Parse(stateContent);
AzureEnvironmentResourceExtensionsTests.cs (8)
127var json = JsonNode.Parse(Assert.IsType<string>(result.Data!.Value))!; 188var json = JsonNode.Parse(Assert.IsType<string>(result.Data!.Value))!; 189var remaining = Assert.Single(json["remainingResources"]!.AsArray())!; 322var json = JsonNode.Parse(Assert.IsType<string>(result.Data!.Value))!; 5384return Assert.IsType<JsonObject>(JsonNode.Parse(data.Value));
AzureFunctionsTests.cs (3)
476var manifest = await ManifestUtils.GetManifest(funcApp.Resource, tempDir.Path); 563var manifest = await ManifestUtils.GetManifest(funcApp.Resource, tempDir.Path); 773private static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource) =>
AzureInfrastructureExtensionsTests.cs (3)
89var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 114var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 153var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource);
AzureManifestUtils.cs (5)
16public static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource, bool skipPreparer = false) => 19public static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(DistributedApplicationModel appModel, IResource resource) => 22private static async Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(DistributedApplicationModel appModel, IResource resource, bool skipPreparer) 32var manifestNode = await ManifestUtils.GetManifest(resource, manifestDir); 34if (!manifestNode.AsObject().TryGetPropertyValue("path", out var pathNode))
AzurePostgresExtensionsTests.cs (1)
561var manifest = await ManifestUtils.GetManifest(postgres.Resource);
AzureStorageExtensionsTests.cs (12)
504var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 519var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 534var tableManifest = await ManifestUtils.GetManifest(table.Resource); 589var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 604var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 619var tableManifest = await ManifestUtils.GetManifest(table.Resource); 727var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 740var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 753var tableManifest = await ManifestUtils.GetManifest(table.Resource); 809var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 824var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 839var tableManifest = await ManifestUtils.GetManifest(table.Resource);
JsonExtensionsTests.cs (4)
15var azureNode = rootJson.Prop("Azure"); 19var retrievedNode = rootJson.Prop("Azure"); 33var newNode = rootJson.Prop("NewProperty"); 47var deeply = rootJson.Prop("Level1")
ProvisioningContextTests.cs (2)
191var parsed = JsonNode.Parse(result);
ProvisioningTestHelpers.cs (1)
1054var sectionData = _state.TryGetPropertyValue(sectionName, out var node) && node is JsonObject obj
PublicApiTests\EventHubsPublicApiTests.cs (2)
359Action<JsonNode> configJson = (_) => { }; 372Action<JsonNode> configJson = null!;
PublicApiTests\ServiceBusPublicApiTests.cs (2)
291Action<JsonNode> configJson = (_) => { }; 304Action<JsonNode> configJson = null!;
RoleAssignmentTests.cs (1)
372private static Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource) =>
Aspire.Hosting.Azure.WebPubSub (1)
AzureWebPubSubExtensions.cs (1)
240["SystemEvents"] = new JsonArray((systemEvents ?? []).Select(e => (JsonNode?)JsonValue.Create(e)).ToArray())
Aspire.Hosting.CodeGeneration.Go (10)
AtsGoCodeGenerator.cs (3)
1248JsonNode? value, 1284private static string RenderGoJsonValue(JsonNode value) => 1302if (!value.TryGetPropertyValue(property.Name, out var propertyValue))
GoApiExportWriter.cs (6)
29modules.Add((JsonNode)WriteModule(module)); 35declarations.Add((JsonNode)new JsonObject 79items.Add((JsonNode)WriteItem(item)); 111members.Add((JsonNode)WriteMember(member)); 195array.Add((JsonNode)json); 256array.Add((JsonNode)JsonValue.Create(value));
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
Aspire.Hosting.CodeGeneration.Go.Tests (16)
AtsGoCodeGeneratorTests.cs (1)
1877Value = JsonNode.Parse("[1,null,2.5]"),
GoApiExportTests.cs (9)
41var declaration = Assert.Single(JsonNode.Parse(json)!["declarations"]!.AsArray()); 87var export = JsonNode.Parse(GoApiExportWriter.WriteToJson(BuildModel(TestTypesAssemblyName)))!; 98var module = Assert.Single(export["modules"]!.AsArray()); 304var json = JsonNode.Parse(GoApiExportWriter.WriteToJson(model))!; 382var strings = Strings(JsonNode.Parse(first)).ToList(); 386static IEnumerable<string> Strings(JsonNode? node) => node switch
GoDocCommentTests.cs (2)
550Value = JsonNode.Parse("""{"DisplayName":"primary","Enabled":true,"Port":8080}"""), 558Value = JsonNode.Parse("""{"DisplayName":"secondary","Enabled":false,"Port":8081}"""),
GoGeneratorEscapingTests.cs (1)
215private static AtsExportedValueInfo ExportedValue(IReadOnlyList<string> pathSegments, AtsTypeRef type, JsonNode value) => new()
GoScaffoldTests.cs (3)
125var profile = JsonNode.Parse(files["apphost.run.json"])!["profiles"]!["https"]!; 126var environmentVariables = profile["environmentVariables"]!;
Aspire.Hosting.CodeGeneration.Java (3)
AtsJavaCodeGenerator.cs (2)
868JsonNode? value, 905if (!value.TryGetPropertyValue(property.Name, out var propertyValue))
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
Aspire.Hosting.CodeGeneration.Java.Tests (8)
AtsJavaCodeGeneratorTests.cs (8)
859var request = JsonNode.Parse(requestLine["REQUEST:".Length..])!; 860var dtoJson = FindProperty(request, "value"); 880static JsonNode? FindProperty(JsonNode? node, string name) 898foreach (var child in array) 3888Value = JsonNode.Parse("[1,null,2.5]"), 3895Value = JsonNode.Parse("[true,null,false]"),
Aspire.Hosting.CodeGeneration.Python (4)
AtsPythonCodeGenerator.cs (3)
1001JsonNode? value, 1042if (!value.TryGetPropertyValue(property.Name, out var propertyValue)) 1053private static string RenderPythonPrimitiveValue(JsonNode value)
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
Aspire.Hosting.CodeGeneration.Rust (1)
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
Aspire.Hosting.CodeGeneration.Rust.Tests (1)
AtsRustCodeGeneratorTests.cs (1)
193Value = JsonNode.Parse("[1,null,2.5]"),
Aspire.Hosting.CodeGeneration.TypeScript (10)
src\Shared\Json\AtsJsonCodeWriter.cs (1)
23internal static string ToRelaxedJsonString(this JsonNode value)
TypeScriptApiExportWriter.cs (6)
28modules.Add((JsonNode)WriteModule(module)); 34declarations.Add((JsonNode)new JsonObject 77items.Add((JsonNode)WriteItem(item)); 112members.Add((JsonNode)WriteMember(member)); 158parameters.Add((JsonNode)parameterJson); 199array.Add((JsonNode)JsonValue.Create(value));
TypeScriptApiProjector.cs (2)
764private string RenderTypeScriptExportedValue(JsonNode? value, AtsTypeRef typeRef) 789if (value.TryGetPropertyValue(property.Name, out var propertyValue))
TypeScriptLanguageSupport.cs (1)
219private static string? GetStringValue(JsonNode? node)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (2)
AtsTypeScriptCodeGeneratorTests.cs (1)
52var packageJson = System.Text.Json.Nodes.JsonNode.Parse(content)!.AsObject();
TypeScriptLanguageSupportTests.cs (1)
356private static JsonObject ParseJson(string content) => JsonNode.Parse(content)!.AsObject();
Aspire.Hosting.Containers.Tests (10)
ContainerResourceTests.cs (5)
137var manifest = await ManifestUtils.GetManifest(c2.Resource); 176var manifest = await ManifestUtils.GetManifest(containerResource); 210var manifest = await ManifestUtils.GetManifest(containerResource); 257var manifest = await ManifestUtils.GetManifest(containerResource); 306var manifest = await ManifestUtils.GetManifest(containerResource, manifestDirectory: appHostPath);
WithDockerfileTests.cs (5)
280var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 329var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 377var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 424var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 880var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath);
Aspire.Hosting.Dotnet.Tests (4)
DotnetProjectResourceTests.cs (4)
174var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 229var manifest = await ManifestUtils.GetManifestOrNull(resource.Resource, workspace.Path); 245var manifest = await ManifestUtils.GetManifest(resource.Resource, workspace.Path); 263var manifest = await ManifestUtils.GetManifest(resource.Resource, workspace.Path);
Aspire.Hosting.DotnetTool.Tests (2)
AddDotnetToolTests.cs (2)
357var manifest = await ManifestUtils.GetManifest(tool.Resource).DefaultTimeout(); 401var manifest = await ManifestUtils.GetManifest(tool.Resource).DefaultTimeout();
Aspire.Hosting.Foundry.Tests (5)
HostedAgentConfigurationTests.cs (4)
88var payload = JsonNode.Parse(ModelReaderWriter.Write(options, ModelReaderWriterOptions.Json).ToString())!; 89var definition = payload["definition"]!; 91var protocolVersion = Assert.Single(definition["protocol_versions"]!.AsArray());
HostedAgentExtensionTests.cs (1)
191Assert.Equal("hello from dashboard", JsonNode.Parse(fakeHandler.RequestContent!)?["message"]?.GetValue<string>());
Aspire.Hosting.Garnet.Tests (3)
AddGarnetTests.cs (3)
93var manifest = await ManifestUtils.GetManifest(garnet.Resource); 133var manifest = await ManifestUtils.GetManifest(garnet.Resource); 169var manifest = await ManifestUtils.GetManifest(garnet.Resource);
Aspire.Hosting.Go.Tests (25)
AddGoAppTests.cs (25)
31var manifest = await ManifestUtils.GetManifest(app.Resource); 46var manifest = await ManifestUtils.GetManifest(app.Resource); 84var manifest = await ManifestUtils.GetManifest(app.Resource); 131var manifest = await ManifestUtils.GetManifest(app.Resource); 158var manifest = await ManifestUtils.GetManifest(app.Resource); 185var manifest = await ManifestUtils.GetManifest(app.Resource); 212var manifest = await ManifestUtils.GetManifest(app.Resource); 243var manifest = await ManifestUtils.GetManifest(app.Resource); 276var manifest = await ManifestUtils.GetManifest(app.Resource); 307var manifest = await ManifestUtils.GetManifest(app.Resource); 335var manifest = await ManifestUtils.GetManifest(app.Resource); 363var manifest = await ManifestUtils.GetManifest(app.Resource); 392var manifest = await ManifestUtils.GetManifest(app.Resource); 422var manifest = await ManifestUtils.GetManifest(app.Resource); 453var manifest = await ManifestUtils.GetManifest(app.Resource); 484var manifest = await ManifestUtils.GetManifest(app.Resource); 519var manifest = await ManifestUtils.GetManifest(app.Resource); 783var manifest = await ManifestUtils.GetManifest(app.Resource); 816var manifest = await ManifestUtils.GetManifest(app.Resource); 849var manifest = await ManifestUtils.GetManifest(app.Resource); 883var manifest = await ManifestUtils.GetManifest(app.Resource); 1020var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1079var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1093var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1107var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path);
Aspire.Hosting.Java.Tests (4)
AddJavaAppTests.cs (4)
69var manifest = await ManifestUtils.GetManifest(app.Resource); 92var manifest = await ManifestUtils.GetManifest(app.Resource); 1330var manifest = await ManifestUtils.GetManifest(app.Resource); 1347var manifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.JavaScript.Tests (17)
AddBunAppTests.cs (1)
21var manifest = await ManifestUtils.GetManifest(bunApp.Resource);
AddDenoAppTests.cs (3)
26var manifest = await ManifestUtils.GetManifest(denoApp.Resource); 49var manifest = await ManifestUtils.GetManifest(denoApp.Resource); 1091var manifest = await ManifestUtils.GetManifest(denoApp.Resource, workspace.Path);
AddJavaScriptAppTests.cs (3)
347var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 365var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 384var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path);
AddNodeAppTests.cs (1)
30var manifest = await ManifestUtils.GetManifest(nodeApp.Resource);
AddViteAppTests.cs (9)
35var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 326var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 346var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 371var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 397var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 423var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 440var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 464var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path); 482var manifest = await ManifestUtils.GetManifest(nodeApp.Resource, workspace.Path);
Aspire.Hosting.Kafka.Tests (1)
AddKafkaTests.cs (1)
143var manifest = await ManifestUtils.GetManifest(kafka.Resource);
Aspire.Hosting.Keycloak.Tests (1)
KeycloakResourceBuilderTests.cs (1)
154var manifest = await ManifestUtils.GetManifest(keycloak.Resource);
Aspire.Hosting.Kubernetes (5)
KubernetesEnvironmentResource.cs (3)
2134metadataNode["annotations"] = System.Text.Json.Nodes.JsonNode.Parse(annotations.GetRawText()); 2139metadataNode["labels"] = System.Text.Json.Nodes.JsonNode.Parse(labels.GetRawText()); 2153minimal["spec"] = System.Text.Json.Nodes.JsonNode.Parse(spec.GetRawText());
KubernetesManifestResource.cs (2)
154JsonNode node => NormalizeJsonNode(node), 213private static object? NormalizeJsonNode(JsonNode node)
Aspire.Hosting.Milvus.Tests (2)
AddMilvusTests.cs (2)
144var serverManifest = await ManifestUtils.GetManifest(milvus.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 145var dbManifest = await ManifestUtils.GetManifest(db1.Resource);
Aspire.Hosting.MongoDB.Tests (3)
AddMongoDBTests.cs (2)
297var mongoManifest = await ManifestUtils.GetManifest(mongo.Resource); 298var dbManifest = await ManifestUtils.GetManifest(db.Resource);
ConnectionPropertiesTests.cs (1)
105var manifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.MySql.Tests (4)
AddMySqlTests.cs (3)
160var mySqlManifest = await ManifestUtils.GetManifest(mysql.Resource); 161var dbManifest = await ManifestUtils.GetManifest(db.Resource); 199var serverManifest = await ManifestUtils.GetManifest(mysql.Resource);
ConnectionPropertiesTests.cs (1)
92var manifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.Native.Client (4)
Authoring\NativeApplication.cs (1)
234var model = System.Text.Json.Nodes.JsonNode.Parse(await revision.ExportPublishModelAsync(token).ConfigureAwait(false))!.AsObject();
Authoring\NativePipeline.cs (2)
115["steps"] = new JsonArray(_steps.Select(step => (JsonNode)new JsonObject 196new(values.Select(value => (JsonNode?)JsonValue.Create(value)).ToArray());
Authoring\Publishing.cs (1)
90var model = JsonNode.Parse(await composition.ExportPublishModelAsync(cancellationToken).ConfigureAwait(false))!.AsObject();
Aspire.Hosting.Native.CodeGeneration (2)
Program.cs (1)
242handle.ClrType!.Name, (JsonNode?)new JsonObject { ["typeId"] = handle.AtsTypeId, ["category"] = "Handle" }))).ToJsonString() +
src\Aspire.Hosting.RemoteHost\AtsCapabilityScanner.cs (1)
1456private static JsonNode? SerializeExportedValue(object? value, Type memberType)
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) =>
DeclarativeApplicationTests.cs (5)
19var session = rpc.CreateSession(); 20var composition = rpc.StartGeneration(session); 21var resource = Result(rpc.Invoke("addContainer", Arguments(("context", composition), 24var value = Result(rpc.Invoke("createLiteralValue", Arguments(("context", composition), 28var configuration = Result(rpc.Invoke("inspectSymbolicConfiguration", Arguments(("context", resource))));
NativeCliControlTests.cs (4)
23var spec = Result(client.Call("getRuntimeSpec", new JsonArray("typescript/nodejs"))); 34var identity = JsonNode.Parse(sdk["apphost-server.json"]!.GetValue<string>())!; 87Assert.True(JsonNode.Parse(response)!["result"]!.GetValue<bool>());
NativeComposeCSharpDockerTests.cs (7)
38var inputs = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(work.FullName, "deployment-inputs.json")))!; 123var state = JsonNode.Parse(await File.ReadAllTextAsync(Path.Combine(work.FullName, "deployment-state.json")))!; 124var web = state["services"]!.AsArray().Single(service => service!["resource"]!.GetValue<string>() == "web")!; 127var body = JsonNode.Parse(await client.GetStringAsync(url, TestContext.Current.CancellationToken))!;
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();
NativeDashboardTests.cs (6)
102var pending = Assert.Single(Result(await ready)["commands"]!.AsArray())!; 108var operation = Result(context.Integration.Invoke("requestConfirmation", Arguments(("context", context.Writer), 153var revision = context.BeginRevision(); 154var cache = context.Author.AddResource(revision, "cache"); 179var next = context.BeginRevision(); 201var replacement = context.Author.StartGeneration(context.Session);
NativeModelAlignmentTests.cs (6)
29var exported = JsonNode.Parse(composition.ExportPublishModel())!; 30var api = exported["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "api")!; 82await Verifier.Verify(JsonNode.Parse(composition.ExportPublishModel())!.ToJsonString( 134var exported = JsonNode.Parse(composition.ExportPublishModel())!;
NativeProtocolParsingTests.cs (3)
49JsonNode? result; 55Assert.True(JsonNode.DeepEquals(JsonNode.Parse(json), result));
NativeProviderClientTests.cs (7)
59var discovery = JsonNode.Parse((await provider.ReadAsync(cancellationToken))!)!.AsObject(); 66["result"] = JsonNode.Parse(PrimitiveDefinition((_, _, _) => 70var rejection = JsonNode.Parse((await provider.ReadAsync(cancellationToken))!)!.AsObject(); 130var request = JsonNode.Parse((await provider.ReadAsync(deadline.Token))!)!.AsObject(); 138["error"] = JsonNode.Parse(error) 220var handle = JsonNode.Parse(result.GetRawText())!.AsObject(); 221handle["$lifetime"] = JsonNode.Parse(arguments.GetProperty("composition").GetRawText());
NativeProviderLifecycleTests.cs (1)
232var manifest = JsonNode.Parse(definition.Metadata.GetRawText())!.AsObject();
NativeProviderProtocolTests.cs (15)
18var metadata = JsonNode.Parse(""" 30var metadata = JsonNode.Parse(""" 45var metadata = JsonNode.Parse(""" 58var metadata = JsonNode.Parse(""" 103var fault = Assert.Throws<RpcFault>(() => NativeProviderMetadata.Read(JsonNode.Parse(metadata))); 112var metadata = JsonNode.Parse($$""" 130var fault = Assert.Throws<RpcFault>(() => NativeProviderValueProtocol.ParseReturnedHandle(JsonNode.Parse(wire), type, contract.CoreHandles)); 139var metadata = JsonNode.Parse(""" 156private static NativeProviderManifest Project(JsonNode? metadata) =>
NativePublishingTests.cs (3)
44var exported = JsonNode.Parse(document)!; 45var application = exported["resources"]!.AsArray().Single(resource => resource!["name"]!.GetValue<string>() == "web")!;
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",
NativeTimeProviderTests.cs (5)
31var session = client.CreateSession(); 32var composition = client.StartGeneration(session); 34var root = Result(client.Call("getApplicationServer", null)); 35var workspace = Result(client.Invoke("createApplicationWorkspace", Arguments(("context", root)))); 36var revision = Result(client.Invoke("beginRevision", Arguments(("context", workspace))));
ResourceWorkloadTests.cs (2)
34var endpoint = Result(await context.Integration.InvokeAsync("startContainer", Arguments( 54var endpoint = Result(await context.Integration.InvokeAsync("startContainer", Arguments(
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))))));
src\Aspire.Hosting\Backchannel\BackchannelDataTypes.cs (3)
455public JsonNode? Arguments { get; init; } 494public JsonNode? Arguments { get; init; } 1191public Dictionary<string, JsonNode?> Properties { get; init; } = [];
TestServices\NativeSocketTestHost.cs (3)
97public async Task<JsonObject> CallAsync(string method, JsonNode? parameters, CancellationToken cancellationToken) 101return JsonNode.Parse(response)!.AsObject(); 104public Task SendAsync(string method, JsonNode? parameters, CancellationToken cancellationToken)
TestServices\RpcTestClient.cs (10)
47public JsonObject Call(string method, JsonNode? parameters) => CallAsync(method, parameters).GetAwaiter().GetResult(); 49public async Task<JsonObject> CallAsync(string method, JsonNode? parameters) 61return JsonNode.Parse(response)?.AsObject() 75public JsonNode CreateSession() => Result(Invoke("createSession", [])); 77public JsonNode StartGeneration(JsonNode session) => 80public JsonNode AddResource(JsonNode composition, string name) => 84public static JsonObject Arguments(params (string Name, JsonNode? Value)[] values) => 87public static JsonNode Result(JsonObject response) => response["result"]?.DeepClone()
TestServices\RuntimeRpcTestContext.cs (9)
18public JsonNode Session { get; } 19public JsonNode Composition { get; } 20public JsonNode Resource { get; } 21public JsonNode Execution { get; } 22public JsonNode Writer { get; } 23public JsonNode Reader { get; } 40var root = Result(Author.Call("getApplicationServer", null)); 57["urls"] = new JsonArray(urls.Select(url => (JsonNode?)JsonValue.Create(url)).ToArray()) 60public JsonNode Read() => Result(Observer.Invoke("readResourceObservations", Arguments(("context", Reader))));
TestServices\WorkspaceRpcTestContext.cs (9)
18public JsonNode Workspace { get; private set; } 19public JsonNode Composition { get; } 20public JsonNode Resource { get; } 21public JsonNode Execution { get; } 22public JsonNode Writer { get; } 23public JsonNode Reader { get; } 46public JsonNode BeginRevision() => Result(Author.Invoke("beginRevision", Arguments(("context", Workspace)))); 50var invitation = Result(Author.Invoke("inviteApplicationWorkspace", Arguments(("context", Workspace)))); 63public JsonNode Read() => Result(Observer.Invoke("readResourceObservations", Arguments(("context", Reader))));
WorkloadDefinitionTests.cs (1)
20var allocation = Result(await context.Integration.InvokeAsync("startContainerWorkload", Arguments(
Aspire.Hosting.Native.Server (87)
Api\ParameterApi.cs (1)
44var configuration = JsonNode.Parse(options) as JsonObject
Api\PublishingApi.cs (12)
27parts => new() { ["kind"] = "composite", ["parts"] = new JsonArray(parts.Cast<JsonNode>().ToArray()) }, 38KeyValuePair.Create(entry.Name, (JsonNode?)JsonValue.Create(entry.Value)))); 56arguments.Add((JsonNode)Expression(binding is null 61resources.Add((JsonNode)new JsonObject 73["endpoints"] = new JsonArray((plan?.Endpoints ?? []).Select(endpoint => (JsonNode)new JsonObject 80["mounts"] = new JsonArray(((plan as ContainerWorkload)?.Mounts ?? []).Select(mount => (JsonNode)new JsonObject 85["dependencies"] = new JsonArray(resource.Dependencies.Select(handle => (JsonNode?)JsonValue.Create(names[handle])).ToArray()), 86["lifecycle"] = new JsonArray((workload?.Lifecycle ?? []).Select(hook => (JsonNode?)JsonValue.Create(hook.Phase)) 87.Concat(resource.ProviderLifecycle.Select(hook => (JsonNode?)JsonValue.Create("provider"))).ToArray()), 97.Select(parameter => (JsonNode?)JsonValue.Create(parameter.ParameterName)).ToArray()), 99.Select(parameter => (JsonNode?)JsonValue.Create(parameter.ParameterName)).ToArray()), 102KeyValuePair.Create(parameter.Value.ParameterName, (JsonNode?)JsonValue.Create(parameter.Value.Resolve(ValueNetworkContext.Host,
artifacts\obj\Aspire.Hosting.Native.Server\Debug\native-ats\NativeDispatch.g.cs (2)
12public static async Task<JsonNode?> InvokeAsync(NativeApplicationServer server, NativeHandles handles, NativeRpcConnection connection, NativeRpcConnection callbackConnection, string capability, JsonObject arguments) 131return new JsonArray(result.Select(value => (JsonNode?)JsonValue.Create(value)).ToArray());
Rpc\INativeRpcPeer.cs (1)
15Task<JsonNode?> RequestAsync(string method, JsonArray arguments, CancellationToken cancellationToken);
Rpc\NativeHandles.cs (1)
45public T Get<T>(JsonNode? value, string expectedTypeId) where T : class
Rpc\NativeLanguageCatalog.cs (2)
65catalog._providers = JsonNode.Parse(File.ReadAllText(Path.Combine(generatedSdkDirectory, "providers.json")))!.AsArray(); 81return JsonNode.Parse(registration.RuntimeSpec.GetRawText())!.AsObject();
Rpc\NativeProviderLifecycle.cs (2)
79var result = await peer.RequestAsync("handleExternalCapability", 146var result = await peer.RequestAsync("releaseIntegrationResource",
Rpc\NativeProviderMetadata.cs (2)
29public static NativeProviderMetadataCapability[] Read(JsonNode? manifest) 58private static NativeProviderMetadataParameter ReadParameter(JsonNode? parameter)
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\NativeProviderValueProtocol.cs (2)
11public static void ValidatePrimitive(JsonNode? value, NativeProviderType type) 24public static NativeProviderHandle ParseReturnedHandle(JsonNode? value, NativeProviderType type, IReadOnlySet<string> coreHandles)
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
Rpc\NativeRpcConnection.Dispatch.cs (14)
12private JsonNode? Authenticate(JsonNode? parameters) 31private JsonNode GetApplicationServer(JsonNode? parameters) 41private static JsonNode GetCapabilities(JsonNode? parameters) 51private JsonNode GetAppHostServerConfiguration(JsonNode? parameters) 62private JsonNode Bootstrap(string method, JsonNode? parameters) 80private async Task<JsonNode?> InvokeCapabilityAsync(JsonNode? parameters) 102private async Task<JsonNode?> InvokeProviderControlAsync(string method, JsonNode? parameters)
Rpc\NativeRpcDataTypes.cs (2)
13public JsonNode? Id { get; init; } 27[JsonSerializable(typeof(JsonNode))]
Rpc\NativeRpcPeer.cs (3)
24private readonly ConcurrentDictionary<string, TaskCompletionSource<JsonNode?>> _pending = new(StringComparer.Ordinal); 29public async Task<JsonNode?> RequestAsync(string method, JsonArray arguments, CancellationToken cancellationToken) 31var completion = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously);
Rpc\NativeRpcProtocol.cs (3)
12internal sealed record NativeRpcRequest(JsonNode? Id, string Method, JsonNode? Parameters, bool IsNotification); 156public static JsonNode? ToNode(JsonElement element) => element.ValueKind switch
Rpc\RpcArguments.cs (7)
21public static string String(JsonNode? value) 31public static bool Boolean(JsonNode? value) => value is JsonValue scalar && scalar.TryGetValue<bool>(out var result) 34public static string[] Strings(JsonNode? value) => value is JsonArray array 38public static object Union(JsonNode? value, NativeHandles handles, string[] typeIds) 52public static int Int32(JsonNode? value) => value is JsonValue scalar && scalar.TryGetValue<int>(out var result) 55public static long Int64(JsonNode? value) => value is JsonValue scalar && scalar.TryGetValue<long>(out var result) 58public static T Dto<T>(JsonNode? value, JsonTypeInfo<T> typeInfo) where T : class =>
Aspire.Hosting.Nats.Tests (3)
AddNatsTests.cs (2)
193var manifest = await ManifestUtils.GetManifest(nats.Resource); 230var manifest = await ManifestUtils.GetManifest(nats.Resource);
ConnectionPropertiesTests.cs (1)
66var manifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.Oracle.Tests (4)
AddOracleTests.cs (3)
199var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource); 200var dbManifest = await ManifestUtils.GetManifest(db.Resource); 238var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource);
ConnectionPropertiesTests.cs (1)
88var oracleManifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.PostgreSQL.Tests (3)
AddPostgresTests.cs (3)
274var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 275var dbManifest = await ManifestUtils.GetManifest(db.Resource); 318var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource);
Aspire.Hosting.Python.Tests (7)
AddPythonAppTests.cs (7)
40var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 78var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 1352var manifest = await ManifestUtils.GetManifest(resource, workspace.Path); 1367var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1382var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1397var manifest = await ManifestUtils.GetManifest(app.Resource, workspace.Path); 1552var manifest = await ManifestUtils.GetManifestForModel(appModel, workspace.Path);
Aspire.Hosting.Qdrant.Tests (2)
AddQdrantTests.cs (2)
346var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 384var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes
Aspire.Hosting.RabbitMQ.Tests (3)
AddRabbitMQTests.cs (2)
207var manifest = await ManifestUtils.GetManifest(rabbit.Resource); 252var manifest = await ManifestUtils.GetManifest(rabbit.Resource);
ConnectionPropertiesTests.cs (1)
66var manifest = await ManifestUtils.GetManifest(app.Resource);
Aspire.Hosting.Radius (1)
Publishing\RadiusDeploymentPipelineStep.cs (1)
73if (JsonNode.Parse(json) is not JsonObject root ||
Aspire.Hosting.Redis.Tests (17)
AddRedisTests.cs (14)
154var fullManifest = await ManifestUtils.GetManifestForModel(model); 155var resources = fullManifest["resources"]!; 156var manifest = resources["redis"]!; 179var fullManifest = await ManifestUtils.GetManifestForModel(model); 180var resources = fullManifest["resources"]!; 181var manifest = resources["redis"]!; 208var fullManifest = await ManifestUtils.GetManifestForModel(model); 209var resources = fullManifest["resources"]!; 210var manifest = resources["redis"]!; 234var fullManifest = await ManifestUtils.GetManifestForModel(model); 235var resources = fullManifest["resources"]!; 236var manifest = resources["redis"]!; 1148private static void AssertConditionalExpressionInManifest(JsonNode resources, string creName) 1150var creEntry = resources[creName];
RedisFunctionalTests.cs (3)
714var jo = JsonNode.Parse(content); 716var agreements = jo["agreements"];
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\AtsMarshaller.cs (17)
137public JsonNode? MarshalToJson(object? value, AtsTypeRef typeRef) 169private JsonNode? MarshalUnion(object value, AtsTypeRef typeRef) 194public JsonNode? MarshalToJson(object? value, Type declaredType) 227private static JsonNode? SerializePrimitive(object value) 252private static JsonNode? SerializeDto(object value) 255return JsonNode.Parse(json); 374var node = JsonNode.Parse(ref reader); 384private JsonNode? SerializeArray(object value, AtsTypeRef? elementType) 438public JsonNode? MarshalToJson(object? value) 466private JsonNode? SerializeArrayRuntime(object value) 476private JsonNode? SerializeCancellationToken(CancellationToken cancellationToken) 487private JsonNode? MarshalListHandle(object value, Type type) 502private JsonNode? MarshalDictHandle(object value, Type type) 525public object? UnmarshalFromJson(JsonNode? node, Type targetType, UnmarshalContext context) 719private static string DescribeJsonNode(JsonNode? node) 1026if (!source.TryGetPropertyValue(prop.Name, out var jsonValue))
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)
Ats\ExternalCapabilityRegistry.cs (6)
444public async Task<(bool Found, JsonNode? Result)> TryInvokeAsync( 486JsonNode? result; 489result = JsonNode.Parse(je.GetRawText()); 491else if (rawResult is JsonNode jn) 552internal async Task<JsonNode?> InvokeGuestCallbackAsync(JsonRpc host, string callbackId, JsonObject? args, CancellationToken cancellationToken) 569return await owner.Invoker.InvokeAsync<JsonNode?>(owner.CallbackId, args, cancellation.Token, _callbackTimeout).ConfigureAwait(false);
Ats\HandleRegistry.cs (3)
195public static HandleRef? FromJsonNode(JsonNode? node) 197if (node is JsonObject obj && obj.TryGetPropertyValue("$handle", out var handleNode)) 211public static bool IsHandleRef(JsonNode? node)
Ats\PolyglotCapabilityInvocationException.cs (2)
259if (!args.TryGetPropertyValue(targetParameterName, out var targetNode)) 268private static string? TryGetResourceName(JsonNode? node, HandleRegistry handles)
Ats\ReferenceExpressionRef.cs (16)
50public JsonNode?[]? ValueProviders { get; init; } 53public JsonNode? Condition { get; init; } 54public JsonNode? WhenTrue { get; init; } 55public JsonNode? WhenFalse { get; init; } 69public static ReferenceExpressionRef? FromJsonNode(JsonNode? node) 71if (node is not JsonObject obj || !obj.TryGetPropertyValue("$expr", out var exprNode)) 82if (exprObj.TryGetPropertyValue("condition", out var conditionNode)) 84exprObj.TryGetPropertyValue("whenTrue", out var whenTrueNode); 85exprObj.TryGetPropertyValue("whenFalse", out var whenFalseNode); 88if (exprObj.TryGetPropertyValue("matchValue", out var matchValueNode) && 105if (!exprObj.TryGetPropertyValue("format", out var formatNode) || 113JsonNode?[]? valueProviders = null; 114if (exprObj.TryGetPropertyValue("valueProviders", out var providersNode) && 117valueProviders = new JsonNode?[providersArray.Count]; 136public static bool IsReferenceExpressionRef(JsonNode? node) 218var providerNode = ValueProviders[i];
AtsCapabilityScanner.cs (1)
1456private static JsonNode? SerializeExportedValue(object? value, Type memberType)
CodeGeneration\CodeGenerationService.cs (1)
592public System.Text.Json.Nodes.JsonNode? Value { get; set; }
ICallbackInvoker.cs (2)
22Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken = default); 30Task InvokeAsync(string callbackId, JsonNode? args, CancellationToken cancellationToken = default);
JsonRpcCallbackInvoker.cs (3)
85public Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken = default) 88internal async Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken, TimeSpan timeout) 133public async Task InvokeAsync(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
RemoteAppHostService.cs (3)
125public async Task<JsonNode?> InvokeCapabilityAsync(string capabilityId, JsonObject? args, CancellationToken cancellationToken) 133var result = await _capabilityDispatcher.InvokeAsync(capabilityId, args, _callbackInvoker, cancellationToken).ConfigureAwait(false); 224public async Task<JsonNode?> InvokeGuestCallbackAsync(string callbackId, JsonObject? args, CancellationToken cancellationToken)
Aspire.Hosting.RemoteHost.Tests (180)
AtsContextFilterTests.cs (1)
595Value = JsonNode.Parse("""{"mode":"Run"}""")
AtsMarshallerTests.cs (30)
124var result = marshaller.MarshalToJson(null); 134var result = marshaller.MarshalToJson("hello"); 145var result = marshaller.MarshalToJson(42); 156var result = marshaller.MarshalToJson(true); 181var result = marshaller.MarshalToJson(value, typeRef); 235var result = marshaller.MarshalToJson(TestEnum.ValueB); 246var result = marshaller.MarshalToJson(TimeSpan.FromSeconds(1.5)); 258var result = marshaller.MarshalToJson(array); 276var result = marshaller.MarshalToJson(cts.Token); 297var result = marshaller.MarshalToJson(cts.Token, typeRef); 526var result = marshaller.MarshalToJson(dateOnly); 549var result = marshaller.MarshalToJson(timeOnly); 570var result = marshaller.MarshalToJson(9223372036854775807L); 581var result = marshaller.MarshalToJson(3.14159); 593var result = marshaller.MarshalToJson(guid); 605var result = marshaller.MarshalToJson(list); 624var result = marshaller.MarshalToJson(dict); 643var result = marshaller.MarshalToJson(obj); 839var result = marshaller.MarshalToJson(dto); 894var result = marshaller.MarshalToJson(dto); 987var result = marshaller.MarshalToJson(dto); 1003var result = marshaller.MarshalToJson(parent); 1023var result = marshaller.MarshalToJson(dto, typeRef); 1039var result = marshaller.MarshalToJson(parent); 1084var source = new JsonObject { ["count"] = JsonNode.Parse(countJson) }; 1098var source = new JsonObject { ["count"] = JsonNode.Parse(countJson) }; 1339var result = marshaller.MarshalToJson(conditional); 1358var json = marshaller.MarshalToJson(conditional); 1378var json = marshaller.MarshalToJson(conditional); 1397var json = marshaller.MarshalToJson(conditional);
CallbackProxyTests.cs (4)
528public List<(string CallbackId, JsonNode? Args)> Invocations { get; } = []; 529public JsonNode? ResultToReturn { get; set; } 533public Task<TResult> InvokeAsync<TResult>(string callbackId, JsonNode? args, CancellationToken cancellationToken = default) 543public Task InvokeAsync(string callbackId, JsonNode? args, CancellationToken cancellationToken = default)
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);
JsonRpcCallbackInvokerTests.cs (7)
21var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously); 36var invocation = invoker.InvokeAsync<JsonNode?>("stall", null, TestContext.Current.CancellationToken); 48await Assert.ThrowsAnyAsync<OperationCanceledException>(() => invoker.InvokeAsync<JsonNode>( 60var response = new TaskCompletionSource<JsonNode?>(TaskCreationOptions.RunContinuationsAsynchronously); 76await Assert.ThrowsAsync<TimeoutException>(() => invoker.InvokeAsync<JsonNode>( 80var result = await invoker.InvokeAsync<JsonNode>(
KubernetesManifestTests.cs (9)
41var manifestHandle = dispatcher.Invoke("Aspire.Hosting.Kubernetes/addManifest", new JsonObject 50void WithField(string path, JsonNode value) 52var result = dispatcher.Invoke("Aspire.Hosting.Kubernetes/withField", new JsonObject 64WithField("spec.endpointSelector.matchLabels", JsonNode.Parse("""{"app.kubernetes.io/component":"api"}""")!); 65WithField("spec.ingress", JsonNode.Parse(""" 99var manifestHandle = dispatcher.Invoke("Aspire.Hosting.Kubernetes/addManifest", new JsonObject 114JsonNode value = shape switch 152var manifestHandle = dispatcher.Invoke("Aspire.Hosting.Kubernetes/addManifest", new JsonObject 165["value"] = JsonNode.Parse(json)
ReferenceExpressionRefTests.cs (7)
135var valueProviders = new JsonNode?[] 156var valueProviders = new JsonNode?[] 173var valueProviders = new JsonNode?[] 195var valueProviders = new JsonNode?[] 235var valueProviders = new JsonNode?[] 250private sealed class ReferenceExpressionRef_Accessor(string format, JsonNode?[]? valueProviders) 266foreach (var p in valueProviders)
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)
AddSeqTests.cs (3)
92var manifest = await ManifestUtils.GetManifest(seq.Resource); 253var manifest = await ManifestUtils.GetManifest(seq.Resource); 283var manifest = await ManifestUtils.GetManifest(seq.Resource);
Aspire.Hosting.SqlServer.Tests (3)
AddSqlServerTests.cs (3)
133var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource); 134var dbManifest = await ManifestUtils.GetManifest(db.Resource); 174var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource);
Aspire.Hosting.Tests (111)
AddConnectionStringTests.cs (1)
31var connectionStringManifest = await ManifestUtils.GetManifest(connectionStringResource).DefaultTimeout();
AddParameterTests.cs (5)
415var paramManifest = await ManifestUtils.GetManifest(appModel.Resources.OfType<ParameterResource>().Single(r => r.Name == "pass")).DefaultTimeout(); 487var paramManifest = await ManifestUtils.GetManifest(appModel.Resources.OfType<ParameterResource>().Single(r => r.Name == "pass")).DefaultTimeout(); 579var paramManifest = await ManifestUtils.GetManifest(appModel.Resources.OfType<ParameterResource>().Single(r => r.Name == "pass")).DefaultTimeout(); 636var paramManifest = await ManifestUtils.GetManifest(appModel.Resources.OfType<ParameterResource>().Single(r => r.Name == "val")).DefaultTimeout(); 664var connectionStringManifest = await ManifestUtils.GetManifest(connectionStringResource).DefaultTimeout();
Backchannel\AuxiliaryBackchannelRpcTargetTests.cs (2)
329Assert.True(snapshot.Properties.TryGetValue(CustomResourceKnownProperties.Source, out var normalValue)); 332Assert.True(snapshot.Properties.TryGetValue("ConnectionString", out var sensitiveValue));
Backchannel\BackchannelContractTests.cs (5)
368if (propertyType == typeof(JsonNode)) 370return JsonNode.Parse($$"""{ "property": "{{propertyName}}" }""")!; 389if (expected is JsonNode expectedNode && actual is JsonNode actualNode) 413JsonNode node => node.ToJsonString(),
ConditionalReferenceExpressionTests.cs (5)
118var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 137var manifest = await ManifestUtils.GetManifestForModel( 156var manifest = await ManifestUtils.GetManifestForModel( 192var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 213var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>());
Dashboard\DashboardResourceTests.cs (1)
806var manifest = await ManifestUtils.GetManifestOrNull(dashboard).DefaultTimeout();
Dcp\AppHostLocalStateStoreTests.cs (5)
39var state = JsonNode.Parse(File.ReadAllText(stateFile)); 67var resources = JsonNode.Parse(File.ReadAllText(stateFile))?["portAllocations"]?["resources"]?.AsObject(); 94var state = JsonNode.Parse(File.ReadAllText(stateFile))!.AsObject(); 122var state = JsonNode.Parse(File.ReadAllText(stateFile))!.AsObject();
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)));
Dcp\TestKubernetesService.cs (1)
405var resultNode = JsonPatch.Apply(JsonSerializer.SerializeToNode(res, resourceType), jsonPatch);
DistributedApplicationBuilderTests.cs (2)
716var state = System.Text.Json.Nodes.JsonNode.Parse(""" 799Assert.Equal(42, System.Text.Json.Nodes.JsonNode.Parse(await File.ReadAllTextAsync(aspirePath))!["Resource:Count"]!.GetValue<int>());
DotnetProgramPublishingTests.cs (1)
160var manifest = await ManifestUtils.GetManifest(
ExecutableResourceTests.cs (1)
68var manifest = await ManifestUtils.GetManifest(exe2.Resource).DefaultTimeout();
ExternalServiceTests.cs (1)
491var manifest = await ManifestUtils.GetManifest(project.Resource);
KestrelConfigTests.cs (4)
177var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout(); 219var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout(); 288var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout(); 308var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout();
ManifestExpressionTests.cs (28)
45var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 72var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 97var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>(), workspace.Path) 174var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 198var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 228var manifest = await ManifestUtils.GetManifestForModel(model); 232var repeated = await ManifestUtils.GetManifestForModel(model); 235Assert.True(JsonNode.DeepEquals(manifest, repeated)); 255var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 276var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 309var initial = await ManifestUtils.GetManifestForModel(model); 314var manifest = await ManifestUtils.GetManifestForModel(model); 329var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 344var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 364var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 392var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 422var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()) 443var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>(), workspace.Path) 459var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()) 482var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 505var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 523var manifest = await ManifestUtils.GetManifestForModel( 552var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 575var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 636var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 658var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>()); 672var manifest = await ManifestUtils.GetManifestForModel( 686var manifest = await ManifestUtils.GetManifestForModel(app.Services.GetRequiredService<DistributedApplicationModel>());
ManifestGenerationTests.cs (5)
102var redisManifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout(); 548var manifest = await ManifestUtils.GetManifest(param.Resource).DefaultTimeout(); 574var destManifest = await ManifestUtils.GetManifest(destContainer.Resource).DefaultTimeout(); 617var destManifest = await ManifestUtils.GetManifest(destContainer.Resource).DefaultTimeout(); 668var destManifest = await ManifestUtils.GetManifest(destContainer.Resource).DefaultTimeout();
Orchestrator\ParameterProcessorTests.cs (9)
1626Assert.True(capturingStateManager.State.TryGetPropertyValue($"Parameters:{parameter.Name}", out var savedValueNode)); 1659Assert.True(capturingStateManager.State.TryGetPropertyValue($"Parameters:{parameter.Name}", out var savedValueNode)); 2042Assert.True(capturingStateManager.State.TryGetPropertyValue("ConnectionStrings:mydb", out var valueNode)); 2083Assert.True(capturingStateManager.State.TryGetPropertyValue("Parameters:myparam", out var valueNode)); 2127Assert.True(capturingStateManager.State.TryGetPropertyValue("MyCustomSection:MyCustomKey", out var valueNode)); 2166Assert.True(capturingStateManager.State.TryGetPropertyValue($"Parameters:{parameter.Name}", out var savedValueNode)); 2184Assert.True(capturingStateManager.State.TryGetPropertyValue($"Parameters:{parameter.Name}", out var savedValueNode)); 2252Assert.True(capturingStateManager.State.TryGetPropertyValue($"Parameters:{parameter.Name}", out var savedValueNode)); 2743var sectionData = _unflattenedState.TryGetPropertyValue(sectionName, out var sectionNode) && sectionNode is JsonObject obj
ProjectResourceTests.cs (2)
630var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout(); 678var manifest = await ManifestUtils.GetManifest(resource).DefaultTimeout();
PublishAsConnectionStringTests.cs (1)
24var manifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout();
PublishAsDockerfileTests.cs (5)
29var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 75var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 124var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 173var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 235var manifest = await ManifestUtils.GetManifest(project.Resource, manifestDirectory: path).DefaultTimeout();
Publishing\ContainerImageArchiveRewriterTests.cs (1)
456metadata[entryName] = JsonNode.Parse(TestContainerImageArchive.ReadEntryText(archivePath, entryName));
WithEndpointTests.cs (10)
275var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 303var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 330var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 357var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 384var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 411var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 438var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 469var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 537var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 606var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout();
Aspire.Hosting.TestUtilities (14)
Utils\ManifestUtils.cs (14)
13public static async Task<JsonNode> GetManifest(IResource resource, string? manifestDirectory = null) 15var node = await GetManifestOrNull(resource, manifestDirectory); 20public static async Task<JsonNode?> GetManifestOrNull(IResource resource, string? manifestDirectory = null) 39var obj = JsonNode.Parse(ms); 41var resourceNode = obj[resource.Name]; 45public static async Task<JsonNode> GetManifestForModel(DistributedApplicationModel model, string? manifestDirectory = null) 61var obj = JsonNode.Parse(ms); 66public static async Task<JsonNode[]> GetManifests(IResource[] resources) 77var results = new List<JsonNode>(); 86var obj = JsonNode.Parse(ms); 88var resourceNode = obj[r.Name];
Aspire.Hosting.Valkey.Tests (2)
AddValkeyTests.cs (2)
127var manifest = await ManifestUtils.GetManifest(valkey.Resource); 165var manifest = await ManifestUtils.GetManifest(valkey.Resource);
Aspire.Hosting.Yarp (3)
YarpJsonConfigGeneratorBuilder.cs (3)
84var jsonProxyConfig = jsonObject["ReverseProxy"] = new JsonObject(); 100var node = JsonSerializer.SerializeToNode(route, _serializerOptions); 114var node = JsonSerializer.SerializeToNode(cluster, _serializerOptions);
Aspire.Managed.Tests (1)
AppHostServerV2CodeGenerationTests.cs (1)
121["providers"] = new JsonArray((JsonNode)new JsonObject
Aspire.TestTools (7)
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);
Aspire.TypeSystem (1)
AtsExportedValueInfo.cs (1)
30public required JsonNode? Value { get; init; }
ConfigurationSchemaGenerator (15)
ConfigSchemaEmitter.cs (15)
119var backupTypeNode = currentNode["type"]; 174var existingValue = propertiesNode[pathSegment]; 240var backupTypeNode = currentNode["type"]; 284var backupPropertyNode = currentNode[property.ConfigurationKeyName]; 315var backupTypeNode = currentNode["type"]; 316var backupContainerNode = currentNode[containerName]; 334private static void RestoreBackup(JsonNode? backupNode, string name, JsonObject parentNode) 449var propertyNodeType = propertyNode["type"]; 718private static void ReplaceNodeWithKeyCasingChange(JsonObject jsonObject, string key, JsonNode value) 729private sealed class SchemaOrderJsonNodeConverter : JsonConverter<JsonNode> 733public override bool CanConvert(Type typeToConvert) => typeof(JsonNode).IsAssignableFrom(typeToConvert) && typeToConvert != typeof(JsonValue); 735public override void Write(Utf8JsonWriter writer, JsonNode? value, JsonSerializerOptions options) 742IEnumerable<KeyValuePair<string, JsonNode>> properties = 756foreach (var item in array) 771public override JsonNode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
ConfigurationSchemaGenerator.Tests (4)
GeneratorTests.cs (4)
1579var actualJson = JsonNode.Parse(actual)!; 1580var expectedJson = JsonNode.Parse(expected)!;
dotnet-aot (4)
parent\dotnet\CliSchema.cs (1)
94var node = s_jsonContext.RootCommandDetails.GetJsonSchemaAsNode(new JsonSchemaExporterOptions());
parent\dotnet\Telemetry\TelemetryDiskLogger.cs (3)
55var root = JsonNode.Parse(jsonText)!; 60activitiesArray.Add(JsonNode.Parse(JsonSerializer.Serialize(CreateActivityJsonModel(activity), s_jsonContext.ActivityModel)));
dotnet-user-jwts (1)
Helpers\SigningKeysHandler.cs (1)
85var toRemove = signingKeys.SingleOrDefault(key => key["Issuer"].GetValue<string>() == issuer);
GenerateTemplateManifest (1)
TemplateRestorePlan.cs (1)
73var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject();
Infrastructure.Tests (193)
Pipelines\NixCliPackageTests.cs (3)
145return JsonNode.Parse(contents)?.AsObject() 187Assert.True(obj.TryGetPropertyValue(propertyName, out var value), $"Expected property '{propertyName}'."); 193Assert.True(obj.TryGetPropertyValue(propertyName, out var value), $"Expected property '{propertyName}'.");
Pipelines\NpmCliPackageTests.cs (2)
350return JsonNode.Parse(json)?.AsObject() 366private static string[] GetStringArray(JsonNode? jsonNode)
TemplateManifest\TemplateManifestCacheTests.cs (4)
50var firstManifest = JsonNode.Parse(File.ReadAllText(environment.ManifestPath)); 56var secondManifest = JsonNode.Parse(File.ReadAllText(environment.ManifestPath));
TemplateManifest\TemplateManifestNpmTests.cs (4)
42var lockfile = JsonNode.Parse(File.ReadAllText(lockPath))!; 80var lockfile = JsonNode.Parse(File.ReadAllText(lockPath))!;
TemplateManifest\TemplateRestorePlanTests.cs (8)
72var config = JsonNode.Parse(File.ReadAllText(configPath))!; 73config["symbols"]!["IsNew"] = JsonNode.Parse("""{"type":"computed","value":"(Mode == \"New\")"}"""); 74config["sources"] = JsonNode.Parse("""[{"modifiers":[{"condition":"(Mode == \"None\")","exclude":["*.csproj"]}]}]"""); 238var config = JsonNode.Parse(""" 290var config = JsonNode.Parse(""" 304config["symbols"]!["Mode"] = JsonNode.Parse(mode);
WorkflowScripts\AnalyzeCiFailureReportTemplatesTests.cs (5)
25var result = await RunAsync(eventName, sourceRunId); 41var result = await RunAsync("workflow_run", "40727814372", missingTemplate); 57var result = await RunAsync( 67private async Task<JsonNode> RunAsync( 128return JsonNode.Parse(result.Output)!;
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)
Helpers\GenericListOrJsonArrayUtilities.cs (2)
35array[index] = (JsonNode)value; 82array.Insert(index, (JsonNode)value);
Helpers\JsonUtilities.cs (3)
24if (a is JsonNode nodeA && b is JsonNode nodeB) 26return JsonNode.DeepEquals(nodeA, nodeB);
Internal\JsonObjectAdapter.cs (3)
37if (!obj.TryGetPropertyValue(segment, out var valueAsToken)) 98if (!obj.TryGetPropertyValue(segment, out var currentValue)) 129if (!obj.TryGetPropertyValue(segment, out var nextTargetToken))
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)
Extensions\OpenApiDocumentExtensions.cs (2)
42Examples = example is JsonNode exampleJson ? [exampleJson] : null, 43Default = defaultAnnotation as JsonNode,
Generated\361d1da7f942c932\OpenApiJsonSchemaContext.GetJsonTypeInfo.g.cs (1)
30if (type == typeof(global::System.Text.Json.Nodes.JsonNode))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\OpenApiJsonSchemaContext.JsonNode.g.cs (8)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.Nodes.JsonNode>? _JsonNode; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.Nodes.JsonNode> JsonNode 22get => _JsonNode ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.Nodes.JsonNode>)Options.GetTypeInfo(typeof(global::System.Text.Json.Nodes.JsonNode)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.Nodes.JsonNode> Create_JsonNode(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Text.Json.Nodes.JsonNode>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Text.Json.Nodes.JsonNode> jsonTypeInfo)) 29jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Text.Json.Nodes.JsonNode>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.JsonNodeConverter);
Schemas\OpenApiJsonSchema.Helpers.cs (3)
90private static JsonNode? ReadJsonNode(ref Utf8JsonReader reader) 93private static JsonNode? ReadJsonNode(ref Utf8JsonReader reader, out JsonSchemaType? type) 221var enumValues = ReadList<JsonNode>(ref reader, context);
Schemas\OpenApiJsonSchemaContext.cs (1)
13[JsonSerializable(typeof(JsonNode))]
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)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (1)
220static JsonNode? JsonElementToJsonNode(JsonElement element) =>
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\AIJsonSchemaCreateOptions.cs (2)
25public Func<AIJsonSchemaCreateContext, JsonNode, JsonNode>? TransformSchemaNode { get; init; }
Utilities\AIJsonSchemaTransformOptions.cs (2)
17public Func<AIJsonSchemaTransformContext, JsonNode, JsonNode>? TransformSchemaNode { get; init; }
Utilities\AIJsonUtilities.cs (3)
114JsonNode? jsonNode = JsonSerializer.SerializeToNode(value, jti); 162static void NormalizeJsonNode(JsonNode? node) 167foreach (JsonNode? item in array)
Utilities\AIJsonUtilities.Defaults.cs (2)
72[JsonSerializable(typeof(JsonNode))] 153[JsonSerializable(typeof(JsonNode))]
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)
AssertExtensions.cs (1)
141if (!JsonNode.DeepEquals(
Contents\FunctionCallContentTests.cs (8)
93var json = JsonSerializer.SerializeToNode(sut, TestJsonSerializerContext.Default.Options); 100JsonNode? informationalOnlyValue = null; 101if (jsonObj.TryGetPropertyValue("informationalOnly", out var value1)) 105else if (jsonObj.TryGetPropertyValue("InformationalOnly", out var value2)) 149var json = JsonSerializer.SerializeToNode(original, TestJsonSerializerContext.Default.Options); 167var json = JsonSerializer.SerializeToNode(sut, TestJsonSerializerContext.Default.Options); 257var arguments = JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(""" 314AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>("""
test\Shared\JsonSchemaExporter\SchemaTestHelpers.cs (11)
17public static void AssertEqualJsonSchema(JsonNode expectedJsonSchema, JsonNode actualJsonSchema) 19if (!JsonNode.DeepEquals(expectedJsonSchema, actualJsonSchema)) 31public static void AssertDocumentMatchesSchema(JsonNode schema, JsonNode? instance) 52public static void AssertDoesNotMatchSchema(JsonNode schema, JsonNode? instance) 67private static EvaluationResults EvaluateSchemaCore(JsonNode schema, JsonNode? instance) 74private static string FormatJson(JsonNode? node) => 78[JsonSerializable(typeof(JsonNode))]
test\Shared\JsonSchemaExporter\TestData.cs (3)
30JsonNode ITestData.ExpectedJsonSchema { get; } = 31JsonNode.Parse(ExpectedJsonSchema, documentOptions: _schemaParseOptions) 63JsonNode ExpectedJsonSchema { get; }
test\Shared\JsonSchemaExporter\TestTypes.cs (6)
103yield return new TestData<JsonNode>(JsonNode.Parse("""[{ "x" : 42 }]"""), "true"); 106yield return new TestData<JsonArray>([(JsonNode)1, (JsonNode)2, (JsonNode)3], """{"type":["array","null"]}"""); 1247[JsonSerializable(typeof(JsonNode))]
TestJsonSerializerContext.cs (1)
36[JsonSerializable(typeof(Dictionary<string, JsonNode>))] // Used in Content tests
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)
AIToolExtensions.cs (3)
24JsonNode functionJsonNode = 29["functionSchema"] = JsonNode.Parse(function.JsonSchema.GetRawText()), 35JsonNode.Parse(function.ReturnJsonSchema.Value.GetRawText());
ChatMessageExtensions.cs (1)
21JsonNode? messageJsonNode =
ChatResponseExtensions.cs (1)
36JsonNode? toolCallOrResultJsonNode =
Microsoft.Extensions.AI.Evaluation.Safety (4)
EvaluationMetricExtensions.cs (4)
81JsonNode? jsonData = JsonNode.Parse(data); 87Failed to parse supplied {nameof(data)} below into a {nameof(JsonNode)}. 97internal static void LogJsonData(this EvaluationMetric metric, JsonNode data)
Microsoft.Extensions.AI.Integration.Tests (5)
VerbatimHttpHandler.cs (5)
108JsonNode? expectedNode = null; 109JsonNode? actualNode = null; 112expectedNode = JsonNode.Parse(expected); 113actualNode = JsonNode.Parse(actual); 121if (!JsonNode.DeepEquals(expectedNode, actualNode))
Microsoft.Extensions.AI.OpenAI (1)
OpenAIClientExtensions.cs (1)
98static void AppendLine(ref StringBuilder? sb, string propName, JsonNode propNode)
Microsoft.Extensions.AI.OpenAI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
141if (!JsonNode.DeepEquals(
Microsoft.Extensions.AI.Tests (3)
Functions\AIFunctionFactoryTest.cs (1)
138["y"] = JsonNode.Parse("2"),
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
141if (!JsonNode.DeepEquals(
TestJsonSerializerContext.cs (1)
23[JsonSerializable(typeof(Dictionary<string, JsonNode>))]
Microsoft.ML.AutoML (12)
SweepableEstimator\Converter\MultiModelPipelineConverter.cs (3)
17var jValue = JsonValue.Parse(ref reader); 26var jsonObject = JsonNode.Parse("{}");
SweepableEstimator\Converter\SweepableEstimatorConverter.cs (2)
18var jsonObject = JsonValue.Parse(ref reader); 29var jObject = JsonObject.Parse("{}");
SweepableEstimator\Converter\SweepableEstimatorPipelineConverter.cs (4)
17var jNode = JsonNode.Parse(ref reader); 29var jNode = JsonNode.Parse("{}");
SweepableEstimator\Converter\SweepablePipelineConverter.cs (3)
17var jValue = JsonValue.Parse(ref reader); 27var jsonObject = JsonNode.Parse("{}");
Microsoft.ML.AutoML.SourceGenerator (5)
SearchSpaceGenerator.cs (5)
35var searchSpacesJNodes = searchSpacesJson.Select(x => JsonNode.Parse(x)); 37foreach (var jNode in searchSpacesJNodes) 65var defaultToken = t.AsObject().ContainsKey("default") ? t["default"] : null; 86var searchSpaceNode = t.AsObject().ContainsKey("search_space") ? t["search_space"] : null; 96var minToken = searchSpaceNode["min"];
Microsoft.NET.Build.Containers (17)
ImageConfig.cs (9)
44internal ImageConfig(string imageConfigJson) : this(JsonNode.Parse(imageConfigJson)!) 48internal ImageConfig(JsonNode config) 129if (_config["config"]?[propertyName] is JsonNode propertyValue) 134newConfig[propertyName] = JsonNode.Parse(propertyValue.ToJsonString()); 163["history"] = new JsonArray(_history.Select(CreateHistory).ToArray<JsonNode>()) 168static JsonArray ToJsonArray(IEnumerable<string> items) => new(items.Where(s => !string.IsNullOrEmpty(s)).Select(s => JsonValue.Create(s)).ToArray<JsonNode?>()); 249foreach (KeyValuePair<string, JsonNode?> property in portsJson) 268foreach (KeyValuePair<string, JsonNode?> property in labelsJson) 284foreach (JsonNode? entry in envVarJson)
LocalDaemons\ContainerArchive.cs (1)
165JsonNode manifestNode = new JsonArray(
LocalDaemons\DockerCli.cs (1)
391JsonNode manifestNode = new JsonArray(new JsonObject
Registry\DefaultBlobOperations.cs (3)
43public async Task<JsonNode> GetJsonAsync(string repositoryName, string digest, CancellationToken cancellationToken) 48JsonNode? configDoc = JsonNode.Parse(content.Span);
Registry\IBlobOperations.cs (1)
20public Task<JsonNode> GetJsonAsync(string repositoryName, string digest, CancellationToken cancellationToken);
Registry\Registry.cs (1)
245JsonNode configDoc = await _registryAPI.Blob.GetJsonAsync(repositoryName, configSha, cancellationToken).ConfigureAwait(false);
Tasks\CreateImageIndex.cs (1)
145var configJson = JsonNode.Parse(config) as JsonObject;
Microsoft.NET.Build.Tasks (9)
GenerateRuntimeConfigurationFiles.cs (7)
295JsonObject runtimeOptionsFromProject = (JsonObject)JsonNode.Parse( 299foreach (KeyValuePair<string, JsonNode> runtimeOption in runtimeOptionsFromProject) 322if (!runtimeOptions.RawOptions.TryGetValue("configProperties", out JsonNode configProperties) 332private static JsonNode GetConfigPropertyValue(ITaskItem hostConfigurationOption) 472probingPaths.Add((JsonNode)probingPath); 481foreach (KeyValuePair<string, JsonNode> rawOption in runtimeOptions.RawOptions) 497array.Add((JsonNode)SerializeFramework(framework));
RuntimeOptions.cs (2)
24public IDictionary<string, JsonNode> RawOptions { get; } = new Dictionary<string, JsonNode>();
Microsoft.NETCore.Platforms (2)
UpdateRuntimeIdentifierGraph.cs (2)
26JsonNode? json; 29json = JsonNode.Parse(stream);
Microsoft.TemplateEngine.Cli (55)
Alias\AliasRegistry.cs (4)
156arr.Add((JsonNode)JsonValue.Create(item)!); 180JsonNode? element = null; 195foreach (KeyValuePair<string, JsonNode?> property in jObj) 208foreach (JsonNode? item in arr)
HostSpecificDataLoader.cs (2)
48JsonObject? jObject = JsonNode.Parse(hostData, nodeOptions: null, s_jsonDocumentOptions)?.AsObject(); 72jsonData = JsonNode.Parse(stream, nodeOptions: null, s_jsonDocumentOptions)?.AsObject();
HostSpecificTemplateData.cs (5)
28JsonNode? usagesNode = GetPropertyCaseInsensitive(jObject, nameof(UsageExamples)); 36JsonNode? symbolsNode = GetPropertyCaseInsensitive(jObject, nameof(SymbolInfo)); 72JsonNode? isHiddenNode = GetPropertyCaseInsensitive(jObject, nameof(IsHidden)); 190private static JsonNode? GetPropertyCaseInsensitive(JsonObject obj, string key) 192if (obj.TryGetPropertyValue(key, out JsonNode? result))
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];
PostActionProcessors\ChmodPostActionProcessor.cs (1)
25JsonArray valueArray = JsonNode.Parse(entry.Value)!.AsArray();
PostActionProcessors\PostActionProcessorBase.cs (1)
126targetFiles.TryParse(out JsonNode? config);
TemplateSearch\CliHostSearchCacheData.cs (1)
36foreach (KeyValuePair<string, JsonNode?> data in cacheObject)
Microsoft.TemplateEngine.Edge (80)
BuiltInManagedProvider\GlobalSettings.cs (1)
86foreach (var package in jObject.Get<JsonArray>(nameof(GlobalSettingsData.Packages)) ?? new JsonArray())
Constraints\ConstraintsExtensions.cs (6)
20JsonNode token = ParseConstraintJsonNode(args); 54JsonNode token = ParseConstraintJsonNode(args); 113private static JsonNode ParseConstraintJsonNode(this string? args) 120JsonNode? token; 123token = JsonNode.Parse(args!); 133private static JsonArray ToConstraintsJsonArray(this JsonNode token, string? args, bool isStringTypeAllowed)
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())
Settings\SettingsStore.cs (5)
21if (obj.TryGetValueCaseInsensitive(nameof(ComponentGuidToAssemblyQualifiedName), out JsonNode? componentGuidToAssemblyQualifiedNameToken)) 35if (obj.TryGetValueCaseInsensitive(nameof(ProbingPaths), out JsonNode? probingPathsToken)) 39foreach (JsonNode? path in probingPathsArray) 49if (obj.TryGetValueCaseInsensitive(nameof(ComponentTypeToGuidList), out JsonNode? componentTypeToGuidListToken)) 60foreach (JsonNode? value in values)
Settings\TemplateCache.cs (5)
78if (contentJObject != null && contentJObject.TryGetValueCaseInsensitive(nameof(Version), out JsonNode? versionToken)) 91Locale = contentJObject.TryGetValueCaseInsensitive(nameof(Locale), out JsonNode? localeToken) 97if (contentJObject.TryGetValueCaseInsensitive(nameof(MountPointsInfo), out JsonNode? mountPointInfoToken) && mountPointInfoToken is JsonObject mountPointInfoObj) 112if (contentJObject.TryGetValueCaseInsensitive(nameof(TemplateInfo), out JsonNode? templateInfoToken) && templateInfoToken is JsonArray arr) 114foreach (JsonNode? entry in arr)
Settings\TemplateInfoReader.cs (6)
24JsonNode? shortNameToken = entry.Get<JsonNode>(nameof(ShortNameList)); 35foreach (JsonNode? item in classificationsArray) 81foreach (JsonNode? item in parametersArray) 110foreach (JsonNode? item in postActionsArray) 125foreach (JsonNode? item in constraintsArray)
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (87)
ConfigModel\BaseValueSymbol.cs (4)
23if (!jObject.TryGetValue(nameof(Forms), out JsonNode? formsToken) || formsToken is not JsonObject formsObject) 72private protected bool TryGetIsRequiredField(JsonNode token, out bool result) 81private bool ParseIsRequiredField(JsonNode token, bool throwOnError) 83if (!token.TryGetValue(nameof(IsRequired), out JsonNode? isRequiredToken))
ConfigModel\CustomFileGlobModel.cs (2)
44if (globData.TryGetValue(nameof(Operations), out JsonNode? operationData)) 46foreach (JsonNode? operationConfig in (JsonArray)operationData!)
ConfigModel\ParameterSymbol.cs (3)
198if (jObject != null && jObject.TryGetValue("IsEnabled", out JsonNode? isEnabledToken)) 246private static string? ParseIsRequiredConditionField(JsonNode token) 248if (!token.TryGetValue(nameof(IsRequired), out JsonNode? isRequiredToken))
ConfigModel\PostActionModel.cs (2)
90JsonNode? action = jArray[postActionIndex]; 191JsonNode? jToken = jArray[i];
ConfigModel\PrimaryOutputModel.cs (1)
39foreach (JsonNode? pathInfo in jsonData)
ConfigModel\ReplacementContext.cs (1)
38foreach (JsonNode? entry in onlyIf)
ConfigModel\SymbolValueFormsModel.cs (1)
35JsonNode? globalConfig = JExtensions.GetPropertyCaseInsensitive(configJson, "global");
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)
Macros\BaseMacroConfig.cs (4)
88var jToken = JExtensions.ParseJsonNode(token); 105var jToken = JExtensions.ParseJsonNode(token); 122var jToken = JExtensions.ParseJsonNode(token); 139var jToken = JExtensions.ParseJsonNode(token);
Macros\JoinMacroConfig.cs (1)
34foreach (JsonNode? entry in jArray)
Macros\RegexMacroConfig.cs (1)
36foreach (JsonNode? entry in jArray)
Macros\SwitchMacroConfig.cs (1)
35foreach (JsonNode? entry in jArray)
OperationConfig\ReplacementConfig.cs (1)
34foreach (JsonNode? entry in onlyIf)
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())
TemplateDiscoveryMetadata\BlobStorageTemplateInfo.cs (5)
155JsonNode? shortNameToken = entry.Get<JsonNode>(nameof(ShortNameList)); 167foreach (JsonNode? item in classificationsArray) 198foreach (JsonNode? item in postActionsArray) 214foreach (JsonNode? item in parametersArray)
TemplateDiscoveryMetadata\LegacySearchCacheReader.cs (10)
84if (cacheObject.TryGetValueCaseInsensitive(nameof(TemplateDiscoveryMetadata.Version), out JsonNode? value)) 104if (cacheObject.TryGetValueCaseInsensitive(nameof(TemplateDiscoveryMetadata.TemplateCache), out JsonNode? templateInfoToken)) 110foreach (JsonNode? entry in arr) 148JsonNode? packToTemplateMapToken = JExtensions.GetPropertyCaseInsensitive(cacheObject, nameof(TemplateDiscoveryMetadata.PackToTemplateMap)); 165JsonNode? versionNode = JExtensions.GetPropertyCaseInsensitive(entryValue, nameof(PackToTemplateEntry.Version)); 166JsonNode? identificationNode = JExtensions.GetPropertyCaseInsensitive(entryValue, nameof(PackToTemplateEntry.TemplateIdentificationEntry)); 173foreach (JsonNode? templateIdentityInfo in identificationArray) 187if (entryValue.TryGetValueCaseInsensitive(nameof(PackToTemplateEntry.TotalDownloads), out JsonNode? totalDownloadsNode) 217JsonNode? additionalDataToken = JExtensions.GetPropertyCaseInsensitive(cacheObject, nameof(TemplateDiscoveryMetadata.AdditionalData)); 232JsonNode? dataNode = JExtensions.GetPropertyCaseInsensitive(additionalDataObject, dataReadInfo.Key);
TemplateSearchCache\TemplatePackageSearchData.Json.cs (2)
33Owners = jObject.Get<JsonNode>(nameof(Owners)).JTokenStringOrArrayToCollection([]); 42foreach (JsonNode? template in templatesData)
TemplateSearchCache\TemplateSearchCache.Json.cs (2)
55foreach (JsonNode? templatePackage in data) 81JsonNode? dataNode = JExtensions.GetPropertyCaseInsensitive(cacheObject, dataReadInfo.Key);
MSBuild (3)
JsonOutputFormatter.cs (3)
20private readonly JsonNode _topLevelNode = new JsonObject(); 36JsonNode propertiesNode = new JsonObject(); 54JsonNode itemsNode = new JsonObject();
NativeIntegrations.DockerCompose (24)
ComposeModels.cs (8)
48return (JsonNode)exposure; 151private void Set(string key, JsonNode? value) 196KeyValuePair.Create(pair.Key, (JsonNode?)JsonValue.Create(ComposeJson.Literal(pair.Value))))); 214KeyValuePair.Create(pair.Key, (JsonNode?)JsonValue.Create(ComposeJson.Literal(pair.Value))))); 266internal static string Json(JsonNode node) => node.ToJsonString(s_indented) + "\n"; 347internal static JsonArray Strings(IEnumerable<string> values) => new(values.Select(value => (JsonNode?)JsonValue.Create(value)).ToArray()); 349private static JsonNode? EscapeNode(JsonNode? node) => node switch
DockerComposeEnvironment.cs (4)
217if (!File.Exists(path) || !JsonNode.DeepEquals(JsonNode.Parse(await File.ReadAllTextAsync(path, context.CancellationToken).ConfigureAwait(false)), expected)) 309rows = source.StartsWith('[') ? Objects(JsonNode.Parse(source)).ToArray() : 310source.Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(line => JsonNode.Parse(line)!.AsObject()).ToArray();
DockerComposeGenerator.cs (12)
110var volumes = new SortedDictionary<string, JsonNode?>(StringComparer.Ordinal); 149var serviceEnvironment = new SortedDictionary<string, JsonNode?>(StringComparer.Ordinal); 172if (serviceEnvironment.TryGetValue(variable, out var existing) && existing!.GetValue<string>() != target) 219return (JsonNode)value; 262return (JsonNode)new JsonObject 272KeyValuePair.Create(names[dependency], (JsonNode?)new JsonObject 288inputs["parameters"] = new JsonArray(used.Select(parameter => (JsonNode)new JsonObject 331return new() { ["kind"] = "composite", ["parts"] = new JsonArray(Objects(value["parts"]).Select(part => (JsonNode)Normalize(part, depth + 1)).ToArray()) }; 429} : JsonNode.Parse(source) as JsonObject ?? throw new ArgumentException("Docker Compose environment configuration must be an object."); 514var options = resource["configuration"]?["publish.dockerCompose"] is { } source ? JsonNode.Parse(source.GetValue<string>())!.AsObject() : new JsonObject(); 569internal static IEnumerable<JsonObject> Objects(JsonNode? value) => (value ?? throw new ArgumentException("Expected a JSON array.")).AsArray().Select(node => node!.AsObject()); 570internal static IEnumerable<string> Strings(JsonNode? value) => (value ?? throw new ArgumentException("Expected a JSON array.")).AsArray().Select(node => node!.GetValue<string>());
sdk-tasks (14)
GetRuntimePackRids.cs (1)
22var runtimeJsonRoot = JsonNode.Parse(runtimeJsonContents)!.AsObject();
PublishMutationUtilities.cs (4)
19var deps = JsonNode.Parse(text); 43if (targetObj.TryGetPropertyValue(entryPoint.Key, out JsonNode value)) 54JsonNode library = libraries[entryPoint.Key];
RemoveAssetFromDepsPackages.cs (4)
37var deps = JsonNode.Parse(text); 45internal static bool RemoveAssets(JsonNode deps, string sectionName, string assetPath) 52var section = pv.Value![sectionName];
UpdateRuntimeConfig.cs (5)
46var config = JsonNode.Parse(text)!.AsObject(); 47var frameworks = config["runtimeOptions"]?["frameworks"]; 48var framework = config["runtimeOptions"]?["framework"]; 51foreach (var item in frameworks.AsArray()) 64private void UpdateFramework(JsonNode item)
Shared.Tests (20)
JsonSchemaExporter\SchemaTestHelpers.cs (11)
17public static void AssertEqualJsonSchema(JsonNode expectedJsonSchema, JsonNode actualJsonSchema) 19if (!JsonNode.DeepEquals(expectedJsonSchema, actualJsonSchema)) 31public static void AssertDocumentMatchesSchema(JsonNode schema, JsonNode? instance) 52public static void AssertDoesNotMatchSchema(JsonNode schema, JsonNode? instance) 67private static EvaluationResults EvaluateSchemaCore(JsonNode schema, JsonNode? instance) 74private static string FormatJson(JsonNode? node) => 78[JsonSerializable(typeof(JsonNode))]
JsonSchemaExporter\TestData.cs (3)
30JsonNode ITestData.ExpectedJsonSchema { get; } = 31JsonNode.Parse(ExpectedJsonSchema, documentOptions: _schemaParseOptions) 63JsonNode ExpectedJsonSchema { get; }
JsonSchemaExporter\TestTypes.cs (6)
103yield return new TestData<JsonNode>(JsonNode.Parse("""[{ "x" : 42 }]"""), "true"); 106yield return new TestData<JsonArray>([(JsonNode)1, (JsonNode)2, (JsonNode)3], """{"type":["array","null"]}"""); 1247[JsonSerializable(typeof(JsonNode))]
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\JsonArray.IList.cs (21)
17/// Adds a <see cref="JsonNode"/> to the end of the <see cref="JsonArray"/>. 20/// The <see cref="JsonNode"/> to be added to the end of the <see cref="JsonArray"/>. 22public void Add(JsonNode? item) 34List<JsonNode?>? list = _list; 58public bool Contains(JsonNode? item) => List.Contains(item); 63/// <param name="item">The <see cref="JsonNode"/> to locate in the <see cref="JsonArray"/>.</param> 67public int IndexOf(JsonNode? item) => List.IndexOf(item); 73/// <param name="item">The <see cref="JsonNode"/> to insert.</param> 77public void Insert(int index, JsonNode? item) 84/// Removes the first occurrence of a specific <see cref="JsonNode"/> from the <see cref="JsonArray"/>. 87/// The <see cref="JsonNode"/> to remove from the <see cref="JsonArray"/>. 92public bool Remove(JsonNode? item) 112JsonNode? item = List[index]; 125public int RemoveAll(Func<JsonNode?, bool> match) 166List<JsonNode?> list = List; 208void ICollection<JsonNode?>.CopyTo(JsonNode?[] array, int index) => List.CopyTo(array, index); 213/// <returns>A <see cref="IEnumerator{JsonNode}"/> for the <see cref="JsonNode"/>.</returns> 214public IEnumerator<JsonNode?> GetEnumerator() => List.GetEnumerator(); 227bool ICollection<JsonNode?>.IsReadOnly => false; 231private static void DetachParent(JsonNode? item)
System\Text\Json\Nodes\JsonNode.cs (30)
16/// declared as an <see cref="object"/> should be deserialized as a <see cref="JsonNode"/>. 22private JsonNode? _parent; 118/// Gets the parent <see cref="JsonNode"/>. 122public JsonNode? Parent 151internal abstract void GetPath(ref ValueStringBuilder path, JsonNode? child); 154/// Gets the root <see cref="JsonNode"/>. 159public JsonNode Root 163JsonNode? parent = Parent; 193/// The current <see cref="JsonNode"/> cannot be represented as a {T}. 196/// The current <see cref="JsonNode"/> is not a <see cref="JsonValue"/> or 210/// The current <see cref="JsonNode"/> is not a <see cref="JsonArray"/> or <see cref="JsonObject"/>. 212public JsonNode? this[int index] 218private protected virtual JsonNode? GetItem(int index) 224private protected virtual void SetItem(int index, JsonNode? node) => 236/// The current <see cref="JsonNode"/> is not a <see cref="JsonObject"/>. 238public JsonNode? this[string propertyName] 251/// Creates a new instance of the <see cref="JsonNode"/>. All children nodes are recursively cloned. 254public JsonNode DeepClone() => DeepCloneCore(); 256internal abstract JsonNode DeepCloneCore(); 304/// <param name="node1">The <see cref="JsonNode"/> to compare.</param> 305/// <param name="node2">The <see cref="JsonNode"/> to compare.</param> 307public static bool DeepEquals(JsonNode? node1, JsonNode? node2) 321internal abstract bool DeepEqualsCore(JsonNode node); 332JsonNode? node; 346internal void AssignParent(JsonNode parent) 353JsonNode? p = parent; 369/// to support arbitrary <see cref="JsonElement"/> and <see cref="JsonNode"/> values. 374internal static JsonNode? ConvertFromValue<T>(T? value, JsonNodeOptions? options = null) 381if (value is JsonNode node)
System\Text\Json\Nodes\JsonNode.Operators.cs (198)
11/// Defines an implicit conversion of a given <see cref="bool"/> to a <see cref="JsonNode"/>. 14/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 15public static implicit operator JsonNode(bool value) => JsonValue.Create(value); 18/// Defines an implicit conversion of a given <see cref="bool"/> to a <see cref="JsonNode"/>. 21/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 22public static implicit operator JsonNode?(bool? value) => JsonValue.Create(value); 25/// Defines an implicit conversion of a given <see cref="byte"/> to a <see cref="JsonNode"/>. 28/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 29public static implicit operator JsonNode(byte value) => JsonValue.Create(value); 32/// Defines an implicit conversion of a given <see cref="byte"/> to a <see cref="JsonNode"/>. 35/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 36public static implicit operator JsonNode?(byte? value) => JsonValue.Create(value); 39/// Defines an implicit conversion of a given <see cref="char"/> to a <see cref="JsonNode"/>. 42/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 43public static implicit operator JsonNode(char value) => JsonValue.Create(value); 46/// Defines an implicit conversion of a given <see cref="char"/> to a <see cref="JsonNode"/>. 49/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 50public static implicit operator JsonNode?(char? value) => JsonValue.Create(value); 53/// Defines an implicit conversion of a given <see cref="DateTime"/> to a <see cref="JsonNode"/>. 56/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 57public static implicit operator JsonNode(DateTime value) => JsonValue.Create(value); 60/// Defines an implicit conversion of a given <see cref="DateTime"/> to a <see cref="JsonNode"/>. 63/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 64public static implicit operator JsonNode?(DateTime? value) => JsonValue.Create(value); 67/// Defines an implicit conversion of a given <see cref="DateTimeOffset"/> to a <see cref="JsonNode"/>. 70/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 71public static implicit operator JsonNode(DateTimeOffset value) => JsonValue.Create(value); 74/// Defines an implicit conversion of a given <see cref="DateTimeOffset"/> to a <see cref="JsonNode"/>. 77/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 78public static implicit operator JsonNode?(DateTimeOffset? value) => JsonValue.Create(value); 81/// Defines an implicit conversion of a given <see cref="decimal"/> to a <see cref="JsonNode"/>. 84/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 85public static implicit operator JsonNode(decimal value) => JsonValue.Create(value); 88/// Defines an implicit conversion of a given <see cref="decimal"/> to a <see cref="JsonNode"/>. 91/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 92public static implicit operator JsonNode?(decimal? value) => JsonValue.Create(value); 95/// Defines an implicit conversion of a given <see cref="double"/> to a <see cref="JsonNode"/>. 98/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 99public static implicit operator JsonNode(double value) => JsonValue.Create(value); 102/// Defines an implicit conversion of a given <see cref="double"/> to a <see cref="JsonNode"/>. 105/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 106public static implicit operator JsonNode?(double? value) => JsonValue.Create(value); 109/// Defines an implicit conversion of a given <see cref="Guid"/> to a <see cref="JsonNode"/>. 112/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 113public static implicit operator JsonNode(Guid value) => JsonValue.Create(value); 116/// Defines an implicit conversion of a given <see cref="Guid"/> to a <see cref="JsonNode"/>. 119/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 120public static implicit operator JsonNode?(Guid? value) => JsonValue.Create(value); 123/// Defines an implicit conversion of a given <see cref="short"/> to a <see cref="JsonNode"/>. 126/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 127public static implicit operator JsonNode(short value) => JsonValue.Create(value); 130/// Defines an implicit conversion of a given <see cref="short"/> to a <see cref="JsonNode"/>. 133/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 134public static implicit operator JsonNode?(short? value) => JsonValue.Create(value); 137/// Defines an implicit conversion of a given <see cref="int"/> to a <see cref="JsonNode"/>. 140/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 141public static implicit operator JsonNode(int value) => JsonValue.Create(value); 144/// Defines an implicit conversion of a given <see cref="int"/> to a <see cref="JsonNode"/>. 147/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 148public static implicit operator JsonNode?(int? value) => JsonValue.Create(value); 151/// Defines an implicit conversion of a given <see cref="long"/> to a <see cref="JsonNode"/>. 154/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 155public static implicit operator JsonNode(long value) => JsonValue.Create(value); 158/// Defines an implicit conversion of a given <see cref="long"/> to a <see cref="JsonNode"/>. 161/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 162public static implicit operator JsonNode?(long? value) => JsonValue.Create(value); 165/// Defines an implicit conversion of a given <see cref="sbyte"/> to a <see cref="JsonNode"/>. 168/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 170public static implicit operator JsonNode(sbyte value) => JsonValue.Create(value); 173/// Defines an implicit conversion of a given <see cref="sbyte"/> to a <see cref="JsonNode"/>. 176/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 178public static implicit operator JsonNode?(sbyte? value) => JsonValue.Create(value); 181/// Defines an implicit conversion of a given <see cref="float"/> to a <see cref="JsonNode"/>. 184/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 185public static implicit operator JsonNode(float value) => JsonValue.Create(value); 188/// Defines an implicit conversion of a given <see cref="float"/> to a <see cref="JsonNode"/>. 191/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 192public static implicit operator JsonNode?(float? value) => JsonValue.Create(value); 195/// Defines an implicit conversion of a given <see cref="string"/> to a <see cref="JsonNode"/>. 198/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 200public static implicit operator JsonNode?(string? value) => JsonValue.Create(value); 203/// Defines an implicit conversion of a given <see cref="ushort"/> to a <see cref="JsonNode"/>. 206/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 208public static implicit operator JsonNode(ushort value) => JsonValue.Create(value); 211/// Defines an implicit conversion of a given <see cref="ushort"/> to a <see cref="JsonNode"/>. 214/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 216public static implicit operator JsonNode?(ushort? value) => JsonValue.Create(value); 219/// Defines an implicit conversion of a given <see cref="uint"/> to a <see cref="JsonNode"/>. 222/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 224public static implicit operator JsonNode(uint value) => JsonValue.Create(value); 227/// Defines an implicit conversion of a given <see cref="uint"/> to a <see cref="JsonNode"/>. 230/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 232public static implicit operator JsonNode?(uint? value) => JsonValue.Create(value); 235/// Defines an implicit conversion of a given <see cref="ulong"/> to a <see cref="JsonNode"/>. 238/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 240public static implicit operator JsonNode(ulong value) => JsonValue.Create(value); 243/// Defines an implicit conversion of a given <see cref="ulong"/> to a <see cref="JsonNode"/>. 246/// <returns>A <see cref="JsonNode"/> instance converted from the <paramref name="value"/> parameter.</returns> 248public static implicit operator JsonNode?(ulong? value) => JsonValue.Create(value); 251/// Defines an explicit conversion of a given <see cref="bool"/> to a <see cref="JsonNode"/>. 254/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 255public static explicit operator bool(JsonNode value) => value.GetValue<bool>(); 258/// Defines an explicit conversion of a given <see cref="bool"/> to a <see cref="JsonNode"/>. 261/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 262public static explicit operator bool?(JsonNode? value) => value?.GetValue<bool>(); 265/// Defines an explicit conversion of a given <see cref="byte"/> to a <see cref="JsonNode"/>. 268/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 269public static explicit operator byte(JsonNode value) => value.GetValue<byte>(); 272/// Defines an explicit conversion of a given <see cref="byte"/> to a <see cref="JsonNode"/>. 275/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 276public static explicit operator byte?(JsonNode? value) => value?.GetValue<byte>(); 279/// Defines an explicit conversion of a given <see cref="char"/> to a <see cref="JsonNode"/>. 282/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 283public static explicit operator char(JsonNode value) => value.GetValue<char>(); 286/// Defines an explicit conversion of a given <see cref="char"/> to a <see cref="JsonNode"/>. 289/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 290public static explicit operator char?(JsonNode? value) => value?.GetValue<char>(); 293/// Defines an explicit conversion of a given <see cref="DateTime"/> to a <see cref="JsonNode"/>. 296/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 297public static explicit operator DateTime(JsonNode value) => value.GetValue<DateTime>(); 300/// Defines an explicit conversion of a given <see cref="DateTime"/> to a <see cref="JsonNode"/>. 303/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 304public static explicit operator DateTime?(JsonNode? value) => value?.GetValue<DateTime>(); 307/// Defines an explicit conversion of a given <see cref="DateTimeOffset"/> to a <see cref="JsonNode"/>. 310/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 311public static explicit operator DateTimeOffset(JsonNode value) => value.GetValue<DateTimeOffset>(); 314/// Defines an explicit conversion of a given <see cref="DateTimeOffset"/> to a <see cref="JsonNode"/>. 317/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 318public static explicit operator DateTimeOffset?(JsonNode? value) => value?.GetValue<DateTimeOffset>(); 321/// Defines an explicit conversion of a given <see cref="decimal"/> to a <see cref="JsonNode"/>. 324/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 325public static explicit operator decimal(JsonNode value) => value.GetValue<decimal>(); 328/// Defines an explicit conversion of a given <see cref="decimal"/> to a <see cref="JsonNode"/>. 331/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 332public static explicit operator decimal?(JsonNode? value) => value?.GetValue<decimal>(); 335/// Defines an explicit conversion of a given <see cref="double"/> to a <see cref="JsonNode"/>. 338/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 339public static explicit operator double(JsonNode value) => value.GetValue<double>(); 342/// Defines an explicit conversion of a given <see cref="double"/> to a <see cref="JsonNode"/>. 345/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 346public static explicit operator double?(JsonNode? value) => value?.GetValue<double>(); 349/// Defines an explicit conversion of a given <see cref="Guid"/> to a <see cref="JsonNode"/>. 352/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 353public static explicit operator Guid(JsonNode value) => value.GetValue<Guid>(); 356/// Defines an explicit conversion of a given <see cref="Guid"/> to a <see cref="JsonNode"/>. 359/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 360public static explicit operator Guid?(JsonNode? value) => value?.GetValue<Guid>(); 363/// Defines an explicit conversion of a given <see cref="short"/> to a <see cref="JsonNode"/>. 366/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 367public static explicit operator short(JsonNode value) => value.GetValue<short>(); 370/// Defines an explicit conversion of a given <see cref="short"/> to a <see cref="JsonNode"/>. 373/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 374public static explicit operator short?(JsonNode? value) => value?.GetValue<short>(); 377/// Defines an explicit conversion of a given <see cref="int"/> to a <see cref="JsonNode"/>. 380/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 381public static explicit operator int(JsonNode value) => value.GetValue<int>(); 384/// Defines an explicit conversion of a given <see cref="int"/> to a <see cref="JsonNode"/>. 387/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 388public static explicit operator int?(JsonNode? value) => value?.GetValue<int>(); 391/// Defines an explicit conversion of a given <see cref="long"/> to a <see cref="JsonNode"/>. 394/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 395public static explicit operator long(JsonNode value) => value.GetValue<long>(); 398/// Defines an explicit conversion of a given <see cref="long"/> to a <see cref="JsonNode"/>. 401/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 402public static explicit operator long?(JsonNode? value) => value?.GetValue<long>(); 405/// Defines an explicit conversion of a given <see cref="sbyte"/> to a <see cref="JsonNode"/>. 408/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 410public static explicit operator sbyte(JsonNode value) => value.GetValue<sbyte>(); 413/// Defines an explicit conversion of a given <see cref="sbyte"/> to a <see cref="JsonNode"/>. 416/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 418public static explicit operator sbyte?(JsonNode? value) => value?.GetValue<sbyte>(); 421/// Defines an explicit conversion of a given <see cref="float"/> to a <see cref="JsonNode"/>. 424/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 425public static explicit operator float(JsonNode value) => value.GetValue<float>(); 428/// Defines an explicit conversion of a given <see cref="float"/> to a <see cref="JsonNode"/>. 431/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 432public static explicit operator float?(JsonNode? value) => value?.GetValue<float>(); 435/// Defines an explicit conversion of a given <see cref="string"/> to a <see cref="JsonNode"/>. 438/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 439public static explicit operator string?(JsonNode? value) => value?.GetValue<string>(); 442/// Defines an explicit conversion of a given <see cref="ushort"/> to a <see cref="JsonNode"/>. 445/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 447public static explicit operator ushort(JsonNode value) => value.GetValue<ushort>(); 450/// Defines an explicit conversion of a given <see cref="ushort"/> to a <see cref="JsonNode"/>. 453/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 455public static explicit operator ushort?(JsonNode? value) => value?.GetValue<ushort>(); 458/// Defines an explicit conversion of a given <see cref="uint"/> to a <see cref="JsonNode"/>. 461/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 463public static explicit operator uint(JsonNode value) => value.GetValue<uint>(); 466/// Defines an explicit conversion of a given <see cref="uint"/> to a <see cref="JsonNode"/>. 469/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 471public static explicit operator uint?(JsonNode? value) => value?.GetValue<uint>(); 474/// Defines an explicit conversion of a given <see cref="ulong"/> to a <see cref="JsonNode"/>. 477/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 479public static explicit operator ulong(JsonNode value) => value.GetValue<ulong>(); 482/// Defines an explicit conversion of a given <see cref="ulong"/> to a <see cref="JsonNode"/>. 485/// <returns>A value converted from the <see cref="JsonNode"/> instance.</returns> 487public static explicit operator ulong?(JsonNode? value) => value?.GetValue<ulong>();
System\Text\Json\Nodes\JsonNode.Parse.cs (12)
20/// The <see cref="JsonNode"/> from the reader. 47public static JsonNode? Parse( 62/// A <see cref="JsonNode"/> representation of the JSON value. 70public static JsonNode? Parse( 88/// A <see cref="JsonNode"/> representation of the JSON value. 93public static JsonNode? Parse( 104/// <see cref="JsonNode"/>. The Stream will be read to completion. 110/// A <see cref="JsonNode"/> representation of the JSON value. 115public static JsonNode? Parse( 128/// <see cref="JsonNode"/>. The Stream will be read to completion. 135/// A <see cref="Task"/> to produce a <see cref="JsonNode"/> representation of the JSON value. 140public static async Task<JsonNode?> ParseAsync(
System\Text\Json\Nodes\JsonNode.To.cs (1)
70/// Write the <see cref="JsonNode"/> into the provided <see cref="Utf8JsonWriter"/> as JSON.
System\Text\Json\Nodes\JsonNodeOptions.cs (1)
7/// Options to control <see cref="JsonNode"/> behavior.
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\Nodes\JsonValue.cs (6)
32/// <seealso cref="JsonNode.GetValue{T}"></seealso> 57if (value is JsonNode) 91if (value is JsonNode) 106internal override bool DeepEqualsCore(JsonNode otherNode) 126static JsonElement ToJsonElement(JsonNode node, out JsonDocument? backingDocument) 154internal sealed override void GetPath(ref ValueStringBuilder path, JsonNode? child)
System\Text\Json\Nodes\JsonValueOfElement.cs (2)
20internal override JsonNode DeepCloneCore() => new JsonValueOfElement(Value.Clone(), Options); 23internal override bool DeepEqualsCore(JsonNode otherNode)
System\Text\Json\Nodes\JsonValueOfJsonPrimitive.cs (3)
46internal override JsonNode DeepCloneCore() => new JsonValueOfJsonString(_value, Options); 137internal override JsonNode DeepCloneCore() => new JsonValueOfJsonBool(_value, Options); 184internal override JsonNode DeepCloneCore() => new JsonValueOfJsonNumber(_value, Options);
System\Text\Json\Nodes\JsonValueOfT.cs (1)
19Debug.Assert(value is not JsonNode);
System\Text\Json\Nodes\JsonValueOfTCustomized.cs (1)
27internal override JsonNode DeepCloneCore() => JsonSerializer.SerializeToNode(Value, _jsonTypeInfo)!;
System\Text\Json\Nodes\JsonValueOfTPrimitive.cs (2)
28internal override JsonNode DeepCloneCore() => new JsonValuePrimitive<TValue>(Value, _converter, Options); 30internal override bool DeepEqualsCore(JsonNode otherNode)
System\Text\Json\Schema\JsonSchema.cs (13)
59public JsonNode? Constant { get; set { VerifyMutable(); field = value; } } 77public JsonNode? DefaultValue { get; set { VerifyMutable(); field = value; } } 142public JsonNode ToJsonNode(JsonSchemaExporterOptions options) 146return CompleteSchema((JsonNode)boolSchema); 161if (MapSchemaType(Type) is JsonNode type) 197requiredArray.Add((JsonNode)requiredProperty); 241objSchema.Add(MinLengthPropertyName, (JsonNode)minLength); 246objSchema.Add(MaxLengthPropertyName, (JsonNode)maxLength); 251objSchema.Add(DeprecatedPropertyName, (JsonNode)deprecated); 261JsonNode CompleteSchema(JsonNode schema) 313public static JsonNode? MapSchemaType(JsonSchemaType schemaType) 330array.Add((JsonNode)ToIdentifier(type)!);
System\Text\Json\Schema\JsonSchemaExporter.cs (7)
22/// Gets the JSON schema for <paramref name="type"/> as a <see cref="JsonNode"/> document. 28public static JsonNode GetJsonSchemaAsNode(this JsonSerializerOptions options, Type type, JsonSchemaExporterOptions? exporterOptions = null) 39/// Gets the JSON schema for <paramref name="typeInfo"/> as a <see cref="JsonNode"/> document. 44public static JsonNode GetJsonSchemaAsNode(this JsonTypeInfo typeInfo, JsonSchemaExporterOptions? exporterOptions = null) 115JsonNode discriminatorNode = discriminatorValue switch 117string stringId => (JsonNode)stringId, 118_ => (JsonNode)(int)discriminatorValue,
System\Text\Json\Schema\JsonSchemaExporterOptions.cs (2)
31public Func<JsonSchemaExporterContext, JsonNode, JsonNode>? TransformSchemaNode { get; init; }
System\Text\Json\Serialization\Attributes\JsonExtensionDataAttribute.cs (1)
18/// <see cref="object"/>, the type of object created will either be a <see cref="System.Text.Json.Nodes.JsonNode"/> or a
System\Text\Json\Serialization\Converters\Node\JsonArrayConverter.cs (1)
57JsonNode? item = JsonNodeConverter.ReadAsJsonNode(ref reader, options);
System\Text\Json\Serialization\Converters\Node\JsonNodeConverter.cs (7)
14internal sealed class JsonNodeConverter : JsonConverter<JsonNode?> 18public override void Write(Utf8JsonWriter writer, JsonNode? value, JsonSerializerOptions options) 30public override JsonNode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 37internal static JsonNode? ReadAsJsonElement(ref Utf8JsonReader reader, JsonNodeOptions options) 58internal static JsonNode? ReadAsJsonNode(ref Utf8JsonReader reader, JsonNodeOptions options) 79public static JsonNode? Create(JsonElement element, JsonNodeOptions? options) 81JsonNode? node;
System\Text\Json\Serialization\Converters\Node\JsonNodeConverterFactory.cs (2)
33Debug.Assert(typeof(JsonNode) == typeToConvert); 37public override bool CanConvert(Type typeToConvert) => typeof(JsonNode).IsAssignableFrom(typeToConvert);
System\Text\Json\Serialization\Converters\Node\JsonObjectConverter.cs (5)
25bool success = JsonNodeConverter.Instance.TryRead(ref reader, typeof(JsonNode), options, ref state, out JsonNode? value, out _); 31Debug.Assert(value is null || value is JsonNode); 32JsonNode? jNodeValue = value; 104JsonNode? value = JsonNodeConverter.ReadAsJsonNode(ref reader, options);
System\Text\Json\Serialization\Converters\Object\ObjectConverter.cs (1)
132JsonNode? node = JsonNodeConverter.Instance.Read(ref reader, typeToConvert, options);
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (1)
505enumValues.Add((JsonNode)fieldInfo.JsonName);
System\Text\Json\Serialization\Converters\Value\JsonPrimitiveConverter.cs (3)
62new JsonSchema { Enum = [(JsonNode)"NaN", (JsonNode)"Infinity", (JsonNode)"-Infinity"] },
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (3)
454JsonNode? jsonNode, 463foreach (KeyValuePair<string, JsonNode?> property in jsonObject) 501static string ReadAsStringMetadataValue(JsonNode? jsonNode)
System\Text\Json\Serialization\JsonSerializer.Read.Node.cs (17)
15/// Converts the <see cref="JsonNode"/> representing a single JSON value into a <typeparamref name="TValue"/>. 19/// <param name="node">The <see cref="JsonNode"/> to convert.</param> 30public static TValue? Deserialize<TValue>(this JsonNode? node, JsonSerializerOptions? options = null) 37/// Converts the <see cref="JsonNode"/> representing a single JSON value into a <paramref name="returnType"/>. 40/// <param name="node">The <see cref="JsonNode"/> to convert.</param> 52public static object? Deserialize(this JsonNode? node, Type returnType, JsonSerializerOptions? options = null) 61/// Converts the <see cref="JsonNode"/> representing a single JSON value into a <typeparamref name="TValue"/>. 65/// <param name="node">The <see cref="JsonNode"/> to convert.</param> 73public static TValue? Deserialize<TValue>(this JsonNode? node, JsonTypeInfo<TValue> jsonTypeInfo) 82/// Converts the <see cref="JsonNode"/> representing a single JSON value into an instance specified by the <paramref name="jsonTypeInfo"/>. 85/// <param name="node">The <see cref="JsonNode"/> to convert.</param> 90public static object? Deserialize(this JsonNode? node, JsonTypeInfo jsonTypeInfo) 99/// Converts the <see cref="JsonNode"/> representing a single JSON value into a <paramref name="returnType"/>. 102/// <param name="node">The <see cref="JsonNode"/> to convert.</param> 130public static object? Deserialize(this JsonNode? node, Type returnType, JsonSerializerContext context) 139private static TValue? ReadFromNode<TValue>(JsonNode? node, JsonTypeInfo<TValue> jsonTypeInfo) 160private static object? ReadFromNodeAsObject(JsonNode? node, JsonTypeInfo jsonTypeInfo)
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());
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Converters.cs (2)
129/// Returns a <see cref="JsonConverter{T}"/> instance that converts <see cref="JsonNode"/> values. 132public static JsonConverter<JsonNode?> JsonNodeConverter => field ??= new JsonNodeConverter();