@@ -96,9 +96,8 @@ public static ScriptAnalyzer Instance
96
96
97
97
[ ImportMany ]
98
98
public IEnumerable < IDSCResourceRule > DSCResourceRules { get ; private set ; }
99
-
100
- #endif // !CORECLR
101
99
// Initializes via ImportMany
100
+ #endif // !CORECLR
102
101
103
102
internal List < ExternalRule > ExternalRules { get ; set ; }
104
103
@@ -507,13 +506,19 @@ private void Initialize(
507
506
508
507
this . outputWriter = outputWriter ;
509
508
510
- #region Verifies rule extensions and loggers path
509
+ #region Verifies rule extensions
511
510
512
511
List < string > paths = this . GetValidCustomRulePaths ( customizedRulePath , path ) ;
513
512
514
- #endregion
513
+ #endregion
514
+
515
+ #if CORECLR
516
+ // For Full CLR logger is loaded via Composition
517
+ // But for Core CLR we need to load it explicitly
518
+ this . Loggers = GetInterfaceImplementationsFromAssembly < ILogger > ( ) ;
519
+ #endif
515
520
516
- #region Initializes Rules
521
+ #region Initializes Rules
517
522
518
523
var includeRuleList = new List < string > ( ) ;
519
524
var excludeRuleList = new List < string > ( ) ;
@@ -669,7 +674,7 @@ private List<string> GetValidCustomRulePaths(string[] customizedRulePath, PathIn
669
674
}
670
675
671
676
672
- private IEnumerable < T > GetRulesFromDLL < T > ( ) where T : class , IRule
677
+ private IEnumerable < T > GetInterfaceImplementationsFromAssembly < T > ( ) where T : class
673
678
{
674
679
string dirName = Path . GetDirectoryName ( typeof ( ScriptAnalyzer ) . GetTypeInfo ( ) . Assembly . Location ) ;
675
680
var dllPaths = Directory . EnumerateFiles ( dirName , "*.dll" , SearchOption . TopDirectoryOnly ) ;
@@ -683,7 +688,7 @@ private IEnumerable<T> GetRulesFromDLL<T>() where T : class, IRule
683
688
return rules ;
684
689
}
685
690
686
- private IEnumerable < T > GetRulesFromDLL < T > ( string ruleDllPath ) where T : class , IRule
691
+ private IEnumerable < T > GetRulesFromDLL < T > ( string ruleDllPath ) where T : class
687
692
{
688
693
var fileName = Path . GetFileNameWithoutExtension ( ruleDllPath ) ;
689
694
var assName = new AssemblyName ( fileName ) ;
@@ -740,9 +745,9 @@ private void LoadRules(Dictionary<string, List<string>> result, CommandInvocatio
740
745
this . ExternalRules = null ;
741
746
742
747
#if CORECLR
743
- this . ScriptRules = GetRulesFromDLL < IScriptRule > ( ) ;
744
- this . TokenRules = GetRulesFromDLL < ITokenRule > ( ) ;
745
- this . DSCResourceRules = GetRulesFromDLL < IDSCResourceRule > ( ) ;
748
+ this . ScriptRules = GetInterfaceImplementationsFromAssembly < IScriptRule > ( ) ;
749
+ this . TokenRules = GetInterfaceImplementationsFromAssembly < ITokenRule > ( ) ;
750
+ this . DSCResourceRules = GetInterfaceImplementationsFromAssembly < IDSCResourceRule > ( ) ;
746
751
#else
747
752
// An aggregate catalog that combines multiple catalogs.
748
753
using ( AggregateCatalog catalog = new AggregateCatalog ( ) )
0 commit comments