Add API to purge orphaned entries from the config #208
Replies: 7 comments 18 replies
-
Moved this to discussions since this requires a bit more API planning. Right now the following API was proposed: bool TryGetOrphanedEntry(ConfigDefinition entry, out string val);
bool TryGetOrphanedEntry(string section, string key, out string val);
ReadOnlyCollection OrphanedEntires { get; }
bool TryRemoveOrphanedEntry(ConfigDefinition entry);
bool TryRemoveOrphanedEntry(string section, string key);
void RemoveAllOrphans(); Courtesy of @Windows10CE (feel free to provide reasoning for the API choices). I think this might be a good start. Do feel free to give other suggestions. |
Beta Was this translation helpful? Give feedback.
-
Waiting on additional discussion about inclusions for this API in #210 |
Beta Was this translation helpful? Give feedback.
-
Was mentioned in a PR review, but I'll also put it here. bool TryPopOrphanedConfig(ConfigDefinition config, out string var);
bool TryPopOrphanedConfig(string section, string key, out string var); |
Beta Was this translation helpful? Give feedback.
-
I think the naming used for MSDN docs also advise against naming abstract classes with the "Base" suffix: https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/base-classes-for-implementing-abstractions I suggest |
Beta Was this translation helpful? Give feedback.
-
I love the discussion. Thank you for considering this change. Here's my two cents. I particularly like notpeelz's TryPopOrphanedConfig option. I could do everything I need to with just that one. notpeelz's example suggests this, but ghorsington and Windows10CE's prototypes don't show it -- Please remember that values are type T, not type string. |
Beta Was this translation helpful? Give feedback.
-
TryGetOrphanedEntry has been made generic and TryPopOrphanedEntry were added in the latest commits to #210 |
Beta Was this translation helpful? Give feedback.
-
What do you think about an API like this? void TryMigrateOrphanedSetting(ConfigDefinition old, ConfigDefinition new, Func(string, string) valueConverter);
ReadOnlyCollection OrphanedSettings { get; }
bool PurgeOrphanedSettingsOnSave { get; set; } The usage would be to call TryMigrateOrphanedSetting before calling Bind. This would convert old setting to new format if the entry exists and remove the old entry. |
Beta Was this translation helpful? Give feedback.
-
Add API to purge orphaned entries from the config.
Currently there's no way to get rid of orphaned entries from
ConfigFile.OrphanedEntries
, other than through reflection.It would be helpful for implementing automatic config upgrades (e.g renaming a config section)
Beta Was this translation helpful? Give feedback.
All reactions