@@ -10,7 +10,8 @@ internal static class XMLConverter
1010 {
1111 public static ( int status , string ? result , int linesFound ) ParseFullDocument (
1212 string inputXML ,
13- string ? trimFolderName = null
13+ string ? trimFolderName = null ,
14+ string ? reportFilenamePrefix = null
1415 )
1516 {
1617 var xDoc = new XmlDocument ( ) ;
@@ -46,24 +47,34 @@ public static (int status, string? result, int linesFound) ParseFullDocument(
4647 . Where ( x => x . Name == "PVS-Studio_Analysis_Log" )
4748 . ToArray ( ) ;
4849
49- var result = ParseAllLogNodes ( logRecords , trimFolderName ) ;
50+ var result = ParseAllLogNodes (
51+ logRecords ,
52+ trimFolderName ,
53+ reportFilenamePrefix
54+ ) ;
5055
5156 return ( 0 , System . Text . Json . JsonSerializer . Serialize ( result ) , result . Count ) ;
5257 }
5358
5459 public static ICollection < CodeQualityLogRecord > ParseAllLogNodes (
5560 ICollection < XmlElement > logRecords ,
56- string trimFolderName
61+ string trimFolderName ,
62+ string ? reportFilenamePrefix
5763 )
5864 {
5965 return logRecords
60- . SelectMany ( t => ParseAllLogNodes ( t , trimFolderName ) )
66+ . SelectMany ( t => ParseAllLogNodes (
67+ logRecord : t ,
68+ trimFolderName : trimFolderName ,
69+ reportFilenamePrefix : reportFilenamePrefix
70+ ) )
6171 . ToArray ( ) ;
6272 }
6373
6474 public static ICollection < CodeQualityLogRecord > ParseAllLogNodes (
6575 XmlElement logRecord ,
66- string trimFolderName
76+ string trimFolderName ,
77+ string ? reportFilenamePrefix
6778 )
6879 {
6980 var fields = new [ ]
@@ -75,16 +86,24 @@ string trimFolderName
7586 {
7687 if ( t . InnerText != null )
7788 {
78- return ( fieldName , value : t . InnerText ) ;
89+ return ( fieldName , value : ( string ? ) t . InnerText ) ;
7990 }
8091 }
8192
82- return ( fieldName , null ) ;
93+ return ( fieldName , value : ( string ? ) null ) ;
8394 } )
8495 . ToDictionary (
8596 t => t . fieldName ,
8697 t => t . value
8798 ) ;
99+ if ( reportFilenamePrefix != null )
100+ {
101+ reportFilenamePrefix = reportFilenamePrefix . TrimEnd ( '/' , '\\ ' ) ;
102+ if ( reportFilenamePrefix == string . Empty )
103+ {
104+ reportFilenamePrefix = null ;
105+ }
106+ }
88107
89108 var additionalPositionNodes = logRecord
90109 . GetElementsByTagName ( "Positions" )
@@ -96,19 +115,23 @@ string trimFolderName
96115 var filename = t . InnerText ;
97116 return lines
98117 . Split ( ',' )
99- . Select ( line => ( filename , lineNumber : int . Parse ( line . Trim ( ) ) ) ) ;
118+ . Select ( line => ( filename : ( string ? ) filename , lineNumber : int . Parse ( line . Trim ( ) ) ) ) ;
100119 } )
101120 . SelectMany ( t => t )
102121 . ToList ( ) ;
103- additionalPositionNodes . Add ( ( values [ "File" ] , int . Parse ( values [ "Line" ] ) ) ) ;
122+ additionalPositionNodes . Add ( ( values [ "File" ] , int . Parse ( values [ "Line" ] ?? "0" ) ) ) ;
104123 var results = additionalPositionNodes
105124 . ToHashSet ( )
106125 . Select ( t =>
107126 {
108127 var localFile = "" ;
109- if ( t . filename != "" )
128+ if ( ! string . IsNullOrEmpty ( t . filename ) )
110129 {
111130 localFile = t . filename . Substring ( trimFolderName . Length ) . TrimStart ( '/' , '\\ ' ) ;
131+ if ( reportFilenamePrefix != null )
132+ {
133+ localFile = reportFilenamePrefix + "/" + localFile ;
134+ }
112135 }
113136
114137 // ReSharper disable once UseObjectOrCollectionInitializer
0 commit comments