Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 6 support #1064

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
45 changes: 45 additions & 0 deletions dmoj/executors/NETCS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os

from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir
from dmoj.executors.compiled_executor import CompiledExecutor

CSPROJ = b"""\
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
</Project>
"""

HELLO_WORLD_PROGRAM = """\
Console.WriteLine("Hello, World!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This program should echo input to output, not just write out "Hello, World!". See e.g. https://github.com/DMOJ/judge-server/blob/master/dmoj/executors/C.py#L11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@Xyene Xyene Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "wrong" because it so happens the string we pass as input is "Hello, World!". But not testing input means it might be broken (for syscall whitelist reasons) and CI wouldn't catch it. Rust should be switched to echoing, but it seems more likely that .NET would have wacky syscalls during input than Rust.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update it sometime later then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will change the behavior

"""
timbussmann marked this conversation as resolved.
Show resolved Hide resolved


class Executor(CompiledExecutor):
ext = 'cs'
command = 'dotnet'
test_program = HELLO_WORLD_PROGRAM
compiler_time_limit = 20
compiler_write_fs = [
RecursiveDir('~/.nuget/packages'),
RecursiveDir('~/.local/share/NuGet'),
RecursiveDir('/tmp/NuGetScratch'),
]

def create_files(self, problem_id, source_code, *args, **kwargs):
with open(self._file('Program.cs'), 'wb') as f:
f.write(source_code)

with open(self._file('DMOJ.csproj'), 'wb') as f:
f.write(CSPROJ)

def get_compile_args(self):
return [self.get_command(), 'publish', '--configuration', 'release', '--self-contained', 'false']

def get_compiled_file(self):
return self._file('bin', 'release', 'net6.0', 'DMOJ.exe')
timbussmann marked this conversation as resolved.
Show resolved Hide resolved
timbussmann marked this conversation as resolved.
Show resolved Hide resolved