Skip to content

Commit

Permalink
Merge pull request #194 from AlamoEngine-Tools/develop
Browse files Browse the repository at this point in the history
Update deps and nullability contract
  • Loading branch information
AnakinRaW authored Oct 8, 2024
2 parents 51f6361 + 8ff4dc6 commit c47e114
Show file tree
Hide file tree
Showing 29 changed files with 208 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<PrivateAssets>all</PrivateAssets>
<Version>3.6.133</Version>
<Version>3.6.143</Version>
</PackageReference>
<PackageReference Include="SauceControl.InheritDoc" Version="2.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
Expand Down
10 changes: 5 additions & 5 deletions src/EawModinfo.Tests/EawModinfo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.2" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.0.2" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.29" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.0.29" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
35 changes: 16 additions & 19 deletions src/EawModinfo.Tests/MergeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ public void Test_MergeInto()
var mainData = new ModinfoData("Mod")
{
Icon = "icon.ico",
Languages = new[] {new LanguageInfo { Code = "en"}},
Dependencies = new DependencyList(new IModReference[] { new ModReference { Identifier = "bla" } }, DependencyResolveLayout.FullResolved),
Languages = [new LanguageInfo { Code = "en"}],
Dependencies = new DependencyList([new ModReference { Identifier = "bla" }], DependencyResolveLayout.FullResolved),
Custom = new Dictionary<string, object> { { "testKey1", "value" } }
};

var variantData = new ModinfoData("Variant of Mod")
{
Languages = new[] {new LanguageInfo { Code = "en"}, new LanguageInfo { Code = "de"}},
SteamData = new JsonSteamData {Id = "123", Tags = new[] {"FOC"}, ContentFolder = "bla", Title = "Title"},
Languages = [new LanguageInfo { Code = "en"}, new LanguageInfo { Code = "de"}],
SteamData = new JsonSteamData {Id = "123", Tags = ["FOC"], ContentFolder = "bla", Title = "Title"},
Custom = new Dictionary<string, object> { { "testKey2", "value" } },
Dependencies = new DependencyList(new IModReference[]
{
Dependencies = new DependencyList([
new ModReference {Identifier = "bla"}, new ModReference {Identifier = "blub"}
}, DependencyResolveLayout.FullResolved),
], DependencyResolveLayout.FullResolved),

Version = SemVersion.Parse("1.2.2", SemVersionStyles.Any)
};
Expand Down Expand Up @@ -64,20 +63,18 @@ public bool Equals(IModIdentity? other)
return false;
}

public string Name { get; } = null!;
public string Name => null!;

public SemVersion? Version { get; } = null!;
public SemVersion? Version => null!;

public IModDependencyList Dependencies { get; } = null!;
public string ToJson(bool validate)
{
return string.Empty;
}
public IModDependencyList Dependencies => null!;

public string ToJson(bool validate) => string.Empty;

public string? Summary { get; } = null!;
public string? Icon { get; } = null!;
public IDictionary<string, object> Custom { get; } = null!;
public ISteamData? SteamData { get; } = null!;
public IEnumerable<ILanguageInfo> Languages { get; } = null!;
public string? Summary => null!;
public string? Icon => null!;
public IDictionary<string, object> Custom => null!;
public ISteamData? SteamData => null!;
public IEnumerable<ILanguageInfo> Languages => null!;
}
}
10 changes: 5 additions & 5 deletions src/EawModinfo.Tests/ModIdentityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public void Test_Equal()

Assert.Equal(d1, d2);

IModIdentity i6 = new ModinfoData("A") { Dependencies = new DependencyList(new IModReference[] { d1, d3 }, DependencyResolveLayout.FullResolved) };
IModIdentity i7 = new ModIdentity("A") { Dependencies = new DependencyList(new IModReference[] { d2, d3 }, DependencyResolveLayout.FullResolved) };
IModIdentity i8 = new ModIdentity("A") { Dependencies = new DependencyList(new IModReference[] { d2 }, DependencyResolveLayout.FullResolved) };
IModIdentity i9 = new ModIdentity("A") { Dependencies = new DependencyList(new IModReference[] { d3, d1 }, DependencyResolveLayout.FullResolved) };
IModIdentity i10 = new ModinfoData("A") { Dependencies = new DependencyList(new IModReference[] { d1 }, DependencyResolveLayout.FullResolved) };
IModIdentity i6 = new ModinfoData("A") { Dependencies = new DependencyList([d1, d3], DependencyResolveLayout.FullResolved) };
IModIdentity i7 = new ModIdentity("A") { Dependencies = new DependencyList([d2, d3], DependencyResolveLayout.FullResolved) };
IModIdentity i8 = new ModIdentity("A") { Dependencies = new DependencyList([d2], DependencyResolveLayout.FullResolved) };
IModIdentity i9 = new ModIdentity("A") { Dependencies = new DependencyList([d3, d1], DependencyResolveLayout.FullResolved) };
IModIdentity i10 = new ModinfoData("A") { Dependencies = new DependencyList([d1], DependencyResolveLayout.FullResolved) };

Assert.Equal(i6, i7);
Assert.NotEqual(i6, i8);
Expand Down
10 changes: 5 additions & 5 deletions src/EawModinfo.Tests/ModInfoFinderCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Test_Enumerate_OnlyVariants()

var variant = new ModinfoVariantFile(ModinfoDataUtils.CreateVariantMainFile(fs, "mods/A"));
var collection = new ModinfoFinderCollection(
fs.DirectoryInfo.New("mods/A"), new[] { variant });
fs.DirectoryInfo.New("mods/A"), [variant]);
Assert.Single(collection);
Assert.Single(collection.Variants);
Assert.Null(collection.MainModinfo);
Expand All @@ -42,7 +42,7 @@ public void Test_Enumerate_MainPlusSingleVariants()
var variant = new ModinfoVariantFile(ModinfoDataUtils.CreateVariantMainFile(fs, "mods/A"));
var mainFile = new MainModinfoFile(ModinfoDataUtils.CreateModifnoFile(fs, "mods/A"));
var collection = new ModinfoFinderCollection(
fs.DirectoryInfo.New("mods/A"), mainFile, new[] { variant });
fs.DirectoryInfo.New("mods/A"), mainFile, [variant]);
Assert.Equal(2, collection.Count());
Assert.Single(collection.Variants);
Assert.NotNull(collection.MainModinfo);
Expand All @@ -58,7 +58,7 @@ public void Test_Enumerate_MainPlusMultipleVariants()
var mainFile = new MainModinfoFile(ModinfoDataUtils.CreateModifnoFile(fs, "mods/A"));
var variantM = new ModinfoVariantFile(variantFileInfo, mainFile);
var collection = new ModinfoFinderCollection(
fs.DirectoryInfo.New("mods/A"), mainFile, new[] { variant, variantM });
fs.DirectoryInfo.New("mods/A"), mainFile, [variant, variantM]);
Assert.Equal(3, collection.Count());
Assert.Equal(2, collection.Variants.Count);
Assert.NotNull(collection.MainModinfo);
Expand All @@ -81,7 +81,7 @@ public void Test_Ctor_MainAsVariant_ThrowsModinfoException()
var fs = new MockFileSystem(new Dictionary<string, MockFileData>());
var mainFile = new MainModinfoFile(ModinfoDataUtils.CreateModifnoFile(fs, "mods/A"));
Assert.Throws<ModinfoException>(() => new ModinfoFinderCollection(
fs.DirectoryInfo.New("mods/A"), new[] { mainFile }));
fs.DirectoryInfo.New("mods/A"), [mainFile]));
}

[Fact]
Expand All @@ -93,7 +93,7 @@ public void Test_Ctor_MainAsVariant_ThrowsModinfoException2()
var mainFile = new MainModinfoFile(ModinfoDataUtils.CreateModifnoFile(fs, "mods/A"));

Assert.Throws<ModinfoException>(() => new ModinfoFinderCollection(
fs.DirectoryInfo.New("mods/A"), new IModinfoFile[] {variant, mainFile}));
fs.DirectoryInfo.New("mods/A"), [variant, mainFile]));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/EawModinfo.Tests/ModinfoFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task Test_GetModinfo_VariantFile3()
var main = new ModinfoData("Main")
{
Version = new SemVersion(1, 1, 1),
Dependencies = new DependencyList(new IModReference[] { new ModReference { Identifier = "123", Type = ModType.Workshops } }, DependencyResolveLayout.FullResolved)
Dependencies = new DependencyList([new ModReference { Identifier = "123", Type = ModType.Workshops }], DependencyResolveLayout.FullResolved)
};

var file = ModinfoDataUtils.CreateVariantFile(new MockFileSystem(), "mods/A");
Expand Down
32 changes: 16 additions & 16 deletions src/EawModinfo.Tests/ModinfoValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public static IEnumerable<object[]> GetModinfo()
[
new ModinfoData("ModName")
{
Languages = new[]
{
Languages =
[
(ILanguageInfo) GetLanguageInfos().ElementAt(0)[0],
(ILanguageInfo) GetLanguageInfos().ElementAt(1)[0]
}
]
}
];
yield return
Expand Down Expand Up @@ -64,14 +64,14 @@ public static IEnumerable<object[]> GetInvalidModinfo()
[
new ModinfoData("ModName")
{
Languages = new []{ (ILanguageInfo) GetInvalidLanguageInfos().ElementAt(0)[0]}
Languages = [(ILanguageInfo) GetInvalidLanguageInfos().ElementAt(0)[0]]
}
];
yield return
[
new ModinfoData("ModName")
{
Dependencies = new DependencyList(new []{ (IModReference) GetInvalidModReferences().ElementAt(0)[0]}, DependencyResolveLayout.FullResolved)
Dependencies = new DependencyList([(IModReference) GetInvalidModReferences().ElementAt(0)[0]], DependencyResolveLayout.FullResolved)
}
];
}
Expand All @@ -97,7 +97,7 @@ public static IEnumerable<object[]> GetSteamData()
[
new JsonSteamData
{
Id = "1234312", Tags = new[] {"EAW"}, Metadata = "bla", ContentFolder = "testFolder",
Id = "1234312", Tags = ["EAW"], Metadata = "bla", ContentFolder = "testFolder",
Visibility = SteamWorkshopVisibility.FriendsOnly, Title = "MyTitle"
},
false
Expand All @@ -106,21 +106,21 @@ public static IEnumerable<object[]> GetSteamData()
[
new JsonSteamData
{
Id = "1234312", Tags = new[] {"EAW"}, Metadata = "bla", ContentFolder = "testFolder",
Id = "1234312", Tags = ["EAW"], Metadata = "bla", ContentFolder = "testFolder",
Title = "MyTitle"
},
false
];
yield return
[
new JsonSteamData {Id = "1234312", Tags = new[] {"EAW"}, ContentFolder = "testFolder", Title = "MyTitle"},
new JsonSteamData {Id = "1234312", Tags = ["EAW"], ContentFolder = "testFolder", Title = "MyTitle"},
false
];
yield return
[
new JsonSteamData
{
Id = "1234312", Tags = new[] {"EAW"}, ContentFolder = "testFolder",
Id = "1234312", Tags = ["EAW"], ContentFolder = "testFolder",
Description = "Some description", Title = "MyTitle"
},
false
Expand All @@ -130,19 +130,19 @@ public static IEnumerable<object[]> GetSteamData()
public static IEnumerable<object[]> GetInvalidSteamData()
{
yield return [new JsonSteamData(), true];
yield return [new JsonSteamData {Id = "asd", Tags = new[] {"EAW"}, ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData {Id = "0", Tags = new[] {"EAW"}, ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData {Id = "-123", Tags = new[] {"EAW"}, ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData {Id = "asd", Tags = ["EAW"], ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData {Id = "0", Tags = ["EAW"], ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData {Id = "-123", Tags = ["EAW"], ContentFolder = "testFolder"}, true];
yield return
[
new JsonSteamData {Id = "129381209812430981329048", Tags = new[] {"EAW"}, ContentFolder = "testFolder"},
new JsonSteamData {Id = "129381209812430981329048", Tags = ["EAW"], ContentFolder = "testFolder"},
true
];
yield return [new JsonSteamData {Id = "1234", Tags = Array.Empty<string>(), ContentFolder = "testFolder"}, true];
yield return [new JsonSteamData { Id = "1234", Tags = null!, ContentFolder = "testFolder" }, true];
yield return [new JsonSteamData { Id = "1234", Tags = new[] { "EAW" }, ContentFolder = "" }, true];
yield return [new JsonSteamData { Id = "1234", Tags = new[] { "EAW" }, ContentFolder = null! }, true];
yield return [new JsonSteamData { Id = "1234312", Tags = new[] { "test" }, Metadata = "bla", ContentFolder = "testFolder" }, true
yield return [new JsonSteamData { Id = "1234", Tags = ["EAW"], ContentFolder = "" }, true];
yield return [new JsonSteamData { Id = "1234", Tags = ["EAW"], ContentFolder = null! }, true];
yield return [new JsonSteamData { Id = "1234312", Tags = ["test"], Metadata = "bla", ContentFolder = "testFolder" }, true
];
}

Expand Down
6 changes: 3 additions & 3 deletions src/EawModinfo.Tests/SteamDataWriteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void Test_ToJson()
{
ContentFolder = "Test",
Id = "123",
Tags = new[] {"FOC"},
Tags = ["FOC"],
Title = "Title",
Visibility = SteamWorkshopVisibility.Private,
};
Expand All @@ -30,7 +30,7 @@ public static void Test_ToJson()
{
ContentFolder = "Test",
Id = "123",
Tags = new[] {"FOC"},
Tags = ["FOC"],
Visibility = SteamWorkshopVisibility.Private,
Title = "Title",
Metadata = "test"
Expand All @@ -49,7 +49,7 @@ public static void Test_ToJson_DefaultData()
{
ContentFolder = "Test Folder",
Id = "123",
Tags = new[] { "FOC", "SinglePlayer" },
Tags = ["FOC", "SinglePlayer"],
Title = "Title",
Metadata = "some metadata",
Visibility = SteamWorkshopVisibility.Public,
Expand Down
8 changes: 1 addition & 7 deletions src/EawModinfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using System.Runtime.CompilerServices;

//#if DEBUG
[assembly: InternalsVisibleTo("EawModinfo.Tests")]
//#else
//[assembly: InternalsVisibleTo("EawModinfo.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001006de98c7e7aaf09d58dcf9b795560d595ba312cc6ada08c10848ff118d8eec62f6175188c7b1a1d3522d2dcaab98888b69a3fe5d0aaff15a2723db78917a7b159749b1a8a8cb8b3294fe6e828277f5209f40979dbdc71cf1c7501bfb1efadec93153731cbff315c4ce7e33e8eb0ef7b36eebc25900fd9c4c7fe5e4c3ffe54e6ca")]
//#endif


[assembly: InternalsVisibleTo("EawModinfo.Tests")]
6 changes: 3 additions & 3 deletions src/EawModinfo/EawModinfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JsonSchema.Net" Version="7.0.2" />
<PackageReference Include="JsonSchema.Net" Version="7.2.3" />
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Semver" Version="2.3.0" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.2" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.29" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand Down
6 changes: 3 additions & 3 deletions src/EawModinfo/File/ModinfoFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ private IModinfo Parse()
return ModinfoData.Parse(text);
}

private Task<string> ReadTextAsync()
private async Task<string> ReadTextAsync()
{
var fs = File.FileSystem;

#if NETSTANDARD2_1
return fs.File.ReadAllTextAsync(File.FullName);
return await fs.File.ReadAllTextAsync(File.FullName);
#else
using var reader = fs.File.OpenText(File.FullName);
return reader.ReadToEndAsync();
return await reader.ReadToEndAsync();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/EawModinfo/Model/Json/JsonLanguageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public JsonLanguageInfo(string code, LanguageSupportLevel support)
/// <summary>
/// Creates a new instance from a given <see cref="ILanguageInfo"/> instance.
/// </summary>
/// <param name="languageInfo">The instance that will copied.</param>
/// <param name="languageInfo">The instance that will be copied.</param>
public JsonLanguageInfo(ILanguageInfo languageInfo)
{
if (languageInfo == null)
Expand Down
Loading

0 comments on commit c47e114

Please sign in to comment.