Skip to content

Commit f235750

Browse files
authored
Merge pull request #94 from gothinkster/updates
update to 5.0.7, enable non-nullable references
2 parents 1ce6b69 + c44ff49 commit f235750

File tree

86 files changed

+889
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+889
-450
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-format": {
6+
"version": "5.1.225507",
7+
"commands": [
8+
"dotnet-format"
9+
]
10+
}
11+
}
12+
}

.editorconfig

Lines changed: 498 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/dotnetcore.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
- uses: actions/checkout@v1
1212
- uses: actions/setup-dotnet@v1
1313
with:
14-
dotnet-version: 5.0.100
14+
dotnet-version: 5.0.301
1515
- run: dotnet run -p build/build.csproj

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#build container
2-
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim as build
2+
FROM mcr.microsoft.com/dotnet/sdk:5.0.301-focal as build
33

44
WORKDIR /build
55
COPY . .
66
RUN dotnet run -p build/build.csproj
77

88
#runtime container
9-
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0.0-alpine3.12
9+
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0.7-alpine3.12
1010
RUN apk add --no-cache tzdata
1111

1212
COPY --from=build /build/publish /app

build/Program.cs

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,71 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using GlobExpressions;
45
using static Bullseye.Targets;
56
using static SimpleExec.Command;
6-
using GlobExpressions;
7-
using System.Threading.Tasks;
87

9-
public static class Program
10-
{
11-
private const string Clean = "clean";
12-
private const string Build = "build";
13-
private const string Test = "test";
14-
private const string Publish = "publish";
8+
const string Clean = "clean";
9+
const string Build = "build";
10+
const string Test = "test";
11+
const string Format = "format";
12+
const string Publish = "publish";
1513

16-
static async Task Main(string[] args)
14+
Target(Clean,
15+
ForEach("publish", "**/bin", "**/obj"),
16+
dir =>
1717
{
18-
Target(Clean,
19-
ForEach("publish", "**/bin", "**/obj"),
20-
dir =>
18+
IEnumerable<string> GetDirectories(string d)
19+
{
20+
return Glob.Directories(".", d);
21+
}
22+
23+
void RemoveDirectory(string d)
24+
{
25+
if (Directory.Exists(d))
2126
{
22-
IEnumerable<string> GetDirectories(string d)
23-
{
24-
return Glob.Directories(".", d);
25-
}
27+
Console.WriteLine($"Cleaning {d}");
28+
Directory.Delete(d, true);
29+
}
30+
}
2631

27-
void RemoveDirectory(string d)
28-
{
29-
if (Directory.Exists(d))
30-
{
31-
Console.WriteLine($"Cleaning {d}");
32-
Directory.Delete(d, true);
33-
}
34-
}
32+
foreach (var d in GetDirectories(dir))
33+
{
34+
RemoveDirectory(d);
35+
}
36+
});
3537

36-
foreach (var d in GetDirectories(dir))
37-
{
38-
RemoveDirectory(d);
39-
}
40-
});
4138

42-
Target(Build, () => Run("dotnet", "build . -c Release"));
39+
Target(Format, () =>
40+
{
41+
Run("dotnet", "tool restore");
42+
Run("dotnet", "format --check");
43+
});
4344

44-
Target(Test, DependsOn(Build),
45-
() =>
46-
{
47-
IEnumerable<string> GetFiles(string d)
48-
{
49-
return Glob.Files(".", d);
50-
}
45+
Target(Build, DependsOn(Format), () => Run("dotnet", "build . -c Release"));
5146

52-
foreach (var file in GetFiles("tests/**/*.csproj"))
53-
{
54-
Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
55-
}
56-
});
47+
Target(Test, DependsOn(Build),
48+
() =>
49+
{
50+
IEnumerable<string> GetFiles(string d)
51+
{
52+
return Glob.Files(".", d);
53+
}
5754

58-
Target(Publish, DependsOn(Test),
59-
ForEach("src/Conduit"),
60-
project =>
61-
{
62-
Run("dotnet",
63-
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal");
64-
});
55+
foreach (var file in GetFiles("tests/**/*.csproj"))
56+
{
57+
Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
58+
}
59+
});
60+
61+
Target(Publish, DependsOn(Test),
62+
ForEach("src/Conduit"),
63+
project =>
64+
{
65+
Run("dotnet",
66+
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal");
67+
});
68+
69+
Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
70+
await RunTargetsAndExitAsync(args);
6571

66-
Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
67-
await RunTargetsAndExitAsync(args);
68-
}
69-
}

build/build.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Bullseye" Version="3.5.0" />
8+
<PackageReference Include="Bullseye" Version="3.7.0" />
99
<PackageReference Include="Glob" Version="1.1.8" />
10-
<PackageReference Include="SimpleExec" Version="6.3.0" />
10+
<PackageReference Include="SimpleExec" Version="7.0.0" />
1111
</ItemGroup>
1212
</Project>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "5.0.100"
3+
"version": "5.0.301"
44
}
55
}

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ This is using ASP.NET Core with:
2525
- Built-in Swagger via [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
2626
- [Bullseye](https://github.com/adamralph/bullseye) for building!
2727
- JWT authentication using [ASP.NET Core JWT Bearer Authentication](https://github.com/aspnet/Security/tree/master/src/Microsoft.AspNetCore.Authentication.JwtBearer).
28+
- Use [dotnet-format](https://github.com/dotnet/format) for style checking
29+
- `.editorconfig` to enforce some usage patterns
2830

2931
This basic architecture is based on this reference architecture: [https://github.com/jbogard/ContosoUniversityCore](https://github.com/jbogard/ContosoUniversityCore)
3032

src/Conduit/Conduit.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
<PropertyGroup>
33
<TargetFramework>net5.0</TargetFramework>
44
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
5+
<Nullable>enable</Nullable>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<PackageReference Include="AutoMapper" Version="10.1.1" />
9-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
10+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.7" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.7" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.7" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.7" />
1415
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.10" />
1516
<PackageReference Include="Serilog" Version="2.10.0" />
1617
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
1718
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
18-
<PackageReference Include="FluentValidation.AspNetCore" Version="9.3.0" />
19+
<PackageReference Include="FluentValidation.AspNetCore" Version="10.2.3" />
1920
<PackageReference Include="MediatR" Version="9.0.0" />
2021
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
21-
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
22+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
2223
</ItemGroup>
2324

2425
<ItemGroup>

src/Conduit/Domain/Article.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ public class Article
1111
[JsonIgnore]
1212
public int ArticleId { get; set; }
1313

14-
public string Slug { get; set; }
14+
public string? Slug { get; set; }
1515

16-
public string Title { get; set; }
16+
public string? Title { get; set; }
1717

18-
public string Description { get; set; }
18+
public string? Description { get; set; }
1919

20-
public string Body { get; set; }
20+
public string? Body { get; set; }
2121

22-
public Person Author { get; set; }
22+
public Person? Author { get; set; }
2323

24-
public List<Comment> Comments { get; set; }
24+
public List<Comment> Comments { get; set; } = new();
2525

2626
[NotMapped]
2727
public bool Favorited => ArticleFavorites?.Any() ?? false;
@@ -30,16 +30,16 @@ public class Article
3030
public int FavoritesCount => ArticleFavorites?.Count ?? 0;
3131

3232
[NotMapped]
33-
public List<string> TagList => (ArticleTags?.Select(x => x.TagId) ?? Enumerable.Empty<string>()).ToList();
33+
public List<string> TagList => ArticleTags.Where(x => x.TagId is not null).Select(x => x.TagId!).ToList();
3434

3535
[JsonIgnore]
36-
public List<ArticleTag> ArticleTags { get; set; }
36+
public List<ArticleTag> ArticleTags { get; set; } = new();
3737

3838
[JsonIgnore]
39-
public List<ArticleFavorite> ArticleFavorites { get; set; }
39+
public List<ArticleFavorite> ArticleFavorites { get; set; } = new();
4040

4141
public DateTime CreatedAt { get; set; }
4242

4343
public DateTime UpdatedAt { get; set; }
4444
}
45-
}
45+
}

0 commit comments

Comments
 (0)