@@ -78,7 +78,12 @@ public void SaveEnabledPlugins(IEnumerable<AvailablePlugin> availablePlugins)
7878 this . optionsProvider . SaveOption ( options ) ;
7979 }
8080
81- public void LoadPlugins ( )
81+ public void UpdateLoadedPlugins ( IReadOnlyList < AvailablePlugin > loadedPlugins )
82+ {
83+ this . loadedPlugins . ClearAnd ( ) . AddRange ( loadedPlugins ) ;
84+ }
85+
86+ public IReadOnlyList < AvailablePlugin > LoadPlugins ( )
8287 {
8388 this . pluginsSemaphore . Wait ( ) ;
8489 var scopedLogger = this . logger . CreateScopedLogger ( ) ;
@@ -105,9 +110,11 @@ public void LoadPlugins()
105110 catch ( Exception e )
106111 {
107112 scopedLogger . LogError ( e , "Caught exception while loading plugins" ) ;
113+ this . pluginsSemaphore . Release ( ) ;
108114 throw ;
109115 }
110116
117+ var loadedPlugins = new List < AvailablePlugin > ( ) ;
111118 foreach ( var result in results )
112119 {
113120 var pluginScopedLogger = this . logger . CreateScopedLogger ( flowIdentifier : result . PluginEntry ? . Name ?? string . Empty ) ;
@@ -119,35 +126,33 @@ public void LoadPlugins()
119126 if ( assembly is null )
120127 {
121128 // Exclude the plugin from the enabled list if it failed to load
122- this . DisablePlugin ( result ) ;
123129 continue ;
124130 }
125131
126132 var entryPoint = assembly . GetTypes ( ) . FirstOrDefault ( t => t . IsSubclassOf ( typeof ( PluginConfigurationBase ) ) ) ;
127133 if ( entryPoint is null )
128134 {
129135 pluginScopedLogger . LogError ( $ "Assembly loaded but unable to find entry point. The plugin will not start") ;
130- this . DisablePlugin ( result ) ;
131136 continue ;
132137 }
133138
134139 var pluginConfig = Activator . CreateInstance ( entryPoint ) ? . As < PluginConfigurationBase > ( ) ;
135140 if ( pluginConfig is null )
136141 {
137142 pluginScopedLogger . LogError ( $ "Assembly loaded but unable to create entry point. The plugin will not start") ;
138- this . DisablePlugin ( result ) ;
139143 continue ;
140144 }
141145
142- this . loadedPlugins . Add ( new AvailablePlugin { Name = result . PluginEntry ? . Name ?? string . Empty , Path = result . PluginEntry ? . Path ?? string . Empty , Enabled = true , Configuration = pluginConfig } ) ;
146+ loadedPlugins . Add ( new AvailablePlugin { Name = result . PluginEntry ? . Name ?? string . Empty , Path = result . PluginEntry ? . Path ?? string . Empty , Enabled = true , Configuration = pluginConfig } ) ;
143147 }
144- catch ( Exception e )
148+ catch ( Exception e )
145149 {
146150 pluginScopedLogger . LogError ( e , $ "Encountered exception while loading plugin") ;
147151 }
148152 }
149153
150154 this . pluginsSemaphore . Release ( ) ;
155+ return loadedPlugins ;
151156 }
152157
153158 public async Task < bool > AddPlugin ( string pathToPlugin )
0 commit comments