Skip to content

Commit 4d7499f

Browse files
committed
_check_no_embedder
1 parent 0756402 commit 4d7499f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

onlinejudge_verify/languages/csharp.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pathlib
66
import subprocess
77
from logging import getLogger
8+
from turtle import st
89
from typing import *
910
import distutils.version
1011
import shutil
@@ -92,6 +93,14 @@ def _check_env(path: pathlib.Path):
9293
_check_embedded_existing(_resolve_csproj(path))
9394

9495

96+
@functools.lru_cache(maxsize=None)
97+
def _check_no_embedder(csproj_path: pathlib.Path) -> None:
98+
root = ET.parse(csproj_path).getroot()
99+
if root.find('.//PackageReference[@Include="SourceExpander.Embedder"]'):
100+
logger.error(
101+
" Test project(%s) has `SourceExpander.Embedder` reference. Libraries and tests should not be in same project.", str(csproj_path))
102+
103+
95104
@functools.lru_cache(maxsize=None)
96105
def _resolve_csproj(path: pathlib.Path) -> Optional[pathlib.Path]:
97106
path = path.resolve()
@@ -120,7 +129,9 @@ def _expand_code_dict(csproj_path: pathlib.Path) -> Dict[pathlib.Path, str]:
120129
@functools.lru_cache(maxsize=None)
121130
def _expand_code(path: pathlib.Path) -> bytes:
122131
_check_expander_console()
123-
d = _expand_code_dict(_resolve_csproj(path))
132+
csproj_path = _resolve_csproj(path)
133+
_check_no_embedder(csproj_path)
134+
d = _expand_code_dict(csproj_path)
124135
return d[path].encode('utf-8')
125136

126137

0 commit comments

Comments
 (0)