Skip to content

Commit

Permalink
imp - Improved RID graph maker
Browse files Browse the repository at this point in the history
---

According to the latest changes made to the RID graph, we've decided to update the RID graph as per https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json, as per dotnet/runtime@dedd914

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Aug 16, 2024
1 parent 2017b84 commit 590f6a4
Show file tree
Hide file tree
Showing 2 changed files with 4,641 additions and 11,772 deletions.
18 changes: 13 additions & 5 deletions SpecProbe.Software/Platform/RidGraphReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Nodes;
Expand All @@ -41,18 +42,25 @@ public static string[] GetGraphFromRid() =>
/// <returns>List of RIDs from the specified RID to the base RID</returns>
public static string[] GetGraphFromRid(string rid)
{
// Sync with this source: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
string graphJson = GetRidGraphJson();
var graphInstance = JsonNode.Parse(graphJson);
var graphInstance = JsonNode.Parse(graphJson)["runtimes"];
List<string> finalGraph = [];
foreach (var ridGraph in graphInstance.AsObject())
{
if (ridGraph.Key == rid)
{
var graph = ridGraph.Value;
var graphArray = graph.Deserialize<string[]>();
return graphArray;
finalGraph.Add(ridGraph.Key);
var currentGraph = ridGraph.Value;
while (((JsonArray)currentGraph["#import"]).Count > 0)
{
foreach (var element in (JsonArray)currentGraph["#import"])
finalGraph.Add(element.GetValue<string>());
currentGraph = graphInstance[finalGraph[finalGraph.Count - 1]];
}
}
}
return [];
return [.. finalGraph];
}

private static string GetRidGraphJson()
Expand Down
Loading

0 comments on commit 590f6a4

Please sign in to comment.