From 0883e311979469ce3dabec3fee42a05f57f97895 Mon Sep 17 00:00:00 2001 From: hatayama Date: Thu, 9 Jul 2026 15:14:27 +0900 Subject: [PATCH] Split first-party screenshot requirement scan out of the migration collector ThirdPartyToolMigrationFastAssemblyRequirementCollector mixed two independent, field-free scanning concerns in one 622-line file: general assembly-reference requirement collection and first-party screenshot API requirement collection. Neither section referenced the other and both were entirely stateless, so this was pure responsibility mixing rather than a single cohesive algorithm. Move CollectFastFirstPartyScreenshotRequirementsAsync and its private helpers (source-level scan, three legacy-detection predicates, and the FirstPartyScreenshotRequirementScan DTO) into a new ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector. The sole caller, ThirdPartyToolMigrationTargetScanner, used `using static` for both entry points, so it now imports the new class alongside the original. Register the new file's async ct-parameter method in StaticFacadeStateGuardTests' tracked path list. --- .../Editor/StaticFacadeStateGuardTests.cs | 3 +- ...grationFastAssemblyRequirementCollector.cs | 274 ---------------- ...irstPartyScreenshotRequirementCollector.cs | 293 ++++++++++++++++++ ...artyScreenshotRequirementCollector.cs.meta | 11 + .../ThirdPartyToolMigrationTargetScanner.cs | 1 + 5 files changed, 307 insertions(+), 275 deletions(-) create mode 100644 Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs create mode 100644 Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs.meta diff --git a/Assets/Tests/Editor/StaticFacadeStateGuardTests.cs b/Assets/Tests/Editor/StaticFacadeStateGuardTests.cs index 68f46a0190..f86a5b346e 100644 --- a/Assets/Tests/Editor/StaticFacadeStateGuardTests.cs +++ b/Assets/Tests/Editor/StaticFacadeStateGuardTests.cs @@ -69,7 +69,8 @@ public sealed class StaticFacadeStateGuardTests "Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputMainThreadCleanup.cs", "Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputActionExecutor.cs", "Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeMissingReturnRetryPolicy.cs", - "Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerRecoveryExecutor.cs" + "Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerRecoveryExecutor.cs", + "Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs" }; private static readonly Dictionary OverloadGuardMethodsByPath = new Dictionary diff --git a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastAssemblyRequirementCollector.cs b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastAssemblyRequirementCollector.cs index c11ace8dba..b34410c723 100644 --- a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastAssemblyRequirementCollector.cs +++ b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastAssemblyRequirementCollector.cs @@ -344,279 +344,5 @@ internal static async Task CollectFastAssemblyScopedCurrentDomainRequirementsAsy } } - internal static async Task CollectFastFirstPartyScreenshotRequirementsAsync( - List csharpFilePaths, - List asmdefDirectories, - List assemblyReferenceDirectories, - string projectRoot, - HashSet legacyAssemblyDirectories, - Dictionary> assemblyScopedLegacyAliasesByDirectory, - HashSet assemblyScopedCurrentToolContractsDirectories, - HashSet assemblyScopedCurrentFirstPartyToolsDirectories, - Dictionary> assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, - Dictionary> assemblyDeclaredTypeNamesByDirectory, - HashSet toolContractsReferenceAssemblyDirectories, - HashSet firstPartyScreenshotReferenceAssemblyDirectories, - CancellationToken ct) - { - Debug.Assert(csharpFilePaths != null, "csharpFilePaths must not be null"); - Debug.Assert(asmdefDirectories != null, "asmdefDirectories must not be null"); - Debug.Assert( - assemblyReferenceDirectories != null, - "assemblyReferenceDirectories must not be null"); - Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); - Debug.Assert(legacyAssemblyDirectories != null, "legacyAssemblyDirectories must not be null"); - Debug.Assert( - assemblyScopedLegacyAliasesByDirectory != null, - "assemblyScopedLegacyAliasesByDirectory must not be null"); - Debug.Assert( - assemblyScopedCurrentToolContractsDirectories != null, - "assemblyScopedCurrentToolContractsDirectories must not be null"); - Debug.Assert( - assemblyScopedCurrentFirstPartyToolsDirectories != null, - "assemblyScopedCurrentFirstPartyToolsDirectories must not be null"); - Debug.Assert( - assemblyScopedCurrentFirstPartyToolsAliasesByDirectory != null, - "assemblyScopedCurrentFirstPartyToolsAliasesByDirectory must not be null"); - Debug.Assert( - assemblyDeclaredTypeNamesByDirectory != null, - "assemblyDeclaredTypeNamesByDirectory must not be null"); - Debug.Assert( - toolContractsReferenceAssemblyDirectories != null, - "toolContractsReferenceAssemblyDirectories must not be null"); - Debug.Assert( - firstPartyScreenshotReferenceAssemblyDirectories != null, - "firstPartyScreenshotReferenceAssemblyDirectories must not be null"); - - int inspectedEntryCount = 0; - foreach (string csharpFilePath in csharpFilePaths) - { - if (ct.IsCancellationRequested) - { - return false; - } - - string source = ThirdPartyToolMigrationFileAccess.ReadAllText(csharpFilePath); - inspectedEntryCount++; - if (inspectedEntryCount % ThirdPartyToolMigrationFileServiceConstants.PreviewYieldBatchSize == 0) - { - await Task.Yield(); - } - - if (!ThirdPartyToolMigrationRules.ContainsMigrationCandidateText(source)) - { - continue; - } - - string assemblyDirectory = FindNearestAssemblyDirectory( - csharpFilePath, - asmdefDirectories, - assemblyReferenceDirectories, - projectRoot); - bool foundMigrationTarget = CollectFastFirstPartyScreenshotRequirementsForSource( - source, - assemblyDirectory, - legacyAssemblyDirectories, - assemblyScopedLegacyAliasesByDirectory, - assemblyScopedCurrentToolContractsDirectories, - assemblyScopedCurrentFirstPartyToolsDirectories, - assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, - assemblyDeclaredTypeNamesByDirectory, - toolContractsReferenceAssemblyDirectories, - firstPartyScreenshotReferenceAssemblyDirectories); - if (foundMigrationTarget) - { - return true; - } - - } - - return false; - } - - private static bool CollectFastFirstPartyScreenshotRequirementsForSource( - string source, - string assemblyDirectory, - HashSet legacyAssemblyDirectories, - Dictionary> assemblyScopedLegacyAliasesByDirectory, - HashSet assemblyScopedCurrentToolContractsDirectories, - HashSet assemblyScopedCurrentFirstPartyToolsDirectories, - Dictionary> assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, - Dictionary> assemblyDeclaredTypeNamesByDirectory, - HashSet toolContractsReferenceAssemblyDirectories, - HashSet firstPartyScreenshotReferenceAssemblyDirectories) - { - string[] assemblyDeclaredTypeNames = - GetAssemblyScopedNames(assemblyDeclaredTypeNamesByDirectory, assemblyDirectory); - string[] legacyAssemblyAliases = - GetAssemblyScopedNames(assemblyScopedLegacyAliasesByDirectory, assemblyDirectory); - string[] currentFirstPartyToolsAssemblyAliases = - GetAssemblyScopedNames(assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, assemblyDirectory); - FirstPartyScreenshotRequirementScan scan = ScanFastFirstPartyScreenshotRequirement( - source, - assemblyDirectory, - legacyAssemblyDirectories, - assemblyScopedCurrentToolContractsDirectories, - assemblyScopedCurrentFirstPartyToolsDirectories, - legacyAssemblyAliases, - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - - if (scan.RequiresToolContractsReference) - { - toolContractsReferenceAssemblyDirectories.Add(assemblyDirectory); - } - - if (scan.RequiresFirstPartyScreenshotReference) - { - firstPartyScreenshotReferenceAssemblyDirectories.Add(assemblyDirectory); - } - - return scan.HasMigrationTarget; - } - - private static FirstPartyScreenshotRequirementScan ScanFastFirstPartyScreenshotRequirement( - string source, - string assemblyDirectory, - HashSet legacyAssemblyDirectories, - HashSet assemblyScopedCurrentToolContractsDirectories, - HashSet assemblyScopedCurrentFirstPartyToolsDirectories, - string[] legacyAssemblyAliases, - string[] currentFirstPartyToolsAssemblyAliases, - string[] assemblyDeclaredTypeNames) - { - bool hasLegacyEditorWindowCaptureUtilitySourceTarget = - HasLegacyEditorWindowCaptureUtilitySourceTarget( - source, - assemblyDirectory, - legacyAssemblyDirectories, - assemblyScopedCurrentToolContractsDirectories, - assemblyScopedCurrentFirstPartyToolsDirectories, - legacyAssemblyAliases, - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - bool hasLegacyScreenshotSourceTarget = HasLegacyScreenshotSourceTarget( - source, - assemblyDirectory, - legacyAssemblyDirectories, - assemblyScopedCurrentToolContractsDirectories, - legacyAssemblyAliases, - assemblyDeclaredTypeNames, - hasLegacyEditorWindowCaptureUtilitySourceTarget); - bool hasCurrentScreenshotReferenceRequirement = - ThirdPartyToolMigrationRules.ContainsCurrentFirstPartyScreenshotApiForAssembly( - source, - assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - bool hasCurrentFirstPartyToolsContractSourceTarget = - ThirdPartyToolMigrationRules.ContainsCurrentFirstPartyScreenshotContractApiForAssembly( - source, - assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - bool hasCurrentRenderingCaptureSourceTarget = - ThirdPartyToolMigrationRules.ContainsCurrentCaptureGameRenderingDeconstructionMigrationForAssembly( - source, - assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - bool hasTimeoutMigration = HasLegacyEditorWindowCaptureUtilityTimeoutMigration( - source, - assemblyDirectory, - legacyAssemblyDirectories, - assemblyScopedCurrentToolContractsDirectories, - assemblyScopedCurrentFirstPartyToolsDirectories, - legacyAssemblyAliases, - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - return new FirstPartyScreenshotRequirementScan( - hasLegacyScreenshotSourceTarget || - hasCurrentFirstPartyToolsContractSourceTarget || - hasCurrentScreenshotReferenceRequirement || - hasTimeoutMigration, - hasCurrentRenderingCaptureSourceTarget || - hasCurrentScreenshotReferenceRequirement, - hasLegacyScreenshotSourceTarget || - hasCurrentRenderingCaptureSourceTarget || - hasCurrentFirstPartyToolsContractSourceTarget || - hasTimeoutMigration); - } - - private static bool HasLegacyEditorWindowCaptureUtilitySourceTarget( - string source, - string assemblyDirectory, - HashSet legacyAssemblyDirectories, - HashSet assemblyScopedCurrentToolContractsDirectories, - HashSet assemblyScopedCurrentFirstPartyToolsDirectories, - string[] legacyAssemblyAliases, - string[] currentFirstPartyToolsAssemblyAliases, - string[] assemblyDeclaredTypeNames) - { - return ThirdPartyToolMigrationRules.ContainsLegacyEditorWindowCaptureUtilityMigrationForAssembly( - source, - legacyAssemblyDirectories.Contains(assemblyDirectory), - assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory), - assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), - legacyAssemblyAliases, - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - } - - private static bool HasLegacyScreenshotSourceTarget( - string source, - string assemblyDirectory, - HashSet legacyAssemblyDirectories, - HashSet assemblyScopedCurrentToolContractsDirectories, - string[] legacyAssemblyAliases, - string[] assemblyDeclaredTypeNames, - bool hasLegacyEditorWindowCaptureUtilitySourceTarget) - { - return ThirdPartyToolMigrationRules.ContainsLegacyFirstPartyScreenshotApiForAssembly( - source, - legacyAssemblyDirectories.Contains(assemblyDirectory) || - assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory) || - ThirdPartyToolMigrationRules.ContainsCurrentToolContractsApi(source), - legacyAssemblyAliases, - assemblyDeclaredTypeNames) || - hasLegacyEditorWindowCaptureUtilitySourceTarget; - } - - private static bool HasLegacyEditorWindowCaptureUtilityTimeoutMigration( - string source, - string assemblyDirectory, - HashSet legacyAssemblyDirectories, - HashSet assemblyScopedCurrentToolContractsDirectories, - HashSet assemblyScopedCurrentFirstPartyToolsDirectories, - string[] legacyAssemblyAliases, - string[] currentFirstPartyToolsAssemblyAliases, - string[] assemblyDeclaredTypeNames) - { - return ThirdPartyToolMigrationRules.ContainsLegacyEditorWindowCaptureUtilityTimeoutMigrationForAssembly( - source, - legacyAssemblyDirectories.Contains(assemblyDirectory), - assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory), - assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), - legacyAssemblyAliases, - currentFirstPartyToolsAssemblyAliases, - assemblyDeclaredTypeNames); - } - - private readonly struct FirstPartyScreenshotRequirementScan - { - public FirstPartyScreenshotRequirementScan( - bool requiresToolContractsReference, - bool requiresFirstPartyScreenshotReference, - bool hasMigrationTarget) - { - RequiresToolContractsReference = requiresToolContractsReference; - RequiresFirstPartyScreenshotReference = requiresFirstPartyScreenshotReference; - HasMigrationTarget = hasMigrationTarget; - } - - public bool RequiresToolContractsReference { get; } - public bool RequiresFirstPartyScreenshotReference { get; } - public bool HasMigrationTarget { get; } - } } } diff --git a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs new file mode 100644 index 0000000000..20ef122001 --- /dev/null +++ b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs @@ -0,0 +1,293 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationAssemblyReferenceResolver; +using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationAssemblyScopedNameMap; + +using io.github.hatayama.UnityCliLoop.Domain; + +namespace io.github.hatayama.UnityCliLoop.Infrastructure +{ + /// + /// Collects first-party screenshot API requirements during fast migration-target scans. + /// + internal static class ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector + { + internal static async Task CollectFastFirstPartyScreenshotRequirementsAsync( + List csharpFilePaths, + List asmdefDirectories, + List assemblyReferenceDirectories, + string projectRoot, + HashSet legacyAssemblyDirectories, + Dictionary> assemblyScopedLegacyAliasesByDirectory, + HashSet assemblyScopedCurrentToolContractsDirectories, + HashSet assemblyScopedCurrentFirstPartyToolsDirectories, + Dictionary> assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, + Dictionary> assemblyDeclaredTypeNamesByDirectory, + HashSet toolContractsReferenceAssemblyDirectories, + HashSet firstPartyScreenshotReferenceAssemblyDirectories, + CancellationToken ct) + { + Debug.Assert(csharpFilePaths != null, "csharpFilePaths must not be null"); + Debug.Assert(asmdefDirectories != null, "asmdefDirectories must not be null"); + Debug.Assert( + assemblyReferenceDirectories != null, + "assemblyReferenceDirectories must not be null"); + Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); + Debug.Assert(legacyAssemblyDirectories != null, "legacyAssemblyDirectories must not be null"); + Debug.Assert( + assemblyScopedLegacyAliasesByDirectory != null, + "assemblyScopedLegacyAliasesByDirectory must not be null"); + Debug.Assert( + assemblyScopedCurrentToolContractsDirectories != null, + "assemblyScopedCurrentToolContractsDirectories must not be null"); + Debug.Assert( + assemblyScopedCurrentFirstPartyToolsDirectories != null, + "assemblyScopedCurrentFirstPartyToolsDirectories must not be null"); + Debug.Assert( + assemblyScopedCurrentFirstPartyToolsAliasesByDirectory != null, + "assemblyScopedCurrentFirstPartyToolsAliasesByDirectory must not be null"); + Debug.Assert( + assemblyDeclaredTypeNamesByDirectory != null, + "assemblyDeclaredTypeNamesByDirectory must not be null"); + Debug.Assert( + toolContractsReferenceAssemblyDirectories != null, + "toolContractsReferenceAssemblyDirectories must not be null"); + Debug.Assert( + firstPartyScreenshotReferenceAssemblyDirectories != null, + "firstPartyScreenshotReferenceAssemblyDirectories must not be null"); + + int inspectedEntryCount = 0; + foreach (string csharpFilePath in csharpFilePaths) + { + if (ct.IsCancellationRequested) + { + return false; + } + + string source = ThirdPartyToolMigrationFileAccess.ReadAllText(csharpFilePath); + inspectedEntryCount++; + if (inspectedEntryCount % ThirdPartyToolMigrationFileServiceConstants.PreviewYieldBatchSize == 0) + { + await Task.Yield(); + } + + if (!ThirdPartyToolMigrationRules.ContainsMigrationCandidateText(source)) + { + continue; + } + + string assemblyDirectory = FindNearestAssemblyDirectory( + csharpFilePath, + asmdefDirectories, + assemblyReferenceDirectories, + projectRoot); + bool foundMigrationTarget = CollectFastFirstPartyScreenshotRequirementsForSource( + source, + assemblyDirectory, + legacyAssemblyDirectories, + assemblyScopedLegacyAliasesByDirectory, + assemblyScopedCurrentToolContractsDirectories, + assemblyScopedCurrentFirstPartyToolsDirectories, + assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, + assemblyDeclaredTypeNamesByDirectory, + toolContractsReferenceAssemblyDirectories, + firstPartyScreenshotReferenceAssemblyDirectories); + if (foundMigrationTarget) + { + return true; + } + + } + + return false; + } + + private static bool CollectFastFirstPartyScreenshotRequirementsForSource( + string source, + string assemblyDirectory, + HashSet legacyAssemblyDirectories, + Dictionary> assemblyScopedLegacyAliasesByDirectory, + HashSet assemblyScopedCurrentToolContractsDirectories, + HashSet assemblyScopedCurrentFirstPartyToolsDirectories, + Dictionary> assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, + Dictionary> assemblyDeclaredTypeNamesByDirectory, + HashSet toolContractsReferenceAssemblyDirectories, + HashSet firstPartyScreenshotReferenceAssemblyDirectories) + { + string[] assemblyDeclaredTypeNames = + GetAssemblyScopedNames(assemblyDeclaredTypeNamesByDirectory, assemblyDirectory); + string[] legacyAssemblyAliases = + GetAssemblyScopedNames(assemblyScopedLegacyAliasesByDirectory, assemblyDirectory); + string[] currentFirstPartyToolsAssemblyAliases = + GetAssemblyScopedNames(assemblyScopedCurrentFirstPartyToolsAliasesByDirectory, assemblyDirectory); + FirstPartyScreenshotRequirementScan scan = ScanFastFirstPartyScreenshotRequirement( + source, + assemblyDirectory, + legacyAssemblyDirectories, + assemblyScopedCurrentToolContractsDirectories, + assemblyScopedCurrentFirstPartyToolsDirectories, + legacyAssemblyAliases, + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + + if (scan.RequiresToolContractsReference) + { + toolContractsReferenceAssemblyDirectories.Add(assemblyDirectory); + } + + if (scan.RequiresFirstPartyScreenshotReference) + { + firstPartyScreenshotReferenceAssemblyDirectories.Add(assemblyDirectory); + } + + return scan.HasMigrationTarget; + } + + private static FirstPartyScreenshotRequirementScan ScanFastFirstPartyScreenshotRequirement( + string source, + string assemblyDirectory, + HashSet legacyAssemblyDirectories, + HashSet assemblyScopedCurrentToolContractsDirectories, + HashSet assemblyScopedCurrentFirstPartyToolsDirectories, + string[] legacyAssemblyAliases, + string[] currentFirstPartyToolsAssemblyAliases, + string[] assemblyDeclaredTypeNames) + { + bool hasLegacyEditorWindowCaptureUtilitySourceTarget = + HasLegacyEditorWindowCaptureUtilitySourceTarget( + source, + assemblyDirectory, + legacyAssemblyDirectories, + assemblyScopedCurrentToolContractsDirectories, + assemblyScopedCurrentFirstPartyToolsDirectories, + legacyAssemblyAliases, + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + bool hasLegacyScreenshotSourceTarget = HasLegacyScreenshotSourceTarget( + source, + assemblyDirectory, + legacyAssemblyDirectories, + assemblyScopedCurrentToolContractsDirectories, + legacyAssemblyAliases, + assemblyDeclaredTypeNames, + hasLegacyEditorWindowCaptureUtilitySourceTarget); + bool hasCurrentScreenshotReferenceRequirement = + ThirdPartyToolMigrationRules.ContainsCurrentFirstPartyScreenshotApiForAssembly( + source, + assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + bool hasCurrentFirstPartyToolsContractSourceTarget = + ThirdPartyToolMigrationRules.ContainsCurrentFirstPartyScreenshotContractApiForAssembly( + source, + assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + bool hasCurrentRenderingCaptureSourceTarget = + ThirdPartyToolMigrationRules.ContainsCurrentCaptureGameRenderingDeconstructionMigrationForAssembly( + source, + assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + bool hasTimeoutMigration = HasLegacyEditorWindowCaptureUtilityTimeoutMigration( + source, + assemblyDirectory, + legacyAssemblyDirectories, + assemblyScopedCurrentToolContractsDirectories, + assemblyScopedCurrentFirstPartyToolsDirectories, + legacyAssemblyAliases, + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + return new FirstPartyScreenshotRequirementScan( + hasLegacyScreenshotSourceTarget || + hasCurrentFirstPartyToolsContractSourceTarget || + hasCurrentScreenshotReferenceRequirement || + hasTimeoutMigration, + hasCurrentRenderingCaptureSourceTarget || + hasCurrentScreenshotReferenceRequirement, + hasLegacyScreenshotSourceTarget || + hasCurrentRenderingCaptureSourceTarget || + hasCurrentFirstPartyToolsContractSourceTarget || + hasTimeoutMigration); + } + + private static bool HasLegacyEditorWindowCaptureUtilitySourceTarget( + string source, + string assemblyDirectory, + HashSet legacyAssemblyDirectories, + HashSet assemblyScopedCurrentToolContractsDirectories, + HashSet assemblyScopedCurrentFirstPartyToolsDirectories, + string[] legacyAssemblyAliases, + string[] currentFirstPartyToolsAssemblyAliases, + string[] assemblyDeclaredTypeNames) + { + return ThirdPartyToolMigrationRules.ContainsLegacyEditorWindowCaptureUtilityMigrationForAssembly( + source, + legacyAssemblyDirectories.Contains(assemblyDirectory), + assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory), + assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), + legacyAssemblyAliases, + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + } + + private static bool HasLegacyScreenshotSourceTarget( + string source, + string assemblyDirectory, + HashSet legacyAssemblyDirectories, + HashSet assemblyScopedCurrentToolContractsDirectories, + string[] legacyAssemblyAliases, + string[] assemblyDeclaredTypeNames, + bool hasLegacyEditorWindowCaptureUtilitySourceTarget) + { + return ThirdPartyToolMigrationRules.ContainsLegacyFirstPartyScreenshotApiForAssembly( + source, + legacyAssemblyDirectories.Contains(assemblyDirectory) || + assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory) || + ThirdPartyToolMigrationRules.ContainsCurrentToolContractsApi(source), + legacyAssemblyAliases, + assemblyDeclaredTypeNames) || + hasLegacyEditorWindowCaptureUtilitySourceTarget; + } + + private static bool HasLegacyEditorWindowCaptureUtilityTimeoutMigration( + string source, + string assemblyDirectory, + HashSet legacyAssemblyDirectories, + HashSet assemblyScopedCurrentToolContractsDirectories, + HashSet assemblyScopedCurrentFirstPartyToolsDirectories, + string[] legacyAssemblyAliases, + string[] currentFirstPartyToolsAssemblyAliases, + string[] assemblyDeclaredTypeNames) + { + return ThirdPartyToolMigrationRules.ContainsLegacyEditorWindowCaptureUtilityTimeoutMigrationForAssembly( + source, + legacyAssemblyDirectories.Contains(assemblyDirectory), + assemblyScopedCurrentToolContractsDirectories.Contains(assemblyDirectory), + assemblyScopedCurrentFirstPartyToolsDirectories.Contains(assemblyDirectory), + legacyAssemblyAliases, + currentFirstPartyToolsAssemblyAliases, + assemblyDeclaredTypeNames); + } + + private readonly struct FirstPartyScreenshotRequirementScan + { + public FirstPartyScreenshotRequirementScan( + bool requiresToolContractsReference, + bool requiresFirstPartyScreenshotReference, + bool hasMigrationTarget) + { + RequiresToolContractsReference = requiresToolContractsReference; + RequiresFirstPartyScreenshotReference = requiresFirstPartyScreenshotReference; + HasMigrationTarget = hasMigrationTarget; + } + + public bool RequiresToolContractsReference { get; } + public bool RequiresFirstPartyScreenshotReference { get; } + public bool HasMigrationTarget { get; } + } + } +} diff --git a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs.meta b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs.meta new file mode 100644 index 0000000000..97e53881f0 --- /dev/null +++ b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29228dda351942e4862e78d3fa5933f4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationTargetScanner.cs b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationTargetScanner.cs index 34a328130d..4a0ecb5cd7 100644 --- a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationTargetScanner.cs +++ b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationTargetScanner.cs @@ -11,6 +11,7 @@ using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationAssemblyReferenceResolver; using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationAsmdefMigrationRequirementResolver; using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationFastAssemblyRequirementCollector; +using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationFastFirstPartyScreenshotRequirementCollector; using static io.github.hatayama.UnityCliLoop.Infrastructure.ThirdPartyToolMigrationFastSourceTargetDetector; namespace io.github.hatayama.UnityCliLoop.Infrastructure