From 8cf080dc3d0c369fa9196a47c981db9a698aa907 Mon Sep 17 00:00:00 2001 From: Abhiram Pai Date: Thu, 1 Aug 2024 21:34:10 +0530 Subject: [PATCH 1/3] Added codemirror csharp package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9675c8a..7f6e00e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@codemirror/legacy-modes": "6.1.0", "@mlc-ai/web-llm": "^0.2.51", "@preact/signals-react": "^2.1.0", + "@replit/codemirror-lang-csharp": "^6.2.0", "@uiw/codemirror-theme-sublime": "4.11.1", "@uiw/react-codemirror": "4.11.1", "@uiw/react-md-editor": "^3.20.6", From 771509b52c98f746713c4ddfa87f90292ea0aa36 Mon Sep 17 00:00:00 2001 From: Abhiram Pai Date: Thu, 1 Aug 2024 21:34:25 +0530 Subject: [PATCH 2/3] Added csharp code stub --- src/Components/LanguageSelector/constants.js | 46 ++++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Components/LanguageSelector/constants.js b/src/Components/LanguageSelector/constants.js index 3de1128..80fc030 100644 --- a/src/Components/LanguageSelector/constants.js +++ b/src/Components/LanguageSelector/constants.js @@ -3,67 +3,77 @@ export const LANGUAGE_OPTIONS = [ title: "Bash", label: "Bash (5.0.0)", value: 46, - stub: "" + stub: "", }, { title: "C", label: "C (GCC 9.2.0)", value: 50, - stub: - '// C: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\n#include \n#include \n#include \n\n#define MAX 255\n\nvoid function_name(int arg){\n // Write your code here\n}\n\nint main() {\n\n int arg;\n scanf("%d", &arg);\n function_name(arg);\n\n return 0;\n}\n\n' + stub: '// C: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\n#include \n#include \n#include \n\n#define MAX 255\n\nvoid function_name(int arg){\n // Write your code here\n}\n\nint main() {\n\n int arg;\n scanf("%d", &arg);\n function_name(arg);\n\n return 0;\n}\n\n', }, { title: "C++", label: "C++ (GCC 9.2.0)", value: 54, - stub: - "// C++: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\n#include \n#include \nusing namespace std;\n\nvoid function_name(string arg){\n // Write your code here\n}\n\nint main(){\n\n string arg;\n getline(cin, arg);\n function_name(arg);\n\n return 0;\n}\n\n" + stub: "// C++: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\n#include \n#include \nusing namespace std;\n\nvoid function_name(string arg){\n // Write your code here\n}\n\nint main(){\n\n string arg;\n getline(cin, arg);\n function_name(arg);\n\n return 0;\n}\n\n", + }, + { + title: "C#", + label: "C# (Mono 6.6.0.161)", + value: 51, + stub: `using System; +namespace Test +{ + class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello, world!"); + } + } +} +`, }, { title: "Go", label: "Go (1.13.5)", value: 60, - stub: "" + stub: "", }, { title: "Java", label: "Java (OpenJDK 13.0.1)", value: 62, - stub: - "// Java: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\nimport java.util.Scanner;\n\nclass Result {\n public static void functionName(String arg){\n // Write your code here\n\n }\n}\n\nclass Main {\n public static void main(String args[]) {\n Scanner scanner = new Scanner(System.in);\n String arg = scanner.nextLine();\n\n Result.functionName(arg);\n }\n}\n" + stub: "// Java: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\nimport java.util.Scanner;\n\nclass Result {\n public static void functionName(String arg){\n // Write your code here\n\n }\n}\n\nclass Main {\n public static void main(String args[]) {\n Scanner scanner = new Scanner(System.in);\n String arg = scanner.nextLine();\n\n Result.functionName(arg);\n }\n}\n", }, { title: "JavaScript", label: "JavaScript (Node.js 12.14.0)", value: 63, - stub: - '// Default code for reading input data\nprocess.stdin.resume();\nprocess.stdin.setEncoding("utf-8");\nvar stdin = "";\n\nprocess.stdin.on("data", (input) => {\n stdin += input;\n});\n\nprocess.stdin.on("end", () => {\n stdin = stdin.split(\'\\n\');\n\n functionName(stdin);\n});\n\nfunction functionName(stdin_array) {\n /**\n NOTE: Start modifying below code\n if necessary parse input as required in question and\n print your program\'s output using console.log\n\n Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n Following is only a sample code snippet and may not have anything to do with the question\n\n stdin_array: array of inputs or lines read from stdin\n */\n console.log(stdin_array);\n}\n\n' + stub: '// Default code for reading input data\nprocess.stdin.resume();\nprocess.stdin.setEncoding("utf-8");\nvar stdin = "";\n\nprocess.stdin.on("data", (input) => {\n stdin += input;\n});\n\nprocess.stdin.on("end", () => {\n stdin = stdin.split(\'\\n\');\n\n functionName(stdin);\n});\n\nfunction functionName(stdin_array) {\n /**\n NOTE: Start modifying below code\n if necessary parse input as required in question and\n print your program\'s output using console.log\n\n Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n Following is only a sample code snippet and may not have anything to do with the question\n\n stdin_array: array of inputs or lines read from stdin\n */\n console.log(stdin_array);\n}\n\n', }, { title: "Python", label: "Python (2.7.17)", value: 70, - stub: - "# Python: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args):\n # Write your code here\n\n\nargs = raw_input().strip()\nprint(function_name(args))\n\n" + stub: "# Python: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args):\n # Write your code here\n\n\nargs = raw_input().strip()\nprint(function_name(args))\n\n", }, { title: "Python", label: "Python (3.8.1)", value: 71, - stub: - "# Python: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args):\n # Write your code here\n\n\nargs = input().strip()\nprint(function_name(args))\n\n" + stub: "# Python: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args):\n # Write your code here\n\n\nargs = input().strip()\nprint(function_name(args))\n\n", }, { title: "Ruby", label: "Ruby (2.7.0)", value: 72, - stub: - "# Ruby: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args)\n # Write your code here\n\nend\n\nargs = gets.chomp\nprint(function_name(args))\n\n" + stub: "# Ruby: following is only a sample code snippet to read the input from stdin and may not have anything to do with the question\n\ndef function_name(args)\n # Write your code here\n\nend\n\nargs = gets.chomp\nprint(function_name(args))\n\n", }, { title: "Rust", label: "Rust (1.40.0)", value: 73, - stub: "" - } + stub: "", + }, ]; From f88c92ec44614227e504e9884cfc3c1a25ce7797 Mon Sep 17 00:00:00 2001 From: Abhiram Pai Date: Thu, 1 Aug 2024 21:34:53 +0530 Subject: [PATCH 3/3] Added csharp to languageMap --- src/Components/CodeEditor/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Components/CodeEditor/utils.js b/src/Components/CodeEditor/utils.js index 103b0bc..67e3f70 100644 --- a/src/Components/CodeEditor/utils.js +++ b/src/Components/CodeEditor/utils.js @@ -7,6 +7,7 @@ import { StreamLanguage } from "@codemirror/language"; import { go } from "@codemirror/legacy-modes/mode/go"; import { ruby } from "@codemirror/legacy-modes/mode/ruby"; import { shell } from "@codemirror/legacy-modes/mode/shell"; +import { csharp } from "@replit/codemirror-lang-csharp"; export const mapLanguages = (value) => { const mappedLanguages = { @@ -16,9 +17,10 @@ export const mapLanguages = (value) => { rust, c: cpp, "c++": cpp, + "c#": csharp, go: () => StreamLanguage.define(go), ruby: () => StreamLanguage.define(ruby), - bash: () => StreamLanguage.define(shell) + bash: () => StreamLanguage.define(shell), }; return mappedLanguages[value]; };