diff --git a/client/src/components/CodeEditorMonaco/const.ts b/client/src/components/CodeEditorMonaco/const.ts index 00b5249..63d86c7 100644 --- a/client/src/components/CodeEditorMonaco/const.ts +++ b/client/src/components/CodeEditorMonaco/const.ts @@ -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!"); + } + } }`, }; diff --git a/client/src/components/CodeEditorMonaco/index.tsx b/client/src/components/CodeEditorMonaco/index.tsx index d57c1a7..c0a6428 100644 --- a/client/src/components/CodeEditorMonaco/index.tsx +++ b/client/src/components/CodeEditorMonaco/index.tsx @@ -34,7 +34,8 @@ type monacoLang = | 'java' | 'php' | 'rust' - | 'c'; + | 'c' + | 'csharp'; export interface Expose { getEditor: () => monaco.editor.IStandaloneCodeEditor | null; @@ -49,6 +50,7 @@ const languageMap: Record = { [CodeType.php]: 'php', [CodeType.rust]: 'rust', [CodeType.c]: 'c', + [CodeType.dotnet]: 'csharp', }; const Component = (props: Props, ref: ForwardedRef) => { diff --git a/client/src/utils/codeType.ts b/client/src/utils/codeType.ts index 7f55572..888c73a 100644 --- a/client/src/utils/codeType.ts +++ b/client/src/utils/codeType.ts @@ -7,6 +7,7 @@ export enum CodeType { php = 'php', rust = 'rust', c = 'c', + dotnet = 'dotnet', } export enum CodeEnv { @@ -18,6 +19,7 @@ export enum CodeEnv { php = 'php:8', rust = 'rust:latest', c = 'cpp:11', + dotnet = 'dotnet:lts', } export enum FileSuffix { @@ -29,4 +31,5 @@ export enum FileSuffix { php = 'php', rust = 'rs', c = 'c', + dotnet = 'cs', } diff --git a/server/src/docker/dotnet/Dockerfile b/server/src/docker/dotnet/Dockerfile new file mode 100644 index 0000000..8a39edd --- /dev/null +++ b/server/src/docker/dotnet/Dockerfile @@ -0,0 +1 @@ +FROM mono:latest \ No newline at end of file diff --git a/server/src/docker/index.ts b/server/src/docker/index.ts index aed55f4..2842715 100644 --- a/server/src/docker/index.ts +++ b/server/src/docker/index.ts @@ -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: { diff --git a/server/src/utils/type.ts b/server/src/utils/type.ts index 7f55572..e59dedd 100644 --- a/server/src/utils/type.ts +++ b/server/src/utils/type.ts @@ -7,6 +7,7 @@ export enum CodeType { php = 'php', rust = 'rust', c = 'c', + dotnet = 'dotnet', } export enum CodeEnv { @@ -18,6 +19,7 @@ export enum CodeEnv { php = 'php:8', rust = 'rust:latest', c = 'cpp:11', + dotnet = 'mono:lts', } export enum FileSuffix { @@ -29,4 +31,5 @@ export enum FileSuffix { php = 'php', rust = 'rs', c = 'c', + dotnet = 'cs', }