@@ -5,6 +5,7 @@ namespace Microsoft.ComponentDetection.Detectors.Go;
55using System . Collections . Generic ;
66using System . Diagnostics . CodeAnalysis ;
77using System . IO ;
8+ using System . Text ;
89using System . Text . Json ;
910using System . Threading . Tasks ;
1011using Microsoft . ComponentDetection . Common . Telemetry . Records ;
@@ -78,10 +79,11 @@ private void RecordBuildDependencies(string goListOutput, ISingleFileComponentRe
7879 using var record = new GoReplaceTelemetryRecord ( ) ;
7980
8081 // Go CLI outputs multiple JSON objects (not an array), so we need to parse them one by one
81- var remaining = goListOutput . AsMemory ( ) ;
82+ var utf8Bytes = Encoding . UTF8 . GetBytes ( goListOutput ) ;
83+ var remaining = utf8Bytes . AsSpan ( ) ;
8284 while ( ! remaining . IsEmpty )
8385 {
84- var reader = new Utf8JsonReader ( System . Text . Encoding . UTF8 . GetBytes ( remaining . ToString ( ) ) ) ;
86+ var reader = new Utf8JsonReader ( remaining ) ;
8587 try
8688 {
8789 var buildModule = JsonSerializer . Deserialize < GoBuildModule > ( ref reader ) ;
@@ -95,7 +97,7 @@ private void RecordBuildDependencies(string goListOutput, ISingleFileComponentRe
9597 remaining = remaining [ consumed ..] ;
9698
9799 // Skip whitespace between JSON objects
98- while ( ! remaining . IsEmpty && char . IsWhiteSpace ( remaining . Span [ 0 ] ) )
100+ while ( ! remaining . IsEmpty && char . IsWhiteSpace ( ( char ) remaining [ 0 ] ) )
99101 {
100102 remaining = remaining [ 1 ..] ;
101103 }
0 commit comments