Skip to content

Commit

Permalink
Merge pull request #2 from codefreak/feature/csharp
Browse files Browse the repository at this point in the history
Add C#/.NET template
  • Loading branch information
erikhofer authored May 27, 2020
2 parents 318d293 + d4f4604 commit 456c69f
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 0 deletions.
5 changes: 5 additions & 0 deletions templates/csharp/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-dotnettools.csharp"
]
}
27 changes: 27 additions & 0 deletions templates/csharp/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/AddFunction/bin/Debug/netcoreapp3.0/AddFunction.dll",
"args": [],
"cwd": "${workspaceFolder}/src/AddFunction",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions templates/csharp/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/AddFunction/AddFunction.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/AddFunction/AddFunction.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/AddFunction/AddFunction.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
31 changes: 31 additions & 0 deletions templates/csharp/AddFunction.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddFunction", "src\AddFunction\AddFunction.csproj", "{DA27DAE8-8C58-4434-91A0-3499695FE44E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddFunctionTest", "tests\AddFunction.Tests\AddFunction.Tests.csproj", "{B0DD0D89-DD33-485F-BA85-A35C5D6DF460}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DA27DAE8-8C58-4434-91A0-3499695FE44E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA27DAE8-8C58-4434-91A0-3499695FE44E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA27DAE8-8C58-4434-91A0-3499695FE44E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA27DAE8-8C58-4434-91A0-3499695FE44E}.Release|Any CPU.Build.0 = Release|Any CPU
{B0DD0D89-DD33-485F-BA85-A35C5D6DF460}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0DD0D89-DD33-485F-BA85-A35C5D6DF460}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0DD0D89-DD33-485F-BA85-A35C5D6DF460}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0DD0D89-DD33-485F-BA85-A35C5D6DF460}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25F81973-18A7-4F83-BE8E-260D70548CC7}
EndGlobalSection
EndGlobal
42 changes: 42 additions & 0 deletions templates/csharp/codefreak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
title: Unnamed C# Task
description: |
# C# Task Example
This is basic C# task to get you started quickly with Code FREAK.
To turn this into a useful programming exercise, you have to do the following.
## Provide Code to Students
If you do not want your students to start completely from scratch, provide some scaffolding code. Look into `src/` for some inspiration.
## Setup Automatic Evaluation
This example comes with two pre-configured evaluation steps. You can see them in the _Evaluation_ tab. To try it out, enter _testing mode_ and start the evaluation.
### Static Code Analysis
The tool [Code Climate](https://github.com/codeclimate/codeclimate) is used to provide your students with tips on how to write better code. It is configured via `.codeclimate.yml` in the task files. See [official documentation](https://docs.codeclimate.com/docs/advanced-configuration) for details.
### Unit Tests
Unit tests are your main instrument for automatically validating your students' answers. To get started, look into `tests/` for example test cases.
The standard testing framework for .NET is NUnit. Refer to the [official documentation](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit) for more information.
## Provide Instructions
Click on this text to edit it. Here you describe to your students what they have to do.
hidden:
- tests/**
protected:
- AddFunction.sln
evaluation:
- step: codeclimate
- step: junit
options:
image: "mcr.microsoft.com/dotnet/core/sdk:3.1"
project-path: /code
results-path: tests/AddFunction.Tests
commands:
- dotnet test tests/AddFunction.Tests/AddFunction.Tests.csproj --logger "junit;LogFilePath=TEST-report.xml"
16 changes: 16 additions & 0 deletions templates/csharp/src/AddFunction/AddFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace AddFunction
{
public class Program
{
public static int Add(int a, int b)
{
return 0;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
8 changes: 8 additions & 0 deletions templates/csharp/src/AddFunction/AddFunction.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>
20 changes: 20 additions & 0 deletions templates/csharp/tests/AddFunction.Tests/AddFunction.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JUnitTestLogger" Version="1.1.0" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AddFunction\AddFunction.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions templates/csharp/tests/AddFunction.Tests/AddFunctionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using NUnit.Framework;
using AddFunction;

namespace AddFunctionTest
{
public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.AreEqual(10, Program.Add(5, 5));
}
}
}

0 comments on commit 456c69f

Please sign in to comment.