Skip to content

Commit

Permalink
feat: 增加 C# 语言
Browse files Browse the repository at this point in the history
  • Loading branch information
xjq7 committed Oct 29, 2022
1 parent 53279c9 commit d7e3183
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions client/src/components/CodeEditorMonaco/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,16 @@ echo 'hello world!';`,
int main() {
printf("Hello, World");
return (0);
}`,
[CodeType.dotnet]: `using System;
namespace CodeApplication
{
class Code
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}`,
};
4 changes: 3 additions & 1 deletion client/src/components/CodeEditorMonaco/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type monacoLang =
| 'java'
| 'php'
| 'rust'
| 'c';
| 'c'
| 'csharp';

export interface Expose {
getEditor: () => monaco.editor.IStandaloneCodeEditor | null;
Expand All @@ -49,6 +50,7 @@ const languageMap: Record<CodeType, monacoLang> = {
[CodeType.php]: 'php',
[CodeType.rust]: 'rust',
[CodeType.c]: 'c',
[CodeType.dotnet]: 'csharp',
};

const Component = (props: Props, ref: ForwardedRef<Expose>) => {
Expand Down
3 changes: 3 additions & 0 deletions client/src/utils/codeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum CodeType {
php = 'php',
rust = 'rust',
c = 'c',
dotnet = 'dotnet',
}

export enum CodeEnv {
Expand All @@ -18,6 +19,7 @@ export enum CodeEnv {
php = 'php:8',
rust = 'rust:latest',
c = 'cpp:11',
dotnet = 'dotnet:lts',
}

export enum FileSuffix {
Expand All @@ -29,4 +31,5 @@ export enum FileSuffix {
php = 'php',
rust = 'rs',
c = 'c',
dotnet = 'cs',
}
1 change: 1 addition & 0 deletions server/src/docker/dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mono:latest
6 changes: 6 additions & 0 deletions server/src/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ expand_arg_files()
shellWithStdin: 'g++ code.c -o code.out && ./code.out < input.txt',
fileSuffix: FileSuffix.c,
},
dotnet: {
env: CodeEnv.dotnet,
shell: 'mcs -out:code.exe code.cs && mono code.exe',
shellWithStdin: 'mcs -out:code.exe code.cs && mono code.exe < input.txt',
fileSuffix: FileSuffix.dotnet,
},
};

export async function run2(params: {
Expand Down
3 changes: 3 additions & 0 deletions server/src/utils/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum CodeType {
php = 'php',
rust = 'rust',
c = 'c',
dotnet = 'dotnet',
}

export enum CodeEnv {
Expand All @@ -18,6 +19,7 @@ export enum CodeEnv {
php = 'php:8',
rust = 'rust:latest',
c = 'cpp:11',
dotnet = 'mono:lts',
}

export enum FileSuffix {
Expand All @@ -29,4 +31,5 @@ export enum FileSuffix {
php = 'php',
rust = 'rs',
c = 'c',
dotnet = 'cs',
}

0 comments on commit d7e3183

Please sign in to comment.