Skip to content

Commit

Permalink
Made Before<,>.Other a required property (#764)
Browse files Browse the repository at this point in the history
* Made Before<,>.Other a required property

* Adapted code to the change
  • Loading branch information
Aragas authored Nov 10, 2023
1 parent bec16f5 commit f699d8e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private IEnumerable<ISortRule<RuleTuple, RelativePath>> GenerateRules(PluginAnal
foreach (var itm in allPlugins)
{
if (DefaultOrdering.Contains(itm.FileName)) continue;
yield return new Before<RuleTuple, RelativePath>(itm.FileName);
yield return new Before<RuleTuple, RelativePath> { Other = itm.FileName };
}

break;
Expand Down
5 changes: 4 additions & 1 deletion src/NexusMods.DataModel/Sorting/Rules/Before.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ namespace NexusMods.DataModel.Sorting.Rules;

/// <summary />
[JsonName("Before")]
public record Before<TType, TId>(TId Other) : ISortRule<TType, TId>;
public record Before<TType, TId>: ISortRule<TType, TId>
{
public required TId Other { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async IAsyncEnumerable<ISortRule<Mod, ModId>> GenerateSortRules(ModId sel
if (modId.Equals(selfId)) continue;
if (string.Compare(other.Name, thisMod.Name, StringComparison.Ordinal) > 0)
{
yield return new Before<Mod, ModId>(other.Id);
yield return new Before<Mod, ModId> { Other = other.Id };
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion tests/NexusMods.DataModel.Tests/SortTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void BeforeAndAfterWorks()
new Item {Id = "B", Rules = new()},
new Item {Id = "A", Rules = new()
{
new Before<Item, string>("B")
new Before<Item, string> { Other = "B" }
}},
new Item {Id = "C", Rules = new()
{
Expand Down

0 comments on commit f699d8e

Please sign in to comment.