void Test <T>(AssetId id, AssetId[] prerequisites, Func <T, ISerializer, T> serdes, Func <T, T> canonicalize = null) where T : class { prerequisites ??= Array.Empty <AssetId>(); var allIds = prerequisites.Append(id); var resultsDir = Path.Combine(_baseDir, "re", "ConversionTests"); var baseAsset = (T)_baseApplier.LoadAsset(id); if (canonicalize != null) { baseAsset = canonicalize(baseAsset); } var(baseBytes, baseNotes) = Asset.Save(baseAsset, serdes); var baseJson = Asset.SaveJson(baseAsset, JsonUtil); var idStrings = allIds.Select(x => $"{x.Type}.{x.Id}").ToArray(); var assetTypes = allIds.Select(x => x.Type).Distinct().ToHashSet(); var mapping = AssetMapping.Global; using (var unpacker = new AssetConverter( mapping, _disk, JsonUtil, new[] { BaseAssetMod }, UnpackedAssetMod)) { unpacker.Convert(idStrings, assetTypes, null); } var unpackedAsset = (T)BuildApplier(UnpackedAssetMod, AssetMapping.Global).LoadAsset(id); Assert.NotNull(unpackedAsset); var(unpackedBytes, unpackedNotes) = Asset.Save(unpackedAsset, serdes); var unpackedJson = Asset.SaveJson(unpackedAsset, JsonUtil); Asset.Compare(resultsDir, id.ToString(), baseBytes, unpackedBytes, new[]
public IMapData LoadMap(MapId id) => (IMapData)_modApplier.LoadAsset(id); // No caching for map data