Skip to content

Commit

Permalink
fix: ready for c# support
Browse files Browse the repository at this point in the history
  • Loading branch information
seo-rii committed Jan 8, 2022
1 parent 0ac32b0 commit b162675
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions res/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
KOTLIN: 'kt',
RUBY: 'rb',
PHP: 'php',
CSHARP: 'cs',
}

const exampleCode = {
Expand Down Expand Up @@ -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 = [
Expand Down
55 changes: 55 additions & 0 deletions src/runner/languages/csharp.ts
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 2 additions & 1 deletion src/types/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b162675

Please sign in to comment.