@@ -28,7 +28,7 @@ public static List<PluginPair> Plugins(List<PluginMetadata> metadatas, PluginsSe
2828 return plugins ;
2929 }
3030
31- private static IEnumerable < PluginPair > DotNetPlugins ( List < PluginMetadata > source )
31+ private static List < PluginPair > DotNetPlugins ( List < PluginMetadata > source )
3232 {
3333 var erroredPlugins = new List < string > ( ) ;
3434
@@ -38,55 +38,57 @@ private static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source
3838 foreach ( var metadata in metadatas )
3939 {
4040 var milliseconds = PublicApi . Instance . StopwatchLogDebug ( ClassName , $ "Constructor init cost for { metadata . Name } ", ( ) =>
41- {
42- Assembly assembly = null ;
43- IAsyncPlugin plugin = null ;
41+ {
42+ Assembly assembly = null ;
43+ IAsyncPlugin plugin = null ;
4444
45- try
46- {
47- var assemblyLoader = new PluginAssemblyLoader ( metadata . ExecuteFilePath ) ;
48- assembly = assemblyLoader . LoadAssemblyAndDependencies ( ) ;
45+ try
46+ {
47+ var assemblyLoader = new PluginAssemblyLoader ( metadata . ExecuteFilePath ) ;
48+ assembly = assemblyLoader . LoadAssemblyAndDependencies ( ) ;
4949
50- var type = assemblyLoader . FromAssemblyGetTypeOfInterface ( assembly ,
51- typeof ( IAsyncPlugin ) ) ;
50+ var type = assemblyLoader . FromAssemblyGetTypeOfInterface ( assembly ,
51+ typeof ( IAsyncPlugin ) ) ;
5252
53- plugin = Activator . CreateInstance ( type ) as IAsyncPlugin ;
53+ plugin = Activator . CreateInstance ( type ) as IAsyncPlugin ;
5454
55- metadata . AssemblyName = assembly . GetName ( ) . Name ;
56- }
55+ metadata . AssemblyName = assembly . GetName ( ) . Name ;
56+ }
5757#if DEBUG
58- catch ( Exception )
59- {
60- throw ;
61- }
58+ catch ( Exception )
59+ {
60+ throw ;
61+ }
6262#else
63- catch ( Exception e ) when ( assembly == null )
64- {
65- PublicApi . Instance . LogException ( ClassName , $ "Couldn't load assembly for the plugin: { metadata . Name } ", e ) ;
66- }
67- catch ( InvalidOperationException e )
68- {
69- PublicApi . Instance . LogException ( ClassName , $ "Can't find the required IPlugin interface for the plugin: <{ metadata . Name } >", e ) ;
70- }
71- catch ( ReflectionTypeLoadException e )
72- {
73- PublicApi . Instance . LogException ( ClassName , $ "The GetTypes method was unable to load assembly types for the plugin: <{ metadata . Name } >", e ) ;
74- }
75- catch ( Exception e )
76- {
77- PublicApi . Instance . LogException ( ClassName , $ "The following plugin has errored and can not be loaded: <{ metadata . Name } >", e ) ;
78- }
63+ catch ( Exception e ) when ( assembly == null )
64+ {
65+ PublicApi . Instance . LogException ( ClassName , $ "Couldn't load assembly for the plugin: { metadata . Name } ", e ) ;
66+ }
67+ catch ( InvalidOperationException e )
68+ {
69+ PublicApi . Instance . LogException ( ClassName , $ "Can't find the required IPlugin interface for the plugin: <{ metadata . Name } >", e ) ;
70+ }
71+ catch ( ReflectionTypeLoadException e )
72+ {
73+ PublicApi . Instance . LogException ( ClassName , $ "The GetTypes method was unable to load assembly types for the plugin: <{ metadata . Name } >", e ) ;
74+ }
75+ catch ( Exception e )
76+ {
77+ PublicApi . Instance . LogException ( ClassName , $ "The following plugin has errored and can not be loaded: <{ metadata . Name } >", e ) ;
78+ }
7979#endif
8080
81- if ( plugin == null )
82- {
83- erroredPlugins . Add ( metadata . Name ) ;
84- return ;
85- }
81+ if ( plugin == null )
82+ {
83+ erroredPlugins . Add ( metadata . Name ) ;
84+ return ;
85+ }
86+
87+ plugins . Add ( new PluginPair { Plugin = plugin , Metadata = metadata } ) ;
88+ } ) ;
8689
87- plugins . Add ( new PluginPair { Plugin = plugin , Metadata = metadata } ) ;
88- } ) ;
8990 metadata . InitTime += milliseconds ;
91+ PublicApi . Instance . LogDebug ( ClassName , $ "Constructor cost for <{ metadata . Name } > is <{ metadata . InitTime } ms>") ;
9092 }
9193
9294 if ( erroredPlugins . Count > 0 )
0 commit comments