-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8741aa1
Showing
5 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This workflow will build a .NET project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | ||
|
||
name: .NET | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
filter: tree:0 | ||
|
||
- name: Get tags | ||
run: git fetch --tags origin | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --configuration Release -p:CollectCoverage=true | ||
|
||
- name: Publish Nuget | ||
run: | | ||
dotnet nuget push '**/*.nupkg' -k ${NUGET} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols | ||
env: | ||
NUGET: ${{ secrets.NUGET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vs | ||
bin | ||
obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# 17 | ||
VisualStudioVersion = 17.10.35027.167 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utility.Guard", "Utility.Guard\Utility.Guard.csproj", "{1DF6CF00-3907-40A3-BA69-B32788F37F4C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1DF6CF00-3907-40A3-BA69-B32788F37F4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1DF6CF00-3907-40A3-BA69-B32788F37F4C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1DF6CF00-3907-40A3-BA69-B32788F37F4C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1DF6CF00-3907-40A3-BA69-B32788F37F4C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7D25D4C6-E7A0-4490-8BDE-9076CA666008} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Linq.Expressions; | ||
|
||
namespace Utility; | ||
|
||
public static class Guard | ||
{ | ||
public static T ThrowIfNull<T>(T item) | ||
{ | ||
if (item is null) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
return item; | ||
} | ||
|
||
public static T ThrowIfNotNull<T>(T item) | ||
{ | ||
if (item is not null) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
return item; | ||
} | ||
|
||
public static int ThrowIfIntegerNotInRange(int item, int start, int end) | ||
{ | ||
if (item >= start && item <= end) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
return item; | ||
} | ||
|
||
public static string ThrowIfStringNullOrEmpty(string value) | ||
{ | ||
if (string.IsNullOrEmpty(value)) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard20</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
<Authors>Simon Jefferies</Authors> | ||
<Company>Simon Jefferies</Company> | ||
<Description></Description> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MinVer" Version="*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |