@@ -92,16 +92,36 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
9292 var dictionary = new Dictionary < string , SeenPaths > ( ) ;
9393 if ( ! string . IsNullOrEmpty ( updateRepository ) && updateReference is not null )
9494 crossLinks = crossLinkResolver . UpdateLinkReference ( updateRepository , updateReference ) ;
95+
96+ var skippedPhantoms = 0 ;
9597 foreach ( var ( repository , linkReference ) in crossLinks . LinkReferences )
9698 {
9799 if ( ! _repositories . Contains ( repository ) )
98100 continue ;
99101
102+ _logger . LogInformation ( "Validating '{Repository}'" , repository ) ;
100103 // Todo publish all relative folders as part of the link reference
101104 // That way we don't need to iterate over all links and find all permutations of their relative paths
102105 foreach ( var ( relativeLink , _) in linkReference . Links )
103106 {
104- var navigationPaths = _uriResolver . ResolveToSubPaths ( new Uri ( $ "{ repository } ://{ relativeLink } ") , relativeLink ) ;
107+ var crossLink = new Uri ( $ "{ repository } ://{ relativeLink . TrimEnd ( '/' ) } ") ;
108+ var navigationPaths = _uriResolver . ResolveToSubPaths ( crossLink , relativeLink ) ;
109+ if ( navigationPaths . Length == 0 )
110+ {
111+ var path = relativeLink . Split ( '/' ) . SkipLast ( 1 ) ;
112+ var pathUri = new Uri ( $ "{ repository } ://{ string . Join ( '/' , path ) } ") ;
113+
114+ var baseOfAPhantom = _phantoms . Any ( p => p == pathUri ) ;
115+ if ( baseOfAPhantom )
116+ {
117+ skippedPhantoms ++ ;
118+ if ( skippedPhantoms > _phantoms . Count * 3 )
119+ collector . EmitError ( repository , $ "Too many items are being marked as part of a phantom this looks like a bug. ({ skippedPhantoms } )") ;
120+ continue ;
121+ }
122+ collector . EmitError ( repository , $ "'Can not validate '{ crossLink } ' it's not declared in any link reference nor is it a phantom") ;
123+ continue ;
124+ }
105125 foreach ( var navigationPath in navigationPaths )
106126 {
107127 if ( dictionary . TryGetValue ( navigationPath , out var seen ) )
0 commit comments