From 160997748f311670b11fb3148b2070cd6e3af915 Mon Sep 17 00:00:00 2001 From: Masamichi Hatayama Date: Sun, 26 Jul 2026 02:18:23 +0900 Subject: [PATCH 1/8] fix: Classify Assets asmdef and compiler-pattern symbols accurately (#2000) Co-authored-by: Cursor --- .../DeadCodeScannerTests.cs | 158 ++++++++++++++++++ .../AsmdefWorkspaceBuilder.cs | 90 ++++++++-- .../UnityKeeperClassifier.cs | 79 +++++++++ 3 files changed, 313 insertions(+), 14 deletions(-) diff --git a/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs b/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs index 67750a1a5e..320ab1f038 100644 --- a/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs +++ b/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs @@ -151,12 +151,103 @@ public async Task ScanAsync_WhenIncludingKeptSymbols_ShouldReportUnityToolAsKept && issue.FullName.Contains("UsedProductionApi", StringComparison.Ordinal)), Is.True); } + /// + /// Verifies that an internal production member referenced through InternalsVisibleTo from an + /// Assets asmdef is classified as TestOnly instead of PublicCandidate. + /// + [Test] + public async Task ScanAsync_WhenInternalMemberIsReferencedViaAssetsAsmdefInternalsVisibleTo_ShouldReportTestOnly() + { + DeadCodeScanner scanner = new(); + ScanOptions options = CreatePublicScopeOptions(_rootPath, includeKept: false); + + System.Collections.Generic.IReadOnlyList issues = + await scanner.ScanAsync(options, CancellationToken.None); + + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.TestOnly + && issue.FullName.Contains("CreateForTesting", StringComparison.Ordinal)), Is.True); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("CreateForTesting", StringComparison.Ordinal)), Is.False); + } + + /// + /// Verifies that compiler-bound awaiter members are kept as KeptByUnityOrReflection + /// and are not reported as PublicCandidate. + /// + [Test] + public async Task ScanAsync_WhenAwaitPatternMembersHaveNoDirectReferences_ShouldReportKeptAndNotPublicCandidate() + { + DeadCodeScanner scanner = new(); + ScanOptions options = CreatePublicScopeOptions(_rootPath, includeKept: true); + + System.Collections.Generic.IReadOnlyList issues = + await scanner.ScanAsync(options, CancellationToken.None); + + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.KeptByUnityOrReflection + && issue.FullName.Contains("SampleAwaitable.Awaiter.IsCompleted", StringComparison.Ordinal)), Is.True); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.KeptByUnityOrReflection + && issue.FullName.Contains("SampleAwaitable.Awaiter.GetResult", StringComparison.Ordinal)), Is.True); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.KeptByUnityOrReflection + && issue.FullName.Contains("SampleAwaitable.GetAwaiter", StringComparison.Ordinal)), Is.True); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("SampleAwaitable.Awaiter.IsCompleted", StringComparison.Ordinal)), Is.False); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("SampleAwaitable.Awaiter.GetResult", StringComparison.Ordinal)), Is.False); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("SampleAwaitable.GetAwaiter", StringComparison.Ordinal)), Is.False); + } + + /// + /// Verifies that the IsExternalInit polyfill type is kept as KeptByUnityOrReflection + /// and is not reported as PublicCandidate. + /// + [Test] + public async Task ScanAsync_WhenIsExternalInitPolyfillHasNoDirectReferences_ShouldReportKeptAndNotPublicCandidate() + { + DeadCodeScanner scanner = new(); + ScanOptions options = CreatePublicScopeOptions(_rootPath, includeKept: true); + + System.Collections.Generic.IReadOnlyList issues = + await scanner.ScanAsync(options, CancellationToken.None); + + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.KeptByUnityOrReflection + && issue.FullName.Contains("IsExternalInit", StringComparison.Ordinal)), Is.True); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("IsExternalInit", StringComparison.Ordinal)), Is.False); + } + + private static ScanOptions CreatePublicScopeOptions(string rootPath, bool includeKept) + { + return new ScanOptions( + rootPath, + ScanScope.Public, + includeTypes: true, + includeMembers: true, + includeLocals: false, + includeTestOnly: true, + includeKept, + ReportFormat.Table, + failOnHighConfidence: false); + } + private static void CreateSampleRepository(string rootPath) { string packageDirectory = Path.Combine(rootPath, "Packages", "src", "Editor", "Sample"); string assetsDirectory = Path.Combine(rootPath, "Assets", "Tests"); + string assetsTestAsmdefDirectory = Path.Combine(assetsDirectory, "Editor"); Directory.CreateDirectory(packageDirectory); Directory.CreateDirectory(assetsDirectory); + Directory.CreateDirectory(assetsTestAsmdefDirectory); WriteFile( Path.Combine(packageDirectory, "Sample.asmdef"), @@ -178,6 +269,9 @@ private static void CreateSampleRepository(string rootPath) Path.Combine(packageDirectory, "SampleCode.cs"), """ using System; + using System.Runtime.CompilerServices; + + [assembly: InternalsVisibleTo("Sample.Tests")] namespace Sample { @@ -227,6 +321,40 @@ public sealed class UnreferencedPublicApi public sealed class TestOnlyFactory { } + + public sealed class InternalVisibleApi + { + internal static int CreateForTesting() + { + return 1; + } + } + + public struct SampleAwaitable + { + public Awaiter GetAwaiter() => new(); + + public struct Awaiter : INotifyCompletion + { + public bool IsCompleted => true; + + public void GetResult() + { + } + + public void OnCompleted(Action continuation) + { + continuation(); + } + } + } + } + + namespace System.Runtime.CompilerServices + { + public sealed class IsExternalInit + { + } } """); WriteFile( @@ -243,6 +371,36 @@ public object Create() } } """); + WriteFile( + Path.Combine(assetsTestAsmdefDirectory, "Sample.Tests.asmdef"), + """ + { + "name": "Sample.Tests", + "references": ["Sample.Editor"], + "includePlatforms": ["Editor"], + "versionDefines": [] + } + """); + WriteFile( + Path.Combine(assetsTestAsmdefDirectory, "Sample.Tests.asmdef.meta"), + """ + fileFormatVersion: 2 + guid: 22222222222222222222222222222222 + """); + WriteFile( + Path.Combine(assetsTestAsmdefDirectory, "SampleInternalUsage.cs"), + """ + namespace SampleConsumer + { + public sealed class SampleInternalUsage + { + public int Create() + { + return Sample.InternalVisibleApi.CreateForTesting(); + } + } + } + """); } private static void WriteFile(string path, string content) diff --git a/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs b/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs index 7bc8d5b5dd..026a1ac176 100644 --- a/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs +++ b/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs @@ -28,7 +28,12 @@ public sealed class AsmdefWorkspaceBuilder public WorkspaceBuildResult Build(string rootPath) { string editorRoot = Path.Combine(rootPath, "Packages", "src", "Editor"); - IReadOnlyList asmdefs = LoadAsmdefs(editorRoot); + string assetsRoot = Path.Combine(rootPath, "Assets"); + IReadOnlyList productionAsmdefs = LoadAsmdefs(editorRoot); + IReadOnlyList assetsAsmdefs = Directory.Exists(assetsRoot) + ? LoadAsmdefs(assetsRoot) + : Array.Empty(); + Dictionary projectIdsByName = new(StringComparer.Ordinal); Dictionary projectIdsByGuid = new(StringComparer.OrdinalIgnoreCase); Dictionary projectInfoById = new(); @@ -36,8 +41,56 @@ public WorkspaceBuildResult Build(string rootPath) Solution solution = workspace.CurrentSolution; ImmutableArray metadataReferences = CreateMetadataReferences(); + solution = AddAsmdefProjects( + solution, + productionAsmdefs, + isProduction: true, + projectIdsByName, + projectIdsByGuid, + projectInfoById, + metadataReferences); + ProjectId[] productionProjectIds = projectInfoById + .Where(pair => pair.Value.IsProduction) + .Select(pair => pair.Key) + .ToArray(); + + solution = AddAsmdefProjects( + solution, + assetsAsmdefs, + isProduction: false, + projectIdsByName, + projectIdsByGuid, + projectInfoById, + metadataReferences); + + AsmdefProjectInfo[] allAsmdefs = productionAsmdefs.Concat(assetsAsmdefs).ToArray(); + solution = AddAsmdefProjectReferences(solution, allAsmdefs, projectIdsByName, projectIdsByGuid); + solution = AddOrphanAssetsProject( + assetsRoot, + assetsAsmdefs, + solution, + productionProjectIds, + projectInfoById, + metadataReferences); + return new WorkspaceBuildResult(solution, projectInfoById); + } + + private static Solution AddAsmdefProjects( + Solution solution, + IReadOnlyList asmdefs, + bool isProduction, + Dictionary projectIdsByName, + Dictionary projectIdsByGuid, + Dictionary projectInfoById, + ImmutableArray metadataReferences) + { foreach (AsmdefProjectInfo asmdef in asmdefs) { + if (projectIdsByName.ContainsKey(asmdef.Name)) + { + throw new InvalidOperationException($"Duplicate asmdef assembly name: {asmdef.Name}"); + } + ProjectId projectId = ProjectId.CreateNewId(asmdef.Name); projectIdsByName[asmdef.Name] = projectId; string guid = ReadAsmdefGuid(asmdef.DirectoryPath, asmdef.Name); @@ -57,7 +110,7 @@ public WorkspaceBuildResult Build(string rootPath) metadataReferences: metadataReferences); solution = solution.AddProject(projectInfo); - projectInfoById[projectId] = new ProjectAnalysisInfo(projectId, isProduction: true); + projectInfoById[projectId] = new ProjectAnalysisInfo(projectId, isProduction); foreach (string sourceFile in asmdef.SourceFiles) { @@ -67,14 +120,17 @@ public WorkspaceBuildResult Build(string rootPath) } } - solution = AddAsmdefProjectReferences(solution, asmdefs, projectIdsByName, projectIdsByGuid); - solution = AddAssetsProject(rootPath, solution, projectIdsByName.Values.ToArray(), projectInfoById, metadataReferences); - return new WorkspaceBuildResult(solution, projectInfoById); + return solution; } - private static IReadOnlyList LoadAsmdefs(string editorRoot) + private static IReadOnlyList LoadAsmdefs(string rootDirectory) { - string[] asmdefPaths = Directory.GetFiles(editorRoot, "*.asmdef", SearchOption.AllDirectories) + if (!Directory.Exists(rootDirectory)) + { + return Array.Empty(); + } + + string[] asmdefPaths = Directory.GetFiles(rootDirectory, "*.asmdef", SearchOption.AllDirectories) .OrderBy(path => path, StringComparer.Ordinal) .ToArray(); List projects = new(); @@ -85,7 +141,7 @@ private static IReadOnlyList LoadAsmdefs(string editorRoot) foreach (string asmdefPath in asmdefPaths) { AsmdefJson json = ReadAsmdefJson(asmdefPath); - string directoryPath = Path.GetDirectoryName(asmdefPath) ?? editorRoot; + string directoryPath = Path.GetDirectoryName(asmdefPath) ?? rootDirectory; string[] sourceFiles = Directory.GetFiles(directoryPath, "*.cs", SearchOption.AllDirectories) .Where(path => IsOwnedByAsmdefDirectory(path, directoryPath, asmdefDirectories)) .OrderBy(path => path, StringComparer.Ordinal) @@ -191,23 +247,29 @@ private static Solution AddAsmdefProjectReferences( return projectIdsByName.TryGetValue(reference, out ProjectId? namedProjectId) ? namedProjectId : null; } - private static Solution AddAssetsProject( - string rootPath, + // Why: Unity puts leftover Assets scripts into Assembly-CSharp(-Editor); keep that fallback so + // files outside any Assets asmdef still contribute non-production references. + private static Solution AddOrphanAssetsProject( + string assetsRoot, + IReadOnlyList assetsAsmdefs, Solution solution, ProjectId[] productionProjectIds, Dictionary projectInfoById, ImmutableArray metadataReferences) { - string assetsRoot = Path.Combine(rootPath, "Assets"); if (!Directory.Exists(assetsRoot)) { return solution; } - string[] sourceFiles = Directory.GetFiles(assetsRoot, "*.cs", SearchOption.AllDirectories) + HashSet ownedSourceFiles = assetsAsmdefs + .SelectMany(asmdef => asmdef.SourceFiles) + .ToHashSet(StringComparer.Ordinal); + string[] orphanSourceFiles = Directory.GetFiles(assetsRoot, "*.cs", SearchOption.AllDirectories) + .Where(path => !ownedSourceFiles.Contains(path)) .OrderBy(path => path, StringComparer.Ordinal) .ToArray(); - if (sourceFiles.Length == 0) + if (orphanSourceFiles.Length == 0) { return solution; } @@ -230,7 +292,7 @@ private static Solution AddAssetsProject( solution = solution.AddProjectReference(projectId, new ProjectReference(productionProjectId)); } - foreach (string sourceFile in sourceFiles) + foreach (string sourceFile in orphanSourceFiles) { DocumentId documentId = DocumentId.CreateNewId(projectId, sourceFile); SourceText sourceText = SourceText.From(File.ReadAllText(sourceFile)); diff --git a/tools/UnityCliLoop.DeadCodeScanner/UnityKeeperClassifier.cs b/tools/UnityCliLoop.DeadCodeScanner/UnityKeeperClassifier.cs index 54623cac64..1ddb89b116 100644 --- a/tools/UnityCliLoop.DeadCodeScanner/UnityKeeperClassifier.cs +++ b/tools/UnityCliLoop.DeadCodeScanner/UnityKeeperClassifier.cs @@ -59,6 +59,14 @@ public static class UnityKeeperClassifier "OnValidate" }; + private static readonly HashSet AwaiterMemberNames = new(StringComparer.Ordinal) + { + "IsCompleted", + "GetResult", + "OnCompleted", + "UnsafeOnCompleted" + }; + public static KeeperDecision Classify(ISymbol symbol) { string attributeReason = FindKeptAttributeReason(symbol); @@ -67,6 +75,22 @@ public static KeeperDecision Classify(ISymbol symbol) return KeeperDecision.Keep(attributeReason); } + // Why: the C# compiler resolves init accessors by this exact type name, so Roslyn + // reference search never sees call sites even though deleting the polyfill breaks builds. + if (IsCompilerRequiredIsExternalInit(symbol)) + { + return KeeperDecision.Keep( + "Type is the compiler-required IsExternalInit polyfill for init accessors."); + } + + // Why: await expressions bind GetAwaiter/IsCompleted/GetResult/OnCompleted by name; + // SymbolFinder therefore reports zero references for these members. + if (IsCompilerRequiredAwaitPatternMember(symbol)) + { + return KeeperDecision.Keep( + "Member is part of the compiler-bound awaiter pattern."); + } + if (symbol is INamedTypeSymbol namedType && HasKeptBaseType(namedType)) { return KeeperDecision.Keep("Type derives from a Unity entry-point base class."); @@ -98,6 +122,61 @@ public static KeeperDecision Classify(ISymbol symbol) return KeeperDecision.Scan(); } + private static bool IsCompilerRequiredIsExternalInit(ISymbol symbol) + { + if (symbol is not INamedTypeSymbol typeSymbol) + { + return false; + } + + if (!string.Equals(typeSymbol.Name, "IsExternalInit", StringComparison.Ordinal)) + { + return false; + } + + string containingNamespace = typeSymbol.ContainingNamespace?.ToDisplayString() ?? string.Empty; + return string.Equals( + containingNamespace, + "System.Runtime.CompilerServices", + StringComparison.Ordinal); + } + + private static bool IsCompilerRequiredAwaitPatternMember(ISymbol symbol) + { + if (symbol is IMethodSymbol getAwaiterMethod + && string.Equals(getAwaiterMethod.Name, "GetAwaiter", StringComparison.Ordinal)) + { + return IsAwaiterType(getAwaiterMethod.ReturnType); + } + + if (!AwaiterMemberNames.Contains(symbol.Name) || symbol.ContainingType == null) + { + return false; + } + + return IsAwaiterType(symbol.ContainingType); + } + + private static bool IsAwaiterType(ITypeSymbol typeSymbol) + { + return typeSymbol.AllInterfaces.Any(IsCompilerServicesAwaiterInterface); + } + + private static bool IsCompilerServicesAwaiterInterface(INamedTypeSymbol interfaceType) + { + if (!string.Equals(interfaceType.Name, "INotifyCompletion", StringComparison.Ordinal) + && !string.Equals(interfaceType.Name, "ICriticalNotifyCompletion", StringComparison.Ordinal)) + { + return false; + } + + string containingNamespace = interfaceType.ContainingNamespace?.ToDisplayString() ?? string.Empty; + return string.Equals( + containingNamespace, + "System.Runtime.CompilerServices", + StringComparison.Ordinal); + } + private static string FindKeptAttributeReason(ISymbol symbol) { foreach (AttributeData attribute in symbol.GetAttributes()) From 75ba9ef4b95f745408f80434292554da5240f55e Mon Sep 17 00:00:00 2001 From: Masamichi Hatayama Date: Sun, 26 Jul 2026 02:26:16 +0900 Subject: [PATCH 2/8] fix: Include Packages/src Runtime asmdefs in dead-code production scan (#2002) Co-authored-by: Cursor --- .../DeadCodeScannerTests.cs | 86 ++++++++++++++++++- .../AsmdefWorkspaceBuilder.cs | 6 +- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs b/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs index 320ab1f038..4b1005326b 100644 --- a/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs +++ b/tests/UnityCliLoop.DeadCodeScanner.Tests/DeadCodeScannerTests.cs @@ -172,6 +172,49 @@ public async Task ScanAsync_WhenInternalMemberIsReferencedViaAssetsAsmdefInterna && issue.FullName.Contains("CreateForTesting", StringComparison.Ordinal)), Is.False); } + /// + /// Verifies that Packages/src/Runtime asmdefs are loaded as production and scanned for + /// unreferenced public symbols. + /// + [Test] + public async Task ScanAsync_WhenRuntimeAsmdefDefinesUnreferencedPublicType_ShouldReportPublicCandidate() + { + DeadCodeScanner scanner = new(); + ScanOptions options = CreatePublicScopeOptions(_rootPath, includeKept: false); + + System.Collections.Generic.IReadOnlyList issues = + await scanner.ScanAsync(options, CancellationToken.None); + + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.SymbolKind == "type" + && issue.FullName.Contains("UnreferencedRuntimeApi", StringComparison.Ordinal) + && issue.AssemblyName == "Sample.Runtime"), Is.True); + } + + /// + /// Verifies that a Runtime internal member referenced from an Editor assembly through + /// InternalsVisibleTo is not reported as any finding. + /// + [Test] + public async Task ScanAsync_WhenRuntimeInternalMemberIsReferencedFromEditorViaInternalsVisibleTo_ShouldNotReportFinding() + { + DeadCodeScanner scanner = new(); + ScanOptions options = CreatePublicScopeOptions(_rootPath, includeKept: false); + + System.Collections.Generic.IReadOnlyList issues = + await scanner.ScanAsync(options, CancellationToken.None); + + Assert.That(issues.Any(issue => + issue.FullName.Contains("RuntimeInternalUsedByEditor", StringComparison.Ordinal)), Is.False); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.PublicCandidate + && issue.FullName.Contains("RuntimeInternalUsedByEditor", StringComparison.Ordinal)), Is.False); + Assert.That(issues.Any(issue => + issue.Category == DeadCodeCategory.TestOnly + && issue.FullName.Contains("RuntimeInternalUsedByEditor", StringComparison.Ordinal)), Is.False); + } + /// /// Verifies that compiler-bound awaiter members are kept as KeptByUnityOrReflection /// and are not reported as PublicCandidate. @@ -243,9 +286,11 @@ private static ScanOptions CreatePublicScopeOptions(string rootPath, bool includ private static void CreateSampleRepository(string rootPath) { string packageDirectory = Path.Combine(rootPath, "Packages", "src", "Editor", "Sample"); + string runtimeDirectory = Path.Combine(rootPath, "Packages", "src", "Runtime", "SampleRuntime"); string assetsDirectory = Path.Combine(rootPath, "Assets", "Tests"); string assetsTestAsmdefDirectory = Path.Combine(assetsDirectory, "Editor"); Directory.CreateDirectory(packageDirectory); + Directory.CreateDirectory(runtimeDirectory); Directory.CreateDirectory(assetsDirectory); Directory.CreateDirectory(assetsTestAsmdefDirectory); @@ -254,7 +299,7 @@ private static void CreateSampleRepository(string rootPath) """ { "name": "Sample.Editor", - "references": [], + "references": ["GUID:33333333333333333333333333333333"], "includePlatforms": ["Editor"], "versionDefines": [] } @@ -298,6 +343,7 @@ public void Caller() usedField++; int unusedLocal = 1; UsedPrivateMethod(); + usedField += Sample.Runtime.RuntimeInternalApi.RuntimeInternalUsedByEditor(); } private void UsedPrivateMethod() @@ -357,6 +403,44 @@ public sealed class IsExternalInit } } """); + WriteFile( + Path.Combine(runtimeDirectory, "Sample.Runtime.asmdef"), + """ + { + "name": "Sample.Runtime", + "references": [], + "includePlatforms": [], + "versionDefines": [] + } + """); + WriteFile( + Path.Combine(runtimeDirectory, "Sample.Runtime.asmdef.meta"), + """ + fileFormatVersion: 2 + guid: 33333333333333333333333333333333 + """); + WriteFile( + Path.Combine(runtimeDirectory, "RuntimeCode.cs"), + """ + using System.Runtime.CompilerServices; + + [assembly: InternalsVisibleTo("Sample.Editor")] + + namespace Sample.Runtime + { + public sealed class UnreferencedRuntimeApi + { + } + + public static class RuntimeInternalApi + { + internal static int RuntimeInternalUsedByEditor() + { + return 1; + } + } + } + """); WriteFile( Path.Combine(assetsDirectory, "SampleAssetUsage.cs"), """ diff --git a/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs b/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs index 026a1ac176..c1c6dff36b 100644 --- a/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs +++ b/tools/UnityCliLoop.DeadCodeScanner/AsmdefWorkspaceBuilder.cs @@ -27,9 +27,11 @@ public sealed class AsmdefWorkspaceBuilder public WorkspaceBuildResult Build(string rootPath) { - string editorRoot = Path.Combine(rootPath, "Packages", "src", "Editor"); + // Why: production code lives under both Editor and Runtime; loading only Editor + // drops Runtime asmdefs so IVT/friend references and Runtime finding coverage break. + string packageSrcRoot = Path.Combine(rootPath, "Packages", "src"); string assetsRoot = Path.Combine(rootPath, "Assets"); - IReadOnlyList productionAsmdefs = LoadAsmdefs(editorRoot); + IReadOnlyList productionAsmdefs = LoadAsmdefs(packageSrcRoot); IReadOnlyList assetsAsmdefs = Directory.Exists(assetsRoot) ? LoadAsmdefs(assetsRoot) : Array.Empty(); From 0e2c6a86e14d7c0d9afe1bd38e03609cc23c1c93 Mon Sep 17 00:00:00 2001 From: Masamichi Hatayama Date: Sun, 26 Jul 2026 02:44:27 +0900 Subject: [PATCH 3/8] chore: Remove unreferenced internal PublicCandidate members (#2004) Co-authored-by: Cursor --- .../Application/UnityCliLoopToolRegistrar.cs | 10 --- ...hirdPartyToolMigrationApiDetectionRules.cs | 39 ---------- ...dPartyToolMigrationDomainDetectionRules.cs | 37 ---------- .../DynamicCompilationHealthMonitor.cs | 74 +------------------ .../ExecuteDynamicCode/DynamicCodeServices.cs | 5 -- .../SharedRoslynCompilerWorkerHost.cs | 10 --- .../SharedRoslynCompilerWorkerSession.cs | 22 +----- .../TestRunnerApiCancelBridge.cs | 25 ------- .../Application/MouseInputState.cs | 5 -- .../CLI/CliInstallationDetector.cs | 5 -- .../ThirdPartyToolMigrationRules.cs | 18 ----- .../Utils/NodeEnvironmentResolver.cs | 24 ------ .../ThirdPartyToolMigrationWizardWindow.cs | 5 -- .../Shared/SkillsSetupPanelView.cs | 8 -- 14 files changed, 5 insertions(+), 282 deletions(-) diff --git a/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs b/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs index 4616321dc0..cf9770a327 100644 --- a/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs +++ b/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs @@ -142,16 +142,6 @@ internal static void RegisterService(UnityCliLoopToolRegistrarService service) ServiceValue = service ?? throw new ArgumentNullException(nameof(service)); } - internal static void AddToolsChangedHandler(Action handler) - { - Service.OnToolsChanged += handler; - } - - internal static void RemoveToolsChangedHandler(Action handler) - { - Service.OnToolsChanged -= handler; - } - public static UnityCliLoopToolRegistrarService Service { get diff --git a/Packages/src/Editor/Domain/ThirdPartyToolMigrationApiDetectionRules.cs b/Packages/src/Editor/Domain/ThirdPartyToolMigrationApiDetectionRules.cs index 343ebeae47..78cbfdbc6c 100644 --- a/Packages/src/Editor/Domain/ThirdPartyToolMigrationApiDetectionRules.cs +++ b/Packages/src/Editor/Domain/ThirdPartyToolMigrationApiDetectionRules.cs @@ -188,32 +188,6 @@ public static bool ContainsCurrentToolContractsApi(string source) return RegexMatchesCode(source, CurrentToolContractsNamespaceRegex); } - public static bool ContainsLegacyDomainMetadataApi(string source) - { - Debug.Assert(source != null, "source must not be null"); - - return RegexMatchesCode(source, LegacyDomainMetadataRegex) || - ContainsLegacyDomainHelperApiForAssembly( - source, - hasLegacyAssemblySource: ContainsLegacyToolMigrationMarker(source), - legacyAssemblyAliases: Array.Empty()); - } - - public static bool ContainsLegacyDomainHelperApiForAssembly( - string source, - bool hasLegacyAssemblySource, - string[] legacyAssemblyAliases) - { - Debug.Assert(source != null, "source must not be null"); - Debug.Assert(legacyAssemblyAliases != null, "legacyAssemblyAliases must not be null"); - - string[] legacyNamespaceAliases = GetCombinedLegacyNamespaceAliases(source, legacyAssemblyAliases); - return ContainsLegacyDomainHelperReference( - source, - hasLegacyAssemblySource, - legacyNamespaceAliases); - } - public static bool ContainsCurrentDomainMetadataApi(string source) { Debug.Assert(source != null, "source must not be null"); @@ -326,19 +300,6 @@ public static bool ContainsLegacyEditorWindowCaptureUtilityTimeoutMigrationForAs requiresTimeoutArgumentMigration: true); } - public static bool ContainsCurrentFirstPartyScreenshotApi(string source) - { - Debug.Assert(source != null, "source must not be null"); - - bool hasCurrentFirstPartyToolsNamespaceUsage = - RegexMatchesCode(source, CurrentFirstPartyToolsNamespaceRegex); - return ContainsCurrentFirstPartyScreenshotApiForAssembly( - source, - hasCurrentFirstPartyToolsNamespaceUsage, - Array.Empty(), - Array.Empty()); - } - public static bool ContainsCurrentFirstPartyScreenshotApiForAssembly( string source, bool hasAssemblyScopedCurrentFirstPartyToolsUsing, diff --git a/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs b/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs index 45ce468179..32e34f8461 100644 --- a/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs +++ b/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs @@ -158,43 +158,6 @@ public static bool ContainsMigratableUnqualifiedLegacyRegistrarDomainReturn(stri return false; } - public static bool ContainsLegacyDomainHelperReference( - string source, - bool canMigrateBareLegacyDomainHelper, - string[] aliases) - { - Debug.Assert(source != null, "source must not be null"); - Debug.Assert(aliases != null, "aliases must not be null"); - - CodeTextMask codeTextMask = CodeTextMask.Create(source); - foreach (TypeReplacementRule rule in DomainTypeReplacementRules) - { - Regex fullyQualifiedRegex = new( - $@"(?:(?:global::)?{Regex.Escape(LegacyNamespace)}\.){Regex.Escape(rule.LegacyName)}\b", - RegexOptions.Compiled); - if (RegexMatchesCode(source, fullyQualifiedRegex)) - { - return true; - } - - foreach (string alias in aliases) - { - if (ContainsAliasQualifiedName(source, alias, rule.LegacyName)) - { - return true; - } - } - - if (canMigrateBareLegacyDomainHelper && - ContainsLegacyAssemblyScopedTypeName(source, codeTextMask, rule.LegacyName)) - { - return true; - } - } - - return false; - } - public static bool ContainsCurrentDomainHelperApi(string source) { Debug.Assert(source != null, "source must not be null"); diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/DynamicCompilationHealthMonitor.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/DynamicCompilationHealthMonitor.cs index dc0d5979af..c6de905c4b 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/DynamicCompilationHealthMonitor.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/DynamicCompilationHealthMonitor.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Threading; using UnityEngine; using io.github.hatayama.UnityCliLoop.ToolContracts; @@ -13,7 +12,6 @@ public static class DynamicCompilationHealthMonitor { private static readonly object ReportedIssueLock = new(); private static readonly HashSet ReportedIssues = new(System.StringComparer.Ordinal); - private static readonly AsyncLocal ConsoleDiagnosticSource = new(); public static void ReportFastPathUnavailable( string editorPath, @@ -91,11 +89,9 @@ private static void LogErrorOnce( string humanNote, string aiTodo) { - string effectiveIssueKey = CreateEffectiveIssueKey(issueKey); - lock (ReportedIssueLock) { - if (!ReportedIssues.Add(effectiveIssueKey)) + if (!ReportedIssues.Add(issueKey)) { return; } @@ -116,11 +112,9 @@ private static void LogInfoOnce( string message, object context) { - string effectiveIssueKey = CreateEffectiveIssueKey(issueKey); - lock (ReportedIssueLock) { - if (!ReportedIssues.Add(effectiveIssueKey)) + if (!ReportedIssues.Add(issueKey)) { return; } @@ -129,75 +123,17 @@ private static void LogInfoOnce( VibeLogger.LogInfo(operation, message, context); } - private static string CreateEffectiveIssueKey(string issueKey) - { - Debug.Assert(!string.IsNullOrEmpty(issueKey), "issueKey must not be empty"); - - if (string.IsNullOrEmpty(ConsoleDiagnosticSource.Value)) - { - return issueKey; - } - - return $"{issueKey}::source::{ConsoleDiagnosticSource.Value}"; - } - - internal static System.IDisposable UseConsoleDiagnosticSource(string source) - { - if (string.IsNullOrEmpty(source)) - { - return EmptyDisposable.Instance; - } - - string previousSource = ConsoleDiagnosticSource.Value; - ConsoleDiagnosticSource.Value = source; - return new ConsoleDiagnosticSourceScope(previousSource); - } - private static string FormatConsoleErrorMessage(string operation, string message, object context) { Debug.Assert(!string.IsNullOrEmpty(operation), "operation must not be empty"); Debug.Assert(!string.IsNullOrEmpty(message), "message must not be empty"); - string diagnosticSourceLine = string.IsNullOrEmpty(ConsoleDiagnosticSource.Value) - ? string.Empty - : $"\ndiagnostic_source: {ConsoleDiagnosticSource.Value}"; - if (context == null) { - return $"[{UnityCliLoopConstants.PROJECT_NAME}] {message}\noperation: {operation}{diagnosticSourceLine}"; + return $"[{UnityCliLoopConstants.PROJECT_NAME}] {message}\noperation: {operation}"; } - return $"[{UnityCliLoopConstants.PROJECT_NAME}] {message}\noperation: {operation}{diagnosticSourceLine}\ncontext: {context}"; - } - - /// - /// Provides Console Diagnostic Source Scope behavior for Unity CLI Loop. - /// - private sealed class ConsoleDiagnosticSourceScope : System.IDisposable - { - private readonly string _previousSource; - - public ConsoleDiagnosticSourceScope(string previousSource) - { - _previousSource = previousSource; - } - - public void Dispose() - { - ConsoleDiagnosticSource.Value = _previousSource; - } - } - - /// - /// Provides Empty Disposable behavior for Unity CLI Loop. - /// - private sealed class EmptyDisposable : System.IDisposable - { - public static readonly EmptyDisposable Instance = new EmptyDisposable(); - - public void Dispose() - { - } + return $"[{UnityCliLoopConstants.PROJECT_NAME}] {message}\noperation: {operation}\ncontext: {context}"; } internal static void ResetForTests() @@ -206,8 +142,6 @@ internal static void ResetForTests() { ReportedIssues.Clear(); } - - ConsoleDiagnosticSource.Value = null; } } } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs index d008753e1d..9325859646 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs @@ -214,11 +214,6 @@ internal static CompiledCommandEntryPointResolver CommandEntryPointResolver get { return GetRegistry().CommandEntryPointResolver; } } - internal static RegistryDynamicCodeExecutorFactory ExecutorFactory - { - get { return GetRegistry().ExecutorFactory; } - } - internal static IExecuteDynamicCodeUseCase GetExecuteDynamicCodeUseCase() { return GetRegistry().GetExecuteDynamicCodeUseCase(); diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerHost.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerHost.cs index 79a9fd5823..f0cd66908a 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerHost.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerHost.cs @@ -265,11 +265,6 @@ internal static void ShutdownForServerReset() Shutdown(); } - internal static Action SwapCompileRequestSenderForTests(Action sender) - { - return ServiceValue.SwapCompileRequestSenderForTests(sender); - } - internal static Func SwapWorkerAssemblyCompilerForTests( Func compiler) @@ -277,11 +272,6 @@ internal static Func _startProcess = ProcessStartHelper.TryStart; - private Action _sendCompileRequest = SendCompileRequestCore; private Func _compileWorkerAssemblyForTests; private Process _workerProcess; @@ -70,16 +69,6 @@ internal int ResponseTimeoutMilliseconds } } - internal void SetResponseTimeoutMillisecondsForTests(int timeoutMilliseconds) - { - Debug.Assert(timeoutMilliseconds > 0, "timeoutMilliseconds must be positive"); - - _coordination.ExecuteWithStateLock(() => - { - _responseTimeoutMilliseconds = timeoutMilliseconds; - }); - } - internal bool HasLiveProcessLocked() { AssertStateLockHeld(); @@ -114,7 +103,7 @@ internal bool StartProcessLocked(ProcessStartInfo startInfo) internal void SendCompileRequestLocked(string requestFilePath) { AssertStateLockHeld(); - _sendCompileRequest(_workerProcess, requestFilePath); + SendCompileRequestCore(_workerProcess, requestFilePath); } internal StreamReader GetOutputReaderLocked() @@ -332,15 +321,6 @@ internal Func SwapProcessStarterForTests( return previous; } - internal Action SwapCompileRequestSenderForTests(Action sender) - { - Debug.Assert(sender != null, "sender must not be null"); - - Action previous = _sendCompileRequest; - _sendCompileRequest = sender; - return previous; - } - internal Func SwapWorkerAssemblyCompilerForTests( Func compiler) diff --git a/Packages/src/Editor/FirstPartyTools/RunTests/TestFramework/TestRunnerApiCancelBridge.cs b/Packages/src/Editor/FirstPartyTools/RunTests/TestFramework/TestRunnerApiCancelBridge.cs index 71901a1865..c04e63dfeb 100644 --- a/Packages/src/Editor/FirstPartyTools/RunTests/TestFramework/TestRunnerApiCancelBridge.cs +++ b/Packages/src/Editor/FirstPartyTools/RunTests/TestFramework/TestRunnerApiCancelBridge.cs @@ -17,21 +17,6 @@ internal static class TestRunnerApiCancelBridge private static volatile bool _resolved; private static MethodInfo _cancelTestRunMethod; private static MethodInfo _isRunActiveMethod; - private static string _resolveLog; - - /// - /// Resets cached lookup state for unit tests. - /// - internal static void ResetResolvedStateForTests() - { - lock (ResolveLock) - { - _resolved = false; - _cancelTestRunMethod = null; - _isRunActiveMethod = null; - _resolveLog = null; - } - } /// /// True when CancelTestRun(string) was resolved. @@ -57,15 +42,6 @@ internal static bool HasIsRunActive } } - internal static string ResolveLogForTests - { - get - { - EnsureResolved(); - return _resolveLog; - } - } - /// /// Invokes CancelTestRun(guid) when available. Returns false when unavailable or invoke fails. /// @@ -117,7 +93,6 @@ internal static void EnsureResolved() TestRunnerApiCancelMethodLookup.Resolve(typeof(TestRunnerApi)); _cancelTestRunMethod = cancel; _isRunActiveMethod = isRunActive; - _resolveLog = log; _resolved = true; if (!string.IsNullOrEmpty(log)) diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs index a51dd88984..994255ea9b 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs @@ -278,11 +278,6 @@ public static void ReleaseAllButtons() { ServiceValue.ReleaseAllButtons(); } - - internal static ButtonControl GetButtonControl(Mouse mouse, RuntimeMouseButton button) - { - return ServiceValue.GetButtonControl(mouse, button); - } } } #endif diff --git a/Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs b/Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs index 6168cc7965..c0ab2c177a 100644 --- a/Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs +++ b/Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs @@ -140,11 +140,6 @@ private static Task DetectCliInstallationAsync(Cancell return Task.Run(() => DetectCliInstallationBlocking(platform, ct), ct); } - internal static string DetectCliVersionBlocking(RuntimePlatform platform, CancellationToken ct) - { - return DetectCliInstallationBlocking(platform, ct).Version; - } - internal static CliInstallationDetection DetectCliInstallationBlocking(RuntimePlatform platform, CancellationToken ct) { CliInstallationDetection packageOwnedDetection = DetectPackageOwnedCliInstallationBlocking(platform, ct); diff --git a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationRules.cs b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationRules.cs index c9861f90cd..313c832abb 100644 --- a/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationRules.cs +++ b/Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationRules.cs @@ -138,19 +138,6 @@ internal static bool ContainsCurrentToolContractsApi(string source) return ThirdPartyToolMigrationApiDetectionRules.ContainsCurrentToolContractsApi(source); } - internal static bool ContainsLegacyDomainMetadataApi(string source) - { - return ThirdPartyToolMigrationApiDetectionRules.ContainsLegacyDomainMetadataApi(source); - } - - internal static bool ContainsLegacyDomainHelperApiForAssembly( - string source, - bool hasLegacyAssemblySource, - string[] legacyAssemblyAliases) - { - return ThirdPartyToolMigrationApiDetectionRules.ContainsLegacyDomainHelperApiForAssembly(source, hasLegacyAssemblySource, legacyAssemblyAliases); - } - internal static bool ContainsCurrentDomainMetadataApi(string source) { return ThirdPartyToolMigrationApiDetectionRules.ContainsCurrentDomainMetadataApi(source); @@ -205,11 +192,6 @@ internal static bool ContainsLegacyEditorWindowCaptureUtilityTimeoutMigrationFor return ThirdPartyToolMigrationApiDetectionRules.ContainsLegacyEditorWindowCaptureUtilityTimeoutMigrationForAssembly(source, hasLegacyAssemblySource, hasAssemblyScopedCurrentToolContractsUsing, hasAssemblyScopedCurrentFirstPartyToolsUsing, legacyAssemblyAliases, currentFirstPartyToolsAssemblyAliases, assemblyDeclaredTypeNames); } - internal static bool ContainsCurrentFirstPartyScreenshotApi(string source) - { - return ThirdPartyToolMigrationApiDetectionRules.ContainsCurrentFirstPartyScreenshotApi(source); - } - internal static bool ContainsCurrentFirstPartyScreenshotApiForAssembly( string source, bool hasAssemblyScopedCurrentFirstPartyToolsUsing, diff --git a/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs b/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs index 5fc1ab4d3c..b4c1d7d38f 100644 --- a/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs +++ b/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs @@ -177,8 +177,6 @@ private static string ExecuteAndGetOutput(ProcessStartInfo startInfo) return null; } - private const string PATH_START_MARKER = "__PATH_START__"; - private const string PATH_END_MARKER = "__PATH_END__"; private const string WHICH_START_MARKER = "__WHICH_START__"; private const string WHICH_END_MARKER = "__WHICH_END__"; private const string POSIX_FALLBACK_SHELL_PATH = "/bin/sh"; @@ -187,28 +185,6 @@ private static string ExecuteAndGetOutput(ProcessStartInfo startInfo) private const string DIRECTORY_SERVICE_USER_SHELL_ATTRIBUTE = "UserShell"; private const string DIRECTORY_SERVICE_USER_SHELL_PREFIX = DIRECTORY_SERVICE_USER_SHELL_ATTRIBUTE + ":"; - // Uses markers to extract PATH value, ignoring any banner/echo output from shell startup files - internal static string GetLoginShellPathAtPlatform(RuntimePlatform platform) - { - if (IsWindowsEditor(platform)) - { - return null; - } - - string shell = GetUserShell(); - ProcessStartInfo startInfo = new() { - FileName = shell, - Arguments = "-l -i -c \"echo " + PATH_START_MARKER + "; printenv PATH; echo " + PATH_END_MARKER + "\"", - UseShellExecute = false, - RedirectStandardOutput = true, - RedirectStandardError = true, - CreateNoWindow = true - }; - - string output = ExecuteAndGetOutput(startInfo); - return ExtractBetweenMarkers(output, PATH_START_MARKER, PATH_END_MARKER); - } - internal static string ExtractBetweenMarkers(string output, string startMarker, string endMarker) { if (string.IsNullOrEmpty(output)) diff --git a/Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs b/Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs index 2eae55a809..0d18207e9b 100644 --- a/Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs +++ b/Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs @@ -176,11 +176,6 @@ internal static bool ShouldRemoveMigrationSkill(SkillInstallState installState) || installState == SkillInstallState.Outdated; } - internal static bool HasFiniteSize(Vector2 size) - { - return ThirdPartyToolMigrationWizardWindowResizer.HasFiniteSize(size); - } - internal static bool ShouldReportMigrationProgress( long lastReportTimestamp, long currentTimestamp, diff --git a/Packages/src/Editor/Presentation/Shared/SkillsSetupPanelView.cs b/Packages/src/Editor/Presentation/Shared/SkillsSetupPanelView.cs index 068c1acdc0..7733d78ca9 100644 --- a/Packages/src/Editor/Presentation/Shared/SkillsSetupPanelView.cs +++ b/Packages/src/Editor/Presentation/Shared/SkillsSetupPanelView.cs @@ -21,7 +21,6 @@ internal sealed class SkillsSetupPanelView private readonly Foldout _installSpecificTargetFoldout; private readonly VisualElement _groupSkillsRow; private readonly Toggle _groupSkillsToggle; - private readonly Label _groupSkillsLabel; private readonly EnumField _skillsTargetField; private readonly Button _refreshSkillsStateButton; private readonly Button _installSelectedSkillsButton; @@ -35,10 +34,6 @@ internal sealed class SkillsSetupPanelView internal event System.Action OnTargetChanged; internal event System.Action OnGroupSkillsChanged; - internal Toggle GroupSkillsToggle => _groupSkillsToggle; - internal Label GroupSkillsLabel => _groupSkillsLabel; - internal VisualElement GroupSkillsRow => _groupSkillsRow; - internal SkillsSetupPanelView(VisualElement panelRoot, Button refreshSkillsStateButton) { Debug.Assert(panelRoot != null, "panelRoot must not be null"); @@ -55,7 +50,6 @@ internal SkillsSetupPanelView(VisualElement panelRoot, Button refreshSkillsState _installSpecificTargetFoldout = root.Q("install-specific-target-foldout"); _groupSkillsRow = root.Q("group-skills-row"); _groupSkillsToggle = root.Q("group-skills-toggle"); - _groupSkillsLabel = root.Q public enum AssemblyLoadingMode { - /// Reference only selected assemblies - SelectiveReference, - /// Add all assemblies AllAssemblies } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/CompilationResult.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/CompilationResult.cs index 84496c6e89..e22fa95522 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/CompilationResult.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/CompilationResult.cs @@ -63,12 +63,6 @@ public enum CompilationFailureReason None, /// Compilation Error - CompilationError, - - /// Dynamic Assembly Addition Failed - DynamicAssemblyFailed, - - /// Using Statement Addition Failed - UsingStatementFailed + CompilationError } } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs index 9325859646..ed735c44b2 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeServices.cs @@ -204,11 +204,6 @@ internal static DynamicCodeServicesRegistry GetRegistry() return RegistryValue; } - internal static IDynamicCodeSourcePreparationService SourcePreparationService - { - get { return GetRegistry().SourcePreparationService; } - } - internal static CompiledCommandEntryPointResolver CommandEntryPointResolver { get { return GetRegistry().CommandEntryPointResolver; } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCompilationTimingFormatter.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCompilationTimingFormatter.cs index c23d089e78..4fd7fdefee 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCompilationTimingFormatter.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCompilationTimingFormatter.cs @@ -7,8 +7,6 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools /// internal static class DynamicCompilationTimingFormatter { - private const string CacheHitTimingEntry = "[Perf] CacheHit: true"; - public static List CreateCompilationTimings( double referenceResolutionMilliseconds, double buildMilliseconds, @@ -30,14 +28,6 @@ public static List CreateCompilationTimings( return timings; } - public static List CreateCachedCompilationTimings( - DynamicCompilationBackendKind backendKind = DynamicCompilationBackendKind.Unknown) - { - List timings = CreateCompilationTimings(0, 0, 0, backendKind); - timings.Add(CacheHitTimingEntry); - return timings; - } - private static string CreateBackendTimingEntry(DynamicCompilationBackendKind backendKind) { return backendKind switch diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeResponse.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeResponse.cs index 3f4b3d5290..78d5e46200 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeResponse.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeResponse.cs @@ -23,14 +23,17 @@ public class ExecuteDynamicCodeResponse : UnityCliLoopToolResponse, IUnityCliLoo /// Error message (on failure) public string ErrorMessage { get; set; } - - /// Error message (alias for ErrorMessage) - public string Error - { - get => ErrorMessage; - set => ErrorMessage = value; + + /// + /// Error message alias for ErrorMessage. + /// Why keep: documented tool-response JSON field (Skill/SKILL.md); agents and CLI read it. + /// + public string Error + { + get => ErrorMessage; + set => ErrorMessage = value; } - + /// /// Code formatted for compilation /// (After extracting/moving using statements and applying class/method wrapping) diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunner.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunner.cs index f990998b67..618f9ea9e3 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunner.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunner.cs @@ -58,11 +58,6 @@ private CancellationTokenSource CreateCombinedCancellationTokenSource( ); } - public void Cancel() - { - _executionSlot.Cancel(); - } - public async Task ExecuteAsync(ExecutionContext context) { string correlationId = UnityCliLoopConstants.GenerateCorrelationId(); diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunnerExecutionSlot.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunnerExecutionSlot.cs index cbf7270e20..44a1a06507 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunnerExecutionSlot.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/CommandRunnerExecutionSlot.cs @@ -39,11 +39,6 @@ public bool TryBegin( return true; } - public void Cancel() - { - _cancellationTokenSource?.Cancel(); - } - /// /// Ends the execution slot even when undo collapse throws. /// Why nested finally: collapse can throw on a torn-down editor; the running flag must clear. diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutor.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutor.cs index a6de8cbf92..080664e10a 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutor.cs @@ -16,15 +16,6 @@ internal sealed class DynamicCodeExecutor : IDynamicCodeExecutor private readonly IDynamicCompilationService _compiler; private readonly ICompiledCommandInvoker _invoker; private readonly IDynamicCodeSourcePreparationService _sourcePreparationService; - private readonly ExecutionStatistics _statistics; - private readonly object _statsLock = new(); - - public DynamicCodeExecutor( - IDynamicCompilationService compiler, - ICompiledCommandInvoker invoker) - : this(compiler, invoker, DynamicCodeServices.SourcePreparationService) - { - } internal DynamicCodeExecutor( IDynamicCompilationService compiler, @@ -34,7 +25,6 @@ internal DynamicCodeExecutor( _compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); _invoker = invoker ?? throw new ArgumentNullException(nameof(invoker)); _sourcePreparationService = sourcePreparationService ?? throw new ArgumentNullException(nameof(sourcePreparationService)); - _statistics = new ExecutionStatistics(); } public async Task ExecuteCodeAsync( @@ -103,39 +93,20 @@ public async Task ExecuteCodeAsync( compileTotalStopwatch.Elapsed.TotalMilliseconds); AppendCompilationAdvisories(executionResult.Logs, compilationResult.AdvisoryLogs); - UpdateStatistics(executionResult, totalStopwatch.Elapsed); return executionResult; } catch (OperationCanceledException) { - ExecutionResult cancelledResult = CreateCancelledResult(totalStopwatch.Elapsed); - UpdateStatistics(cancelledResult, totalStopwatch.Elapsed); - return cancelledResult; + return CreateCancelledResult(totalStopwatch.Elapsed); } catch (Exception ex) { ExecutionResult failureResult = CreateUnexpectedErrorResult(ex, totalStopwatch.Elapsed); - UpdateStatistics(failureResult, totalStopwatch.Elapsed); LogUnexpectedExecutionException(ex, correlationId, totalStopwatch.ElapsedMilliseconds); return failureResult; } } - public ExecutionStatistics GetStatistics() - { - lock (_statsLock) - { - return new ExecutionStatistics - { - TotalExecutions = _statistics.TotalExecutions, - SuccessfulExecutions = _statistics.SuccessfulExecutions, - FailedExecutions = _statistics.FailedExecutions, - AverageExecutionTime = _statistics.AverageExecutionTime, - CompilationErrors = _statistics.CompilationErrors - }; - } - } - public void Dispose() { if (_compiler is IDisposable disposableCompiler) @@ -155,16 +126,7 @@ private async Task CompileCodeAsync( Namespace = DynamicCodeConstants.DEFAULT_NAMESPACE }; - CompilationResult result = await _compiler.CompileAsync(request, ct).ConfigureAwait(false); - if (!result.Success) - { - lock (_statsLock) - { - _statistics.CompilationErrors++; - } - } - - return result; + return await _compiler.CompileAsync(request, ct).ConfigureAwait(false); } private ExecutionResult TryCreateCompilationFailureResult( @@ -266,28 +228,6 @@ private static void AppendCompilationAdvisories( destination.AddRange(advisoryLogs); } - private void UpdateStatistics(ExecutionResult result, TimeSpan executionTime) - { - lock (_statsLock) - { - _statistics.TotalExecutions++; - if (result.Success) - { - _statistics.SuccessfulExecutions++; - } - else - { - _statistics.FailedExecutions++; - } - - double totalMilliseconds = - _statistics.AverageExecutionTime.TotalMilliseconds * (_statistics.TotalExecutions - 1); - totalMilliseconds += executionTime.TotalMilliseconds; - _statistics.AverageExecutionTime = - TimeSpan.FromMilliseconds(totalMilliseconds / _statistics.TotalExecutions); - } - } - private static Dictionary BuildExecutionParameters( object[] parameters, IReadOnlyCollection hoistedLiteralBindings) diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutorStub.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutorStub.cs index 0d8184c780..9ccfa8ea0e 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutorStub.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Execution/DynamicCodeExecutorStub.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -11,13 +10,6 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools /// public class DynamicCodeExecutorStub : IDynamicCodeExecutor { - private readonly ExecutionStatistics _statistics; - - public DynamicCodeExecutorStub() - { - _statistics = new ExecutionStatistics(); - } - /// Execute code asynchronously (always returns a Roslyn required error) public Task ExecuteCodeAsync( string code, @@ -29,19 +21,6 @@ public Task ExecuteCodeAsync( return Task.FromResult(CreateCompilationProviderUnavailableResult()); } - /// Retrieve execution statistics - public ExecutionStatistics GetStatistics() - { - return new ExecutionStatistics - { - TotalExecutions = _statistics.TotalExecutions, - SuccessfulExecutions = _statistics.SuccessfulExecutions, - FailedExecutions = _statistics.FailedExecutions, - AverageExecutionTime = _statistics.AverageExecutionTime, - CompilationErrors = _statistics.CompilationErrors - }; - } - public void Dispose() { } @@ -52,8 +31,7 @@ private ExecutionResult CreateCompilationProviderUnavailableResult() { Success = false, ErrorMessage = "COMPILATION_PROVIDER_UNAVAILABLE: No compilation provider is registered. Check initialization.", - ExecutionTime = TimeSpan.Zero, - Statistics = _statistics + ExecutionTime = TimeSpan.Zero }; } } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/IDynamicCodeExecutor.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/IDynamicCodeExecutor.cs index fdbc51c2e3..da8e88f319 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/IDynamicCodeExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/IDynamicCodeExecutor.cs @@ -17,28 +17,5 @@ System.Threading.Tasks.Task ExecuteCodeAsync( CancellationToken cancellationToken = default, bool compileOnly = false ); - - - - ExecutionStatistics GetStatistics(); - } - - /// Execution statistics - public class ExecutionStatistics - { - /// Total execution count - public int TotalExecutions { get; set; } - - /// Successful execution count - public int SuccessfulExecutions { get; set; } - - /// Failed execution count - public int FailedExecutions { get; set; } - - /// Average execution time - public TimeSpan AverageExecutionTime { get; set; } - - /// Compilation error count - public int CompilationErrors { get; set; } } } diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Models/ExecutionResult.cs b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Models/ExecutionResult.cs index 485005b6bb..037a4b5d23 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Models/ExecutionResult.cs +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Models/ExecutionResult.cs @@ -28,9 +28,6 @@ public class ExecutionResult /// Logs public List Logs { get; set; } = new(); - /// Execution Statistics - public ExecutionStatistics Statistics { get; set; } - /// /// Structured compilation errors when compilation failed. /// Preserved to enable rich diagnostics formatting at the tool layer. From e4adacbdf11146958eb24464cdf111237c9e68f6 Mon Sep 17 00:00:00 2001 From: Masamichi Hatayama Date: Sun, 26 Jul 2026 03:10:20 +0900 Subject: [PATCH 5/8] chore: Remove unreferenced Domain/Application/Infrastructure/Presentation PublicCandidates (#2006) Co-authored-by: Cursor --- .../Application/CliSetupApplicationService.cs | 25 -------- .../UnityCliLoopServerApplicationService.cs | 14 ----- .../Application/UnityCliLoopToolRegistrar.cs | 15 ----- .../Application/UnityCliLoopUIConstants.cs | 1 - .../ThirdPartyToolMigrationUseCase.cs | 14 ----- Packages/src/Editor/Domain/CliConstants.cs | 3 - .../Domain/IUnityCliLoopEditorSettingsPort.cs | 2 - ...dPartyToolMigrationDomainDetectionRules.cs | 8 --- .../ThirdPartyToolMigrationRuleCatalog.cs | 1 - .../Server/UnityCliLoopServerController.cs | 10 --- .../UnityCliLoopEditorSettingsRepository.cs | 15 ----- .../SkillSetup/SkillInstallationDetector.cs | 16 ----- .../SkillSetup/ToolSkillSynchronizer.cs | 16 ----- .../Utils/NodeEnvironmentResolver.cs | 10 --- .../SkillsTargetSelectionResolver.cs | 6 -- .../UIToolkit/Bindings/ViewDataBinder.cs | 63 ------------------- .../Presentation/UnityCliLoopSettingsModel.cs | 43 ------------- 17 files changed, 262 deletions(-) diff --git a/Packages/src/Editor/Application/CliSetupApplicationService.cs b/Packages/src/Editor/Application/CliSetupApplicationService.cs index a7ed8b9d66..420f2014ab 100644 --- a/Packages/src/Editor/Application/CliSetupApplicationService.cs +++ b/Packages/src/Editor/Application/CliSetupApplicationService.cs @@ -155,11 +155,6 @@ public Task IsCliVisibleFromShellAsync(RuntimePlatform platform, Cancellat return _cliInstallationDetector.IsCliVisibleFromShellAsync(platform, ct); } - public void InvalidateCliCache() - { - _cliInstallationDetector.InvalidateCache(); - } - public string GetMinimumRequiredCliVersion() { // Why: v3 setup installs the global dispatcher and reads the minimum from the package pin JSON @@ -179,26 +174,6 @@ public bool HasPackageOwnedCurrentUserInstall(RuntimePlatform platform) return _nativeCliInstaller.HasPackageOwnedCurrentUserInstall(platform); } - public bool IsCliVersionLessThan(string leftVersion, string rightVersion) - { - return CliVersionComparer.IsVersionLessThan(leftVersion, rightVersion); - } - - public bool IsCliVersionGreaterThan(string leftVersion, string rightVersion) - { - return CliVersionComparer.IsVersionGreaterThan(leftVersion, rightVersion); - } - - public bool IsCliVersionGreaterThanOrEqual(string leftVersion, string rightVersion) - { - return CliVersionComparer.IsVersionGreaterThanOrEqual(leftVersion, rightVersion); - } - - public bool IsCliVersionEqual(string leftVersion, string rightVersion) - { - return CliVersionComparer.IsVersionEqual(leftVersion, rightVersion); - } - public async Task InstallGlobalCliAsync( RuntimePlatform platform, IProgress installProgress, diff --git a/Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs b/Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs index 36576a9527..ef8bc231b7 100644 --- a/Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs +++ b/Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs @@ -61,10 +61,6 @@ public interface IUnityCliLoopServerController void AddServerStateChangedHandler(Action handler); void RemoveServerStateChangedHandler(Action handler); - - void AddServerStartedHandler(Action handler); - - void RemoveServerStartedHandler(Action handler); } /// @@ -235,15 +231,5 @@ public void RemoveServerStateChangedHandler(Action handler) { _controller.RemoveServerStateChangedHandler(handler); } - - public void AddServerStartedHandler(Action handler) - { - _controller.AddServerStartedHandler(handler); - } - - public void RemoveServerStartedHandler(Action handler) - { - _controller.RemoveServerStartedHandler(handler); - } } } diff --git a/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs b/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs index cf9770a327..edb28f4532 100644 --- a/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs +++ b/Packages/src/Editor/Application/UnityCliLoopToolRegistrar.cs @@ -174,20 +174,5 @@ public static bool IsCustomToolRegistered(string toolName) { return Service.IsCustomToolRegistered(toolName); } - - public static UnityCliLoopToolRegistry TryGetRegistry() - { - return Service.TryGetRegistry(); - } - - public static string GetDebugInfo() - { - return Service.GetDebugInfo(); - } - - public static void NotifyToolChanges() - { - Service.NotifyToolChanges(); - } } } diff --git a/Packages/src/Editor/Application/UnityCliLoopUIConstants.cs b/Packages/src/Editor/Application/UnityCliLoopUIConstants.cs index 1af521aeef..9cfb0c7925 100644 --- a/Packages/src/Editor/Application/UnityCliLoopUIConstants.cs +++ b/Packages/src/Editor/Application/UnityCliLoopUIConstants.cs @@ -8,7 +8,6 @@ public static class UnityCliLoopUIConstants { // Tool Settings public const string TOOL_SETTINGS_MENU_PATH = "Window > Unity CLI Loop > Settings"; - public const string CLI_COMMAND_REFERENCE_URL = "https://github.com/hatayama/unity-cli-loop#direct-cli-usage-advanced"; public const string PROJECT_REPOSITORY_URL = "https://github.com/hatayama/unity-cli-loop"; } } diff --git a/Packages/src/Editor/Application/UseCases/ThirdPartyToolMigrationUseCase.cs b/Packages/src/Editor/Application/UseCases/ThirdPartyToolMigrationUseCase.cs index 43a018c3ae..4fe24a0029 100644 --- a/Packages/src/Editor/Application/UseCases/ThirdPartyToolMigrationUseCase.cs +++ b/Packages/src/Editor/Application/UseCases/ThirdPartyToolMigrationUseCase.cs @@ -22,13 +22,6 @@ public ThirdPartyToolMigrationUseCase(IThirdPartyToolMigrationPort migrationPort _migrationPort = migrationPort ?? throw new ArgumentNullException(nameof(migrationPort)); } - public ThirdPartyToolMigrationPreview PreviewMigration(string projectRoot) - { - Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); - - return _migrationPort.PreviewMigration(projectRoot); - } - public Task PreviewMigrationAsync( string projectRoot, IProgress progress, @@ -55,13 +48,6 @@ public Task HasMigrationTargetsAsync(string projectRoot, CancellationToken return _migrationPort.HasMigrationTargetsAsync(projectRoot, ct); } - public ThirdPartyToolMigrationResult ApplyMigration(string projectRoot) - { - Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); - - return _migrationPort.ApplyMigration(projectRoot); - } - public Task ApplyMigrationAsync( string projectRoot, IProgress progress, diff --git a/Packages/src/Editor/Domain/CliConstants.cs b/Packages/src/Editor/Domain/CliConstants.cs index 90289497ba..7ecd6cfb91 100644 --- a/Packages/src/Editor/Domain/CliConstants.cs +++ b/Packages/src/Editor/Domain/CliConstants.cs @@ -32,14 +32,11 @@ public static class CliConstants public const string POSIX_PATH_SEPARATOR = ":"; public const string WINDOWS_PATH_SEPARATOR = ";"; public const string DISPATCHER_RELEASE_TAG_PREFIX = "dispatcher-v"; - public const string BETA_VERSION_MARKER = "-beta."; public const string SKILL_DIR_PREFIX = "uloop-"; public const string TEMPORARY_SKILLS_DIR_NAME = "TemporarySkills~"; public const string V3_CLI_INVOCATION_MIGRATION_SKILL_NAME = "v3-cli-invocation-migration"; public const string UNITY_PACKAGES_DIR_NAME = "Packages"; public const string PACKAGE_SOURCE_DIR_NAME = "src"; - public const string CLI_LAYOUT_CONTRACT_FILE_NAME = "layout-contract.json"; - public const string CLI_CONTRACT_FILE_NAME = "contract.json"; public const string GLOBAL_UNIX_COMMAND_NAME = EXECUTABLE_NAME; public const string GLOBAL_WINDOWS_COMMAND_NAME = EXECUTABLE_NAME + ".exe"; } diff --git a/Packages/src/Editor/Domain/IUnityCliLoopEditorSettingsPort.cs b/Packages/src/Editor/Domain/IUnityCliLoopEditorSettingsPort.cs index 8745fd0e03..af2e5c11c2 100644 --- a/Packages/src/Editor/Domain/IUnityCliLoopEditorSettingsPort.cs +++ b/Packages/src/Editor/Domain/IUnityCliLoopEditorSettingsPort.cs @@ -12,10 +12,8 @@ public interface IUnityCliLoopEditorSettingsPort void SaveSettings(UnityCliLoopEditorSettingsData settings); void UpdateSettings(Func transform); string GetLastSeenSetupWizardVersion(); - void SetLastSeenSetupWizardVersion(string version); bool GetSuppressSetupWizardAutoShow(); void SetSuppressSetupWizardAutoShow(bool suppressAutoShow); - void SetShowUnityCliLoopSecuritySetting(bool showUnityCliLoopSecuritySetting); void SetShowToolSettings(bool showToolSettings); void SetInstallSkillsFlat(bool installSkillsFlat); } diff --git a/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs b/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs index 32e34f8461..af7d5e02a0 100644 --- a/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs +++ b/Packages/src/Editor/Domain/ThirdPartyToolMigrationDomainDetectionRules.cs @@ -158,14 +158,6 @@ public static bool ContainsMigratableUnqualifiedLegacyRegistrarDomainReturn(stri return false; } - public static bool ContainsCurrentDomainHelperApi(string source) - { - Debug.Assert(source != null, "source must not be null"); - - bool hasCurrentDomainNamespaceUsage = RegexMatchesCode(source, CurrentDomainNamespaceRegex); - return ContainsCurrentDomainHelperApiForAssembly(source, hasCurrentDomainNamespaceUsage); - } - public static bool ContainsCurrentDomainHelperApiForAssembly( string source, bool canUseBareCurrentDomainType) diff --git a/Packages/src/Editor/Domain/ThirdPartyToolMigrationRuleCatalog.cs b/Packages/src/Editor/Domain/ThirdPartyToolMigrationRuleCatalog.cs index 632be3cfff..9590c30a86 100644 --- a/Packages/src/Editor/Domain/ThirdPartyToolMigrationRuleCatalog.cs +++ b/Packages/src/Editor/Domain/ThirdPartyToolMigrationRuleCatalog.cs @@ -33,7 +33,6 @@ public static class ThirdPartyToolMigrationRuleCatalog public const string DescriptionAttributeArgumentName = "Description"; public const string DisplayDevelopmentOnlyAttributeArgumentName = "DisplayDevelopmentOnly"; public const string RequiredSecuritySettingAttributeArgumentName = "RequiredSecuritySetting"; - public const string LegacySecuritySettingsTypeName = "SecuritySettings"; public const string CurrentSecuritySettingTypeName = "UnityCliLoopSecuritySetting"; public const string LegacyEditorDelayTypeName = "EditorDelay"; public const string LegacyEditorDelayMethodName = "DelayFrame"; diff --git a/Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs b/Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs index 0c42a97820..e4fe040528 100644 --- a/Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs +++ b/Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs @@ -395,16 +395,6 @@ public void RemoveServerStateChangedHandler(Action handler) { _serverLifecycleRegistry.ServerStateChanged -= handler; } - - public void AddServerStartedHandler(Action handler) - { - _serverLifecycleRegistry.ServerStarted += handler; - } - - public void RemoveServerStartedHandler(Action handler) - { - _serverLifecycleRegistry.ServerStarted -= handler; - } } } diff --git a/Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsRepository.cs b/Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsRepository.cs index c958200a28..330bb33503 100644 --- a/Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsRepository.cs +++ b/Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsRepository.cs @@ -121,14 +121,6 @@ public string GetLastSeenSetupWizardVersion() return GetSettings().lastSeenSetupWizardVersion ?? string.Empty; } - public void SetLastSeenSetupWizardVersion(string version) - { - string normalizedVersion = version ?? string.Empty; - UnityCliLoopEditorSettingsData settings = GetSettings(); - UnityCliLoopEditorSettingsData updatedSettings = settings with { lastSeenSetupWizardVersion = normalizedVersion }; - SaveSettings(updatedSettings); - } - public bool GetSuppressSetupWizardAutoShow() { return GetSettings().suppressSetupWizardAutoShow; @@ -141,13 +133,6 @@ public void SetSuppressSetupWizardAutoShow(bool suppressAutoShow) SaveSettings(updatedSettings); } - public void SetShowUnityCliLoopSecuritySetting(bool showUnityCliLoopSecuritySetting) - { - UnityCliLoopEditorSettingsData settings = GetSettings(); - UnityCliLoopEditorSettingsData newSettings = settings with { showUnityCliLoopSecuritySetting = showUnityCliLoopSecuritySetting }; - SaveSettings(newSettings); - } - public void SetShowToolSettings(bool showToolSettings) { UnityCliLoopEditorSettingsData settings = GetSettings(); diff --git a/Packages/src/Editor/Infrastructure/SkillSetup/SkillInstallationDetector.cs b/Packages/src/Editor/Infrastructure/SkillSetup/SkillInstallationDetector.cs index 3a4de7cade..5e2baa2c64 100644 --- a/Packages/src/Editor/Infrastructure/SkillSetup/SkillInstallationDetector.cs +++ b/Packages/src/Editor/Infrastructure/SkillSetup/SkillInstallationDetector.cs @@ -11,22 +11,6 @@ namespace io.github.hatayama.UnityCliLoop.Infrastructure /// public sealed class SkillInstallationDetector { - public bool AreSkillsInstalled(string targetDir) - { - Debug.Assert(!string.IsNullOrEmpty(targetDir), "targetDir must not be null or empty"); - - string projectRoot = UnityCliLoopPathResolver.GetProjectRoot(); - return AreSkillsInstalledInAnyLayout(projectRoot, targetDir); - } - - public bool AreSkillsInstalled(string targetDir, bool groupSkillsUnderUnityCliLoop) - { - Debug.Assert(!string.IsNullOrEmpty(targetDir), "targetDir must not be null or empty"); - - string projectRoot = UnityCliLoopPathResolver.GetProjectRoot(); - return AreSkillsInstalledForLayout(projectRoot, targetDir, groupSkillsUnderUnityCliLoop); - } - internal bool AreSkillsInstalledInAnyLayout(string projectRoot, string targetDir) { Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); diff --git a/Packages/src/Editor/Infrastructure/SkillSetup/ToolSkillSynchronizer.cs b/Packages/src/Editor/Infrastructure/SkillSetup/ToolSkillSynchronizer.cs index ab71d38e14..4a2cd94c93 100644 --- a/Packages/src/Editor/Infrastructure/SkillSetup/ToolSkillSynchronizer.cs +++ b/Packages/src/Editor/Infrastructure/SkillSetup/ToolSkillSynchronizer.cs @@ -79,22 +79,6 @@ public static bool IsSkillInstalled(string toolName) return false; } - public static List DetectTargetsForLayout(bool groupSkillsUnderUnityCliLoop) - { - string projectRoot = UnityCliLoopPathResolver.GetProjectRoot(); - Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); - - return DetectTargetsForLayoutAtProjectRoot(projectRoot, groupSkillsUnderUnityCliLoop); - } - - public static List DetectTargetsForLayoutFast(bool groupSkillsUnderUnityCliLoop) - { - string projectRoot = UnityCliLoopPathResolver.GetProjectRoot(); - Debug.Assert(!string.IsNullOrEmpty(projectRoot), "projectRoot must not be null or empty"); - - return DetectTargetsForLayoutFastAtProjectRoot(projectRoot, groupSkillsUnderUnityCliLoop); - } - internal static List DetectTargetsForLayoutAtProjectRoot( string projectRoot, bool groupSkillsUnderUnityCliLoop) diff --git a/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs b/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs index b4c1d7d38f..4fb85acdb2 100644 --- a/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs +++ b/Packages/src/Editor/Infrastructure/Utils/NodeEnvironmentResolver.cs @@ -13,16 +13,6 @@ public static class NodeEnvironmentResolver { private const int PROCESS_TIMEOUT_MS = 5000; - /// - /// Finds an executable path using platform-appropriate resolution. - /// On Windows, resolves .cmd shims via 'where' command. - /// On Unix, resolves via login shell 'which' command. - /// - public static string FindExecutablePath(string executableName) - { - return FindExecutablePathAtPlatform(executableName, UnityEngine.Application.platform); - } - internal static string FindExecutablePathAtPlatform(string executableName, RuntimePlatform platform) { if (IsWindowsEditor(platform)) diff --git a/Packages/src/Editor/Presentation/SkillsTargetSelectionResolver.cs b/Packages/src/Editor/Presentation/SkillsTargetSelectionResolver.cs index 5d7a647476..5e96a458c6 100644 --- a/Packages/src/Editor/Presentation/SkillsTargetSelectionResolver.cs +++ b/Packages/src/Editor/Presentation/SkillsTargetSelectionResolver.cs @@ -1,5 +1,4 @@ using io.github.hatayama.UnityCliLoop.Application; -using io.github.hatayama.UnityCliLoop.Domain; namespace io.github.hatayama.UnityCliLoop.Presentation { @@ -55,10 +54,5 @@ public static bool IsInstalled(CliSetupData data, SkillsTarget target) _ => false }; } - - public static SkillInstallState GetInstallState(CliSetupData data, SkillsTarget target) - { - return data.SelectedTarget == target ? data.SelectedTargetInstallState : SkillInstallState.Missing; - } } } diff --git a/Packages/src/Editor/Presentation/UIToolkit/Bindings/ViewDataBinder.cs b/Packages/src/Editor/Presentation/UIToolkit/Bindings/ViewDataBinder.cs index 3edf4dc83c..cf599c3cdc 100644 --- a/Packages/src/Editor/Presentation/UIToolkit/Bindings/ViewDataBinder.cs +++ b/Packages/src/Editor/Presentation/UIToolkit/Bindings/ViewDataBinder.cs @@ -10,56 +10,11 @@ namespace io.github.hatayama.UnityCliLoop.Presentation /// public static class ViewDataBinder { - public static void BindToggle(Toggle toggle, Func getter, Action onChanged) - { - toggle.SetValueWithoutNotify(getter()); - toggle.RegisterValueChangedCallback(evt => onChanged(evt.newValue)); - } - - public static void BindIntegerField(IntegerField field, Func getter, Action onChanged) - { - field.SetValueWithoutNotify(getter()); - field.RegisterValueChangedCallback(evt => onChanged(evt.newValue)); - } - - public static void BindEnumField(EnumField field, Func getter, Action onChanged) where T : Enum - { - field.Init(getter()); - field.RegisterValueChangedCallback(evt => - { - if (evt.newValue is T newValue) - { - onChanged(newValue); - } - }); - } - - public static void BindFoldout(Foldout foldout, Func getter, Action onChanged) - { - foldout.SetValueWithoutNotify(getter()); - foldout.RegisterValueChangedCallback(evt => onChanged(evt.newValue)); - } - - public static void BindButton(Button button, Action onClick) - { - button.clicked += onClick; - } - - public static void BindLabel(Label label, Action