Skip to content

Commit 4891ddf

Browse files
csharp update
1 parent b33726b commit 4891ddf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

language/csharp/csharp.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package csharp
33
import (
44
"github.com/coderbyte-org/cb-code-runner/cmd"
55
"path/filepath"
6+
"strings"
67
)
78

89
func Run(files []string, stdin string) (string, string, error, string) {
910
workDir := filepath.Dir(files[0])
1011
projFile := "Main.csproj"
12+
lastFile := files[len(files) - 1]
1113

1214
// run using `dotnet` now instead of the previous `mcs` method, this allows us to add .csproj files
1315
// https://stackoverflow.com/a/64646610
@@ -19,5 +21,10 @@ func Run(files []string, stdin string) (string, string, error, string) {
1921
}
2022

2123
binPath := filepath.Join(workDir, projFile)
22-
return cmd.RunStdin(workDir, stdin, "dotnet", "run", binPath)
24+
25+
if (strings.Contains(lastFile, "dotnet_test")) {
26+
return cmd.RunStdin(workDir, stdin, "dotnet", "test", projFile, "--logger", "\"console;verbosity=detailed\"")
27+
} else {
28+
return cmd.RunStdin(workDir, stdin, "dotnet", "run", binPath)
29+
}
2330
}

0 commit comments

Comments
 (0)