From 719058b2ff47a334348d9d9141025b04e080b002 Mon Sep 17 00:00:00 2001 From: divlo Date: Thu, 24 Jun 2021 22:04:28 +0200 Subject: [PATCH] feat(languages): add C# support --- README.md | 1 + .../hello-world/solutions/cs/function/README.md | 3 +++ .../hello-world/solutions/cs/function/Solution.cs | 15 +++++++++++++++ .../hello-world/solutions/cs/function/cs.csproj | 6 ++++++ cli/services/GitAffected.ts | 2 +- templates/docker/cs/Dockerfile | 5 +++++ templates/solution/cs/Solution.cs | 15 +++++++++++++++ templates/solution/cs/cs.csproj | 6 ++++++ 8 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 challenges/hello-world/solutions/cs/function/README.md create mode 100644 challenges/hello-world/solutions/cs/function/Solution.cs create mode 100644 challenges/hello-world/solutions/cs/function/cs.csproj create mode 100644 templates/docker/cs/Dockerfile create mode 100644 templates/solution/cs/Solution.cs create mode 100644 templates/solution/cs/cs.csproj diff --git a/README.md b/README.md index 5326674..469f644 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Each challenge has its **solutions**, its **instructions** and **input/output ex ### ✅ Programming languages available - [C/C++ (gcc)](https://gcc.gnu.org/) +- [C# (.NET Core)](https://docs.microsoft.com/en-us/dotnet/csharp/) - [Dart](https://dart.dev/) - [JavaScript/TypeScript (Node.js)](https://nodejs.org/) - [Python](https://www.python.org/) diff --git a/challenges/hello-world/solutions/cs/function/README.md b/challenges/hello-world/solutions/cs/function/README.md new file mode 100644 index 0000000..e2ef5c9 --- /dev/null +++ b/challenges/hello-world/solutions/cs/function/README.md @@ -0,0 +1,3 @@ +# hello-world/cs/function + +Created by [@Divlo](https://github.com/Divlo) on 24 June 2021. diff --git a/challenges/hello-world/solutions/cs/function/Solution.cs b/challenges/hello-world/solutions/cs/function/Solution.cs new file mode 100644 index 0000000..2ca42b3 --- /dev/null +++ b/challenges/hello-world/solutions/cs/function/Solution.cs @@ -0,0 +1,15 @@ +namespace Solution +{ + class Program + { + static void Main() + { + string line; + while ((line = System.Console.ReadLine()) != null) + { + + System.Console.WriteLine($"Hello, {line}!"); + } + } + } +} diff --git a/challenges/hello-world/solutions/cs/function/cs.csproj b/challenges/hello-world/solutions/cs/function/cs.csproj new file mode 100644 index 0000000..dbc7a12 --- /dev/null +++ b/challenges/hello-world/solutions/cs/function/cs.csproj @@ -0,0 +1,6 @@ + + + Exe + net5.0 + + diff --git a/cli/services/GitAffected.ts b/cli/services/GitAffected.ts index 1e8246a..eae3200 100644 --- a/cli/services/GitAffected.ts +++ b/cli/services/GitAffected.ts @@ -6,7 +6,7 @@ import { Solution } from './Solution' const git = simpleGit() const solutionsRegex = new RegExp( - /challenges\/[\s\S]*\/solutions\/(c|cpp|dart|javascript|python|rust|typescript)\/[\s\S]*\/solution.(c|cpp|dart|js|py|rs|ts)/ + /challenges\/[\s\S]*\/solutions\/(c|cpp|cs|dart|javascript|python|rust|typescript)\/[\s\S]*\/(solution|Solution).(c|cpp|cs|dart|js|py|rs|ts)/ ) class GitAffected { diff --git a/templates/docker/cs/Dockerfile b/templates/docker/cs/Dockerfile new file mode 100644 index 0000000..c71206e --- /dev/null +++ b/templates/docker/cs/Dockerfile @@ -0,0 +1,5 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0 +WORKDIR /usr/src/app +COPY ./ ./ +RUN dotnet restore +ENTRYPOINT ["dotnet", "run"] diff --git a/templates/solution/cs/Solution.cs b/templates/solution/cs/Solution.cs new file mode 100644 index 0000000..2ca42b3 --- /dev/null +++ b/templates/solution/cs/Solution.cs @@ -0,0 +1,15 @@ +namespace Solution +{ + class Program + { + static void Main() + { + string line; + while ((line = System.Console.ReadLine()) != null) + { + + System.Console.WriteLine($"Hello, {line}!"); + } + } + } +} diff --git a/templates/solution/cs/cs.csproj b/templates/solution/cs/cs.csproj new file mode 100644 index 0000000..dbc7a12 --- /dev/null +++ b/templates/solution/cs/cs.csproj @@ -0,0 +1,6 @@ + + + Exe + net5.0 + +