Skip to content

Commit

Permalink
Spruce up the c-sharp template and bump to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
UnstoppableMango authored and kylehoehns committed Feb 7, 2025
1 parent 0529a95 commit 9032854
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode
localstack/data
.mypy_cache
target
target
2 changes: 1 addition & 1 deletion c-sharp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bin
obj
obj
12 changes: 3 additions & 9 deletions c-sharp/Check.Tests/Check.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" PrivateAssets="all" />
<PackageReference Include="coverlet.collector" Version="6.0.4" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 11 additions & 12 deletions c-sharp/Check.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using Xunit;

namespace Check.Tests
namespace Check.Tests;

public class GeneratorTests
{
public class GeneratorTests
[Fact]
public void GetGreeting_ReturnsCorrectGreeting()
{
[Fact]
public void GetGreeting_ReturnsCorrectGreeting()
{
Assert.Equal("Hello", Generator.GetGreeting());
}
Assert.Equal("Hello", Generator.GetGreeting());
}

[Fact]
public void GetName_ReturnsCorrectName()
{
Assert.Equal("World", Generator.GetName());
}
[Fact]
public void GetName_ReturnsCorrectName()
{
Assert.Equal("World", Generator.GetName());
}
}
2 changes: 1 addition & 1 deletion c-sharp/Check/Check.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
19 changes: 9 additions & 10 deletions c-sharp/Check/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
namespace Check
namespace Check;

public static class Generator
{
public static class Generator
public static string GetGreeting()
{
public static string GetGreeting()
{
return "Hello";
}
return "Hello";
}

public static string GetName()
{
return "World";
}
public static string GetName()
{
return "World";
}
}
11 changes: 5 additions & 6 deletions c-sharp/Check/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;

namespace Check
namespace Check;

public class Program
{
class Program
public static void Main(string[] args)
{
static void Main(string[] args)
{
Console.WriteLine($"{Generator.GetGreeting()} {Generator.GetName()}");
}
Console.WriteLine($"{Generator.GetGreeting()} {Generator.GetName()}");
}
}
3 changes: 1 addition & 2 deletions c-sharp/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
init:
dotnet restore;
dotnet build

verify:
dotnet test

.PHONY: init verify
.PHONY: init verify
11 changes: 7 additions & 4 deletions c-sharp/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# C# Project

## Tech Stack
- .NET 7
- C# 11

- .NET 8
- C# 12
- xUnit

## Common Commands

- `make init`
- build the project
- build the project

- `make verify`
- run tests
- run tests
6 changes: 6 additions & 0 deletions c-sharp/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.403",
"rollForward": "latestMajor"
}
}

0 comments on commit 9032854

Please sign in to comment.