@@ -96,9 +96,8 @@ public static ScriptAnalyzer Instance
9696
9797 [ ImportMany ]
9898 public IEnumerable < IDSCResourceRule > DSCResourceRules { get ; private set ; }
99-
100- #endif // !CORECLR
10199 // Initializes via ImportMany
100+ #endif // !CORECLR
102101
103102 internal List < ExternalRule > ExternalRules { get ; set ; }
104103
@@ -507,13 +506,19 @@ private void Initialize(
507506
508507 this . outputWriter = outputWriter ;
509508
510- #region Verifies rule extensions and loggers path
509+ #region Verifies rule extensions
511510
512511 List < string > paths = this . GetValidCustomRulePaths ( customizedRulePath , path ) ;
513512
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
515520
516- #region Initializes Rules
521+ #region Initializes Rules
517522
518523 var includeRuleList = new List < string > ( ) ;
519524 var excludeRuleList = new List < string > ( ) ;
@@ -669,7 +674,7 @@ private List<string> GetValidCustomRulePaths(string[] customizedRulePath, PathIn
669674 }
670675
671676
672- private IEnumerable < T > GetRulesFromDLL < T > ( ) where T : class , IRule
677+ private IEnumerable < T > GetInterfaceImplementationsFromAssembly < T > ( ) where T : class
673678 {
674679 string dirName = Path . GetDirectoryName ( typeof ( ScriptAnalyzer ) . GetTypeInfo ( ) . Assembly . Location ) ;
675680 var dllPaths = Directory . EnumerateFiles ( dirName , "*.dll" , SearchOption . TopDirectoryOnly ) ;
@@ -683,7 +688,7 @@ private IEnumerable<T> GetRulesFromDLL<T>() where T : class, IRule
683688 return rules ;
684689 }
685690
686- private IEnumerable < T > GetRulesFromDLL < T > ( string ruleDllPath ) where T : class , IRule
691+ private IEnumerable < T > GetRulesFromDLL < T > ( string ruleDllPath ) where T : class
687692 {
688693 var fileName = Path . GetFileNameWithoutExtension ( ruleDllPath ) ;
689694 var assName = new AssemblyName ( fileName ) ;
@@ -740,9 +745,9 @@ private void LoadRules(Dictionary<string, List<string>> result, CommandInvocatio
740745 this . ExternalRules = null ;
741746
742747#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 > ( ) ;
746751#else
747752 // An aggregate catalog that combines multiple catalogs.
748753 using ( AggregateCatalog catalog = new AggregateCatalog ( ) )
0 commit comments