don't write to the manifest when reloading dev plugins(fixes #1328)

genericizes the way WorkingPluginId is accessed away from the manifest, since we probably don't want to have it there in the future for regular plugins either
This commit is contained in:
goat 2024-05-14 00:27:11 +02:00
parent 9f32b05587
commit 913d4732b5
8 changed files with 82 additions and 79 deletions

View file

@ -221,7 +221,7 @@ internal class AddonEventManagerPluginScoped : IInternalDisposableService, IAddo
{
this.plugin = plugin;
this.eventManagerService.AddPluginEventController(plugin.Manifest.WorkingPluginId);
this.eventManagerService.AddPluginEventController(plugin.EffectiveWorkingPluginId);
}
/// <inheritdoc/>
@ -233,16 +233,16 @@ internal class AddonEventManagerPluginScoped : IInternalDisposableService, IAddo
this.eventManagerService.ResetCursor();
}
this.eventManagerService.RemovePluginEventController(this.plugin.Manifest.WorkingPluginId);
this.eventManagerService.RemovePluginEventController(this.plugin.EffectiveWorkingPluginId);
}
/// <inheritdoc/>
public IAddonEventHandle? AddEvent(IntPtr atkUnitBase, IntPtr atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventHandler eventHandler)
=> this.eventManagerService.AddEvent(this.plugin.Manifest.WorkingPluginId, atkUnitBase, atkResNode, eventType, eventHandler);
=> this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventHandler);
/// <inheritdoc/>
public void RemoveEvent(IAddonEventHandle eventHandle)
=> this.eventManagerService.RemoveEvent(this.plugin.Manifest.WorkingPluginId, eventHandle);
=> this.eventManagerService.RemoveEvent(this.plugin.EffectiveWorkingPluginId, eventHandle);
/// <inheritdoc/>
public void SetCursor(AddonCursorType cursor)

View file

@ -2438,7 +2438,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (this.hasDevPlugins)
{
ImGuiHelpers.ScaledDummy(3);
ImGui.TextColored(ImGuiColors.DalamudGrey, $"WorkingPluginId: {manifest.WorkingPluginId}");
ImGui.TextColored(ImGuiColors.DalamudGrey, $"WorkingPluginId: {plugin.EffectiveWorkingPluginId}");
ImGuiHelpers.ScaledDummy(3);
}
@ -2621,10 +2621,10 @@ internal class PluginInstallerWindow : Window, IDisposable
var applicableForProfiles = plugin.Manifest.SupportsProfiles /*&& !plugin.IsDev*/;
var profilesThatWantThisPlugin = profileManager.Profiles
.Where(x => x.WantsPlugin(plugin.Manifest.WorkingPluginId) != null)
.Where(x => x.WantsPlugin(plugin.EffectiveWorkingPluginId) != null)
.ToArray();
var isInSingleProfile = profilesThatWantThisPlugin.Length == 1;
var isDefaultPlugin = profileManager.IsInDefaultProfile(plugin.Manifest.WorkingPluginId);
var isDefaultPlugin = profileManager.IsInDefaultProfile(plugin.EffectiveWorkingPluginId);
// Disable everything if the updater is running or another plugin is operating
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress;
@ -2659,17 +2659,17 @@ internal class PluginInstallerWindow : Window, IDisposable
foreach (var profile in profileManager.Profiles.Where(x => !x.IsDefaultProfile))
{
var inProfile = profile.WantsPlugin(plugin.Manifest.WorkingPluginId) != null;
var inProfile = profile.WantsPlugin(plugin.EffectiveWorkingPluginId) != null;
if (ImGui.Checkbox($"###profilePick{profile.Guid}{plugin.Manifest.InternalName}", ref inProfile))
{
if (inProfile)
{
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true))
Task.Run(() => profile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, true))
.ContinueWith(this.DisplayErrorContinuation, Locs.Profiles_CouldNotAdd);
}
else
{
Task.Run(() => profile.RemoveAsync(plugin.Manifest.WorkingPluginId))
Task.Run(() => profile.RemoveAsync(plugin.EffectiveWorkingPluginId))
.ContinueWith(this.DisplayErrorContinuation, Locs.Profiles_CouldNotRemove);
}
}
@ -2689,11 +2689,11 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGuiComponents.IconButton(FontAwesomeIcon.Times))
{
// TODO: Work this out
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, plugin.IsLoaded, false))
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, plugin.IsLoaded, false))
.GetAwaiter().GetResult();
foreach (var profile in profileManager.Profiles.Where(x => !x.IsDefaultProfile && x.Plugins.Any(y => y.InternalName == plugin.Manifest.InternalName)))
{
Task.Run(() => profile.RemoveAsync(plugin.Manifest.WorkingPluginId, false))
Task.Run(() => profile.RemoveAsync(plugin.EffectiveWorkingPluginId, false))
.GetAwaiter().GetResult();
}
@ -2718,7 +2718,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGui.IsItemHovered())
ImGui.SetTooltip(Locs.PluginButtonToolTip_UnloadFailed);
}
else if (this.enableDisableStatus == OperationStatus.InProgress && this.enableDisableWorkingPluginId == plugin.Manifest.WorkingPluginId)
else if (this.enableDisableStatus == OperationStatus.InProgress && this.enableDisableWorkingPluginId == plugin.EffectiveWorkingPluginId)
{
ImGuiComponents.DisabledToggleButton(toggleId, this.loadingIndicatorKind == LoadingIndicatorKind.EnablingSingle);
}
@ -2743,9 +2743,9 @@ internal class PluginInstallerWindow : Window, IDisposable
{
// Reload the devPlugin manifest if it's a dev plugin
// The plugin might rely on changed values in the manifest
if (plugin.IsDev)
if (plugin is LocalDevPlugin devPlugin)
{
plugin.ReloadManifest();
devPlugin.ReloadManifest();
}
}
catch (Exception ex)
@ -2761,13 +2761,13 @@ internal class PluginInstallerWindow : Window, IDisposable
{
this.enableDisableStatus = OperationStatus.InProgress;
this.loadingIndicatorKind = LoadingIndicatorKind.DisablingSingle;
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
this.enableDisableWorkingPluginId = plugin.EffectiveWorkingPluginId;
Task.Run(async () =>
{
await plugin.UnloadAsync();
await applicableProfile.AddOrUpdateAsync(
plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, false, false);
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, NotificationType.Success);
}).ContinueWith(t =>
@ -2782,9 +2782,9 @@ internal class PluginInstallerWindow : Window, IDisposable
{
this.enableDisableStatus = OperationStatus.InProgress;
this.loadingIndicatorKind = LoadingIndicatorKind.EnablingSingle;
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
this.enableDisableWorkingPluginId = plugin.EffectiveWorkingPluginId;
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
await applicableProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, true, false);
await plugin.LoadAsync(PluginLoadReason.Installer);
notifications.AddNotification(Locs.Notifications_PluginEnabled(plugin.Manifest.Name), Locs.Notifications_PluginEnabledTitle, NotificationType.Success);
@ -2805,7 +2805,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (shouldUpdate)
{
// We need to update the profile right here, because PM will not enable the plugin otherwise
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
await applicableProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, true, false);
await this.UpdateSinglePlugin(availableUpdate);
}
else
@ -3076,7 +3076,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (localPlugin is LocalDevPlugin plugin)
{
var isInDefaultProfile =
Service<ProfileManager>.Get().IsInDefaultProfile(localPlugin.Manifest.WorkingPluginId);
Service<ProfileManager>.Get().IsInDefaultProfile(localPlugin.EffectiveWorkingPluginId);
// https://colorswall.com/palette/2868/
var greenColor = new Vector4(0x5C, 0xB8, 0x5C, 0xFF) / 0xFF;
@ -3426,7 +3426,7 @@ internal class PluginInstallerWindow : Window, IDisposable
this.pluginListAvailable.Sort((p1, p2) => p1.Name.CompareTo(p2.Name));
var profman = Service<ProfileManager>.Get();
this.pluginListInstalled.Sort((p1, p2) => profman.IsInDefaultProfile(p1.Manifest.WorkingPluginId).CompareTo(profman.IsInDefaultProfile(p2.Manifest.WorkingPluginId)));
this.pluginListInstalled.Sort((p1, p2) => profman.IsInDefaultProfile(p1.EffectiveWorkingPluginId).CompareTo(profman.IsInDefaultProfile(p2.EffectiveWorkingPluginId)));
break;
default:
throw new InvalidEnumArgumentException("Unknown plugin sort type.");

View file

@ -324,7 +324,7 @@ internal class ProfileManagerWidget
if (ImGui.Selectable($"{plugin.Manifest.Name}{(plugin is LocalDevPlugin ? "(dev plugin)" : string.Empty)}###selector{plugin.Manifest.InternalName}"))
{
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false))
Task.Run(() => profile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, true, false))
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
}
}
@ -430,7 +430,7 @@ internal class ProfileManagerWidget
foreach (var profileEntry in profile.Plugins.ToArray())
{
didAny = true;
var pmPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.Manifest.WorkingPluginId == profileEntry.WorkingPluginId);
var pmPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.EffectiveWorkingPluginId == profileEntry.WorkingPluginId);
var btnOffset = 2;
if (pmPlugin != null)
@ -485,7 +485,7 @@ internal class ProfileManagerWidget
FontAwesomeIcon.Check,
"Yes, use this one"))
{
profileEntry.WorkingPluginId = firstAvailableInstalled.Manifest.WorkingPluginId;
profileEntry.WorkingPluginId = firstAvailableInstalled.EffectiveWorkingPluginId;
Task.Run(async () =>
{
await profman.ApplyAllWantStatesAsync();

View file

@ -398,7 +398,7 @@ public sealed class DalamudPluginInterface : IDisposable
if (currentConfig == null)
return;
this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.Manifest.WorkingPluginId);
this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
}
/// <summary>
@ -425,7 +425,7 @@ public sealed class DalamudPluginInterface : IDisposable
}
// this shouldn't be a thing, I think, but just in case
return this.configs.Load(this.plugin.InternalName, this.plugin.Manifest.WorkingPluginId);
return this.configs.Load(this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
}
/// <summary>

View file

@ -1029,7 +1029,7 @@ internal class PluginManager : IInternalDisposableService
{
var plugin = metadata.InstalledPlugin;
var workingPluginId = metadata.InstalledPlugin.Manifest.WorkingPluginId;
var workingPluginId = metadata.InstalledPlugin.EffectiveWorkingPluginId;
if (workingPluginId == Guid.Empty)
throw new Exception("Existing plugin had no WorkingPluginId");
@ -1331,16 +1331,16 @@ internal class PluginManager : IInternalDisposableService
foreach (var installedPlugin in this.InstalledPlugins)
{
if (installedPlugin.Manifest.WorkingPluginId == Guid.Empty)
if (installedPlugin.EffectiveWorkingPluginId == Guid.Empty)
throw new Exception($"{(installedPlugin is LocalDevPlugin ? "DevPlugin" : "Plugin")} '{installedPlugin.Manifest.InternalName}' has an empty WorkingPluginId.");
if (seenIds.Contains(installedPlugin.Manifest.WorkingPluginId))
if (seenIds.Contains(installedPlugin.EffectiveWorkingPluginId))
{
throw new Exception(
$"{(installedPlugin is LocalDevPlugin ? "DevPlugin" : "Plugin")} '{installedPlugin.Manifest.InternalName}' has a duplicate WorkingPluginId '{installedPlugin.Manifest.WorkingPluginId}'");
$"{(installedPlugin is LocalDevPlugin ? "DevPlugin" : "Plugin")} '{installedPlugin.Manifest.InternalName}' has a duplicate WorkingPluginId '{installedPlugin.EffectiveWorkingPluginId}'");
}
seenIds.Add(installedPlugin.Manifest.WorkingPluginId);
seenIds.Add(installedPlugin.EffectiveWorkingPluginId);
}
this.profileManager.ParanoiaValidateProfiles();
@ -1388,7 +1388,7 @@ internal class PluginManager : IInternalDisposableService
{
// Only remove entries from the default profile that are NOT currently tied to an active LocalPlugin
var guidsToRemove = this.profileManager.DefaultProfile.Plugins
.Where(x => this.InstalledPlugins.All(y => y.Manifest.WorkingPluginId != x.WorkingPluginId))
.Where(x => this.InstalledPlugins.All(y => y.EffectiveWorkingPluginId != x.WorkingPluginId))
.Select(x => x.WorkingPluginId)
.ToArray();
@ -1560,9 +1560,9 @@ internal class PluginManager : IInternalDisposableService
// This will also happen if you are installing a plugin with the installer, and that's intended!
// It means that, if you have a profile which has unsatisfied plugins, installing a matching plugin will
// enter it into the profiles it can match.
if (plugin.Manifest.WorkingPluginId == Guid.Empty)
if (plugin.EffectiveWorkingPluginId == Guid.Empty)
throw new Exception("Plugin should have a WorkingPluginId at this point");
this.profileManager.MigrateProfilesToGuidsForPlugin(plugin.Manifest.InternalName, plugin.Manifest.WorkingPluginId);
this.profileManager.MigrateProfilesToGuidsForPlugin(plugin.Manifest.InternalName, plugin.EffectiveWorkingPluginId);
var wantedByAnyProfile = false;
@ -1573,7 +1573,7 @@ internal class PluginManager : IInternalDisposableService
loadPlugin &= !isBoot;
var wantsInDefaultProfile =
this.profileManager.DefaultProfile.WantsPlugin(plugin.Manifest.WorkingPluginId);
this.profileManager.DefaultProfile.WantsPlugin(plugin.EffectiveWorkingPluginId);
if (wantsInDefaultProfile == null)
{
// We don't know about this plugin, so we don't want to do anything here.
@ -1582,7 +1582,7 @@ internal class PluginManager : IInternalDisposableService
// Check if any profile wants this plugin. We need to do this here, since we want to allow loading a dev plugin if a non-default profile wants it active.
// Note that this will not add the plugin to the default profile. That's done below in any other case.
wantedByAnyProfile = await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
wantedByAnyProfile = await this.profileManager.GetWantStateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, false, false);
// If it is wanted by any other profile, we do want to load it.
if (wantedByAnyProfile)
@ -1592,28 +1592,28 @@ internal class PluginManager : IInternalDisposableService
{
// We didn't want this plugin, and StartOnBoot is on. That means we don't want it and it should stay off until manually enabled.
Log.Verbose("DevPlugin {Name} disabled and StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot)
{
// We wanted this plugin, and StartOnBoot is on. That means we actually do want it.
Log.Verbose("DevPlugin {Name} enabled and StartOnBoot => enable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, true, false);
loadPlugin = !doNotLoad;
}
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
{
// We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore.
Log.Verbose("DevPlugin {Name} enabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot)
{
// We didn't want this plugin, and StartOnBoot is off. We don't want it.
Log.Verbose("DevPlugin {Name} disabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
@ -1626,7 +1626,7 @@ internal class PluginManager : IInternalDisposableService
// Plugins that aren't in any profile will be added to the default profile with this call.
// We are skipping a double-lookup for dev plugins that are wanted by non-default profiles, as noted above.
wantedByAnyProfile = wantedByAnyProfile || await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, defaultState);
wantedByAnyProfile = wantedByAnyProfile || await this.profileManager.GetWantStateAsync(plugin.EffectiveWorkingPluginId, plugin.Manifest.InternalName, defaultState);
Log.Information("{Name} defaultState: {State} wantedByAnyProfile: {WantedByAny} loadPlugin: {LoadPlugin}", plugin.Manifest.InternalName, defaultState, wantedByAnyProfile, loadPlugin);
if (loadPlugin)

View file

@ -183,8 +183,8 @@ internal class ProfileManager : IServiceType
var installedPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.Manifest.InternalName == plugin.InternalName);
if (installedPlugin != null)
{
Log.Information("Satisfying plugin {InternalName} for profile {Name} with {Guid}", plugin.InternalName, newModel.Name, installedPlugin.Manifest.WorkingPluginId);
plugin.WorkingPluginId = installedPlugin.Manifest.WorkingPluginId;
Log.Information("Satisfying plugin {InternalName} for profile {Name} with {Guid}", plugin.InternalName, newModel.Name, installedPlugin.EffectiveWorkingPluginId);
plugin.WorkingPluginId = installedPlugin.EffectiveWorkingPluginId;
}
else
{
@ -237,7 +237,7 @@ internal class ProfileManager : IServiceType
var pm = Service<PluginManager>.Get();
foreach (var installedPlugin in pm.InstalledPlugins)
{
var wantThis = wantActive.Any(x => x.WorkingPluginId == installedPlugin.Manifest.WorkingPluginId);
var wantThis = wantActive.Any(x => x.WorkingPluginId == installedPlugin.EffectiveWorkingPluginId);
switch (wantThis)
{
case true when !installedPlugin.IsLoaded:

View file

@ -50,14 +50,6 @@ internal class LocalDevPlugin : LocalPlugin, IDisposable
Log.Verbose("{InternalName} was assigned new devPlugin GUID {Guid}", this.InternalName, this.devSettings.WorkingPluginId);
configuration.QueueSave();
}
// If the ID in the manifest is wrong, force the good one
if (this.DevImposedWorkingPluginId != this.manifest.WorkingPluginId)
{
Debug.Assert(this.DevImposedWorkingPluginId != Guid.Empty, "Empty guid for devPlugin");
this.manifest.WorkingPluginId = this.DevImposedWorkingPluginId;
this.SaveManifest("dev imposed working plugin id");
}
if (this.AutomaticReload)
{
@ -99,7 +91,10 @@ internal class LocalDevPlugin : LocalPlugin, IDisposable
/// Gets an ID uniquely identifying this specific instance of a devPlugin.
/// </summary>
public Guid DevImposedWorkingPluginId => this.devSettings.WorkingPluginId;
/// <inheritdoc/>
public override Guid EffectiveWorkingPluginId => this.DevImposedWorkingPluginId;
/// <summary>
/// Gets a list of validation problems that have been dismissed by the user.
/// </summary>
@ -148,6 +143,23 @@ internal class LocalDevPlugin : LocalPlugin, IDisposable
}
}
/// <summary>
/// Reload the manifest if it exists, to update possible changes.
/// </summary>
/// <exception cref="Exception">Thrown if the manifest could not be loaded.</exception>
public void ReloadManifest()
{
var manifestPath = LocalPluginManifest.GetManifestFile(this.DllFile);
if (manifestPath.Exists)
this.manifest = LocalPluginManifest.Load(manifestPath) ?? throw new Exception("Could not reload manifest.");
}
/// <inheritdoc/>
protected override void OnPreReload()
{
this.ReloadManifest();
}
private void OnFileChanged(object sender, FileSystemEventArgs args)
{
var current = Interlocked.Increment(ref this.reloadCounter);

View file

@ -91,7 +91,7 @@ internal class LocalPlugin : IDisposable
}
// Create an installation instance ID for this plugin, if it doesn't have one yet
if (this.manifest.WorkingPluginId == Guid.Empty)
if (this.manifest.WorkingPluginId == Guid.Empty && !this.IsDev)
{
this.manifest.WorkingPluginId = Guid.NewGuid();
@ -162,7 +162,7 @@ internal class LocalPlugin : IDisposable
/// INCLUDES the default profile.
/// </summary>
public bool IsWantedByAnyProfile =>
Service<ProfileManager>.Get().GetWantStateAsync(this.manifest.WorkingPluginId, this.Manifest.InternalName, false, false).GetAwaiter().GetResult();
Service<ProfileManager>.Get().GetWantStateAsync(this.EffectiveWorkingPluginId, this.Manifest.InternalName, false, false).GetAwaiter().GetResult();
/// <summary>
/// Gets a value indicating whether this plugin's API level is out of date.
@ -215,6 +215,11 @@ internal class LocalPlugin : IDisposable
/// </summary>
public Version EffectiveVersion => this.manifest.EffectiveVersion;
/// <summary>
/// Gets the effective working plugin ID for this plugin.
/// </summary>
public virtual Guid EffectiveWorkingPluginId => this.manifest.WorkingPluginId;
/// <summary>
/// Gets the service scope for this plugin.
/// </summary>
@ -271,11 +276,8 @@ internal class LocalPlugin : IDisposable
await this.pluginLoadStateLock.WaitAsync();
try
{
if (reloading && this.IsDev)
{
// Reload the manifest in-case there were changes here too.
this.ReloadManifest();
}
if (reloading)
this.OnPreReload();
// If we reload a plugin we don't want to delete it. Makes sense, right?
if (this.manifest.ScheduledForDeletion)
@ -578,24 +580,6 @@ internal class LocalPlugin : IDisposable
this.SaveManifest("scheduling for deletion");
}
/// <summary>
/// Reload the manifest if it exists, preserve the internal Disabled state.
/// </summary>
public void ReloadManifest()
{
var manifestPath = LocalPluginManifest.GetManifestFile(this.DllFile);
if (manifestPath.Exists)
{
// Save some state that we do actually want to carry over
var guid = this.manifest.WorkingPluginId;
this.manifest = LocalPluginManifest.Load(manifestPath) ?? throw new Exception("Could not reload manifest.");
this.manifest.WorkingPluginId = guid;
this.SaveManifest("dev reload");
}
}
/// <summary>
/// Get the repository this plugin was installed from.
/// </summary>
@ -620,6 +604,13 @@ internal class LocalPlugin : IDisposable
/// </summary>
/// <param name="reason">Why it should be saved.</param>
protected void SaveManifest(string reason) => this.manifest.Save(this.manifestFile, reason);
/// <summary>
/// Called before a plugin is reloaded.
/// </summary>
protected virtual void OnPreReload()
{
}
private static void SetupLoaderConfig(LoaderConfig config)
{