Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Packages/src/Cli~/src/__tests__/package-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ type AssemblyDefinition = {

const TEST_FRAMEWORK_PACKAGE_NAME = 'com.unity.test-framework';
const TEST_FRAMEWORK_DEFINE = 'ULOOPMCP_HAS_TEST_FRAMEWORK';
const METADATA_VALIDATION_DEPENDENCY_META_PATHS = [
'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Collections.Immutable.dll.meta',
'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Reflection.Metadata.dll.meta',
'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Runtime.CompilerServices.Unsafe.dll.meta',
] as const;
const METADATA_VALIDATION_PRIVATE_ASSEMBLIES = [
{
relativePath:
'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Collections.Immutable.dll',
assemblyName: 'uLoopMCP.System.Collections.Immutable',
assemblyReferences: ['uLoopMCP.System.Runtime.CompilerServices.Unsafe'],
},
{
relativePath: 'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Reflection.Metadata.dll',
assemblyName: 'uLoopMCP.System.Reflection.Metadata',
assemblyReferences: [
'uLoopMCP.System.Collections.Immutable',
'uLoopMCP.System.Runtime.CompilerServices.Unsafe',
],
},
{
relativePath:
'Editor/MetadataValidation/Dependencies/uLoopMCP.System.Runtime.CompilerServices.Unsafe.dll',
assemblyName: 'uLoopMCP.System.Runtime.CompilerServices.Unsafe',
assemblyReferences: [],
},
] as const;

function loadPackageManifest(): PackageManifest {
const packageJsonPath = join(__dirname, '..', '..', 'package.json');
Expand All @@ -45,6 +72,18 @@ function loadEditorAssemblyDefinition(): AssemblyDefinition {
return JSON.parse(asmdefText) as AssemblyDefinition;
}

function loadUnityPackageText(relativePath: string): string {
const assetPath = join(__dirname, '..', '..', '..', relativePath);
// eslint-disable-next-line security/detect-non-literal-fs-filename
return readFileSync(assetPath, 'utf8');
}

function loadUnityPackageBytes(relativePath: string): Buffer {
const assetPath = join(__dirname, '..', '..', '..', relativePath);
// eslint-disable-next-line security/detect-non-literal-fs-filename
return readFileSync(assetPath);
}

describe('package metadata', () => {
it('avoids bin target prefixes that npm normalizes during publish', () => {
const packageManifest = loadPackageManifest();
Expand Down Expand Up @@ -75,4 +114,27 @@ describe('package metadata', () => {
}),
);
});

it('keeps bundled metadata validation dependencies out of implicit project references', () => {
for (const metaPath of METADATA_VALIDATION_DEPENDENCY_META_PATHS) {
const metaText = loadUnityPackageText(metaPath);

expect(metaText).toContain('isExplicitlyReferenced: 1');
}
});

it('uses private assembly identities for metadata validation dependencies', () => {
for (const assembly of METADATA_VALIDATION_PRIVATE_ASSEMBLIES) {
const dllBytes = loadUnityPackageBytes(assembly.relativePath);

expect(dllBytes.includes(Buffer.from(assembly.assemblyName))).toBe(true);
for (const assemblyReference of assembly.assemblyReferences) {
expect(dllBytes.includes(Buffer.from(assemblyReference))).toBe(true);
}
}
});

it('does not keep orphaned plugin folder metadata', () => {
expect(() => loadUnityPackageText('Plugins.meta')).toThrow();
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"System.Collections.Immutable.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Reflection.Metadata.dll"
"uLoopMCP.System.Collections.Immutable.dll",
"uLoopMCP.System.Runtime.CompilerServices.Unsafe.dll",
"uLoopMCP.System.Reflection.Metadata.dll"
],
"autoReferenced": true,
"defineConstraints": [],
Expand Down
8 changes: 0 additions & 8 deletions Packages/src/Plugins/CodeAnalysis.meta

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.