diff --git a/Dockerfile b/Dockerfile index eb06cff..8d1317b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,14 @@ RUN ruby --version RUN apk add php7 RUN php --version +# Install .NET +RUN apk add bash icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib +RUN apk add libgdiplus --repository https://dl-3.alpinelinux.org/alpine/edge/testing/ +RUN wget https://dot.net/v1/dotnet-install.sh +RUN bash /dotnet-install.sh -c Current +RUN ln -s /root/.dotnet/dotnet /usr/local/bin/ +RUN dotnet --version + # Copy files & Install requirements RUN addgroup execute WORKDIR /HANA diff --git a/res/test.html b/res/test.html index 4854176..978172b 100644 --- a/res/test.html +++ b/res/test.html @@ -150,6 +150,7 @@ KOTLIN: 'kt', RUBY: 'rb', PHP: 'php', + CSHARP: 'cs', } const exampleCode = { @@ -243,6 +244,19 @@ fscanf(STDIN,"%d %d",$a,$b); fprintf(STDOUT,"%d",$a+$b); ?>`, + CSHARP: `using System; + +namespace HANA { + class Program { + static void Main() { + string s = Console.ReadLine(); + string[] ss = s.Split(); + int a = int.Parse(ss[0]); + int b = int.Parse(ss[1]); + Console.WriteLine(a+b); + } + } +}`, } const ProblemDataSet = [ diff --git a/src/runner/languages/csharp.ts b/src/runner/languages/csharp.ts new file mode 100644 index 0000000..d342f65 --- /dev/null +++ b/src/runner/languages/csharp.ts @@ -0,0 +1,55 @@ +import { JudgeSourceType, JudgeType } from '../../types/request' +import { execute, getLimitString, ResultType } from '../util' + +export async function build( + path: string, + uid: string, + sourceName: string = 'Main' +) { + await execute( + `p-${uid}`, + getLimitString( + { cpuLimit: 50 }, + `dotnet new console --force -o ${sourceName} && dotnet publish ${sourceName} --configuration Release --self-contained true --runtime linux-x64` + ), + { cwd: path } + ) + return { + resultType: ResultType.normal, + code: 0, + stderr: '', + stdout: '', + } +} + +export function getExecuteCommand( + path: string, + uid: string, + sourceName: string = 'Main' +) { + return `${path}/${sourceName}` +} + +export function getLanguage() { + return JudgeSourceType.CSHARP +} + +export function getExtension() { + return 'cs' +} + +export function getSupportedType() { + return [ + JudgeType.CommonJudge, + JudgeType.Interactive, + JudgeType.SpecialJudge, + ] +} + +export function getTimeLimit(baseTime: number) { + return baseTime +} + +export function getMemoryLimit(baseMemory: number) { + return baseMemory +} diff --git a/src/types/request.ts b/src/types/request.ts index d9c3853..a375395 100644 --- a/src/types/request.ts +++ b/src/types/request.ts @@ -32,9 +32,10 @@ export const enum JudgeSourceType { TYPESCRIPT = 'TYPESCRIPT', GO = 'GO', RUST = 'RUST', - KOTLIN = 'KOTLIN', + KOTLIN = '__KOTLIN', RUBY = 'RUBY', PHP = 'PHP', + CSHARP = '__CSHARP', } export interface SourceFile {