Skip to content

Commit 074f159

Browse files
committed
Clarify method summaries and rename ReplaceLinkedItemInAllLoadouts to ReplaceLinkedItemsInAllLoadouts for consistency
1 parent 83e72c1 commit 074f159

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

src/NexusMods.Abstractions.Library/ILibraryService.cs

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface ILibraryService
4545

4646
/// <summary>
4747
/// Installs a library item into a target loadout.
48-
/// To remove an item, use <see cref="RemoveLinkedItemFromLoadout"/>.
48+
/// To remove an installed item, use <see cref="RemoveLinkedItemFromLoadout"/>.
4949
/// </summary>
5050
/// <param name="libraryItem">The item to install.</param>
5151
/// <param name="targetLoadout">The target loadout.</param>
@@ -75,82 +75,87 @@ IJobTask<IInstallLoadoutItemJob, InstallLoadoutItemJobResult> InstallItem(
7575
Task RemoveLibraryItems(IEnumerable<LibraryItem.ReadOnly> libraryItems, GarbageCollectorRunMode gcRunMode = GarbageCollectorRunMode.RunAsynchronously);
7676

7777
/// <summary>
78-
/// Unlinks a single item added by <see cref="InstallItem"/> function call from a loadout.
78+
/// Removes a single linked loadout item from its loadout,
79+
/// managing the transaction automatically.
7980
/// </summary>
80-
/// <param name="itemId">The <see cref="LibraryLinkedLoadoutItem"/> to remove from the loadout.</param>
81+
/// <param name="itemId">The ID of the linked loadout item to remove from the loadout.</param>
8182
Task RemoveLinkedItemFromLoadout(LibraryLinkedLoadoutItemId itemId);
8283

8384
/// <summary>
84-
/// Unlinks a number of items added by <see cref="InstallItem"/> function call from a loadout.
85+
/// Removes multiple linked loadout items from their loadout,
86+
/// managing the transaction automatically.
8587
/// </summary>
86-
/// <param name="itemIds">The <see cref="LibraryLinkedLoadoutItem"/>s to remove from the loadout.</param>
88+
/// <param name="itemIds">The IDs of the linked loadout items to remove from their loadout.</param>
8789
Task RemoveLinkedItemsFromLoadout(IEnumerable<LibraryLinkedLoadoutItemId> itemIds);
8890

8991
/// <summary>
90-
/// Unlinks a single item added by <see cref="InstallItem"/> function call from a loadout.
92+
/// Removes a single linked loadout item from a loadout,
93+
/// using the provided transaction.
9194
/// </summary>
92-
/// <param name="itemId">The <see cref="LibraryLinkedLoadoutItem"/>s to remove from the loadout.</param>
93-
/// <param name="tx">Existing transaction to use</param>
95+
/// <param name="itemId">The ID of the linked loadout item to remove from its loadout.</param>
96+
/// <param name="tx">Existing transaction to use for this operation.</param>
9497
void RemoveLinkedItemFromLoadout(LibraryLinkedLoadoutItemId itemId, ITransaction tx);
9598

9699
/// <summary>
97-
/// Unlinks a number of items added by <see cref="InstallItem"/> function call from a loadout.
100+
/// Removes multiple linked loadout items from their loadout,
101+
/// using the provided transaction.
98102
/// </summary>
99-
/// <param name="itemIds">The <see cref="LibraryLinkedLoadoutItem"/>s to remove</param>
100-
/// <param name="tx">Existing transaction to use</param>
103+
/// <param name="itemIds">The IDs of the linked loadout items to remove from their loadout.</param>
104+
/// <param name="tx">Existing transaction to use for this operation.</param>
101105
void RemoveLinkedItemsFromLoadout(IEnumerable<LibraryLinkedLoadoutItemId> itemIds, ITransaction tx);
102106

103107
/// <summary>
104-
/// Removes library items (originally installed via <see cref="InstallItem"/>) from all
105-
/// loadouts using an existing transaction
108+
/// Removes all linked loadout items from all loadouts,
109+
/// using the provided transaction.
106110
/// </summary>
107-
/// <param name="libraryItems">The library items to remove from the loadouts</param>
108-
/// <param name="tx">Existing transaction to use</param>
111+
/// <param name="libraryItems">The library items whose associated linked loadout items should be removed.</param>
112+
/// <param name="tx">Existing transaction to use for this operation.</param>
109113
void RemoveLinkedItemsFromAllLoadouts(IEnumerable<LibraryItem.ReadOnly> libraryItems, ITransaction tx);
110114

111115
/// <summary>
112-
/// Removes library items (originally installed via <see cref="InstallItem"/>) from all
113-
/// loadouts with automatic transaction
116+
/// Removes all linked loadout items from all loadouts,
117+
/// managing the transaction automatically.
114118
/// </summary>
115-
/// <param name="libraryItems">The library items to remove from the loadouts</param>
119+
/// <param name="libraryItems">The library items whose associated linked loadout items should be removed.</param>
116120
Task RemoveLinkedItemsFromAllLoadouts(IEnumerable<LibraryItem.ReadOnly> libraryItems);
117121

118122
/// <summary>
119-
/// Replaces all occurrences of a library item with a new version in all loadouts
123+
/// Replaces linked loadout items across all loadouts with installations of a different library item.
120124
/// </summary>
121-
/// <param name="oldItem">The library item to be replaced</param>
122-
/// <param name="newItem">The replacement library item</param>
123-
/// <param name="options">Options regarding how to replace this library item.</param>
124-
/// <param name="tx">The transaction to use</param>
125+
/// <param name="oldItem">The library item whose linked loadout items should be replaced.</param>
126+
/// <param name="newItem">The replacement library item from which to install the new linked loadout items from.</param>
127+
/// <param name="options">Options controlling how to replace the linked loadout items.</param>
128+
/// <param name="tx">The transaction to use for this operation.</param>
125129
/// <returns>
126-
/// If an error occurs at any step of the way, this returns a 'fail' enum.
130+
/// A result indicating success or failure of the replacement operation.
127131
/// </returns>
128-
ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemInAllLoadouts(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem, ReplaceLibraryItemOptions options, ITransaction tx);
132+
ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemsInAllLoadouts(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem, ReplaceLibraryItemOptions options, ITransaction tx);
129133

130134
/// <summary>
131-
/// Replaces all occurrences of a library item with a new version in all loadouts
135+
/// Replaces multiple sets of linked loadout items across all loadouts with new versions.
132136
/// </summary>
133-
/// <param name="replacements">The replacements to perform</param>
134-
/// <param name="options">Options regarding how to replace these library items.</param>
135-
/// <param name="tx">The transaction to add this replace operation to.</param>
137+
/// <param name="replacements">The pairs of library items (old and new) whose linked loadout items should be replaced.</param>
138+
/// <param name="options">Options controlling how to replace the linked loadout items.</param>
139+
/// <param name="tx">The transaction to use for this operation.</param>
136140
/// <returns>
137-
/// If an error occurs at any step of the way, this returns a 'fail' enum.
141+
/// A result indicating success or failure of the replacement operation.
138142
/// </returns>
139143
ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemsInAllLoadouts(IEnumerable<(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem)> replacements, ReplaceLibraryItemsOptions options, ITransaction tx);
140144

141145
/// <summary>
142-
/// Replaces all occurrences of a library item with a new version in all loadouts
146+
/// Replaces multiple sets of linked loadout items across all loadouts with new versions,
147+
/// managing the transaction automatically.
143148
/// </summary>
144-
/// <param name="replacements">The replacements to perform</param>
145-
/// <param name="options">Options regarding how to replace this library item.</param>
149+
/// <param name="replacements">The pairs of library items (old and new) whose linked loadout items should be replaced.</param>
150+
/// <param name="options">Options controlling how to replace the linked loadout items.</param>
146151
/// <returns>
147-
/// If an error occurs at any step of the way, this returns a 'fail' enum.
152+
/// A result indicating success or failure of the replacement operation.
148153
/// </returns>
149154
ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemsInAllLoadouts(IEnumerable<(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem)> replacements, ReplaceLibraryItemsOptions options);
150155
}
151156

152157
/// <summary>
153-
/// Represents the result of a <see cref="ILibraryService.ReplaceLinkedItemInAllLoadouts"/> operation.
158+
/// Represents the result of a <see cref="ILibraryService.ReplaceLinkedItemsInAllLoadouts(NexusMods.Abstractions.Library.Models.LibraryItem.ReadOnly,NexusMods.Abstractions.Library.Models.LibraryItem.ReadOnly,NexusMods.Abstractions.Library.ReplaceLibraryItemOptions,NexusMods.MnemonicDB.Abstractions.ITransaction)"/> operation.
154159
/// </summary>
155160
public enum LibraryItemReplacementResult
156161
{
@@ -166,24 +171,24 @@ public enum LibraryItemReplacementResult
166171
}
167172

168173
/// <summary>
169-
/// Options for the <see cref="ILibraryService.ReplaceLinkedItemInAllLoadouts"/>
174+
/// Options for the <see cref="ILibraryService.ReplaceLinkedItemsInAllLoadouts(NexusMods.Abstractions.Library.Models.LibraryItem.ReadOnly,NexusMods.Abstractions.Library.Models.LibraryItem.ReadOnly,NexusMods.Abstractions.Library.ReplaceLibraryItemOptions,NexusMods.MnemonicDB.Abstractions.ITransaction)"/>
170175
/// API.
171176
/// </summary>
172177
public struct ReplaceLibraryItemOptions
173178
{
174179
/// <summary>
175-
/// Ignores items in ReadOnly collections such as collections from Nexus Mods.
180+
/// Skips items in ReadOnly collections such as collections from Nexus Mods.
176181
/// </summary>
177182
public bool IgnoreReadOnlyCollections { get; set; }
178183
}
179184

180185
/// <summary>
181-
/// Options for the 'ReplaceLibraryItemsInAllLoadouts' API.
186+
/// Options controlling how multiple sets of linked loadout items are replaced across loadouts.
182187
/// </summary>
183188
public struct ReplaceLibraryItemsOptions
184189
{
185190
/// <summary>
186-
/// Ignores items in ReadOnly collections such as collections from Nexus Mods.
191+
/// Skips items in ReadOnly collections such as collections from Nexus Mods.
187192
/// </summary>
188193
public bool IgnoreReadOnlyCollections { get; set; }
189194

src/NexusMods.Library/LibraryService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public async Task RemoveLinkedItemsFromAllLoadouts(IEnumerable<LibraryItem.ReadO
130130
RemoveLinkedItemsFromAllLoadouts(libraryItems, tx);
131131
await tx.Commit();
132132
}
133-
public async ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemInAllLoadouts(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem, ReplaceLibraryItemOptions options, ITransaction tx)
133+
public async ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemsInAllLoadouts(LibraryItem.ReadOnly oldItem, LibraryItem.ReadOnly newItem, ReplaceLibraryItemOptions options, ITransaction tx)
134134
{
135135
try
136136
{
@@ -172,7 +172,7 @@ public async ValueTask<LibraryItemReplacementResult> ReplaceLinkedItemsInAllLoad
172172
{
173173
foreach (var (oldItem, newItem) in replacementsArr)
174174
{
175-
var result = await ReplaceLinkedItemInAllLoadouts(oldItem, newItem, options.ToReplaceLibraryItemOptions(), tx);
175+
var result = await ReplaceLinkedItemsInAllLoadouts(oldItem, newItem, options.ToReplaceLibraryItemOptions(), tx);
176176
if (result != LibraryItemReplacementResult.Success)
177177
return result; // failed due to some reason.
178178
}

0 commit comments

Comments
 (0)