@@ -200,7 +200,7 @@ public void AssembliesAreReferenceAssemblies()
200
200
return ;
201
201
}
202
202
203
- IEnumerable < string > dlls = Directory . GetFiles ( _targetingPackRoot , "*.dll" , SearchOption . AllDirectories ) ;
203
+ IEnumerable < string > dlls = Directory . GetFiles ( Path . Combine ( _targetingPackRoot , "ref" ) , "*.dll" , SearchOption . AllDirectories ) ;
204
204
Assert . NotEmpty ( dlls ) ;
205
205
206
206
Assert . All ( dlls , path =>
@@ -312,32 +312,48 @@ public void FrameworkListListsContainsCorrectEntries()
312
312
313
313
var frameworkListDoc = XDocument . Load ( frameworkListPath ) ;
314
314
var frameworkListEntries = frameworkListDoc . Root . Descendants ( ) ;
315
+ var managedEntries = frameworkListEntries . Where ( i => i . Attribute ( "Type" ) . Value . Equals ( "Managed" , StringComparison . Ordinal ) ) ;
316
+ var analyzerEntries = frameworkListEntries . Where ( i => i . Attribute ( "Type" ) . Value . Equals ( "Analyzer" , StringComparison . Ordinal ) ) ;
315
317
316
- _output . WriteLine ( "==== file contents ====" ) ;
317
- _output . WriteLine ( string . Join ( '\n ' , frameworkListEntries . Select ( i => i . Attribute ( "AssemblyName" ) . Value ) . OrderBy ( i => i ) ) ) ;
318
- _output . WriteLine ( "==== expected assemblies ====" ) ;
319
- _output . WriteLine ( string . Join ( '\n ' , expectedAssemblies . OrderBy ( i => i ) ) ) ;
320
-
321
- var actualAssemblies = frameworkListEntries
322
- . Select ( i =>
323
- {
324
- var fileName = i . Attribute ( "AssemblyName" ) . Value ;
325
- return fileName . EndsWith ( ".dll" , StringComparison . Ordinal )
326
- ? fileName . Substring ( 0 , fileName . Length - 4 )
327
- : fileName ;
328
- } )
329
- . ToHashSet ( ) ;
318
+ var analyzersDir = Path . Combine ( _targetingPackRoot , "analyzers" ) ;
319
+ var expectedAnalyzers = Directory . Exists ( analyzersDir ) ?
320
+ Directory . GetFiles ( analyzersDir , "*.dll" , SearchOption . AllDirectories )
321
+ . Select ( p => Path . GetFileNameWithoutExtension ( p ) )
322
+ . Where ( f => ! f . EndsWith ( ".resources" , StringComparison . OrdinalIgnoreCase ) )
323
+ . ToHashSet ( ) :
324
+ new HashSet < string > ( ) ;
330
325
331
- var missing = expectedAssemblies . Except ( actualAssemblies ) ;
332
- var unexpected = actualAssemblies . Except ( expectedAssemblies ) ;
333
-
334
- _output . WriteLine ( "==== missing assemblies from the framework list ====" ) ;
335
- _output . WriteLine ( string . Join ( '\n ' , missing ) ) ;
336
- _output . WriteLine ( "==== unexpected assemblies in the framework list ====" ) ;
337
- _output . WriteLine ( string . Join ( '\n ' , unexpected ) ) ;
326
+ CompareFrameworkElements ( expectedAssemblies , managedEntries , "managed" ) ;
327
+ CompareFrameworkElements ( expectedAnalyzers , analyzerEntries , "analyzer" ) ;
338
328
339
- Assert . Empty ( missing ) ;
340
- Assert . Empty ( unexpected ) ;
329
+ void CompareFrameworkElements ( HashSet < string > expectedAssemblyNames , IEnumerable < XElement > actualElements , string type )
330
+ {
331
+ _output . WriteLine ( $ "==== file contents ({ type } ) ====") ;
332
+ _output . WriteLine ( string . Join ( '\n ' , actualElements . Select ( i => i . Attribute ( "AssemblyName" ) . Value ) . OrderBy ( i => i ) ) ) ;
333
+ _output . WriteLine ( $ "==== expected { type } assemblies ====") ;
334
+ _output . WriteLine ( string . Join ( '\n ' , expectedAssemblyNames . OrderBy ( i => i ) ) ) ;
335
+
336
+ var actualAssemblyNames = managedEntries
337
+ . Select ( i =>
338
+ {
339
+ var fileName = i . Attribute ( "AssemblyName" ) . Value ;
340
+ return fileName . EndsWith ( ".dll" , StringComparison . Ordinal )
341
+ ? fileName . Substring ( 0 , fileName . Length - 4 )
342
+ : fileName ;
343
+ } )
344
+ . ToHashSet ( ) ;
345
+
346
+ var missing = actualAssemblyNames . Except ( actualAssemblyNames ) ;
347
+ var unexpected = actualAssemblyNames . Except ( expectedAssemblies ) ;
348
+
349
+ _output . WriteLine ( $ "==== missing { type } assemblies from the framework list ====") ;
350
+ _output . WriteLine ( string . Join ( '\n ' , missing ) ) ;
351
+ _output . WriteLine ( $ "==== unexpected { type } assemblies in the framework list ====") ;
352
+ _output . WriteLine ( string . Join ( '\n ' , unexpected ) ) ;
353
+
354
+ Assert . Empty ( missing ) ;
355
+ Assert . Empty ( unexpected ) ;
356
+ }
341
357
342
358
Assert . All ( frameworkListEntries , i =>
343
359
{
@@ -370,7 +386,7 @@ public void FrameworkListListsContainsCorrectPaths()
370
386
ZipArchive archive = ZipFile . OpenRead ( targetingPackPath ) ;
371
387
372
388
var actualPaths = archive . Entries
373
- . Where ( i => i . FullName . EndsWith ( ".dll" , StringComparison . Ordinal ) )
389
+ . Where ( i => i . FullName . EndsWith ( ".dll" , StringComparison . Ordinal ) && ! i . FullName . EndsWith ( ".resources.dll" , StringComparison . Ordinal ) )
374
390
. Select ( i => i . FullName ) . ToHashSet ( ) ;
375
391
376
392
var expectedPaths = frameworkListEntries . Select ( i => i . Attribute ( "Path" ) . Value ) . ToHashSet ( ) ;
@@ -391,5 +407,38 @@ public void FrameworkListListsContainsCorrectPaths()
391
407
Assert . Empty ( missing ) ;
392
408
Assert . Empty ( unexpected ) ;
393
409
}
410
+
411
+ [ Fact ]
412
+ public void FrameworkListListsContainsAnalyzerLanguage ( )
413
+ {
414
+ if ( ! _isTargetingPackBuilding || string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
415
+ {
416
+ return ;
417
+ }
418
+
419
+ var frameworkListPath = Path . Combine ( _targetingPackRoot , "data" , "FrameworkList.xml" ) ;
420
+
421
+ AssertEx . FileExists ( frameworkListPath ) ;
422
+
423
+ var frameworkListDoc = XDocument . Load ( frameworkListPath ) ;
424
+ var frameworkListEntries = frameworkListDoc . Root . Descendants ( ) ;
425
+
426
+ var analyzerEntries = frameworkListEntries . Where ( i => i . Attribute ( "Type" ) . Value . Equals ( "Analyzer" , StringComparison . Ordinal ) ) ;
427
+
428
+ Assert . All ( analyzerEntries , analyzerEntry =>
429
+ {
430
+ var actualLanguage = analyzerEntry . Attribute ( "Language" ) ? . Value ;
431
+ var assemblyPath = analyzerEntry . Attribute ( "Path" ) . Value ;
432
+
433
+ string expectedLanguage = Path . GetFileName ( Path . GetDirectoryName ( assemblyPath ) ) ;
434
+
435
+ if ( expectedLanguage . Equals ( "dotnet" , StringComparison . OrdinalIgnoreCase ) )
436
+ {
437
+ expectedLanguage = null ;
438
+ }
439
+
440
+ Assert . Equal ( expectedLanguage , actualLanguage ) ;
441
+ } ) ;
442
+ }
394
443
}
395
444
}
0 commit comments