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 7282390 commit 9faa087
Showing 1 changed file with 8 additions and 0 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

0 comments on commit 9faa087

Please sign in to comment.