Skip to content

Commit 3d936f1

Browse files
authored
Merge pull request #1007 from erri120/feat/915-stardew-valley-diagnostics
Rework Stardew Valley diagnostics
2 parents 9f8e770 + 092796c commit 3d936f1

33 files changed

+350
-550
lines changed

.github/workflows/git-builds.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v3
24+
with:
25+
submodules: "recursive"
2426

2527
- name: Info
2628
run: dotnet --info

.github/workflows/mod_install_tests.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232

3333
steps:
3434
- uses: actions/checkout@v3
35+
with:
36+
submodules: "recursive"
3537

3638
- name: Setup .NET Core SDK 7.0.x
3739
uses: actions/setup-dotnet@v3

.github/workflows/networking_tests.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626

2727
steps:
2828
- uses: actions/checkout@v3
29+
with:
30+
submodules: "recursive"
2931

3032
- name: Setup .NET Core SDK 7.0.x
3133
uses: actions/setup-dotnet@v3

.github/workflows/validate-nupkgs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v3
24+
with:
25+
submodules: "recursive"
2426

2527
- name: Setup .NET SDK
2628
uses: actions/setup-dotnet@v3

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[submodule "docs/Nexus"]
22
path = docs/Nexus
33
url = https://github.com/Nexus-Mods/NexusMods.MkDocsMaterial.Themes.Next.git
4+
[submodule "extern/SMAPI"]
5+
path = extern/SMAPI
6+
url = https://github.com/Pathoschild/SMAPI.git
7+
branch = stable

NexusMods.App.sln

+7
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.App.Generators.Di
211211
EndProject
212212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.App.Generators.Diagnostics.Tests", "tests\NexusMods.App.Generators.Diagnostics.Tests\NexusMods.App.Generators.Diagnostics.Tests.csproj", "{D497C3DF-C84C-460A-88B9-DD3D129387CC}"
213213
EndProject
214+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.Games.StardewValley.SMAPI", "src\Games\NexusMods.Games.StardewValley.SMAPI\NexusMods.Games.StardewValley.SMAPI.csproj", "{674E8B0A-8F77-4DDE-BFCD-618F030DE01B}"
215+
EndProject
214216
Global
215217
GlobalSection(SolutionConfigurationPlatforms) = preSolution
216218
Debug|Any CPU = Debug|Any CPU
@@ -545,6 +547,10 @@ Global
545547
{D497C3DF-C84C-460A-88B9-DD3D129387CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
546548
{D497C3DF-C84C-460A-88B9-DD3D129387CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
547549
{D497C3DF-C84C-460A-88B9-DD3D129387CC}.Release|Any CPU.Build.0 = Release|Any CPU
550+
{674E8B0A-8F77-4DDE-BFCD-618F030DE01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
551+
{674E8B0A-8F77-4DDE-BFCD-618F030DE01B}.Debug|Any CPU.Build.0 = Debug|Any CPU
552+
{674E8B0A-8F77-4DDE-BFCD-618F030DE01B}.Release|Any CPU.ActiveCfg = Release|Any CPU
553+
{674E8B0A-8F77-4DDE-BFCD-618F030DE01B}.Release|Any CPU.Build.0 = Release|Any CPU
548554
EndGlobalSection
549555
GlobalSection(SolutionProperties) = preSolution
550556
HideSolutionNode = FALSE
@@ -641,6 +647,7 @@ Global
641647
{76F37CC8-994C-4A43-AB99-C1618FF83272} = {E7BAE287-D505-4D6D-A090-665A64309B2D}
642648
{6AE7F1F0-3E5A-42D9-BFF9-2B8F76410F4C} = {E7BAE287-D505-4D6D-A090-665A64309B2D}
643649
{D497C3DF-C84C-460A-88B9-DD3D129387CC} = {52AF9D62-7D5B-4AD0-BA12-86F2AA67428B}
650+
{674E8B0A-8F77-4DDE-BFCD-618F030DE01B} = {70D38D24-79AE-4600-8E83-17F3C11BA81F}
644651
EndGlobalSection
645652
GlobalSection(ExtensibilityGlobals) = postSolution
646653
SolutionGuid = {9F9F8352-34DD-42C0-8564-EE9AF34A3501}

extern/SMAPI

Submodule SMAPI added at 5919337

src/NexusMods.DataModel/Diagnostics/IDiagnosticManager.cs src/Abstractions/NexusMods.Abstractions.Games.Diagnostics/IDiagnosticManager.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using DynamicData;
22
using JetBrains.Annotations;
3-
using NexusMods.Abstractions.Diagnostics;
43
using NexusMods.Abstractions.Loadouts;
54

6-
namespace NexusMods.DataModel.Diagnostics;
5+
namespace NexusMods.Abstractions.Diagnostics;
76

87
/// <summary>
98
/// A diagnostic manager, which keeps track of all current diagnostics and refreshes them if necessary.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JetBrains.Annotations;
2+
using NexusMods.Abstractions.Loadouts.Mods;
3+
using NexusMods.Abstractions.Serialization;
4+
5+
namespace NexusMods.Abstractions.Loadouts.Extensions;
6+
7+
/// <summary>
8+
/// Extension methods for <see cref="AModFile"/>
9+
/// </summary>
10+
[PublicAPI]
11+
public static class AModFileExtensions
12+
{
13+
/// <summary>
14+
/// Checks whether any items in <see cref="AModFile.Metadata"/> are of type
15+
/// <typeparamref name="T"/>.
16+
/// </summary>
17+
public static bool HasMetadata<T>(this AModFile file) where T : IMetadata
18+
{
19+
return file.Metadata.Any(m => m is T);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<ItemGroup>
4+
<Compile Include="..\..\..\extern\SMAPI\src\SMAPI.Toolkit\**\*.cs">
5+
<Link>Toolkit\%(RecursiveDir)\%(FileName)%(Extension)</Link>
6+
<Visible>false</Visible>
7+
</Compile>
8+
9+
<Compile Include="..\..\..\extern\SMAPI\src\SMAPI.Toolkit.CoreInterfaces\**\*.cs">
10+
<Link>CoreInterfaces\%(RecursiveDir)\%(FileName)%(Extension)</Link>
11+
<Visible>false</Visible>
12+
</Compile>
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="HtmlAgilityPack" VersionOverride="1.11.52" />
17+
<PackageReference Include="Newtonsoft.Json" VersionOverride="13.0.3" />
18+
<PackageReference Include="Pathoschild.Http.FluentClient" VersionOverride="4.3.0" />
19+
</ItemGroup>
20+
21+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SMAPI Helper
2+
3+
None of the libraries in [Pathoschild/SMAPI](https://github.com/Pathoschild/SMAPI) except for the `ModBuildConfig` project are uploaded to NuGet. As such, the only way to use the code without much hassle is to include the source code as a submodule and have this wrapper project compile the files.

src/Games/NexusMods.Games.StardewValley/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace NexusMods.Games.StardewValley;
55

6-
public class Constants
6+
public static class Constants
77
{
88
public static readonly RelativePath ModsFolder = "Mods".ToRelativePath();
99
public static readonly RelativePath ManifestFile = "manifest.json".ToRelativePath();
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1+
using JetBrains.Annotations;
12
using NexusMods.Abstractions.Diagnostics;
23
using NexusMods.Abstractions.Diagnostics.References;
3-
using NexusMods.Abstractions.Loadouts;
4-
using NexusMods.Abstractions.Loadouts.Mods;
4+
using NexusMods.Generators.Diagnostics;
55

66
namespace NexusMods.Games.StardewValley;
77

8-
internal static class Diagnostics
8+
internal static partial class Diagnostics
99
{
10-
internal const string Source = "NexusMods.Games.StardewValley";
10+
private const string Source = "NexusMods.Games.StardewValley";
1111

12-
internal static Diagnostic MissingRequiredDependency(Loadout loadout, Mod mod, string missingDependency)
13-
{
14-
return new Diagnostic
15-
{
16-
Id = new DiagnosticId(Source, 1),
17-
Severity = DiagnosticSeverity.Warning,
18-
Summary = DiagnosticMessage.From($"Mod '{mod.Name}' is missing required dependency '{missingDependency}'"),
19-
Details = DiagnosticMessage.DefaultValue,
20-
DataReferences = new Dictionary<DataReferenceDescription, IDataReference>
21-
{
22-
{ DataReferenceDescription.Loadout, loadout.ToReference() },
23-
{ DataReferenceDescription.Mod, mod.ToReference(loadout) },
24-
},
25-
};
26-
}
12+
[DiagnosticTemplate]
13+
[UsedImplicitly]
14+
internal static IDiagnosticTemplate MissingRequiredDependencyTemplate = DiagnosticTemplateBuilder
15+
.Start()
16+
.WithId(new DiagnosticId(Source, number: 1))
17+
.WithSeverity(DiagnosticSeverity.Warning)
18+
.WithSummary("Mod {Mod} is missing required dependency {MissingDependency}")
19+
.WithoutDetails()
20+
.WithMessageData(messageBuilder => messageBuilder
21+
.AddDataReference<ModReference>("Mod")
22+
.AddValue<string>("MissingDependency")
23+
)
24+
.Finish();
25+
26+
[DiagnosticTemplate]
27+
[UsedImplicitly]
28+
internal static IDiagnosticTemplate OutdatedDependencyTemplate = DiagnosticTemplateBuilder
29+
.Start()
30+
.WithId(new DiagnosticId(Source, number: 2))
31+
.WithSeverity(DiagnosticSeverity.Warning)
32+
.WithSummary("Mod {Dependent} requires at least version {MinimumVersion} of {Dependency} but installed is {CurrentVersion}")
33+
.WithoutDetails()
34+
.WithMessageData(messageBuilder => messageBuilder
35+
.AddDataReference<ModReference>("Dependent")
36+
.AddDataReference<ModReference>("Dependency")
37+
.AddValue<string>("MinimumVersion")
38+
.AddValue<string>("CurrentVersion")
39+
)
40+
.Finish();
2741
}

src/Games/NexusMods.Games.StardewValley/Emitters/001_MissingDependencies.cs

-90
This file was deleted.

0 commit comments

Comments
 (0)