mirror of https://github.com/tuyoogame/YooAsset
根据NETAnalyzers调整代码
https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1819 https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1825 https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1841 https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1854 https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1864 https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1865-ca1867pull/317/head
parent
2987d356b6
commit
3d3fbedea2
|
@ -180,9 +180,9 @@ namespace YooAsset.Editor
|
|||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
if (_cacheBundleTags.ContainsKey(index))
|
||||
if (_cacheBundleTags.TryGetValue(index, out var value))
|
||||
{
|
||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||
packageBundle.Tags = value.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -56,9 +56,9 @@ namespace YooAsset.Editor
|
|||
string bundleName = collectAssetInfo.BundleName;
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(dependAsset.AssetPath))
|
||||
if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out var value))
|
||||
{
|
||||
allBuildAssetInfos[dependAsset.AssetPath].AddReferenceBundleName(bundleName);
|
||||
value.AddReferenceBundleName(bundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
|||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return new string[] { };
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -275,23 +275,23 @@ namespace YooAsset.Editor
|
|||
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheActiveRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasAddressRuleName(string ruleName)
|
||||
{
|
||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheAddressRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasPackRuleName(string ruleName)
|
||||
{
|
||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||
return _cachePackRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasFilterRuleName(string ruleName)
|
||||
{
|
||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheFilterRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasIgnoreRuleName(string ruleName)
|
||||
{
|
||||
return _cacheIgnoreRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheIgnoreRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
|
|
|
@ -94,11 +94,8 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
if (_wrappers.ContainsKey(cacheGUID))
|
||||
{
|
||||
_wrappers.Remove(cacheGUID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取记录对象
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 子资源对象集合
|
||||
/// </summary>
|
||||
public UnityEngine.Object[] AllAssetObjects
|
||||
public IReadOnlyList<UnityEngine.Object> AllAssetObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 子资源对象集合
|
||||
/// </summary>
|
||||
public UnityEngine.Object[] AllAssetObjects
|
||||
public IReadOnlyList<Object> AllAssetObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -166,10 +166,8 @@ namespace YooAsset
|
|||
{
|
||||
// 注意:我们不允许原始路径存在重名
|
||||
string assetPath = packageAsset.AssetPath;
|
||||
if (manifest.AssetDic.ContainsKey(assetPath))
|
||||
if (!manifest.AssetDic.TryAdd(assetPath, packageAsset))
|
||||
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
manifest.AssetDic.Add(assetPath, packageAsset);
|
||||
}
|
||||
|
||||
return manifest;
|
||||
|
|
|
@ -124,10 +124,8 @@ namespace YooAsset
|
|||
|
||||
// 注意:我们不允许原始路径存在重名
|
||||
string assetPath = packageAsset.AssetPath;
|
||||
if (Manifest.AssetDic.ContainsKey(assetPath))
|
||||
if (!Manifest.AssetDic.TryAdd(assetPath, packageAsset))
|
||||
throw new System.Exception($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
Manifest.AssetDic.Add(assetPath, packageAsset);
|
||||
|
||||
// 填充AssetPathMapping1
|
||||
{
|
||||
|
@ -136,19 +134,15 @@ namespace YooAsset
|
|||
location = location.ToLower();
|
||||
|
||||
// 添加原生路径的映射
|
||||
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
||||
if (!Manifest.AssetPathMapping1.TryAdd(location, packageAsset.AssetPath))
|
||||
throw new System.Exception($"Location have existed : {location}");
|
||||
else
|
||||
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||
|
||||
// 添加无后缀名路径的映射
|
||||
string locationWithoutExtension = Path.ChangeExtension(location, null);
|
||||
if (ReferenceEquals(location, locationWithoutExtension) == false)
|
||||
{
|
||||
if (Manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
|
||||
if (!Manifest.AssetPathMapping1.TryAdd(locationWithoutExtension, packageAsset.AssetPath))
|
||||
YooLogger.Warning($"Location have existed : {locationWithoutExtension}");
|
||||
else
|
||||
Manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
if (Manifest.EnableAddressable)
|
||||
|
@ -156,20 +150,16 @@ namespace YooAsset
|
|||
string location = packageAsset.Address;
|
||||
if (string.IsNullOrEmpty(location) == false)
|
||||
{
|
||||
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
||||
if (!Manifest.AssetPathMapping1.TryAdd(location, packageAsset.AssetPath))
|
||||
throw new System.Exception($"Location have existed : {location}");
|
||||
else
|
||||
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 填充AssetPathMapping2
|
||||
if (Manifest.IncludeAssetGUID)
|
||||
{
|
||||
if (Manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
|
||||
if (!Manifest.AssetPathMapping2.TryAdd(packageAsset.AssetGUID, packageAsset.AssetPath))
|
||||
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
||||
else
|
||||
Manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
|
||||
}
|
||||
|
||||
_packageAssetCount--;
|
||||
|
|
|
@ -344,7 +344,7 @@ namespace YooAsset
|
|||
if (string.IsNullOrEmpty(location) == false)
|
||||
{
|
||||
// 检查路径末尾是否有空格
|
||||
int index = location.LastIndexOf(" ");
|
||||
int index = location.LastIndexOf(' ');
|
||||
if (index != -1)
|
||||
{
|
||||
if (location.Length == index + 1)
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
|
@ -29,7 +27,7 @@ namespace YooAsset
|
|||
if (string.IsNullOrEmpty(str))
|
||||
return str;
|
||||
|
||||
int index = str.LastIndexOf(".");
|
||||
int index = str.LastIndexOf('.');
|
||||
if (index == -1)
|
||||
return str;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue