11using System . CommandLine ;
22using System . Text . Json ;
3+ using System . Text . Json . Serialization . Metadata ;
34using Microsoft . Build . Locator ;
5+ using TestMyCode . CSharp . Bootstrap ;
46using TestMyCode . CSharp . Core . Compiler ;
57using TestMyCode . CSharp . Core . Data ;
68using TestMyCode . CSharp . Core . Test ;
@@ -84,7 +86,7 @@ static async Task<int> CommandHandler(bool generatePointsFile, bool runTests, Di
8486 {
8587 FileInfo resultsFile = outputFile ?? new FileInfo ( Path . Combine ( projectDir . FullName , ".tmc_available_points.json" ) ) ;
8688
87- await WriteToFile ( resultsFile , projectData . Points ) ;
89+ await WriteToFile ( resultsFile , projectData . Points , RunnerJsonContext . Default . IReadOnlyDictionaryStringHashSetString ) ;
8890 }
8991
9092 if ( runTests )
@@ -94,10 +96,10 @@ static async Task<int> CommandHandler(bool generatePointsFile, bool runTests, Di
9496
9597 FileInfo resultsFile = outputFile ?? new FileInfo ( Path . Combine ( projectDir . FullName , ".tmc_test_results.json" ) ) ;
9698
97- await WriteToFile ( resultsFile , testRunner . TestResults ) ;
99+ await WriteToFile ( resultsFile , testRunner . TestResults , RunnerJsonContext . Default . IReadOnlyListMethodTestResult ) ;
98100 }
99101
100- static async Task WriteToFile < T > ( FileInfo resultsFile , T data )
102+ static async Task WriteToFile < T > ( FileInfo resultsFile , T data , JsonTypeInfo < T > jsonTypeInfo )
101103 {
102104 if ( resultsFile . Exists )
103105 {
@@ -106,10 +108,7 @@ static async Task WriteToFile<T>(FileInfo resultsFile, T data)
106108
107109 await using FileStream stream = resultsFile . Open ( FileMode . OpenOrCreate , FileAccess . Write ) ;
108110
109- await JsonSerializer . SerializeAsync ( stream , data , options : new JsonSerializerOptions
110- {
111- WriteIndented = true
112- } ) ;
111+ await JsonSerializer . SerializeAsync ( stream , data , jsonTypeInfo ) ;
113112 }
114113
115114 return 0 ;
0 commit comments