Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin committed Apr 8, 2024
1 parent 7bec5f4 commit 20499aa
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/NodeApi.Generator/TypeDefinitionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public enum ModuleType
import dotnet from 'node-api-dotnet';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252
import { dlopen, platform, arch } from 'node:process';
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -92,6 +93,7 @@ function importAotModule(moduleName) {
private const string LoadModuleCJS = @"
const dotnet = require('node-api-dotnet');
const path = require('node:path');
// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252
const { dlopen, platform, arch } = require('node:process');
const moduleName = path.basename(__filename, __filename.match(/(\.[cm]?js)?$/)[0]);
Expand Down Expand Up @@ -610,8 +612,14 @@ private IEnumerable<MemberInfo> GetExportedMembers()
}
}

/// <summary>
/// Generates a type definition for a single type. Primarily for unit-testing purposes.
/// </summary>
public string GenerateTypeDefinition(Type type)
{
// Don't use namespaces when generating a single type definition.
_isModule = true;

SourceBuilder s = new();
ExportType(ref s, type);
return s.ToString();
Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/projects/js-esm-module/net472.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net472.js';
import 'node-api-dotnet/net472';
import './test.js';
2 changes: 1 addition & 1 deletion test/TestCases/projects/js-esm-module/net6.0.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net6.0.js';
import 'node-api-dotnet/net6.0';
import './test.js';
2 changes: 1 addition & 1 deletion test/TestCases/projects/js-esm-module/net8.0.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net8.0.js';
import 'node-api-dotnet/net8.0';
import './test.js';
2 changes: 1 addition & 1 deletion test/TestCases/projects/ts-esm-module/net472.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net472.js';
import 'node-api-dotnet/net472';
import './test.js';
2 changes: 1 addition & 1 deletion test/TestCases/projects/ts-esm-module/net6.0.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net6.0.js';
import 'node-api-dotnet/net6.0';
import './test.js';
2 changes: 1 addition & 1 deletion test/TestCases/projects/ts-esm-module/net8.0.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import 'node-api-dotnet/net8.0.js';
import 'node-api-dotnet/net8.0';
import './test.js';

0 comments on commit 20499aa

Please sign in to comment.