fix all warnings to simplify migration to nullable annotations (#837)
This commit is contained in:
parent
2e7c233f6c
commit
b4e979cc99
|
@ -414,6 +414,7 @@ when you compile it.
|
||||||
## Release notes
|
## Release notes
|
||||||
## Upcoming release
|
## Upcoming release
|
||||||
* Added detection for Xbox app game folders.
|
* Added detection for Xbox app game folders.
|
||||||
|
* Internal refactoring.
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
Released 30 November 2021.
|
Released 30 November 2021.
|
||||||
|
|
|
@ -53,17 +53,17 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents)
|
protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents)
|
||||||
{
|
{
|
||||||
var projects = new HashSet<Project>();
|
var projects = new HashSet<Project>();
|
||||||
foreach (var document in documents)
|
foreach (Document document in documents)
|
||||||
{
|
{
|
||||||
projects.Add(document.Project);
|
projects.Add(document.Project);
|
||||||
}
|
}
|
||||||
|
|
||||||
var diagnostics = new List<Diagnostic>();
|
var diagnostics = new List<Diagnostic>();
|
||||||
foreach (var project in projects)
|
foreach (Project project in projects)
|
||||||
{
|
{
|
||||||
var compilationWithAnalyzers = project.GetCompilationAsync().Result.WithAnalyzers(ImmutableArray.Create(analyzer));
|
CompilationWithAnalyzers compilationWithAnalyzers = project.GetCompilationAsync().Result.WithAnalyzers(ImmutableArray.Create(analyzer));
|
||||||
var diags = compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().Result;
|
var diags = compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().Result;
|
||||||
foreach (var diag in diags)
|
foreach (Diagnostic diag in diags)
|
||||||
{
|
{
|
||||||
if (diag.Location == Location.None || diag.Location.IsInMetadata)
|
if (diag.Location == Location.None || diag.Location.IsInMetadata)
|
||||||
{
|
{
|
||||||
|
@ -73,8 +73,8 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
{
|
{
|
||||||
for (int i = 0; i < documents.Length; i++)
|
for (int i = 0; i < documents.Length; i++)
|
||||||
{
|
{
|
||||||
var document = documents[i];
|
Document document = documents[i];
|
||||||
var tree = document.GetSyntaxTreeAsync().Result;
|
SyntaxTree tree = document.GetSyntaxTreeAsync().Result;
|
||||||
if (tree == diag.Location.SourceTree)
|
if (tree == diag.Location.SourceTree)
|
||||||
{
|
{
|
||||||
diagnostics.Add(diag);
|
diagnostics.Add(diag);
|
||||||
|
@ -115,7 +115,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
throw new ArgumentException("Unsupported Language");
|
throw new ArgumentException("Unsupported Language");
|
||||||
}
|
}
|
||||||
|
|
||||||
var project = CreateProject(sources, language);
|
Project project = CreateProject(sources, language);
|
||||||
var documents = project.Documents.ToArray();
|
var documents = project.Documents.ToArray();
|
||||||
|
|
||||||
if (sources.Length != documents.Length)
|
if (sources.Length != documents.Length)
|
||||||
|
@ -148,9 +148,9 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
string fileNamePrefix = DefaultFilePathPrefix;
|
string fileNamePrefix = DefaultFilePathPrefix;
|
||||||
string fileExt = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt;
|
string fileExt = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt;
|
||||||
|
|
||||||
var projectId = ProjectId.CreateNewId(debugName: TestProjectName);
|
ProjectId projectId = ProjectId.CreateNewId(debugName: TestProjectName);
|
||||||
|
|
||||||
var solution = new AdhocWorkspace()
|
Solution solution = new AdhocWorkspace()
|
||||||
.CurrentSolution
|
.CurrentSolution
|
||||||
.AddProject(projectId, TestProjectName, TestProjectName, language)
|
.AddProject(projectId, TestProjectName, TestProjectName, language)
|
||||||
.AddMetadataReference(projectId, DiagnosticVerifier.SelfReference)
|
.AddMetadataReference(projectId, DiagnosticVerifier.SelfReference)
|
||||||
|
@ -160,10 +160,10 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
.AddMetadataReference(projectId, CodeAnalysisReference);
|
.AddMetadataReference(projectId, CodeAnalysisReference);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (var source in sources)
|
foreach (string source in sources)
|
||||||
{
|
{
|
||||||
var newFileName = fileNamePrefix + count + "." + fileExt;
|
string newFileName = fileNamePrefix + count + "." + fileExt;
|
||||||
var documentId = DocumentId.CreateNewId(projectId, debugName: newFileName);
|
DocumentId documentId = DocumentId.CreateNewId(projectId, debugName: newFileName);
|
||||||
solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
|
solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
|
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
|
||||||
protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected)
|
protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected)
|
||||||
{
|
{
|
||||||
VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
|
this.VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -54,7 +54,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
|
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
|
||||||
protected void VerifyCSharpDiagnostic(string[] sources, params DiagnosticResult[] expected)
|
protected void VerifyCSharpDiagnostic(string[] sources, params DiagnosticResult[] expected)
|
||||||
{
|
{
|
||||||
VerifyDiagnostics(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
|
this.VerifyDiagnostics(sources, LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -67,8 +67,8 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
|
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
|
||||||
private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected)
|
private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected)
|
||||||
{
|
{
|
||||||
var diagnostics = GetSortedDiagnostics(sources, language, analyzer);
|
var diagnostics = DiagnosticVerifier.GetSortedDiagnostics(sources, language, analyzer);
|
||||||
VerifyDiagnosticResults(diagnostics, analyzer, expected);
|
DiagnosticVerifier.VerifyDiagnosticResults(diagnostics, analyzer, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -88,7 +88,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
|
|
||||||
if (expectedCount != actualCount)
|
if (expectedCount != actualCount)
|
||||||
{
|
{
|
||||||
string diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE.";
|
string diagnosticsOutput = actualResults.Any() ? DiagnosticVerifier.FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE.";
|
||||||
|
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Mismatch between number of diagnostics returned, expected \"{0}\" actual \"{1}\"\r\n\r\nDiagnostics:\r\n{2}\r\n", expectedCount, actualCount, diagnosticsOutput));
|
string.Format("Mismatch between number of diagnostics returned, expected \"{0}\" actual \"{1}\"\r\n\r\nDiagnostics:\r\n{2}\r\n", expectedCount, actualCount, diagnosticsOutput));
|
||||||
|
@ -105,12 +105,12 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected:\nA project diagnostic with No location\nActual:\n{0}",
|
string.Format("Expected:\nA project diagnostic with No location\nActual:\n{0}",
|
||||||
FormatDiagnostics(analyzer, actual)));
|
DiagnosticVerifier.FormatDiagnostics(analyzer, actual)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
|
DiagnosticVerifier.VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
|
||||||
var additionalLocations = actual.AdditionalLocations.ToArray();
|
var additionalLocations = actual.AdditionalLocations.ToArray();
|
||||||
|
|
||||||
if (additionalLocations.Length != expected.Locations.Length - 1)
|
if (additionalLocations.Length != expected.Locations.Length - 1)
|
||||||
|
@ -118,12 +118,12 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
|
string.Format("Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
|
||||||
expected.Locations.Length - 1, additionalLocations.Length,
|
expected.Locations.Length - 1, additionalLocations.Length,
|
||||||
FormatDiagnostics(analyzer, actual)));
|
DiagnosticVerifier.FormatDiagnostics(analyzer, actual)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < additionalLocations.Length; ++j)
|
for (int j = 0; j < additionalLocations.Length; ++j)
|
||||||
{
|
{
|
||||||
VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
|
DiagnosticVerifier.VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,21 +131,21 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Id, actual.Id, FormatDiagnostics(analyzer, actual)));
|
expected.Id, actual.Id, DiagnosticVerifier.FormatDiagnostics(analyzer, actual)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actual.Severity != expected.Severity)
|
if (actual.Severity != expected.Severity)
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Severity, actual.Severity, FormatDiagnostics(analyzer, actual)));
|
expected.Severity, actual.Severity, DiagnosticVerifier.FormatDiagnostics(analyzer, actual)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actual.GetMessage() != expected.Message)
|
if (actual.GetMessage() != expected.Message)
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Message, actual.GetMessage(), FormatDiagnostics(analyzer, actual)));
|
expected.Message, actual.GetMessage(), DiagnosticVerifier.FormatDiagnostics(analyzer, actual)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
|
|
||||||
Assert.IsTrue(actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")),
|
Assert.IsTrue(actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")),
|
||||||
string.Format("Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Path, actualSpan.Path, FormatDiagnostics(analyzer, diagnostic)));
|
expected.Path, actualSpan.Path, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic)));
|
||||||
|
|
||||||
var actualLinePosition = actualSpan.StartLinePosition;
|
var actualLinePosition = actualSpan.StartLinePosition;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
|
expected.Line, actualLinePosition.Line + 1, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
||||||
{
|
{
|
||||||
Assert.IsTrue(false,
|
Assert.IsTrue(false,
|
||||||
string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
|
||||||
expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
|
expected.Column, actualLinePosition.Character + 1, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
## Release 2.1.0
|
||||||
|
### New Rules
|
||||||
|
Rule ID | Category | Severity | Notes
|
||||||
|
------------------------- | ------------------ | -------- | ------------------------------------------------------------
|
||||||
|
AvoidImplicitNetFieldCast | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings).
|
||||||
|
AvoidNetField | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings).
|
||||||
|
AvoidObsoleteField | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings).
|
|
@ -12,6 +12,10 @@
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
|
||||||
|
|
||||||
<!--NuGet package-->
|
<!--NuGet package-->
|
||||||
<PackageId>Pathoschild.Stardew.ModBuildConfig</PackageId>
|
<PackageId>Pathoschild.Stardew.ModBuildConfig</PackageId>
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace SMAPI.Tests.Core
|
||||||
name = PathUtilities.NormalizeAssetName(name);
|
name = PathUtilities.NormalizeAssetName(name);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
string calledWithLocale = null;
|
|
||||||
IAssetName assetName = AssetName.Parse(name, parseLocale: _ => expectedLanguageCode);
|
IAssetName assetName = AssetName.Parse(name, parseLocale: _ => expectedLanguageCode);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
|
|
|
@ -610,6 +610,7 @@ namespace StardewModdingAPI.Framework
|
||||||
yield return group;
|
yield return group;
|
||||||
|
|
||||||
// legacy load operations
|
// legacy load operations
|
||||||
|
#pragma warning disable CS0612, CS0618 // deprecated code
|
||||||
foreach (ModLinked<IAssetLoader> loader in this.Loaders)
|
foreach (ModLinked<IAssetLoader> loader in this.Loaders)
|
||||||
{
|
{
|
||||||
// check if loader applies
|
// check if loader applies
|
||||||
|
@ -695,6 +696,7 @@ namespace StardewModdingAPI.Framework
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0612, CS0618
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get an asset info compatible with legacy <see cref="IAssetLoader"/> and <see cref="IAssetEditor"/> instances, which always expect the base name.</summary>
|
/// <summary>Get an asset info compatible with legacy <see cref="IAssetLoader"/> and <see cref="IAssetEditor"/> instances, which always expect the base name.</summary>
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
/// <summary>Load an asset through the content pipeline, using a localized variant of the <paramref name="assetName"/> if available.</summary>
|
/// <summary>Load an asset through the content pipeline, using a localized variant of the <paramref name="assetName"/> if available.</summary>
|
||||||
/// <typeparam name="T">The type of asset to load.</typeparam>
|
/// <typeparam name="T">The type of asset to load.</typeparam>
|
||||||
/// <param name="assetName">The asset name relative to the loader root directory.</param>
|
/// <param name="assetName">The asset name relative to the loader root directory.</param>
|
||||||
|
/// <param name="language">The language for which to load the asset.</param>
|
||||||
/// <param name="useCache">Whether to read/write the loaded asset to the asset cache.</param>
|
/// <param name="useCache">Whether to read/write the loaded asset to the asset cache.</param>
|
||||||
T LoadLocalized<T>(IAssetName assetName, LocalizedContentManager.LanguageCode language, bool useCache);
|
T LoadLocalized<T>(IAssetName assetName, LocalizedContentManager.LanguageCode language, bool useCache);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,13 @@ namespace StardewModdingAPI.Framework.ModHelpers
|
||||||
/// <param name="translationHelper">An API for reading translations stored in the mod's <c>i18n</c> folder.</param>
|
/// <param name="translationHelper">An API for reading translations stored in the mod's <c>i18n</c> folder.</param>
|
||||||
/// <exception cref="ArgumentNullException">An argument is null or empty.</exception>
|
/// <exception cref="ArgumentNullException">An argument is null or empty.</exception>
|
||||||
/// <exception cref="InvalidOperationException">The <paramref name="modDirectory"/> path does not exist on disk.</exception>
|
/// <exception cref="InvalidOperationException">The <paramref name="modDirectory"/> path does not exist on disk.</exception>
|
||||||
public ModHelper(string modID, string modDirectory, Func<SInputState> currentInputState, IModEvents events, ContentHelper contentHelper, IGameContentHelper gameContentHelper, IModContentHelper modContentHelper, IContentPackHelper contentPackHelper, ICommandHelper commandHelper, IDataHelper dataHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, IMultiplayerHelper multiplayer, ITranslationHelper translationHelper)
|
public ModHelper(
|
||||||
|
string modID, string modDirectory, Func<SInputState> currentInputState, IModEvents events,
|
||||||
|
#pragma warning disable CS0612 // deprecated code
|
||||||
|
ContentHelper contentHelper,
|
||||||
|
#pragma warning restore CS0612
|
||||||
|
IGameContentHelper gameContentHelper, IModContentHelper modContentHelper, IContentPackHelper contentPackHelper, ICommandHelper commandHelper, IDataHelper dataHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, IMultiplayerHelper multiplayer, ITranslationHelper translationHelper
|
||||||
|
)
|
||||||
: base(modID)
|
: base(modID)
|
||||||
{
|
{
|
||||||
// validate directory
|
// validate directory
|
||||||
|
@ -106,7 +112,9 @@ namespace StardewModdingAPI.Framework.ModHelpers
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
this.DirectoryPath = modDirectory;
|
this.DirectoryPath = modDirectory;
|
||||||
|
#pragma warning disable CS0612 // deprecated code
|
||||||
this.ContentImpl = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper));
|
this.ContentImpl = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper));
|
||||||
|
#pragma warning restore CS0612
|
||||||
this.GameContent = gameContentHelper ?? throw new ArgumentNullException(nameof(gameContentHelper));
|
this.GameContent = gameContentHelper ?? throw new ArgumentNullException(nameof(gameContentHelper));
|
||||||
this.ModContent = modContentHelper ?? throw new ArgumentNullException(nameof(modContentHelper));
|
this.ModContent = modContentHelper ?? throw new ArgumentNullException(nameof(modContentHelper));
|
||||||
this.ContentPacks = contentPackHelper ?? throw new ArgumentNullException(nameof(contentPackHelper));
|
this.ContentPacks = contentPackHelper ?? throw new ArgumentNullException(nameof(contentPackHelper));
|
||||||
|
|
|
@ -1593,6 +1593,7 @@ namespace StardewModdingAPI.Framework
|
||||||
|
|
||||||
// initialize loaded non-content-pack mods
|
// initialize loaded non-content-pack mods
|
||||||
this.Monitor.Log("Launching mods...", LogLevel.Debug);
|
this.Monitor.Log("Launching mods...", LogLevel.Debug);
|
||||||
|
#pragma warning disable CS0612, CS0618 // deprecated code
|
||||||
foreach (IModMetadata metadata in loadedMods)
|
foreach (IModMetadata metadata in loadedMods)
|
||||||
{
|
{
|
||||||
// add interceptors
|
// add interceptors
|
||||||
|
@ -1628,6 +1629,7 @@ namespace StardewModdingAPI.Framework
|
||||||
content.ObservableAssetEditors.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetEditor>(), e.OldItems?.Cast<IAssetEditor>(), this.ContentCore.Editors);
|
content.ObservableAssetEditors.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetEditor>(), e.OldItems?.Cast<IAssetEditor>(), this.ContentCore.Editors);
|
||||||
content.ObservableAssetLoaders.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetLoader>(), e.OldItems?.Cast<IAssetLoader>(), this.ContentCore.Loaders);
|
content.ObservableAssetLoaders.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetLoader>(), e.OldItems?.Cast<IAssetLoader>(), this.ContentCore.Loaders);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0612, CS0618
|
||||||
|
|
||||||
// call entry method
|
// call entry method
|
||||||
try
|
try
|
||||||
|
@ -1847,7 +1849,9 @@ namespace StardewModdingAPI.Framework
|
||||||
IModEvents events = new ModEvents(mod, this.EventManager);
|
IModEvents events = new ModEvents(mod, this.EventManager);
|
||||||
ICommandHelper commandHelper = new CommandHelper(mod, this.CommandManager);
|
ICommandHelper commandHelper = new CommandHelper(mod, this.CommandManager);
|
||||||
CaseInsensitivePathCache relativePathCache = this.ContentCore.GetCaseInsensitivePathCache(mod.DirectoryPath);
|
CaseInsensitivePathCache relativePathCache = this.ContentCore.GetCaseInsensitivePathCache(mod.DirectoryPath);
|
||||||
|
#pragma warning disable CS0612 // deprecated code
|
||||||
ContentHelper contentHelper = new(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, monitor);
|
ContentHelper contentHelper = new(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, monitor);
|
||||||
|
#pragma warning restore CS0612
|
||||||
GameContentHelper gameContentHelper = new(contentCore, manifest.UniqueID, mod.DisplayName, monitor);
|
GameContentHelper gameContentHelper = new(contentCore, manifest.UniqueID, mod.DisplayName, monitor);
|
||||||
IModContentHelper modContentHelper = new ModContentHelper(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, gameContentHelper.GetUnderlyingContentManager(), relativePathCache);
|
IModContentHelper modContentHelper = new ModContentHelper(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, gameContentHelper.GetUnderlyingContentManager(), relativePathCache);
|
||||||
IContentPackHelper contentPackHelper = new ContentPackHelper(manifest.UniqueID, new Lazy<IContentPack[]>(GetContentPacks), CreateFakeContentPack);
|
IContentPackHelper contentPackHelper = new ContentPackHelper(manifest.UniqueID, new Lazy<IContentPack[]>(GetContentPacks), CreateFakeContentPack);
|
||||||
|
|
Loading…
Reference in New Issue