@atelierai/uco 1.0.8 → 1.0.10
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.
- package/CHANGELOG.md +32 -8
- package/package.json +2 -2
- package/vendor/plugin/com.atelierai.unity.copilot/CHANGELOG.md +4 -4
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/API/Tool/ToolGroups.SetEnabled.cs +92 -92
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/CopilotServerManager.cs +0 -147
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Startup.Editor.cs +16 -0
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/UI/Window/MainWindowEditor.CopilotServer.cs +3 -3
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/Scripts/Utils/ToolGroupRegistry.cs +461 -460
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotPromptsWindow.uss +11 -11
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotResourcesWindow.uss +16 -16
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/CopilotToolsWindow.uss +36 -36
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/MainWindow.uss +183 -183
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/{_mcp-list-window.uss → _copilot-list-window.uss} +18 -18
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/_list-view.uss +77 -77
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotPromptsWindow.uxml +18 -18
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotResourcesWindow.uxml +18 -18
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/CopilotToolsWindow.uxml +18 -18
- package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uxml/MainWindow.uxml +115 -115
- package/vendor/plugin/com.atelierai.unity.copilot/Plugins/ReflectorNet.dll +0 -0
- package/vendor/plugin/com.atelierai.unity.copilot/Plugins/Uco.Framework.Common.dll +0 -0
- package/vendor/plugin/com.atelierai.unity.copilot/Plugins/Uco.Framework.dll +0 -0
- package/vendor/plugin/com.atelierai.unity.copilot/README.md +88 -88
- package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Unity/Logs/BufferedFileLogStorage.cs +208 -207
- package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Unity/Logs/FileLogStorage.cs +3 -1
- package/vendor/plugin/com.atelierai.unity.copilot/Runtime/Unity/Logs/UnityLogCollector.cs +282 -280
- package/vendor/plugin/com.atelierai.unity.copilot/Runtime/UnityCopilotPlugin.cs +1 -1
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetExtractorDevelopmentDependencyTests.cs +148 -148
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetExtractorFlatLayoutTests.cs +166 -166
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetInstallManifestTests.cs +436 -436
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetLegacyMigrationTests.cs +1 -1
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/DependencyResolver/NuGetPackageInstallerStaleVersionCleanupTests.cs +200 -200
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Environment/EnvironmentUtilsTests.cs +1 -1
- package/vendor/plugin/com.atelierai.unity.copilot/Tests/Editor/Tool/GameObject/TestJsonSchema.cs +199 -199
- package/vendor/plugin/com.atelierai.unity.copilot/package.json +1 -1
- /package/vendor/plugin/com.atelierai.unity.copilot/Editor/UI/uss/common/{_mcp-list-window.uss.meta → _copilot-list-window.uss.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><developmentDependency>true</developmentDependency></c>
|
|
24
|
-
/// in their .nuspec and legitimately have no runtime DLLs under <c>lib/<tfm>/</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(), "
|
|
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><developmentDependency>true</developmentDependency></c>
|
|
24
|
+
/// in their .nuspec and legitimately have no runtime DLLs under <c>lib/<tfm>/</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(), "
|
|
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
|
+
}
|