Skip to content

Commit

Permalink
feat: Add csharp to srcmak options
Browse files Browse the repository at this point in the history
  • Loading branch information
haodeon authored Jul 23, 2024
1 parent 148ca1f commit 5ca5a8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/cmds/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { parseImports } from '../../util';
const config = readConfigSync();

const DEFAULT_OUTDIR = 'imports';
const LANGUAGES = ['typescript', 'python', 'java', 'go'];
const LANGUAGES = ['typescript', 'python', 'java', 'csharp', 'go'];

class Command implements yargs.CommandModule {
public readonly command = 'import [SPEC]';
Expand Down
16 changes: 15 additions & 1 deletion src/import/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { mkdtemp } from '../util';
export enum Language {
TYPESCRIPT = 'typescript',
PYTHON = 'python',
DOTNET = 'dotnet',
JAVA = 'java',
DOTNET = 'csharp',
GO = 'go',
}

Expand Down Expand Up @@ -59,6 +59,7 @@ export abstract class ImportBase {
switch (options.targetLanguage) {
case Language.PYTHON:
case Language.JAVA:
case Language.DOTNET:
name = name.split('.').reverse().join('.');
break;
}
Expand Down Expand Up @@ -128,6 +129,19 @@ export abstract class ImportBase {
};
}

// dotnet!
if (options.targetLanguage === Language.DOTNET) {
const dotnetNamespace = `${moduleNamePrefix ? `${moduleNamePrefix}.${module.name}` : module.name}`
.replace(/-/g, '_')
.split('.')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join('.');
opts.csharp = {
outdir: outdir,
namespace: dotnetNamespace,
};
}

// go!
if (options.targetLanguage === Language.GO) {
const { userModuleName, userModulePath } = this.getGoModuleName(outdir);
Expand Down

0 comments on commit 5ca5a8a

Please sign in to comment.