Skip to content

Commit

Permalink
Update to net6.0, moved to GitHub actions, removed deprecations (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileydoestech authored Jan 18, 2022
1 parent ad04873 commit efede0d
Show file tree
Hide file tree
Showing 30 changed files with 2,214 additions and 2,386 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build
on:
push:
branches:
- master
tags:
- "*"
pull_request:
jobs:
calculate-version:
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.8.1"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Version
id: version
run: |
version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
if [ "${{ github.event_name }}" == "pull_request" ]
then
version=${version}-${{ steps.gitversion.outputs.shortSha }}
fi
echo "::set-output name=version::${version}"
build:
runs-on: ${{ matrix.os }}
needs: [calculate-version]
strategy:
matrix:
include:
- os: ubuntu-20.04
nugetPush: false
- os: windows-2019
nugetPush: true
- os: macos-10.15
nugetPush: false
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
submodules: recursive
- name: Setup dotnet SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.101"
- name: Build
run: |
dotnet build -c Release -p:Version=${{ needs.calculate-version.outputs.version }}
shell: bash
- name: Test
run: dotnet test -c Release --no-build
shell: bash
- name: Archive NuGet Packages
uses: actions/upload-artifact@v2
if: ${{ matrix.nugetPush }}
with:
name: packages
path: |
**/*.nupkg
**/*.snupkg
retention-days: 1
nuget-push:
runs-on: ubuntu-20.04
needs: [build]
if: github.event_name != 'pull_request'
steps:
- name: Download NuGet Packages
uses: actions/download-artifact@v2
with:
name: packages
- name: NuGet Push
run: dotnet nuget push **/*.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<Authors>Winton</Authors>
<Company>Winton</Company>
<Copyright>Copyright 2020 Winton</Copyright>
<Copyright>Copyright 2022 Winton</Copyright>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Rules.ruleset</CodeAnalysisRuleSet>
<LangVersion>8.0</LangVersion>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2018 Winton
Copyright 2022 Winton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Winton.DomainModelling.Abstractions

[![Appveyor](https://ci.appveyor.com/api/projects/status/7mba8m947ed603r1?svg=true)](https://ci.appveyor.com/project/wintoncode/winton-domainmodelling-abstractions/branch/master)
[![Travis CI](https://travis-ci.com/wintoncode/Winton.DomainModelling.Abstractions.svg?branch=master)](https://travis-ci.com/wintoncode/Winton.DomainModelling.Abstractions)
[![NuGet version](https://img.shields.io/nuget/v/Winton.DomainModelling.Abstractions.svg)](https://www.nuget.org/packages/Winton.DomainModelling.Abstractions)
[![NuGet version](https://img.shields.io/nuget/vpre/Winton.DomainModelling.Abstractions.svg)](https://www.nuget.org/packages/Winton.DomainModelling.Abstractions)

Abstractions useful for modelling a domain.

[![NuGet Badge](https://buildstats.info/nuget/Winton.DomainModelling.Abstractions)](https://www.nuget.org/packages/Winton.DomainModelling.Abstractions/)

[![Build history](https://buildstats.info/github/chart/wintoncode/Winton.DomainModelling.Abstractions?branch=master)](https://github.com/wintoncode/Winton.DomainModelling.Abstractions/actions)

## Building blocks

### `Entity`
Expand All @@ -16,7 +15,7 @@ Instances are equal if their IDs are equal. Any equatable ID type can be used.

## Results

### `Result<TData>`
### `Result<TData>`

Represents the result of a domain operation that returns data of type `TData`. It is an abstract type with exactly two concretions: `Success` and `Failure`. It is a specialisation of the more generic `Either` type found in functional programming and is inspired by [Scott Wlaschin's Railway Oriented Programming](https://fsharpforfunandprofit.com/rop/) in F#.

Expand All @@ -41,6 +40,7 @@ public Person GetAdult(int id)
```

This implementation has two major drawbacks:

1) From a client's perspective, the API is not expressive enough. The method signature gives no indication that it might throw, so the client would need to peek inside to find that out.
2) From an implementer's perspective, the error checking, whilst simple enough in this example, can often grow quite complex. This makes the implementation of the method hard to follow due to the number of conditional branches. We may try factoring out the condition checking blocks into separate methods to solve this problem. This would also allow us to share some of this logic with other parts of the code base. These factored-out methods would then have a signature like `void CheckPersonExists(Person person)`. Again, this signature tells us nothing about the fact that the method might throw an exception. Currently, the compiler is also not able to do the flow analysis necessary to determine that the `person` is not `null` after calling such a method and so we may be left with warnings in the original call site about possible null references, even though we know we've checked for that condition.

Expand All @@ -66,7 +66,8 @@ Now we have a much more expressive method signature, which indicates that we mig

If the operation has no data to return then a `Result<Unit>` can be used. `Unit` is a special type that indicates the absence of a value, because `void` is not a valid type in C#.

Some recommendations on using `Result` types:
Some recommendations on using `Result` types:

* Make all public domain methods return a `Result<TData>`. Most domain operations will have a failure case that the client should be informed about, but even if they don't, by returning `Result` now it can be easily added later without breaking the public API.
* Once an operation is in "result space", keep it there for as long as possible. `Result` has a fluent API to facilitate this. This is similar to how, once one operation becomes `async` it is best to make all surrounding operations `async` too. This can be re-phrased as, don't match on the result until the last possible moment. For example, in a web API this would mean only unwrapping the result in the Controller.

Expand All @@ -83,6 +84,7 @@ Represents a failed `Result`. When constructed it takes an `Error` which contain
Like exceptions, errors form a hierarchy, with all errors deriving from the base `Error` type. This library defines a few common domain error types, which are listed below, but it is expected that more specific errors will be defined on a per-domain basis.

Some recommendations on designing errors:

* Try not to create custom errors that are too granular. Model them as you would entities and use the language of the domain model to guide their creation. The concept should make sense to a domain expert.
* The title should be the same for all instances of the error. The details are where instance specific information can be provided. If you are creating a custom error, make the title static and only let clients customise the details. See implementations of errors in this library for examples.
* Only use them for domain errors. Exceptions should still be used for system failures, such as network requests, and programming errors.
Expand Down
2 changes: 0 additions & 2 deletions Winton.DomainModelling.Abstractions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{859C9252-D63B-4ECB-9AB5-0BA8415C76AE}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.travis.yml = .travis.yml
appveyor.yml = appveyor.yml
CONTRIBUTING.md = CONTRIBUTING.md
Directory.Build.props = Directory.Build.props
GitVersion.yml = GitVersion.yml
Expand Down
27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

Loading

0 comments on commit efede0d

Please sign in to comment.