Skip to content

Commit 4bc20bc

Browse files
authored
Tidy build files, publish symbols and use C#8. (#13)
1 parent f72e71e commit 4bc20bc

File tree

13 files changed

+112
-97
lines changed

13 files changed

+112
-97
lines changed

.travis.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ env:
66
global:
77
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
88
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
9-
matrix:
9+
jobs:
1010
include:
1111
- os: linux
12-
dist: xenial
13-
dotnet: 2.2
12+
dist: bionic
13+
dotnet: 3.1
1414
- os: osx
15-
osx_image: xcode9 # OSX 10.12
16-
dotnet: 2.2.104
15+
osx_image: xcode11.2
16+
dotnet: 3.1.301
1717
before_install:
1818
- ulimit -n 4096
1919
script:
2020
- dotnet build -c Release
2121
- dotnet test -c Release --no-build
22-
notifications:
23-
on_success: always
24-
on_failure: always
25-
on_start: always

Directory.Build.props

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Authors>Winton</Authors>
4+
<Company>Winton</Company>
5+
<Copyright>Copyright 2020 Winton</Copyright>
6+
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Rules.ruleset</CodeAnalysisRuleSet>
7+
<LangVersion>8.0</LangVersion>
8+
<Nullable>enable</Nullable>
9+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
18+
</ItemGroup>
19+
</Project>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Winton.DomainModelling.AspNetCore
22

3-
[![Build status](https://ci.appveyor.com/api/projects/status/k94y5or6toq2un7d?svg=true)](https://ci.appveyor.com/project/wintoncode/winton-domainmodelling-aspnetcore/branch/master)
4-
[![Travis Build Status](https://travis-ci.org/wintoncode/Winton.DomainModelling.AspNetCore.svg?branch=master)](https://travis-ci.org/wintoncode/Winton.DomainModelling.AspNetCore)
3+
[![Appveyor](https://ci.appveyor.com/api/projects/status/k94y5or6toq2un7d?svg=true)](https://ci.appveyor.com/project/wintoncode/winton-domainmodelling-aspnetcore/branch/master)
4+
[![Travis CI](https://travis-ci.com/wintoncode/Winton.DomainModelling.AspNetCore.svg?branch=master)](https://travis-ci.com/wintoncode/Winton.DomainModelling.AspNetCore)
55
[![NuGet version](https://img.shields.io/nuget/v/Winton.DomainModelling.AspNetCore.svg)](https://www.nuget.org/packages/Winton.DomainModelling.AspNetCore)
66
[![NuGet version](https://img.shields.io/nuget/vpre/Winton.DomainModelling.AspNetCore.svg)](https://www.nuget.org/packages/Winton.DomainModelling.AspNetCore)
77

Rules.ruleset

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules" Description=" " ToolsVersion="16.0">
3+
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
4+
<Rule Id="CA2007" Action="None" />
5+
</Rules>
6+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
7+
<Rule Id="SA1101" Action="None" />
8+
<Rule Id="SA1309" Action="None" />
9+
<Rule Id="SA1413" Action="None" />
10+
</Rules>
11+
</RuleSet>

Winton.DomainModelling.AspNetCore.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27703.2026
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30128.74
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E61DDF24-3DEB-49A2-8D27-E6D04105B28B}"
77
ProjectSection(SolutionItems) = preProject
88
.gitignore = .gitignore
99
.travis.yml = .travis.yml
1010
appveyor.yml = appveyor.yml
1111
CONTRIBUTING.md = CONTRIBUTING.md
12+
Directory.Build.props = Directory.Build.props
1213
GitVersion.yml = GitVersion.yml
1314
icon.jpg = icon.jpg
1415
LICENSE = LICENSE
1516
README.md = README.md
17+
Rules.ruleset = Rules.ruleset
1618
stylecop.json = stylecop.json
1719
EndProjectSection
1820
EndProject
1921
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6BF06986-D228-4BDA-87B6-015792391C04}"
2022
EndProject
2123
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C4EF1CA3-45F0-47C6-B217-8418788BB088}"
24+
ProjectSection(SolutionItems) = preProject
25+
test\Directory.Build.props = test\Directory.Build.props
26+
test\Rules.ruleset = test\Rules.ruleset
27+
EndProjectSection
2228
EndProject
2329
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Winton.DomainModelling.AspNetCore", "src\Winton.DomainModelling.AspNetCore\Winton.DomainModelling.AspNetCore.csproj", "{083025CE-85A8-4FED-BE30-9756B3947EE4}"
2430
EndProject

appveyor.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
version: '{build}'
21
environment:
3-
CLI_VERSION: latest
4-
DOTNET_CLI_TELEMETRY_OPTOUT: 1
5-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
6-
image: Visual Studio 2017
2+
CLI_VERSION: latest
3+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
4+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
5+
image: Visual Studio 2019
76
configuration:
87
- Release
9-
skip_tags: true
108
before_build:
11-
- dotnet tool install -g GitVersion.Tool --version 4.0.1-beta1-58
9+
- dotnet tool install -g GitVersion.Tool
1210
- dotnet gitversion /l console /output buildserver
1311
build_script:
1412
- dotnet build -c Release -p:Version=%GitVersion_NuGetVersion%
1513
test_script:
16-
- dotnet test -c Release --no-restore --no-build
14+
- dotnet test -c Release --no-build
1715
artifacts:
18-
- path: .\**\*.nupkg
19-
name: NuGet
20-
nuget:
21-
disable_publish_on_pr: true
16+
- name: NuGet
17+
path: .\**\*.nupkg
18+
- name: Symbols
19+
path: .\**\*.snupkg
2220
deploy:
23-
- provider: NuGet
24-
api_key:
25-
secure: K7GBfAz5cr3lqVzn2+KbM45GA2ZeDjOpgnDU2jpw76PxBL2Qph3OBcfXWuGb+wwD
26-
on:
27-
branch:
28-
- master
29-
- /release\/[0-9]\.[0-9]/
21+
- provider: NuGet
22+
api_key:
23+
secure: +CD+4G+gMInD/BjNvO24NW9u1udGdsx0fUi6bh0muNezQ9fP0sHnS1f96f0OXUy6
24+
on:
25+
branch:
26+
- master
27+
- /release\/[0-9]\.[0-9]/

src/Winton.DomainModelling.AspNetCore/DomainExceptionFilter.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Winton.DomainModelling.AspNetCore
1414
[Obsolete("Prefer returning Result types from the domain and convert to an ActionResult using the extensions provided in this library.", false)]
1515
public sealed class DomainExceptionFilter : IExceptionFilter
1616
{
17-
private readonly Func<DomainException, ErrorResponse, IActionResult> _exceptionMapper;
17+
private readonly Func<DomainException, ErrorResponse, IActionResult?>? _exceptionMapper;
1818

1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="DomainExceptionFilter" /> class.
@@ -33,7 +33,7 @@ public DomainExceptionFilter()
3333
/// This parameter can be used to extend the capabilities of this exception filter to meet an application's specific
3434
/// requirements.
3535
/// </param>
36-
public DomainExceptionFilter(Func<DomainException, ErrorResponse, IActionResult> exceptionMapper)
36+
public DomainExceptionFilter(Func<DomainException, ErrorResponse, IActionResult?>? exceptionMapper)
3737
{
3838
_exceptionMapper = exceptionMapper;
3939
}
@@ -51,16 +51,12 @@ public void OnException(ExceptionContext context)
5151
private IActionResult CreateResult(DomainException domainException)
5252
{
5353
var errorResponse = new ErrorResponse(domainException);
54-
switch (domainException)
54+
return domainException switch
5555
{
56-
case EntityNotFoundException _:
57-
return new NotFoundObjectResult(errorResponse);
58-
case UnauthorizedException _:
59-
return new UnauthorizedResult();
60-
default:
61-
return _exceptionMapper?.Invoke(domainException, errorResponse) ??
62-
new BadRequestObjectResult(errorResponse);
63-
}
56+
EntityNotFoundException _ => new NotFoundObjectResult(errorResponse),
57+
UnauthorizedException _ => new UnauthorizedResult(),
58+
_ => _exceptionMapper?.Invoke(domainException, errorResponse) ?? new BadRequestObjectResult(errorResponse)
59+
};
6460
}
6561
}
6662
}

src/Winton.DomainModelling.AspNetCore/ErrorExtensions.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Winton.DomainModelling.AspNetCore
99
{
1010
internal static class ErrorExtensions
1111
{
12-
internal static ActionResult ToActionResult(this Error error, Func<Error, ProblemDetails> selectProblemDetails)
12+
internal static ActionResult ToActionResult(this Error error, Func<Error, ProblemDetails?>? selectProblemDetails)
1313
{
1414
ProblemDetails problemDetails = selectProblemDetails?.Invoke(error) ?? CreateDefaultProblemDetails(error);
1515
return new ObjectResult(problemDetails)
@@ -20,22 +20,13 @@ internal static ActionResult ToActionResult(this Error error, Func<Error, Proble
2020

2121
private static ProblemDetails CreateDefaultProblemDetails(Error error)
2222
{
23-
int GetStatusCode()
23+
int statusCode = error switch
2424
{
25-
switch (error)
26-
{
27-
case UnauthorizedError _:
28-
return StatusCodes.Status403Forbidden;
29-
case NotFoundError _:
30-
return StatusCodes.Status404NotFound;
31-
case ConflictError _:
32-
return StatusCodes.Status409Conflict;
33-
default:
34-
return StatusCodes.Status400BadRequest;
35-
}
36-
}
37-
38-
int statusCode = GetStatusCode();
25+
UnauthorizedError _ => StatusCodes.Status403Forbidden,
26+
NotFoundError _ => StatusCodes.Status404NotFound,
27+
ConflictError _ => StatusCodes.Status409Conflict,
28+
_ => StatusCodes.Status400BadRequest
29+
};
3930
return new ProblemDetails
4031
{
4132
Detail = error.Detail,

src/Winton.DomainModelling.AspNetCore/ResultExtensions.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static IActionResult ToActionResult(this Result<Unit> result)
3737
/// <param name="onError">
3838
/// The function that is invoked if this <paramref name="result"/> is a <see cref="Failure{TData}"/>.
3939
/// It is responsible for mapping the <see cref="Error"/> to <see cref="ProblemDetails"/>.
40-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
40+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
4141
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
4242
/// </param>
4343
/// <returns>
@@ -47,7 +47,7 @@ public static IActionResult ToActionResult(this Result<Unit> result)
4747
/// </returns>
4848
public static IActionResult ToActionResult(
4949
this Result<Unit> result,
50-
Func<Error, ProblemDetails> onError)
50+
Func<Error, ProblemDetails>? onError)
5151
{
5252
return result.Match(_ => new NoContentResult(), error => error.ToActionResult(onError));
5353
}
@@ -77,7 +77,7 @@ public static async Task<IActionResult> ToActionResult(this Task<Result<Unit>> r
7777
/// <param name="onError">
7878
/// The function that is invoked if this <paramref name="resultTask"/> is a <see cref="Failure{TData}"/>.
7979
/// It is responsible for mapping the <see cref="Error"/> to <see cref="ProblemDetails"/>.
80-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
80+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
8181
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
8282
/// </param>
8383
/// <returns>
@@ -123,7 +123,7 @@ public static ActionResult<TData> ToActionResult<TData>(this Result<TData> resul
123123
/// <param name="onError">
124124
/// The function that is invoked if this <paramref name="result"/> is a <see cref="Failure{TData}"/>.
125125
/// It is responsible for mapping the <see cref="Error"/> to <see cref="ProblemDetails"/>.
126-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
126+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
127127
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
128128
/// </param>
129129
/// <returns>
@@ -133,7 +133,7 @@ public static ActionResult<TData> ToActionResult<TData>(this Result<TData> resul
133133
/// </returns>
134134
public static ActionResult<TData> ToActionResult<TData>(
135135
this Result<TData> result,
136-
Func<Error, ProblemDetails> onError)
136+
Func<Error, ProblemDetails>? onError)
137137
{
138138
return result.Match(data => new ActionResult<TData>(data), error => error.ToActionResult(onError));
139139
}
@@ -171,7 +171,7 @@ public static async Task<ActionResult<TData>> ToActionResult<TData>(this Task<Re
171171
/// <param name="onError">
172172
/// The function that is invoked if this <paramref name="resultTask"/> is a <see cref="Failure{TData}"/>.
173173
/// It is responsible for mapping the <see cref="Error"/> to <see cref="ProblemDetails"/>.
174-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
174+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
175175
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
176176
/// </param>
177177
/// <returns>
@@ -227,7 +227,7 @@ public static IActionResult ToActionResult<TData>(
227227
/// <param name="onError">
228228
/// The function that is invoked if this <paramref name="result"/> is a <see cref="Failure{TData}"/>.
229229
/// It is invoked to map the <see cref="Error"/> to <see cref="ProblemDetails"/>.
230-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
230+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
231231
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
232232
/// </param>
233233
/// <returns>
@@ -238,7 +238,7 @@ public static IActionResult ToActionResult<TData>(
238238
public static IActionResult ToActionResult<TData>(
239239
this Result<TData> result,
240240
Func<TData, IActionResult> onSuccess,
241-
Func<Error, ProblemDetails> onError)
241+
Func<Error, ProblemDetails>? onError)
242242
{
243243
return result.Match(onSuccess, error => error.ToActionResult(onError));
244244
}
@@ -286,7 +286,7 @@ public static async Task<IActionResult> ToActionResult<TData>(
286286
/// <param name="onError">
287287
/// The function that is invoked if this <paramref name="resultTask"/> is a <see cref="Failure{TData}"/>.
288288
/// It is invoked to map the <see cref="Error"/> to <see cref="ProblemDetails"/>.
289-
/// If this function returns <code>null</code> then the default error mapping conventions are used.
289+
/// If this function returns <c>null</c> then the default error mapping conventions are used.
290290
/// This therefore provides a way to customize the error mapping from <see cref="Error"/> to <see cref="ProblemDetails"/>.
291291
/// </param>
292292
/// <returns>
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Authors>Winton</Authors>
5-
<Company>Winton</Company>
6-
<Copyright>Copyright 2018 Winton</Copyright>
74
<Description>Provides conventions for creating an ASP.NET Core based REST API on top of a domain model.</Description>
85
<GenerateDocumentationFile>True</GenerateDocumentationFile>
9-
<NoWarn>$(NoWarn);SA1101;SA1309</NoWarn>
6+
<IncludeSymbols>true</IncludeSymbols>
107
<PackageId>Winton.DomainModelling.AspNetCore</PackageId>
11-
<PackageIconUrl>https://raw.githubusercontent.com/wintoncode/Winton.DomainModelling.AspNetCore/master/icon.jpg</PackageIconUrl>
8+
<PackageIcon>icon.jpg</PackageIcon>
129
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1310
<PackageProjectUrl>https://github.com/wintoncode/Winton.DomainModelling.AspNetCore</PackageProjectUrl>
1411
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
1512
<PackageTags>Winton, AspNetCore, ASP, .NET, Core, Domain, Driven, Design, Modelling, DDD</PackageTags>
16-
<PackageVersion>$(NuGetVersion)</PackageVersion>
13+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1714
<RepositoryType>git</RepositoryType>
1815
<RepositoryUrl>https://github.com/wintoncode/Winton.DomainModelling.AspNetCore</RepositoryUrl>
16+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1917
<TargetFramework>netstandard2.0</TargetFramework>
2018
<Title>Winton Domain Modelling ASP.NET Core</Title>
21-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
22-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23-
<IncludeSymbols>true</IncludeSymbols>
24-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2519
</PropertyGroup>
2620

27-
<ItemGroup>
28-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
29-
</ItemGroup>
30-
3121
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
3222
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
3323
</PropertyGroup>
3424

3525
<ItemGroup>
36-
<AdditionalFiles Include="../../stylecop.json" />
26+
<None Include="../../icon.jpg" Pack="true" PackagePath="" />
3727
<None Include="../../LICENSE" Pack="true" PackagePath="" />
3828
</ItemGroup>
3929

4030
<ItemGroup>
4131
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.3" />
42-
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
32+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
4333
<PackageReference Include="Winton.DomainModelling.Abstractions" Version="1.4.0" />
4434
</ItemGroup>
4535
</Project>

0 commit comments

Comments
 (0)