|
| 1 | +using JetBrains.Annotations; |
1 | 2 | using NexusMods.Abstractions.Diagnostics;
|
2 | 3 | using NexusMods.Abstractions.Diagnostics.References;
|
3 |
| -using NexusMods.Abstractions.Loadouts; |
4 |
| -using NexusMods.Abstractions.Loadouts.Mods; |
| 4 | +using NexusMods.Generators.Diagnostics; |
5 | 5 |
|
6 | 6 | namespace NexusMods.Games.StardewValley;
|
7 | 7 |
|
8 |
| -internal static class Diagnostics |
| 8 | +internal static partial class Diagnostics |
9 | 9 | {
|
10 |
| - internal const string Source = "NexusMods.Games.StardewValley"; |
| 10 | + private const string Source = "NexusMods.Games.StardewValley"; |
11 | 11 |
|
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(); |
27 | 41 | }
|
0 commit comments