@@ -8,9 +8,9 @@ public static class ModelExtensions
88 public static string ToMarkdownBody (
99 this ISet < ProjectSupportReport > psrs ,
1010 string tfm ,
11- string rootDirectory ,
12- string branch )
11+ IRepoOptions options )
1312 {
13+ var ( rootDirectory , branch ) = ( options . Directory , options . Branch ) ;
1414 IMarkdownDocument document = new MarkdownDocument ( ) ;
1515
1616 document . AppendParagraph (
@@ -44,17 +44,8 @@ public static string ToMarkdownBody(
4444 new MarkdownList (
4545 psrs . OrderBy ( psr => psr . Project . FullPath ) . Select ( psr =>
4646 {
47- var relativePath =
48- Path . GetRelativePath ( rootDirectory , psr . Project . FullPath ) ;
49-
50- var lineNumberFileReference =
51- $ "../blob/{ branch } /{ relativePath . Replace ( "\\ " , "/" ) } #L{ psr . Project . TfmLineNumber } "
52- . EscapeUriString ( ) ;
53- var name = relativePath . ShrinkPath ( "..." ) ;
54-
55- // Must force anchor link, as GitHub assumes site-relative links.
56- var anchor = $ "<a href='{ lineNumberFileReference } ' title='{ name } at line number { psr . Project . TfmLineNumber : #,0} '>{ name } </a>";
57-
47+ var anchor = ToLineNumberUrl (
48+ psr . Project . FullPath , psr . Project . TfmLineNumber , options ) ;
5849 return new MarkdownCheckListItem ( false , anchor ) ;
5950 } ) ) ) ;
6051
@@ -79,9 +70,9 @@ public static string ToMarkdownBody(
7970 public static string ToMarkdownBody (
8071 this ISet < DockerfileSupportReport > dfsr ,
8172 string tfm ,
82- string rootDirectory ,
83- string branch )
73+ IRepoOptions options )
8474 {
75+ var ( rootDirectory , branch ) = ( options . Directory , options . Branch ) ;
8576 IMarkdownDocument document = new MarkdownDocument ( ) ;
8677
8778 document . AppendParagraph (
@@ -115,20 +106,13 @@ public static string ToMarkdownBody(
115106 new MarkdownList (
116107 dfsr . SelectMany ( sr => sr . TargetFrameworkMonikerSupports . Select ( tfms => ( sr . Dockerfile , tfms ) ) )
117108 . OrderBy ( t => t . Dockerfile . FullPath )
118- . Select ( t =>
109+ . SelectMany ( t =>
119110 {
120- var relativePath =
121- Path . GetRelativePath ( rootDirectory , t . Dockerfile . FullPath ) ;
122- // TODO: 1
123- var lineNumberFileReference =
124- $ "../blob/{ branch } /{ relativePath . Replace ( "\\ " , "/" ) } #L{ 1 } "
125- . EscapeUriString ( ) ;
126- var name = relativePath . ShrinkPath ( "..." ) ;
127-
128- // Must force anchor link, as GitHub assumes site-relative links.
129- var anchor = $ "<a href='{ lineNumberFileReference } ' title='{ name } at line number { 1 : #,0} '>{ name } </a>";
130-
131- return new MarkdownCheckListItem ( false , anchor ) ;
111+ return t . Dockerfile . ImageDetails ! . Select ( i =>
112+ {
113+ var anchor = ToLineNumberUrl ( t . Dockerfile . FullPath , i . LineNumber , options ) ;
114+ return new MarkdownCheckListItem ( false , anchor ) ;
115+ } ) ;
132116 } ) ) ) ;
133117
134118 document . AppendParagraph (
@@ -149,6 +133,25 @@ public static string ToMarkdownBody(
149133 return document . ToString ( ) ;
150134 }
151135
136+ private static string ToLineNumberUrl (
137+ string fullPath , int lineNumber , IRepoOptions options )
138+ {
139+ if ( fullPath is null )
140+ {
141+ return "N/A" ;
142+ }
143+
144+ var relativePath =
145+ Path . GetRelativePath ( options . Directory , fullPath ! )
146+ . Replace ( "\\ " , "/" ) ;
147+ var lineNumberFileReference =
148+ $ "https://github.com/{ options . Owner } /{ options . Name } /blob/{ options . Branch } /{ relativePath } #L{ lineNumber } ";
149+ var name = relativePath . ShrinkPath ( "..." ) ;
150+
151+ // Must force anchor link, as GitHub assumes site-relative links.
152+ return $ "<a href='{ lineNumberFileReference } ' title='{ name } '>{ name } </a>";
153+ }
154+
152155 public static bool TryCreateIssueContent (
153156 this ISet < ModelProject > projects ,
154157 string rootDirectory ,
0 commit comments