@@ -4,17 +4,29 @@ import (
4
4
"github.com/coderbyte-org/cb-code-runner/cmd"
5
5
"github.com/coderbyte-org/cb-code-runner/util"
6
6
"path/filepath"
7
+ "io"
8
+ "os"
9
+ "fmt"
7
10
)
8
11
9
12
func Run (files []string , stdin string ) (string , string , error , string ) {
10
13
workDir := filepath .Dir (files [0 ])
11
14
binName := "a.exe"
15
+ sourceFiles := util .FilterByExtension (files , "cs" )
12
16
13
- // TODO: getting JSON package to work with C#
17
+ // for C#, need to link .dll files to this project and include them in directory
14
18
// https://stackoverflow.com/questions/50079804/how-do-i-add-json-assembly-to-compile-c-sharp-code-on-ubuntu-terminal-using-mcs
15
19
// https://stackoverflow.com/questions/49767212/how-to-compile-and-run-c-sharp-project-from-terminal-mac-os
16
- sourceFiles := util .FilterByExtension (files , "cs" )
17
- args := append ([]string {"mcs" , "-out:" + binName }, sourceFiles ... )
20
+ // https://docs.unity3d.com/462/Documentation/Manual/UsingDLL.html
21
+ oldLocation := "/usr/local/bin/Newtonsoft.Json.dll"
22
+ newLocation := workDir + "/Newtonsoft.Json.dll"
23
+ srcFile , err := os .Open (oldLocation )
24
+ destFile , err := os .Create (newLocation )
25
+ _ , err = io .Copy (destFile , srcFile )
26
+ err = destFile .Sync ()
27
+
28
+ args := append ([]string {"mcs" , "-r:Newtonsoft.Json.dll" , "-out:" + binName }, sourceFiles ... )
29
+
18
30
stdout , stderr , err , duration := cmd .Run (workDir , args ... )
19
31
if err != nil || stderr != "" {
20
32
return stdout , stderr , err , duration
0 commit comments