Skip to content

Commit 5707cc5

Browse files
authored
Maintenance changes/updates (#345)
I got tired of seeing complaints that we're using nuget packages that have vulnerabilities (transitively via xUnit), and then decided to fix some (a lot of?) other suggestion-level noise that keeps popping up in VS. I've done some development based on this, but the only things I was concerned enough about to explicitly check were the xUnit upgrade and the Shevron->Chevron rename.
2 parents 31c9906 + a5b6317 commit 5707cc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+285
-273
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,5 @@ dotnet_diagnostic.IDE0052.severity = none
164164

165165
# Disable "IDE0130: Namespace does not match folder structure" because VS Code Cleanup applies it automatically and breaks things.
166166
dotnet_style_namespace_match_folder = false
167+
168+
spelling_exclusion_path = exclusion.dic

FactorioCalc.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1919
ProjectSection(SolutionItems) = preProject
2020
changelog.txt = changelog.txt
2121
Directory.Build.props = Directory.Build.props
22+
exclusion.dic = exclusion.dic
2223
EndProjectSection
2324
EndProject
2425
Global

Yafc.Model.Tests/Data/DataUtils.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
namespace Yafc.Model.Data.Tests;
55

66
public class DataUtilsTests {
7-
public DataUtilsTests() {
8-
Project.current = new();
9-
}
7+
public DataUtilsTests() => Project.current = new();
108

119
[Fact]
1210
public void TryParseAmount_IsInverseOfFormatValue() {
@@ -49,7 +47,7 @@ public void TryParseAmount_IsInverseOfFormatValue() {
4947
[Fact]
5048
public void TryParseAmount_IsInverseOfFormatValue_WithBeltsAndPipes() {
5149
// Hammer the formatter and parser with lots of random but repeatable values, making sure TryParseAmount can correctly read anything FormatAmount generates.
52-
// This time, include b and p suffixes. These suffixes noticably reduce precision, so do them separately.
50+
// This time, include b and p suffixes. These suffixes noticeably reduce precision, so do them separately.
5351
Random r = new Random(0);
5452
byte[] bytes = new byte[4];
5553
for (int i = 0; i < 1000; i++) {

Yafc.Model.Tests/Data/LocalisedStringParserTests.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,61 @@
44
namespace Yafc.Model.Data.Tests;
55

66
public class LocalisedStringParserTests {
7-
public LocalisedStringParserTests() {
8-
FactorioLocalization.Initialize(new System.Collections.Generic.Dictionary<string, string>() {
9-
["hours"] = "__1__ __plural_for_parameter__1__{1=hour|rest=hours}__",
10-
["si-unit-kilometer-per-hour"] = "__1__ km/h",
11-
["not-enough-ingredients"] = "Not enough ingredients.",
12-
["item-name.iron-plate"] = "Iron plate",
13-
["item-name.big-iron-plate"] = "Big __ITEM__iron-plate__",
14-
["connecting"] = "__plural_for_parameter__1__{1=__1__ player is|rest=__1__ players are}__ connecting",
15-
["ends.in"] = "__plural_for_parameter__1__{ends in 12=option 1|ends in 2=option 2|rest=option 3}__"
16-
});
17-
}
7+
public LocalisedStringParserTests() => FactorioLocalization.Initialize(new System.Collections.Generic.Dictionary<string, string>() {
8+
["hours"] = "__1__ __plural_for_parameter__1__{1=hour|rest=hours}__",
9+
["si-unit-kilometer-per-hour"] = "__1__ km/h",
10+
["not-enough-ingredients"] = "Not enough ingredients.",
11+
["item-name.iron-plate"] = "Iron plate",
12+
["item-name.big-iron-plate"] = "Big __ITEM__iron-plate__",
13+
["connecting"] = "__plural_for_parameter__1__{1=__1__ player is|rest=__1__ players are}__ connecting",
14+
["ends.in"] = "__plural_for_parameter__1__{ends in 12=option 1|ends in 2=option 2|rest=option 3}__"
15+
});
1816

1917
[Fact]
2018
public void Parse_JustString() {
21-
var localised = LocalisedStringParser.Parse("test");
19+
string localised = LocalisedStringParser.Parse("test");
2220
Assert.Equal("test", localised);
2321
}
2422

2523
[Fact]
2624
public void Parse_RemoveRichText() {
27-
var localised = LocalisedStringParser.Parse("[color=#ffffff]iron[/color] [color=1,0,0]plate[.color] [item=iron-plate]");
25+
string localised = LocalisedStringParser.Parse("[color=#ffffff]iron[/color] [color=1,0,0]plate[.color] [item=iron-plate]");
2826
Assert.Equal("iron plate ", localised);
2927
}
3028

3129
[Fact]
3230
public void Parse_NoParameters() {
33-
var localised = LocalisedStringParser.Parse("not-enough-ingredients", []);
31+
string localised = LocalisedStringParser.Parse("not-enough-ingredients", []);
3432
Assert.Equal("Not enough ingredients.", localised);
3533
}
3634

3735
[Fact]
3836
public void Parse_Parameter() {
39-
var localised = LocalisedStringParser.Parse("si-unit-kilometer-per-hour", ["100"]);
37+
string localised = LocalisedStringParser.Parse("si-unit-kilometer-per-hour", ["100"]);
4038
Assert.Equal("100 km/h", localised);
4139
}
4240

4341
[Fact]
4442
public void Parse_LinkItem() {
45-
var localised = LocalisedStringParser.Parse("item-name.big-iron-plate", []);
43+
string localised = LocalisedStringParser.Parse("item-name.big-iron-plate", []);
4644
Assert.Equal("Big Iron plate", localised);
4745
}
4846

4947
[Fact]
5048
public void Parse_PluralSpecial() {
51-
var localised = LocalisedStringParser.Parse("hours", ["1"]);
49+
string localised = LocalisedStringParser.Parse("hours", ["1"]);
5250
Assert.Equal("1 hour", localised);
5351
}
5452

5553
[Fact]
5654
public void Parse_PluralRest() {
57-
var localised = LocalisedStringParser.Parse("hours", ["2"]);
55+
string localised = LocalisedStringParser.Parse("hours", ["2"]);
5856
Assert.Equal("2 hours", localised);
5957
}
6058

6159
[Fact]
6260
public void Parse_PluralWithParameter() {
63-
var localised = LocalisedStringParser.Parse("connecting", ["1"]);
61+
string localised = LocalisedStringParser.Parse("connecting", ["1"]);
6462
Assert.Equal("1 player is connecting", localised);
6563
}
6664

@@ -69,7 +67,7 @@ public void Parse_PluralWithParameter() {
6967
[InlineData(22, "option 2")]
7068
[InlineData(5, "option 3")]
7169
public void Parse_PluralEndsIn(int n, string expectedResult) {
72-
var localised = LocalisedStringParser.Parse("ends.in", [n.ToString()]);
70+
string localised = LocalisedStringParser.Parse("ends.in", [n.ToString()]);
7371
Assert.Equal(expectedResult, localised);
7472
}
7573
}

Yafc.Model.Tests/LuaDependentTestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static LuaDependentTestHelper() {
3333
/// Do not use <c>require</c> in the embedded files.</remarks>
3434
/// <param name="targetStreamName">The name of the embedded resource to load, if the default name selection does not work for you.</param>
3535
internal static Project GetProjectForLua(string targetStreamName = null) {
36-
// Verify correct non-parallel declaration for tests, to accomodate the singleton analyses.
36+
// Verify correct non-parallel declaration for tests, to accommodate the singleton analyses.
3737
StackTrace stack = new();
3838

3939
for (int i = 1; i < stack.FrameCount; i++) {

Yafc.Model.Tests/Model/ProductionTableContentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void testCombinations(RecipeRow row, ProductionTable table, Action assert) {
7979
for (int beaconCount = 0; beaconCount < 13; beaconCount++) {
8080
for (float payback = 1; payback < float.MaxValue; payback *= 16) {
8181
if (table.GetType().GetProperty("modules").SetMethod is MethodInfo method) {
82-
// Pre-emptive code for if ProductionTable.modules is made writable.
82+
// Preemptive code for if ProductionTable.modules is made writable.
8383
// The ProductionTable.modules setter must notify all relevant recipes if it is added.
8484
_ = method.Invoke(table, [new ModuleFillerParameters(table) {
8585
beacon = new(beacon, Quality.Normal),
@@ -103,7 +103,7 @@ void testCombinations(RecipeRow row, ProductionTable table, Action assert) {
103103
}
104104

105105
/// <summary>
106-
/// Run the preceeding tests for fixed buildings, fuel, ingredients, and products.
106+
/// Run the preceding tests for fixed buildings, fuel, ingredients, and products.
107107
/// </summary>
108108
/// <param name="row">The row containing the recipe to test with fixed amounts.</param>
109109
/// <param name="testCombinations">An action that loops through the various combinations of entities, beacons, etc, and calls its third parameter for each combination.</param>

Yafc.Model.Tests/Model/RecipeParametersTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using System.Threading.Tasks;
34
using Xunit;
45

56
namespace Yafc.Model.Tests.Model;
67

78
[Collection("LuaDependentTests")]
89
public class RecipeParametersTests {
910
[Fact]
10-
public void FluidBoilingRecipes_HaveCorrectConsumption() {
11+
public async Task FluidBoilingRecipes_HaveCorrectConsumption() {
1112
Project project = LuaDependentTestHelper.GetProjectForLua();
1213

1314
ProjectPage page = new(project, typeof(ProductionTable));
@@ -22,7 +23,7 @@ public void FluidBoilingRecipes_HaveCorrectConsumption() {
2223
RecipeRow heatExchanger = table.recipes[1];
2324
boiler.fixedBuildings = 1;
2425
heatExchanger.fixedBuildings = 1;
25-
table.Solve((ProjectPage)table.owner).Wait(); // Initial Solve to set RecipeRow.Ingredients
26+
await table.Solve((ProjectPage)table.owner); // Initial Solve to set RecipeRow.Ingredients
2627

2728
for (int i = 0; i < 3; i++) {
2829
if (i != 0) {
@@ -32,7 +33,7 @@ public void FluidBoilingRecipes_HaveCorrectConsumption() {
3233
boiler.ChangeVariant(boiler.Ingredients.Single().Goods, water[i]);
3334
heatExchanger.ChangeVariant(boiler.Ingredients.Single().Goods, water[i]);
3435

35-
table.Solve((ProjectPage)table.owner).Wait();
36+
await table.Solve((ProjectPage)table.owner);
3637

3738
// boil 60, 78.26, 120 water per second from 15, 50, 90° to 165°
3839
float expectedBoilerAmount = 1800 / .2f / (165 - water[i].temperature);

Yafc.Model.Tests/Model/SelectableVariantsTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System.Linq;
2+
using System.Threading.Tasks;
23
using Xunit;
34

45
namespace Yafc.Model.Tests.Model;
56

67
[Collection("LuaDependentTests")]
78
public class SelectableVariantsTests {
89
[Fact]
9-
public void CanSelectVariantFuel_VariantFuelChanges() {
10+
public async Task CanSelectVariantFuel_VariantFuelChanges() {
1011
Project project = LuaDependentTestHelper.GetProjectForLua();
1112

1213
ProjectPage page = new ProjectPage(project, typeof(ProductionTable));
@@ -15,16 +16,16 @@ public void CanSelectVariantFuel_VariantFuelChanges() {
1516
RecipeRow row = table.GetAllRecipes().Single();
1617

1718
// Solve is not necessary in this test, but I'm calling it in case we decide to hide the fuel on disabled recipes.
18-
table.Solve((ProjectPage)table.owner).Wait();
19+
await table.Solve((ProjectPage)table.owner);
1920
Assert.Equal("steam@165", row.FuelInformation.Goods.name);
2021

2122
row.fuel = row.FuelInformation.Variants[1];
22-
table.Solve((ProjectPage)table.owner).Wait();
23+
await table.Solve((ProjectPage)table.owner);
2324
Assert.Equal("steam@500", row.FuelInformation.Goods.name);
2425
}
2526

2627
[Fact]
27-
public void CanSelectVariantFuelWithFavorites_VariantFuelChanges() {
28+
public async Task CanSelectVariantFuelWithFavorites_VariantFuelChanges() {
2829
Project project = LuaDependentTestHelper.GetProjectForLua();
2930
project.preferences.ToggleFavorite(Database.fluids.all.Single(c => c.name == "steam@500"));
3031

@@ -34,16 +35,16 @@ public void CanSelectVariantFuelWithFavorites_VariantFuelChanges() {
3435
RecipeRow row = table.GetAllRecipes().Single();
3536

3637
// Solve is not necessary in this test, but I'm calling it in case we decide to hide the fuel on disabled recipes.
37-
table.Solve((ProjectPage)table.owner).Wait();
38+
await table.Solve((ProjectPage)table.owner);
3839
Assert.Equal("steam@500", row.FuelInformation.Goods.name);
3940

4041
row.fuel = row.FuelInformation.Variants[0];
41-
table.Solve((ProjectPage)table.owner).Wait();
42+
await table.Solve((ProjectPage)table.owner);
4243
Assert.Equal("steam@165", row.FuelInformation.Goods.name);
4344
}
4445

4546
[Fact]
46-
public void CanSelectVariantIngredient_VariantIngredientChanges() {
47+
public async Task CanSelectVariantIngredient_VariantIngredientChanges() {
4748
Project project = LuaDependentTestHelper.GetProjectForLua();
4849

4950
ProjectPage page = new ProjectPage(project, typeof(ProductionTable));
@@ -52,11 +53,11 @@ public void CanSelectVariantIngredient_VariantIngredientChanges() {
5253
RecipeRow row = table.GetAllRecipes().Single();
5354

5455
// Solve is necessary here: Disabled recipes have null ingredients (and products), and Solve is the call that updates hierarchyEnabled.
55-
table.Solve((ProjectPage)table.owner).Wait();
56+
await table.Solve((ProjectPage)table.owner);
5657
Assert.Equal("steam@165", row.Ingredients.Single().Goods.name);
5758

5859
row.ChangeVariant(row.Ingredients.Single().Goods, row.Ingredients.Single().Variants[1]);
59-
table.Solve((ProjectPage)table.owner).Wait();
60+
await table.Solve((ProjectPage)table.owner);
6061
Assert.Equal("steam@500", row.Ingredients.Single().Goods.name);
6162
}
6263

Yafc.Model.Tests/PrepareForTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
namespace Yafc.Model.Tests;
1111
public class PrepareForTests : XunitTestFramework {
1212
public PrepareForTests(IMessageSink messageSink)
13-
: base(messageSink) {
14-
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
15-
}
13+
: base(messageSink) => Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
1614
}

Yafc.Model.Tests/Yafc.Model.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
9-
<PackageReference Include="xunit" Version="2.4.2" />
10-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
9+
<PackageReference Include="xunit" Version="2.9.2" />
10+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
<PrivateAssets>all</PrivateAssets>
1313
</PackageReference>

0 commit comments

Comments
 (0)