Skip to content

Commit cb7d60f

Browse files
committed
Parse compiler warnings and errors
1 parent aaba1ac commit cb7d60f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tested/languages/csharp/config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import re
23
from pathlib import Path
34
from typing import List, Tuple, Optional
45

@@ -32,6 +33,7 @@ def file_filter(file: Path) -> bool:
3233
"--nologo",
3334
f"-p:AssemblyName={name}",
3435
f"-p:StartupObject=Tested.{name}",
36+
"-consoleloggerparameters:NoSummary",
3537
]
3638

3739
return args, file_filter
@@ -87,3 +89,25 @@ class {class_name}
8789

8890
with open(solution, "w") as file:
8991
file.write(result)
92+
93+
def compiler_output(
94+
self, namespace: str, stdout: str, stderr: str
95+
) -> Tuple[List[Message], List[AnnotateCode], str, str]:
96+
submission_name = self.with_extension(self.conventionalize_namespace(namespace))
97+
message_regex = (
98+
rf"{submission_name}\((\d+),(\d+)\): (error|warning) ([A-Z0-9]+): (.*) \["
99+
)
100+
messages = re.findall(message_regex, stdout)
101+
annotations = []
102+
for message in messages:
103+
annotations.append(
104+
AnnotateCode(
105+
row=int(message[0]),
106+
text=message[4],
107+
externalUrl="https://learn.microsoft.com/dotnet/csharp/language-reference/compiler-messages/",
108+
column=int(message[1]),
109+
type=message[2],
110+
)
111+
)
112+
113+
return [], annotations, stdout, stderr

0 commit comments

Comments
 (0)