@atelierai/uco 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +29 -8
  2. package/package.json +2 -2
  3. package/vendor/plugin/com.atelierai.unity.copilot/CHANGELOG.md +4 -4
  4. package/vendor/plugin/com.atelierai.unity.copilot/Editor/DependencyResolver/NuGetConfig.cs +132 -132
  5. package/vendor/plugin/com.atelierai.unity.copilot/Editor/DependencyResolver/NuGetDependencyResolver.cs +237 -237
  6. package/vendor/plugin/com.atelierai.unity.copilot/Editor/DependencyResolver/NuGetDownloader.cs +82 -82
  7. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Resource/MenuItems.cs +247 -247
  8. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Resource/ToolGroups.cs +153 -153
  9. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/SystemTool/Skills.Create.SkillBody.cs +155 -155
  10. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Console.GetLogs.cs +95 -95
  11. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Docs.HttpFetcher.cs +139 -139
  12. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Instance.ListAll.cs +72 -72
  13. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/PathReadHelper.cs +106 -106
  14. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Script.Validate.cs +252 -252
  15. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Tests/TestResultCollector.cs +537 -537
  16. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/Tests.cs +400 -400
  17. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/ToolGroups.SetEnabled.cs +92 -92
  18. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Branding/ProductInfo.cs +62 -62
  19. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/CopilotServerManager.cs +887 -1034
  20. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Skills/Skill_InitialSetup.cs +197 -197
  21. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Startup.Editor.cs +201 -201
  22. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Startup.cs +67 -67
  23. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/CopilotListWindowBase.cs +393 -393
  24. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/CopilotWindowBase.cs +113 -113
  25. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.Connection.cs +3 -3
  26. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.CopilotFeatures.cs +195 -195
  27. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.CopilotServer.cs +22 -22
  28. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.CreateGUI.cs +354 -354
  29. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.cs +78 -78
  30. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowInitializer.cs +47 -47
  31. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/SerializationCheckWindow.cs +190 -190
  32. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UnityCopilotPluginEditor.Build.cs +91 -91
  33. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UnityCopilotPluginEditor.Config.cs +298 -298
  34. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UnityCopilotPluginEditor.Static.cs +296 -296
  35. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UnityCopilotPluginEditor.cs +69 -69
  36. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/PackageUtils.cs +168 -168
  37. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/PrefsKeyMigration.cs +119 -119
  38. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/SafeDefaultsGuard.cs +180 -180
  39. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/ScriptUtils.cs +229 -229
  40. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/ToolGroupRegistry.cs +461 -460
  41. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/ToolsManifestGenerator.cs +200 -200
  42. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/UnityAuthoringAdapters.cs +1467 -1467
  43. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/UnityAuthoringSafetyReloadGuard.cs +65 -65
  44. package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/UnityCopilotUpdateProjectSettings.cs +66 -66
  45. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotPromptsWindow.uss +11 -11
  46. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotResourcesWindow.uss +16 -16
  47. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotToolsWindow.uss +36 -36
  48. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/MainWindow.uss +183 -183
  49. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/{_mcp-list-window.uss → _copilot-list-window.uss} +18 -18
  50. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/_list-view.uss +77 -77
  51. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotPromptsWindow.uxml +18 -18
  52. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotResourcesWindow.uxml +18 -18
  53. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotToolsWindow.uxml +18 -18
  54. package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/MainWindow.uxml +115 -115
  55. package/vendor/plugin/com.atelierai.unity.copilot/Plugins/ReflectorNet.dll +0 -0
  56. package/vendor/plugin/com.atelierai.unity.copilot/Plugins/Uco.Framework.Common.dll +0 -0
  57. package/vendor/plugin/com.atelierai.unity.copilot/Plugins/Uco.Framework.dll +0 -0
  58. package/vendor/plugin/com.atelierai.unity.copilot/README.md +88 -88
  59. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Converter/Json/Structures/EntityIdConverter.cs +120 -120
  60. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Data/GameObjectMetadata.cs +110 -110
  61. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Data/GameObjectMetadata.pre-Unity.6.5.cs +110 -110
  62. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Unity/Logs/FileLogStorage.cs +547 -547
  63. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPlugin.Build.cs +243 -243
  64. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPlugin.Config.cs +3 -3
  65. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPlugin.cs +295 -295
  66. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPluginBuilder.cs +105 -105
  67. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPluginRuntime.Static.cs +155 -155
  68. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPluginRuntime.cs +59 -59
  69. package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Utils/EnvironmentUtils.cs +11 -11
  70. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/AtomicApi/AtomicApiTestFixtures.cs +99 -99
  71. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/AtomicApi/TryModifyAtTests.cs +227 -227
  72. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/AuthoringSafetyPilotTests.cs +1050 -1050
  73. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetExtractorDevelopmentDependencyTests.cs +148 -148
  74. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetExtractorFlatLayoutTests.cs +166 -166
  75. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetInstallManifestTests.cs +436 -436
  76. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetLegacyMigrationTests.cs +304 -304
  77. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetPackageInstallerStaleVersionCleanupTests.cs +200 -200
  78. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Environment/EnvironmentUtilsTests.cs +2 -2
  79. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/BlacklistTypeTests.cs +416 -416
  80. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataFieldScriptableObjectPopulationTests.cs +172 -172
  81. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataFieldScriptableObjectPopulationTests.pre-Unity.6.5.cs +169 -169
  82. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPopulationTests.cs +182 -182
  83. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPopulationTests.pre-Unity.6.5.cs +179 -179
  84. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPropertyPopulationTests.cs +175 -175
  85. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPropertyPopulationTests.pre-Unity.6.5.cs +174 -174
  86. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPropertyScriptableObjectPopulationTests.cs +171 -171
  87. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ReflectionConverter/DataPropertyScriptableObjectPopulationTests.pre-Unity.6.5.cs +170 -170
  88. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Assets/AssetsCreateFolderTests.cs +243 -243
  89. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Assets/AssetsMaterialTests.cs +101 -101
  90. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Assets/AssetsPrefabCreateTests.cs +348 -348
  91. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Assets/AssetsPrefabCreateTests.pre-Unity.6.5.cs +348 -348
  92. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Assets/AssetsShaderTests.cs +194 -194
  93. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/GameObject/TestJsonSchema.cs +199 -199
  94. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/PathBasedToolTests.cs +573 -573
  95. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/PathBasedToolTests.pre-Unity.6.5.cs +513 -513
  96. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Screenshot/ScreenshotCameraTests.cs +154 -154
  97. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Screenshot/ScreenshotCameraTests.pre-Unity.6.5.cs +154 -154
  98. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Screenshot/ScreenshotGameViewTests.cs +164 -164
  99. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/Screenshot/ScreenshotSceneViewTests.cs +155 -155
  100. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/ToolParameterTests.cs +56 -56
  101. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/ToolThreadSafetyTests.cs +651 -651
  102. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/ToolThreadSafetyTests.pre-Unity.6.5.cs +651 -651
  103. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/ToolBatchExecutionIntegrationTests.cs +407 -407
  104. package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/{McpPluginTests.cs → UcoPluginTests.cs} +105 -105
  105. package/vendor/plugin/com.atelierai.unity.copilot/package.json +1 -1
  106. /package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/{_mcp-list-window.uss.meta → _copilot-list-window.uss.meta} +0 -0
  107. /package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/{McpPluginTests.cs.meta → UcoPluginTests.cs.meta} +0 -0
@@ -1,148 +1,148 @@
1
- /*
2
- +------------------------------------------------------------------+
3
- | Author: Ivan Murzak (https://github.com/IvanMurzak) |
4
- | Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) |
5
- | Copyright (c) 2025 Ivan Murzak |
6
- | Licensed under the Apache License, Version 2.0. |
7
- | See the LICENSE file in the project root for more information. |
8
- +------------------------------------------------------------------+
9
- */
10
-
11
- #nullable enable
12
- using System.IO;
13
- using System.IO.Compression;
14
- using NUnit.Framework;
15
- using com.AtelierAI.Unity.Copilot.Editor.DependencyResolver;
16
-
17
- namespace com.AtelierAI.Unity.Copilot.Editor.Tests.DependencyResolverTests
18
- {
19
- /// <summary>
20
- /// Regression coverage for issue #670: DependencyResolver was logging
21
- /// "No compatible framework found" / "No DLLs extracted" warnings for
22
- /// Roslyn analyzer packages (e.g. Microsoft.CodeAnalysis.Analyzers), which
23
- /// are marked <c>&lt;developmentDependency&gt;true&lt;/developmentDependency&gt;</c>
24
- /// in their .nuspec and legitimately have no runtime DLLs under <c>lib/&lt;tfm&gt;/</c>.
25
- /// </summary>
26
- [TestFixture]
27
- public class NuGetExtractorDevelopmentDependencyTests
28
- {
29
- string _tempDir = string.Empty;
30
-
31
- [SetUp]
32
- public void SetUp()
33
- {
34
- _tempDir = Path.Combine(Path.GetTempPath(), "UnityMcp-NuGetExtractor-" + Path.GetRandomFileName());
35
- Directory.CreateDirectory(_tempDir);
36
- }
37
-
38
- [TearDown]
39
- public void TearDown()
40
- {
41
- if (Directory.Exists(_tempDir))
42
- {
43
- try { Directory.Delete(_tempDir, recursive: true); } catch { /* best-effort cleanup */ }
44
- }
45
- }
46
-
47
- [Test]
48
- public void IsDevelopmentDependency_ReturnsTrue_WhenNuspecDeclaresDevDependencyTrue()
49
- {
50
- var nupkg = BuildNupkg(
51
- id: "Example.Analyzer",
52
- version: "1.0.0",
53
- developmentDependencyElement: "<developmentDependency>true</developmentDependency>");
54
-
55
- Assert.IsTrue(NuGetExtractor.IsDevelopmentDependency(nupkg));
56
- }
57
-
58
- [Test]
59
- public void IsDevelopmentDependency_ReturnsTrue_WhenValueHasWhitespace()
60
- {
61
- // Some package authors pretty-print their nuspec; we must not choke on whitespace.
62
- var nupkg = BuildNupkg(
63
- id: "Example.Analyzer",
64
- version: "1.0.0",
65
- developmentDependencyElement: "<developmentDependency> true </developmentDependency>");
66
-
67
- Assert.IsTrue(NuGetExtractor.IsDevelopmentDependency(nupkg));
68
- }
69
-
70
- [Test]
71
- public void IsDevelopmentDependency_ReturnsFalse_WhenNuspecDeclaresDevDependencyFalse()
72
- {
73
- var nupkg = BuildNupkg(
74
- id: "Example.Library",
75
- version: "1.0.0",
76
- developmentDependencyElement: "<developmentDependency>false</developmentDependency>");
77
-
78
- Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
79
- }
80
-
81
- [Test]
82
- public void IsDevelopmentDependency_ReturnsFalse_WhenDevDependencyElementIsMissing()
83
- {
84
- // The overwhelmingly common case: normal runtime libraries simply omit the element.
85
- var nupkg = BuildNupkg(
86
- id: "Example.Library",
87
- version: "1.0.0",
88
- developmentDependencyElement: null);
89
-
90
- Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
91
- }
92
-
93
- [Test]
94
- public void IsDevelopmentDependency_ReturnsFalse_WhenNupkgIsCorrupt()
95
- {
96
- // An invalid zip header is not a valid zip archive; the helper must swallow the
97
- // exception and return false so the caller falls back to normal extraction.
98
- var bogus = Path.Combine(_tempDir, "corrupt.nupkg");
99
- File.WriteAllBytes(bogus, new byte[] { 0, 0, 0, 0 });
100
-
101
- Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(bogus));
102
- }
103
-
104
- [Test]
105
- public void IsDevelopmentDependency_ReturnsFalse_WhenNupkgHasNoNuspec()
106
- {
107
- var nupkg = Path.Combine(_tempDir, "no-nuspec.nupkg");
108
- using (var zip = ZipFile.Open(nupkg, ZipArchiveMode.Create))
109
- {
110
- var entry = zip.CreateEntry("readme.txt");
111
- using var writer = new StreamWriter(entry.Open());
112
- writer.Write("no nuspec here");
113
- }
114
-
115
- Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
116
- }
117
-
118
- /// <summary>
119
- /// Builds a minimal synthetic .nupkg containing a single .nuspec entry at the root.
120
- /// Mirrors enough of the real NuGet v3 layout to exercise the parser without downloading
121
- /// anything over the network.
122
- /// </summary>
123
- string BuildNupkg(string id, string version, string? developmentDependencyElement)
124
- {
125
- var nupkg = Path.Combine(_tempDir, $"{id}.{version}.nupkg");
126
- var nuspec =
127
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
128
- "<package xmlns=\"http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd\">" +
129
- " <metadata>" +
130
- $" <id>{id}</id>" +
131
- $" <version>{version}</version>" +
132
- " <authors>test</authors>" +
133
- " <description>test fixture package</description>" +
134
- (developmentDependencyElement ?? string.Empty) +
135
- " </metadata>" +
136
- "</package>";
137
-
138
- using (var zip = ZipFile.Open(nupkg, ZipArchiveMode.Create))
139
- {
140
- var entry = zip.CreateEntry($"{id}.nuspec");
141
- using var writer = new StreamWriter(entry.Open());
142
- writer.Write(nuspec);
143
- }
144
-
145
- return nupkg;
146
- }
147
- }
148
- }
1
+ /*
2
+ +------------------------------------------------------------------+
3
+ | Author: Ivan Murzak (https://github.com/IvanMurzak) |
4
+ | Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) |
5
+ | Copyright (c) 2025 Ivan Murzak |
6
+ | Licensed under the Apache License, Version 2.0. |
7
+ | See the LICENSE file in the project root for more information. |
8
+ +------------------------------------------------------------------+
9
+ */
10
+
11
+ #nullable enable
12
+ using System.IO;
13
+ using System.IO.Compression;
14
+ using NUnit.Framework;
15
+ using com.AtelierAI.Unity.Copilot.Editor.DependencyResolver;
16
+
17
+ namespace com.AtelierAI.Unity.Copilot.Editor.Tests.DependencyResolverTests
18
+ {
19
+ /// <summary>
20
+ /// Regression coverage for issue #670: DependencyResolver was logging
21
+ /// "No compatible framework found" / "No DLLs extracted" warnings for
22
+ /// Roslyn analyzer packages (e.g. Microsoft.CodeAnalysis.Analyzers), which
23
+ /// are marked <c>&lt;developmentDependency&gt;true&lt;/developmentDependency&gt;</c>
24
+ /// in their .nuspec and legitimately have no runtime DLLs under <c>lib/&lt;tfm&gt;/</c>.
25
+ /// </summary>
26
+ [TestFixture]
27
+ public class NuGetExtractorDevelopmentDependencyTests
28
+ {
29
+ string _tempDir = string.Empty;
30
+
31
+ [SetUp]
32
+ public void SetUp()
33
+ {
34
+ _tempDir = Path.Combine(Path.GetTempPath(), "Uco-NuGetExtractor-" + Path.GetRandomFileName());
35
+ Directory.CreateDirectory(_tempDir);
36
+ }
37
+
38
+ [TearDown]
39
+ public void TearDown()
40
+ {
41
+ if (Directory.Exists(_tempDir))
42
+ {
43
+ try { Directory.Delete(_tempDir, recursive: true); } catch { /* best-effort cleanup */ }
44
+ }
45
+ }
46
+
47
+ [Test]
48
+ public void IsDevelopmentDependency_ReturnsTrue_WhenNuspecDeclaresDevDependencyTrue()
49
+ {
50
+ var nupkg = BuildNupkg(
51
+ id: "Example.Analyzer",
52
+ version: "1.0.0",
53
+ developmentDependencyElement: "<developmentDependency>true</developmentDependency>");
54
+
55
+ Assert.IsTrue(NuGetExtractor.IsDevelopmentDependency(nupkg));
56
+ }
57
+
58
+ [Test]
59
+ public void IsDevelopmentDependency_ReturnsTrue_WhenValueHasWhitespace()
60
+ {
61
+ // Some package authors pretty-print their nuspec; we must not choke on whitespace.
62
+ var nupkg = BuildNupkg(
63
+ id: "Example.Analyzer",
64
+ version: "1.0.0",
65
+ developmentDependencyElement: "<developmentDependency> true </developmentDependency>");
66
+
67
+ Assert.IsTrue(NuGetExtractor.IsDevelopmentDependency(nupkg));
68
+ }
69
+
70
+ [Test]
71
+ public void IsDevelopmentDependency_ReturnsFalse_WhenNuspecDeclaresDevDependencyFalse()
72
+ {
73
+ var nupkg = BuildNupkg(
74
+ id: "Example.Library",
75
+ version: "1.0.0",
76
+ developmentDependencyElement: "<developmentDependency>false</developmentDependency>");
77
+
78
+ Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
79
+ }
80
+
81
+ [Test]
82
+ public void IsDevelopmentDependency_ReturnsFalse_WhenDevDependencyElementIsMissing()
83
+ {
84
+ // The overwhelmingly common case: normal runtime libraries simply omit the element.
85
+ var nupkg = BuildNupkg(
86
+ id: "Example.Library",
87
+ version: "1.0.0",
88
+ developmentDependencyElement: null);
89
+
90
+ Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
91
+ }
92
+
93
+ [Test]
94
+ public void IsDevelopmentDependency_ReturnsFalse_WhenNupkgIsCorrupt()
95
+ {
96
+ // An invalid zip header is not a valid zip archive; the helper must swallow the
97
+ // exception and return false so the caller falls back to normal extraction.
98
+ var bogus = Path.Combine(_tempDir, "corrupt.nupkg");
99
+ File.WriteAllBytes(bogus, new byte[] { 0, 0, 0, 0 });
100
+
101
+ Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(bogus));
102
+ }
103
+
104
+ [Test]
105
+ public void IsDevelopmentDependency_ReturnsFalse_WhenNupkgHasNoNuspec()
106
+ {
107
+ var nupkg = Path.Combine(_tempDir, "no-nuspec.nupkg");
108
+ using (var zip = ZipFile.Open(nupkg, ZipArchiveMode.Create))
109
+ {
110
+ var entry = zip.CreateEntry("readme.txt");
111
+ using var writer = new StreamWriter(entry.Open());
112
+ writer.Write("no nuspec here");
113
+ }
114
+
115
+ Assert.IsFalse(NuGetExtractor.IsDevelopmentDependency(nupkg));
116
+ }
117
+
118
+ /// <summary>
119
+ /// Builds a minimal synthetic .nupkg containing a single .nuspec entry at the root.
120
+ /// Mirrors enough of the real NuGet v3 layout to exercise the parser without downloading
121
+ /// anything over the network.
122
+ /// </summary>
123
+ string BuildNupkg(string id, string version, string? developmentDependencyElement)
124
+ {
125
+ var nupkg = Path.Combine(_tempDir, $"{id}.{version}.nupkg");
126
+ var nuspec =
127
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
128
+ "<package xmlns=\"http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd\">" +
129
+ " <metadata>" +
130
+ $" <id>{id}</id>" +
131
+ $" <version>{version}</version>" +
132
+ " <authors>test</authors>" +
133
+ " <description>test fixture package</description>" +
134
+ (developmentDependencyElement ?? string.Empty) +
135
+ " </metadata>" +
136
+ "</package>";
137
+
138
+ using (var zip = ZipFile.Open(nupkg, ZipArchiveMode.Create))
139
+ {
140
+ var entry = zip.CreateEntry($"{id}.nuspec");
141
+ using var writer = new StreamWriter(entry.Open());
142
+ writer.Write(nuspec);
143
+ }
144
+
145
+ return nupkg;
146
+ }
147
+ }
148
+ }
@@ -1,166 +1,166 @@
1
- /*
2
- +------------------------------------------------------------------+
3
- | Author: Ivan Murzak (https://github.com/IvanMurzak) |
4
- | Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) |
5
- | Copyright (c) 2025 Ivan Murzak |
6
- | Licensed under the Apache License, Version 2.0. |
7
- | See the LICENSE file in the project root for more information. |
8
- +------------------------------------------------------------------+
9
- */
10
-
11
- #nullable enable
12
- using System.IO;
13
- using System.IO.Compression;
14
- using NUnit.Framework;
15
- using com.AtelierAI.Unity.Copilot.Editor.DependencyResolver;
16
-
17
- namespace com.AtelierAI.Unity.Copilot.Editor.Tests.DependencyResolverTests
18
- {
19
- /// <summary>
20
- /// Coverage for <see cref="NuGetExtractor"/>'s flat-layout extraction.
21
- /// Synthetic .nupkg fixtures exercise the extractor directly without
22
- /// touching nuget.org. DLLs are written FLAT under the install directory
23
- /// using the original <c>{stem}.dll</c> filename from the .nupkg lib
24
- /// folder — the package version is NOT embedded in the on-disk filename
25
- /// (it is tracked in <see cref="NuGetInstallManifest"/> instead, so
26
- /// asmdef <c>precompiledReferences</c> stay stable across version bumps).
27
- /// </summary>
28
- [TestFixture]
29
- public class NuGetExtractorFlatLayoutTests
30
- {
31
- string _tempDir = string.Empty;
32
- string _installDir = string.Empty;
33
-
34
- [SetUp]
35
- public void SetUp()
36
- {
37
- _tempDir = Path.Combine(Path.GetTempPath(), "UnityMcp-Extractor-" + Path.GetRandomFileName());
38
- Directory.CreateDirectory(_tempDir);
39
- _installDir = Path.Combine(_tempDir, "install");
40
- Directory.CreateDirectory(_installDir);
41
- }
42
-
43
- [TearDown]
44
- public void TearDown()
45
- {
46
- if (Directory.Exists(_tempDir))
47
- {
48
- try { Directory.Delete(_tempDir, recursive: true); }
49
- catch { /* best-effort */ }
50
- }
51
- }
52
-
53
- [Test]
54
- public void ExtractDlls_WritesUnversionedFlatFilename()
55
- {
56
- // Output filename is the original {stem}.dll from the .nupkg's
57
- // lib/<tfm>/ folder; version is tracked in the manifest, not the
58
- // filename. The DLL sits directly under the install path (no
59
- // per-package subfolder, no version tail).
60
- var nupkg = BuildNupkg("System.Text.Json", "8.0.5", "lib/netstandard2.0/System.Text.Json.dll");
61
-
62
- var extracted = NuGetExtractor.ExtractDlls(nupkg, _installDir);
63
-
64
- CollectionAssert.AreEqual(new[] { "System.Text.Json.dll" }, extracted);
65
- Assert.IsTrue(File.Exists(Path.Combine(_installDir, "System.Text.Json.dll")));
66
- Assert.IsFalse(File.Exists(Path.Combine(_installDir, "System.Text.Json.8.0.5.dll")),
67
- "Versioned-filename layout is no longer produced.");
68
- }
69
-
70
- [Test]
71
- public void ExtractDlls_WritesAllShippedDlls_ForMultiDllPackage()
72
- {
73
- // Multi-DLL packages (e.g. Microsoft.Bcl.Memory) write every DLL
74
- // under its original stem; the per-package version (10.0.3 here)
75
- // lives in the manifest entry.
76
- var nupkg = BuildNupkg("Microsoft.Bcl.Memory", "10.0.3",
77
- "lib/netstandard2.0/System.Memory.dll",
78
- "lib/netstandard2.0/System.Buffers.dll",
79
- "lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll");
80
-
81
- var extracted = NuGetExtractor.ExtractDlls(nupkg, _installDir);
82
-
83
- CollectionAssert.AreEquivalent(
84
- new[]
85
- {
86
- "System.Memory.dll",
87
- "System.Buffers.dll",
88
- "System.Runtime.CompilerServices.Unsafe.dll",
89
- },
90
- extracted);
91
- }
92
-
93
- [Test]
94
- public void ExtractDlls_OverwritesExistingFile_ForVersionBumpInPlace()
95
- {
96
- // Steady-state version-bump: the same {stem}.dll filename is
97
- // reused across versions, so re-extraction overwrites bytes in
98
- // place. This is the primary win of the unversioned layout —
99
- // asmdef precompiledReferences never need to be edited when the
100
- // configured package version bumps.
101
- var nupkg = BuildNupkg("Foo.Bar", "1.0.0", "lib/netstandard2.0/Foo.Bar.dll");
102
- var targetPath = Path.Combine(_installDir, "Foo.Bar.dll");
103
-
104
- File.WriteAllText(targetPath, "old-version-bytes");
105
- NuGetExtractor.ExtractDlls(nupkg, _installDir);
106
-
107
- Assert.AreEqual("dummy-dll-content", File.ReadAllText(targetPath),
108
- "Extraction must overwrite the existing file with the new version's bytes.");
109
- }
110
-
111
- [Test]
112
- public void ExtractDlls_ReturnsEmpty_WhenPackageHasNoCompatibleFramework()
113
- {
114
- // Build a nupkg with NO lib/ entries.
115
- var emptyNupkg = Path.Combine(_tempDir, "Empty.1.0.0.nupkg");
116
- using (var zip = ZipFile.Open(emptyNupkg, ZipArchiveMode.Create))
117
- {
118
- var entry = zip.CreateEntry("Empty.nuspec");
119
- using var w = new StreamWriter(entry.Open());
120
- w.Write("<?xml version=\"1.0\"?><package><metadata><id>Empty</id><version>1.0.0</version><authors>t</authors><description>t</description></metadata></package>");
121
- }
122
-
123
- var extracted = NuGetExtractor.ExtractDlls(emptyNupkg, _installDir);
124
-
125
- Assert.AreEqual(0, extracted.Count);
126
- Assert.AreEqual(0, Directory.GetFiles(_installDir).Length,
127
- "Empty package must not write anything to disk.");
128
- }
129
-
130
- /// <summary>
131
- /// Builds a minimal synthetic .nupkg zip with a .nuspec at the root and
132
- /// the given lib/{tfm}/*.dll entries. Sufficient input for the
133
- /// extractor under test.
134
- /// </summary>
135
- string BuildNupkg(string id, string version, params string[] entryPaths)
136
- {
137
- var nupkgPath = Path.Combine(_tempDir, $"{id}.{version}.nupkg");
138
- using var zip = ZipFile.Open(nupkgPath, ZipArchiveMode.Create);
139
-
140
- // Minimal .nuspec at root.
141
- var nuspec = zip.CreateEntry($"{id}.nuspec");
142
- using (var w = new StreamWriter(nuspec.Open()))
143
- {
144
- w.Write(
145
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
146
- "<package xmlns=\"http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd\">" +
147
- "<metadata>" +
148
- $"<id>{id}</id>" +
149
- $"<version>{version}</version>" +
150
- "<authors>test</authors>" +
151
- "<description>fixture</description>" +
152
- "</metadata>" +
153
- "</package>");
154
- }
155
-
156
- foreach (var path in entryPaths)
157
- {
158
- var entry = zip.CreateEntry(path);
159
- using var w = new StreamWriter(entry.Open());
160
- w.Write("dummy-dll-content");
161
- }
162
-
163
- return nupkgPath;
164
- }
165
- }
166
- }
1
+ /*
2
+ +------------------------------------------------------------------+
3
+ | Author: Ivan Murzak (https://github.com/IvanMurzak) |
4
+ | Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) |
5
+ | Copyright (c) 2025 Ivan Murzak |
6
+ | Licensed under the Apache License, Version 2.0. |
7
+ | See the LICENSE file in the project root for more information. |
8
+ +------------------------------------------------------------------+
9
+ */
10
+
11
+ #nullable enable
12
+ using System.IO;
13
+ using System.IO.Compression;
14
+ using NUnit.Framework;
15
+ using com.AtelierAI.Unity.Copilot.Editor.DependencyResolver;
16
+
17
+ namespace com.AtelierAI.Unity.Copilot.Editor.Tests.DependencyResolverTests
18
+ {
19
+ /// <summary>
20
+ /// Coverage for <see cref="NuGetExtractor"/>'s flat-layout extraction.
21
+ /// Synthetic .nupkg fixtures exercise the extractor directly without
22
+ /// touching nuget.org. DLLs are written FLAT under the install directory
23
+ /// using the original <c>{stem}.dll</c> filename from the .nupkg lib
24
+ /// folder — the package version is NOT embedded in the on-disk filename
25
+ /// (it is tracked in <see cref="NuGetInstallManifest"/> instead, so
26
+ /// asmdef <c>precompiledReferences</c> stay stable across version bumps).
27
+ /// </summary>
28
+ [TestFixture]
29
+ public class NuGetExtractorFlatLayoutTests
30
+ {
31
+ string _tempDir = string.Empty;
32
+ string _installDir = string.Empty;
33
+
34
+ [SetUp]
35
+ public void SetUp()
36
+ {
37
+ _tempDir = Path.Combine(Path.GetTempPath(), "Uco-Extractor-" + Path.GetRandomFileName());
38
+ Directory.CreateDirectory(_tempDir);
39
+ _installDir = Path.Combine(_tempDir, "install");
40
+ Directory.CreateDirectory(_installDir);
41
+ }
42
+
43
+ [TearDown]
44
+ public void TearDown()
45
+ {
46
+ if (Directory.Exists(_tempDir))
47
+ {
48
+ try { Directory.Delete(_tempDir, recursive: true); }
49
+ catch { /* best-effort */ }
50
+ }
51
+ }
52
+
53
+ [Test]
54
+ public void ExtractDlls_WritesUnversionedFlatFilename()
55
+ {
56
+ // Output filename is the original {stem}.dll from the .nupkg's
57
+ // lib/<tfm>/ folder; version is tracked in the manifest, not the
58
+ // filename. The DLL sits directly under the install path (no
59
+ // per-package subfolder, no version tail).
60
+ var nupkg = BuildNupkg("System.Text.Json", "8.0.5", "lib/netstandard2.0/System.Text.Json.dll");
61
+
62
+ var extracted = NuGetExtractor.ExtractDlls(nupkg, _installDir);
63
+
64
+ CollectionAssert.AreEqual(new[] { "System.Text.Json.dll" }, extracted);
65
+ Assert.IsTrue(File.Exists(Path.Combine(_installDir, "System.Text.Json.dll")));
66
+ Assert.IsFalse(File.Exists(Path.Combine(_installDir, "System.Text.Json.8.0.5.dll")),
67
+ "Versioned-filename layout is no longer produced.");
68
+ }
69
+
70
+ [Test]
71
+ public void ExtractDlls_WritesAllShippedDlls_ForMultiDllPackage()
72
+ {
73
+ // Multi-DLL packages (e.g. Microsoft.Bcl.Memory) write every DLL
74
+ // under its original stem; the per-package version (10.0.3 here)
75
+ // lives in the manifest entry.
76
+ var nupkg = BuildNupkg("Microsoft.Bcl.Memory", "10.0.3",
77
+ "lib/netstandard2.0/System.Memory.dll",
78
+ "lib/netstandard2.0/System.Buffers.dll",
79
+ "lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll");
80
+
81
+ var extracted = NuGetExtractor.ExtractDlls(nupkg, _installDir);
82
+
83
+ CollectionAssert.AreEquivalent(
84
+ new[]
85
+ {
86
+ "System.Memory.dll",
87
+ "System.Buffers.dll",
88
+ "System.Runtime.CompilerServices.Unsafe.dll",
89
+ },
90
+ extracted);
91
+ }
92
+
93
+ [Test]
94
+ public void ExtractDlls_OverwritesExistingFile_ForVersionBumpInPlace()
95
+ {
96
+ // Steady-state version-bump: the same {stem}.dll filename is
97
+ // reused across versions, so re-extraction overwrites bytes in
98
+ // place. This is the primary win of the unversioned layout —
99
+ // asmdef precompiledReferences never need to be edited when the
100
+ // configured package version bumps.
101
+ var nupkg = BuildNupkg("Foo.Bar", "1.0.0", "lib/netstandard2.0/Foo.Bar.dll");
102
+ var targetPath = Path.Combine(_installDir, "Foo.Bar.dll");
103
+
104
+ File.WriteAllText(targetPath, "old-version-bytes");
105
+ NuGetExtractor.ExtractDlls(nupkg, _installDir);
106
+
107
+ Assert.AreEqual("dummy-dll-content", File.ReadAllText(targetPath),
108
+ "Extraction must overwrite the existing file with the new version's bytes.");
109
+ }
110
+
111
+ [Test]
112
+ public void ExtractDlls_ReturnsEmpty_WhenPackageHasNoCompatibleFramework()
113
+ {
114
+ // Build a nupkg with NO lib/ entries.
115
+ var emptyNupkg = Path.Combine(_tempDir, "Empty.1.0.0.nupkg");
116
+ using (var zip = ZipFile.Open(emptyNupkg, ZipArchiveMode.Create))
117
+ {
118
+ var entry = zip.CreateEntry("Empty.nuspec");
119
+ using var w = new StreamWriter(entry.Open());
120
+ w.Write("<?xml version=\"1.0\"?><package><metadata><id>Empty</id><version>1.0.0</version><authors>t</authors><description>t</description></metadata></package>");
121
+ }
122
+
123
+ var extracted = NuGetExtractor.ExtractDlls(emptyNupkg, _installDir);
124
+
125
+ Assert.AreEqual(0, extracted.Count);
126
+ Assert.AreEqual(0, Directory.GetFiles(_installDir).Length,
127
+ "Empty package must not write anything to disk.");
128
+ }
129
+
130
+ /// <summary>
131
+ /// Builds a minimal synthetic .nupkg zip with a .nuspec at the root and
132
+ /// the given lib/{tfm}/*.dll entries. Sufficient input for the
133
+ /// extractor under test.
134
+ /// </summary>
135
+ string BuildNupkg(string id, string version, params string[] entryPaths)
136
+ {
137
+ var nupkgPath = Path.Combine(_tempDir, $"{id}.{version}.nupkg");
138
+ using var zip = ZipFile.Open(nupkgPath, ZipArchiveMode.Create);
139
+
140
+ // Minimal .nuspec at root.
141
+ var nuspec = zip.CreateEntry($"{id}.nuspec");
142
+ using (var w = new StreamWriter(nuspec.Open()))
143
+ {
144
+ w.Write(
145
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
146
+ "<package xmlns=\"http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd\">" +
147
+ "<metadata>" +
148
+ $"<id>{id}</id>" +
149
+ $"<version>{version}</version>" +
150
+ "<authors>test</authors>" +
151
+ "<description>fixture</description>" +
152
+ "</metadata>" +
153
+ "</package>");
154
+ }
155
+
156
+ foreach (var path in entryPaths)
157
+ {
158
+ var entry = zip.CreateEntry(path);
159
+ using var w = new StreamWriter(entry.Open());
160
+ w.Write("dummy-dll-content");
161
+ }
162
+
163
+ return nupkgPath;
164
+ }
165
+ }
166
+ }