From 21fbb01ce4e97770156a7d1cf66411cffbeb9ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Mon, 8 Jul 2024 18:54:07 +0800 Subject: [PATCH] merge #317 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据NETAnalyzers调整代码 --- .../BuildPipeline/BaseTasks/TaskCreateManifest.cs | 4 ++-- .../BuildPipeline/BaseTasks/TaskGetBuildMap.cs | 4 ++-- .../BuildTasks/TaskCreateManifest_RFBP.cs | 2 +- .../AssetBundleCollectorSettingData.cs | 12 ++++++------ .../ResourceManager/Handle/AllAssetsHandle.cs | 2 +- .../ResourceManager/Handle/SubAssetsHandle.cs | 2 +- .../Runtime/ResourcePackage/PackageManifest.cs | 2 +- Assets/YooAsset/Runtime/Utility/YooUtility.cs | 6 ++---- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs index 23120ef4..4c8af55e 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs @@ -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 { diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs index 6e78c054..68be80dd 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs @@ -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 { diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskCreateManifest_RFBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskCreateManifest_RFBP.cs index 4a7778af..816063a9 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskCreateManifest_RFBP.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskCreateManifest_RFBP.cs @@ -14,7 +14,7 @@ namespace YooAsset.Editor protected override string[] GetBundleDepends(BuildContext context, string bundleName) { - return new string[] { }; + return Array.Empty(); } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index c0c41a25..3f44c409 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -23,7 +23,7 @@ namespace YooAsset.Editor private static readonly Dictionary _cacheIgnoreRuleTypes = new Dictionary(); private static readonly Dictionary _cacheIgnoreRuleInstance = new Dictionary(); - + /// /// 配置数据是否被修改 /// @@ -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) diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs index cd2ef538..ac620e63 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs @@ -67,7 +67,7 @@ namespace YooAsset /// /// 子资源对象集合 /// - public UnityEngine.Object[] AllAssetObjects + public IReadOnlyList AllAssetObjects { get { diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs index 449df0ba..22b38d57 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs @@ -67,7 +67,7 @@ namespace YooAsset /// /// 子资源对象集合 /// - public UnityEngine.Object[] AllAssetObjects + public IReadOnlyList AllAssetObjects { get { diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs b/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs index 3bac3e6a..015e74e8 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs @@ -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) diff --git a/Assets/YooAsset/Runtime/Utility/YooUtility.cs b/Assets/YooAsset/Runtime/Utility/YooUtility.cs index 0f64cc4a..1f12aa62 100644 --- a/Assets/YooAsset/Runtime/Utility/YooUtility.cs +++ b/Assets/YooAsset/Runtime/Utility/YooUtility.cs @@ -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