remove System.ValueTuple

This caused reference errors on Linux/Mac, and there aren't enough use cases to look into it further for now.
This commit is contained in:
Jesse Plamondon-Willard 2017-07-03 01:29:56 -04:00
parent 771263299c
commit 136525b40d
8 changed files with 13 additions and 23 deletions

View File

@ -27,7 +27,6 @@ For players:
For modders:
* Added `SDate` utility for in-game date calculations (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Dates)).
* Added support for minimum dependency versions in `manifest.json` (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Manifest)).
* Added `System.ValueTuple.dll` to the SMAPI install package so mods can use [C# 7 value tuples](https://docs.microsoft.com/en-us/dotnet/csharp/tuples).
* Added more useful logging when loading mods.
* Changed `manifest.MinimumApiVersion` from string to `ISemanticVersion`. This shouldn't affect mods unless they referenced that field in code.
* Fixed `SemanticVersion` parsing some invalid versions into close approximations (like `1.apple` → `1.0-apple`).

View File

@ -43,9 +43,6 @@
<HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyInfo.cs">

View File

@ -4,5 +4,4 @@
<package id="Moq" version="4.7.10" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="NUnit" version="3.6.1" targetFramework="net452" />
<package id="System.ValueTuple" version="4.3.1" targetFramework="net45" />
</packages>

View File

@ -228,7 +228,7 @@ namespace StardewModdingAPI.Framework.ModLoading
from entry in mod.Manifest.Dependencies
let dependencyMod = mods.FirstOrDefault(m => string.Equals(m.Manifest?.UniqueID, entry.UniqueID, StringComparison.InvariantCultureIgnoreCase))
orderby entry.UniqueID
select (ID: entry.UniqueID, MinVersion: entry.MinimumVersion, Mod: dependencyMod)
select new { ID = entry.UniqueID, MinVersion = entry.MinimumVersion, Mod = dependencyMod }
)
.ToArray();

View File

@ -232,11 +232,11 @@ namespace StardewModdingAPI.Framework
{
try
{
return entry.Interceptor.CanLoad<T>(info);
return entry.Value.CanLoad<T>(info);
}
catch (Exception ex)
{
this.Monitor.Log($"{entry.Mod.DisplayName} crashed when checking whether it could load asset '{info.AssetName}', and will be ignored. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
this.Monitor.Log($"{entry.Key.DisplayName} crashed when checking whether it could load asset '{info.AssetName}', and will be ignored. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
return false;
}
})
@ -247,14 +247,14 @@ namespace StardewModdingAPI.Framework
return null;
if (loaders.Length > 1)
{
string[] loaderNames = loaders.Select(p => p.Mod.DisplayName).ToArray();
string[] loaderNames = loaders.Select(p => p.Key.DisplayName).ToArray();
this.Monitor.Log($"Multiple mods want to provide the '{info.AssetName}' asset ({string.Join(", ", loaderNames)}), but an asset can't be loaded multiple times. SMAPI will use the default asset instead; uninstall one of the mods to fix this. (Message for modders: you should usually use {typeof(IAssetEditor)} instead to avoid conflicts.)", LogLevel.Warn);
return null;
}
// fetch asset from loader
IModMetadata mod = loaders[0].Mod;
IAssetLoader loader = loaders[0].Interceptor;
IModMetadata mod = loaders[0].Key;
IAssetLoader loader = loaders[0].Value;
T data;
try
{
@ -290,8 +290,8 @@ namespace StardewModdingAPI.Framework
foreach (var entry in this.GetInterceptors(this.Editors))
{
// check for match
IModMetadata mod = entry.Mod;
IAssetEditor editor = entry.Interceptor;
IModMetadata mod = entry.Key;
IAssetEditor editor = entry.Value;
try
{
if (!editor.CanEdit<T>(info))
@ -299,7 +299,7 @@ namespace StardewModdingAPI.Framework
}
catch (Exception ex)
{
this.Monitor.Log($"{entry.Mod.DisplayName} crashed when checking whether it could edit asset '{info.AssetName}', and will be ignored. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
this.Monitor.Log($"{mod.DisplayName} crashed when checking whether it could edit asset '{info.AssetName}', and will be ignored. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
continue;
}
@ -312,7 +312,7 @@ namespace StardewModdingAPI.Framework
}
catch (Exception ex)
{
this.Monitor.Log($"{entry.Mod.DisplayName} crashed when editing asset '{info.AssetName}', which may cause errors in-game. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
this.Monitor.Log($"{mod.DisplayName} crashed when editing asset '{info.AssetName}', which may cause errors in-game. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
}
// validate edit
@ -333,7 +333,7 @@ namespace StardewModdingAPI.Framework
}
/// <summary>Get all registered interceptors from a list.</summary>
private IEnumerable<(IModMetadata Mod, T Interceptor)> GetInterceptors<T>(IDictionary<IModMetadata, IList<T>> entries)
private IEnumerable<KeyValuePair<IModMetadata, T>> GetInterceptors<T>(IDictionary<IModMetadata, IList<T>> entries)
{
foreach (var entry in entries)
{
@ -342,11 +342,11 @@ namespace StardewModdingAPI.Framework
// special case if mod is an interceptor
if (metadata.Mod is T modAsInterceptor)
yield return (metadata, modAsInterceptor);
yield return new KeyValuePair<IModMetadata, T>(metadata, modAsInterceptor);
// registered editors
foreach (T interceptor in interceptors)
yield return (metadata, interceptor);
yield return new KeyValuePair<IModMetadata, T>(metadata, interceptor);
}
}
}

View File

@ -79,9 +79,6 @@
<Reference Include="System.Runtime.Caching">
<Private>True</Private>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" Condition="$(OS) == 'Windows_NT'" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />

View File

@ -2,5 +2,4 @@
<packages>
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="System.ValueTuple" version="4.3.1" targetFramework="net45" />
</packages>

View File

@ -31,7 +31,6 @@
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.config.json" DestinationFolder="$(PackageInternalPath)\Mono" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Numerics.dll" DestinationFolder="$(PackageInternalPath)\Mono" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Runtime.Caching.dll" DestinationFolder="$(PackageInternalPath)\Mono" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.ValueTuple.dll" DestinationFolder="$(PackageInternalPath)\Mono" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\unix-launcher.sh" DestinationFiles="$(PackageInternalPath)\Mono\StardewModdingAPI" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\steam_appid.txt" DestinationFolder="$(PackageInternalPath)\Mono" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="@(CompiledMods)" DestinationFolder="$(PackageInternalPath)\Mono\Mods\%(RecursiveDir)" />