From de51feaf705f283540a21b1cb7c317ed36cbd03e Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Tue, 23 Apr 2019 09:19:25 +0200 Subject: [PATCH 01/13] Add icon --- nuspec/nuget/icon.png | Bin 0 -> 2818 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 nuspec/nuget/icon.png diff --git a/nuspec/nuget/icon.png b/nuspec/nuget/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9925180b6a366b2cb303e50c6c5473f394f383f9 GIT binary patch literal 2818 zcmbW(`9Bkm9|v%>2}_Qaqg8G>QzA!%hR(HP6wCqi>Ja?3Sm2njiA z%#}XmSS4fbBMhJUWc&9055AAj5AWCehu5#KAD&O)HWq>c=LER8xCCLAruM%->VL<_ z^E)|@c}{R~2@JwaO%RV>ZoIU@Kq$wQcA+kJ`Yo_oQi&-HtU$HF48GyvY<6$z{z-gq z>|bPTYY1*mY877|*mC;NKQSK!Ui__58sz0K3B+`6~Ed&GyPQCbF2u7qe8DNUW8X zih?!K{_=OlJdG;}y>+%BkF%X&+`U+~RB~fK!{Qp}d;uK3Z*jg@S_x`mkLvgfTiL`g zc4?Xl{NjhO-$Kh|w*`mOk4j1DjP!WEbXmOhml&Hv6DdAz-$|!|!6hIE@32?xH>eqU>0-GmJa^eo;JU+!{}lf@=82=N8+6u3bx$D= zD+cdu?Lf=q5tETE@g7dvxq^q#`O_8Ng%ztCCWM?J^Q08*pDR1}n6nx1kk(t|7hXIC zA72NX9rr$|)SCEU{zKKt+Gn9jRcNWVZ_G`t{|iA^!r=2{NsUiXSgu5$&9`2GtiF`+S>jHuUg%Z8J@?3H*j^3%QS#ruYs=vh!@xk8w@f!Fw zgd(4TEOd zOVD+{0^y1_!}j2^z7d^d`N8Ny)oHr$go9E;#?TIl>C+7dszfex0* zA9KGLWwR6Eja^lUuT9G3Pk@mV(~5YL-9P~%1}?$Kj2XBU;_)eNwrLP;{&efNB8K>q zgd&kz*2J2sCqN{ue-4}qd#kQ5*o~LV2NwT=kj^kjf+uXqQ|M|XSulizQOV1A#l9e2 zhpUd)WZ`djx#57jFMwCG#84ps?rX*|>QsBqX$C4olrKi0Uk;aGN~F~Mj8G|<6$PvK zad|38Cp^+T#>%NH0VF@A-?aow4hxulp@Q<0l*k^*b-bm0^2))tQFxi7;6R0ROUF#n zc(;n{zZZ(vs9bq|&Myxd$~yg&|4!KW2s21Su&?*IvKXtX&&AD${H>B1Frhfy@|=85JW-t~!=HWwPe^tNm4L<@-Z$d<*9- z5Sb62;|tgJa2vkRj`A)f1Co$dhD(v6Wr4#Vng4eSdCU zJp(&IPbaClWa_0wYNwB=1RxPn)t1Y5rPTb7H}YJG0ex(@=FxMr2j z*&AyWr*9`|u1%Q7Wp_XA$#NeH)v2gtpA_2>gHWEtlB=j;_)`7Erj0oZD>TX6W(#2{l5V!PywS*kB3E>6xx9fpx92CaPUy8;qU>)o)p&Q0DX}Y2|c*E8AcUD zSM@N-6)cIq^^@E^GBbm!Qc?hmIJs`?4<~zG_3dyCtFMi5cT#H@ti@>V9nX|pUDxKd z_P%E(j7%gR8)n&+USExe7V$Xm3OtofL(=Lk0SOIl3JkZo?7KIiGH~2AkRMLVqwxZ* z=Ia<;x6`?bw%JH@?oTKAW(mhzjUR$u%f%tbvKLDChy&);C7BC9X0+B8|HFKyVQ#Tp z+K5U(YFV#qsR+{bL&GhdEXCV5zj^lL*(l9XuO*Z7mY;l-O6;vV-)B@lkGY~d%xj%e zhLFiV78`<~{?LDg9e^y|gAgv9>%Q@itcwRLDBK|IfkWKUQE<8Q7dpbO z0XWcr!9Q64GMr5Kn)lcT9$duW@VKSbE{zV_=u?t-9wVy+1?|E96GWa?5rkyrkdO4z^V{-e=lxTX+QJM^_*ZMPEJc;ofj=r{j z(5jCySN~j_nW|yDBJ!tTz z*1k5Deyjc1`PCb23<^w84U&Nw?DPlB8B%&`TE`Y7HvD6v*}l?6)vcbdI|*Yjag_l7 zEK&P>bID+xi$cv?K@VevKS#p02tTb%4;lScS3ueOo7UOfg&jw=CfdRuhE8THmpc3D ztfuWhvIWvyFpA1TK)#3CG+z8==U8FOalkW0YNfrN+ELHtG1Bn`8?wm$)h7tWl@PG* zhtcsn4TE0S{N#N`0o_5Z*kQcE)h-D+Wqykee(0?XvCfZP+P~f5pNTTe_Y!lfGeV|X z>DdcFopWEWOkO0<@RGIy?*bcBCPGmG3dGqEN%mQcA5+_T?WO>y^CHKHQx?Yof&Mk% h{x1v0Z~(tK%OR}N48B*%75ug>7tGAYv<~VK`(IndX0HGM literal 0 HcmV?d00001 From e2db93030f19cb2ce5814d39e722d3f6067e123a Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Tue, 23 Apr 2019 09:20:00 +0200 Subject: [PATCH 02/13] Setup build infrastructure --- .appveyor.yml | 30 ++++++ .gitattributes | 63 ++++++++++++ .mergify.yml | 5 + .travis.yml | 10 ++ GitReleaseManager.yaml | 12 +++ README.md | 44 +++++++- build.ps1 | 184 ++++++++++++++++++++++++++++++++++ build.sh | 82 +++++++++++++++ nuspec/nuget/BBT.Maybe.nuspec | 25 +++++ setup.cake | 25 +++++ tools/packages.config | 4 + 11 files changed, 482 insertions(+), 2 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .gitattributes create mode 100644 .mergify.yml create mode 100644 .travis.yml create mode 100644 GitReleaseManager.yaml create mode 100644 build.ps1 create mode 100644 build.sh create mode 100644 nuspec/nuget/BBT.Maybe.nuspec create mode 100644 setup.cake create mode 100644 tools/packages.config diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..2b5f541 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,30 @@ +#---------------------------------# +# Build Image # +#---------------------------------# +image: Visual Studio 2017 + +#---------------------------------# +# Build Script # +#---------------------------------# +build_script: + - ps: .\build.ps1 -Target AppVeyor + +# Tests +test: off + +#---------------------------------# +# Branches to build # +#---------------------------------# +branches: + # Whitelist + only: + - develop + - master + - /release/.*/ + - /hotfix/.*/ + +#---------------------------------# +# Build Cache # +#---------------------------------# +cache: +- tools -> setup.cake \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 0000000..8c38b80 --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,5 @@ +pull_request_rules: + - name: delete head branch after merge + conditions: [] + actions: + delete_head_branch: {} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..eb79eee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: csharp +script: + - ./build.sh -v diagnostic +os: + - linux + - osx +cache: + directories: + - packages + - tools diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml new file mode 100644 index 0000000..721c1ba --- /dev/null +++ b/GitReleaseManager.yaml @@ -0,0 +1,12 @@ +issue-labels-include: +- Breaking change +- Feature +- Bug +- Improvement +- Documentation +issue-labels-exclude: +- Build +issue-labels-alias: + - name: Documentation + header: Documentation + plural: Documentation \ No newline at end of file diff --git a/README.md b/README.md index 2a08c4d..e70890d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,42 @@ -# bbt.maybe -An option type for .NET +# BBT.Maybe + +An option type for .NET. + +[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/bbtsoftware/BBT.Maybe/blob/master/LICENSE) + +## Information + +| | Stable | Pre-release | +|:--:|:--:|:--:| +|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/bbtsoftware/BBT.Maybe.svg)](https://github.com/bbtsoftware/BBT.Maybe/releases/latest)| +|NuGet|[![NuGet](https://img.shields.io/nuget/v/BBT.Maybe.svg)](https://www.nuget.org/packages/BBT.Maybe)|[![NuGet](https://img.shields.io/nuget/vpre/BBT.Maybe.svg)](https://www.nuget.org/packages/BBT.Maybe)| + +## Build Status + +|Develop|Master| +|:--:|:--:| +|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/develop?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/BBT.Maybe/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/master?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/BBT.Maybe/branch/master)| + +## Code Coverage + +[![Coverage Status](https://coveralls.io/repos/github/BBTSoftwareAG/BBT.Maybe/badge.svg?branch=develop)](https://coveralls.io/github/BBTSoftwareAG/BBT.Maybe?branch=develop) + +## Quick Links + +* [Documentation](https://bbtsoftware.github.io/BBT.Maybe/) + +## Build + +To build this package we are using Cake. + +On Windows PowerShell run: + +```powershell +./build +``` + +On OSX/Linux run: + +```bash +./build.sh +``` diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..bdfb32b --- /dev/null +++ b/build.ps1 @@ -0,0 +1,184 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. +.DESCRIPTION +This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) +and execute your Cake build script with the parameters you provide. +.PARAMETER Script +The build script to execute. +.PARAMETER Target +The build script target to run. +.PARAMETER Configuration +The build configuration to use. +.PARAMETER Verbosity +Specifies the amount of information to be displayed. +.PARAMETER Experimental +Tells Cake to use the latest Roslyn release. +.PARAMETER WhatIf +Performs a dry run of the build script. +No tasks will be executed. +.PARAMETER Mono +Tells Cake to use the Mono scripting engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.PARAMETER ScriptArgs +Remaining arguments are added here. +.LINK +http://cakebuild.net +#> + +[CmdletBinding()] +Param( + [string]$Script = "setup.cake", + [string]$Target = "Default", + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity = "Verbose", + [switch]$Experimental, + [Alias("DryRun","Noop")] + [switch]$WhatIf, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" + +# Should we use mono? +$UseMono = ""; +if($Mono.IsPresent) { + Write-Verbose -Message "Using the Mono based scripting engine." + $UseMono = "-mono" +} + +# Should we use the new Roslyn? +$UseExperimental = ""; +if($Experimental.IsPresent -and !($Mono.IsPresent)) { + Write-Verbose -Message "Using experimental version of Roslyn." + $UseExperimental = "-experimental" +} + +# Is this a dry run? +$UseDryRun = ""; +if($WhatIf.IsPresent) { + $UseDryRun = "-dryrun" +} + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Remove-Item * -Recurse -Exclude packages.config,nuget.exe + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -PreRelease -OutputDirectory `"$TOOLS_DIR`" -Source https://www.myget.org/F/cake/api/v3/index.json" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occured while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + +# Start Cake +Write-Host "Running build script..." +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +exit $LASTEXITCODE \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..a541ec1 --- /dev/null +++ b/build.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +############################################################### +# This is the Cake bootstrapper script that is responsible for +# downloading Cake and all specified tools from NuGet. +############################################################### + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +NUGET_EXE=$TOOLS_DIR/nuget.exe +CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe + +# Define default arguments. +SCRIPT="setup.cake" +TARGET="Default" +CONFIGURATION="Release" +VERBOSITY="verbose" +DRYRUN= +SHOW_VERSION=false +SCRIPT_ARGUMENTS=() + +# Parse arguments. +for i in "$@"; do + case $1 in + -s|--script) SCRIPT="$2"; shift ;; + -t|--target) TARGET="$2"; shift ;; + -c|--configuration) CONFIGURATION="$2"; shift ;; + -v|--verbosity) VERBOSITY="$2"; shift ;; + -d|--dryrun) DRYRUN="-dryrun" ;; + --version) SHOW_VERSION=true ;; + --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; + *) SCRIPT_ARGUMENTS+=("$1") ;; + esac + shift +done + +# Make sure the tools folder exist. +if [ ! -d $TOOLS_DIR ]; then + mkdir $TOOLS_DIR +fi + +# Make sure that packages.config exist. +if [ ! -f $TOOLS_DIR/packages.config ]; then + echo "Downloading packages.config..." + curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages + if [ $? -ne 0 ]; then + echo "An error occured while downloading packages.config." + exit 1 + fi +fi + +# Download NuGet if it does not exist. +if [ ! -f $NUGET_EXE ]; then + echo "Downloading NuGet..." + curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + if [ $? -ne 0 ]; then + echo "An error occured while downloading nuget.exe." + exit 1 + fi +fi + +# Restore tools from NuGet. +pushd $TOOLS_DIR >/dev/null +mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json +if [ $? -ne 0 ]; then + echo "Could not restore NuGet packages." + exit 1 +fi +popd >/dev/null + +# Make sure that Cake has been installed. +if [ ! -f $CAKE_EXE ]; then + echo "Could not find Cake.exe at '$CAKE_EXE'." + exit 1 +fi + +# Start Cake +if $SHOW_VERSION; then + exec mono $CAKE_EXE -version +else + exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" +fi diff --git a/nuspec/nuget/BBT.Maybe.nuspec b/nuspec/nuget/BBT.Maybe.nuspec new file mode 100644 index 0000000..03b083f --- /dev/null +++ b/nuspec/nuget/BBT.Maybe.nuspec @@ -0,0 +1,25 @@ + + + + BBT.Maybe + BBT Maybe + 0.0.0 + BBT Software AG + bbtsoftware + An option type for .NET. + An option type for .NET. + MIT + https://github.com/bbtsoftware/BBT.Maybe/ + https://raw.githubusercontent.com/bbtsoftware/BBT.Maybe/de51feaf705f283540a21b1cb7c317ed36cbd03e/nuspec/nuget/icon.png + false + + Copyright © BBT Software AG + Maybe Functional + https://github.com/bbtsoftware/BBT.Maybe/releases/tag/1.0.0 + + + + + + + diff --git a/setup.cake b/setup.cake new file mode 100644 index 0000000..1c2eb13 --- /dev/null +++ b/setup.cake @@ -0,0 +1,25 @@ +#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&prerelease + +Environment.SetVariableNames(); + +BuildParameters.SetParameters( + context: Context, + buildSystem: BuildSystem, + sourceDirectoryPath: "./src", + title: "BBT.Maybe", + repositoryOwner: "bbtsoftware", + repositoryName: "BBT.Maybe", + appVeyorAccountName: "BBTSoftwareAG", + shouldPublishMyGet: false, + shouldRunCodecov: false); + +BuildParameters.PrintParameters(Context); + +ToolSettings.SetToolSettings( + context: Context, + dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/BBT.Maybe.Tests/*.cs" }, + testCoverageFilter: "+[*]* -[xunit.*]* -[*.Tests]* ", + testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", + testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); + +Build.RunDotNetCore(); diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000..e7f7fdd --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From fc60ca5ea4c915abd637c49310580e95fe9c0f6c Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Tue, 23 Apr 2019 08:46:14 +0200 Subject: [PATCH 03/13] Add empty solution --- src/Bbt.Maybe.Tests.ruleset | 8 + src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj | 34 +++ src/Bbt.Maybe.Tests/UnitTest1.cs | 14 ++ src/Bbt.Maybe.ruleset | 241 +++++++++++++++++++++ src/Bbt.Maybe.sln | 31 +++ src/Bbt.Maybe.sln.DotSettings | 3 + src/Bbt.Maybe/Bbt.Maybe.csproj | 33 +++ src/Bbt.Maybe/Class1.cs | 8 + 8 files changed, 372 insertions(+) create mode 100644 src/Bbt.Maybe.Tests.ruleset create mode 100644 src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj create mode 100644 src/Bbt.Maybe.Tests/UnitTest1.cs create mode 100644 src/Bbt.Maybe.ruleset create mode 100644 src/Bbt.Maybe.sln create mode 100644 src/Bbt.Maybe.sln.DotSettings create mode 100644 src/Bbt.Maybe/Bbt.Maybe.csproj create mode 100644 src/Bbt.Maybe/Class1.cs diff --git a/src/Bbt.Maybe.Tests.ruleset b/src/Bbt.Maybe.Tests.ruleset new file mode 100644 index 0000000..49a4588 --- /dev/null +++ b/src/Bbt.Maybe.Tests.ruleset @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj new file mode 100644 index 0000000..356125f --- /dev/null +++ b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj @@ -0,0 +1,34 @@ + + + + netcoreapp2.1 + false + Bbt.Maybe + BBT Software AG + Bbt.Maybe + Tests for Bbt.Maybe + Copyright © BBT Software AG + ..\Bbt.Maybe.Tests.ruleset + bin\$(Configuration)\ + + + + full + + + pdbonly + + + + + + + all + + + + + + + + diff --git a/src/Bbt.Maybe.Tests/UnitTest1.cs b/src/Bbt.Maybe.Tests/UnitTest1.cs new file mode 100644 index 0000000..c14b369 --- /dev/null +++ b/src/Bbt.Maybe.Tests/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Bbt.Maybe.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} diff --git a/src/Bbt.Maybe.ruleset b/src/Bbt.Maybe.ruleset new file mode 100644 index 0000000..d5812a1 --- /dev/null +++ b/src/Bbt.Maybe.ruleset @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Bbt.Maybe.sln b/src/Bbt.Maybe.sln new file mode 100644 index 0000000..4fa705e --- /dev/null +++ b/src/Bbt.Maybe.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.271 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bbt.Maybe", "Bbt.Maybe\Bbt.Maybe.csproj", "{2F38B821-95F8-4560-B08E-9796C44D0C86}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bbt.Maybe.Tests", "Bbt.Maybe.Tests\Bbt.Maybe.Tests.csproj", "{86D8402D-88CF-4887-A9BC-5662FC23BAFE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F38B821-95F8-4560-B08E-9796C44D0C86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F38B821-95F8-4560-B08E-9796C44D0C86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F38B821-95F8-4560-B08E-9796C44D0C86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F38B821-95F8-4560-B08E-9796C44D0C86}.Release|Any CPU.Build.0 = Release|Any CPU + {86D8402D-88CF-4887-A9BC-5662FC23BAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86D8402D-88CF-4887-A9BC-5662FC23BAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86D8402D-88CF-4887-A9BC-5662FC23BAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86D8402D-88CF-4887-A9BC-5662FC23BAFE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9E9EFC94-8A6D-473C-BA4C-2C793E565BA6} + EndGlobalSection +EndGlobal diff --git a/src/Bbt.Maybe.sln.DotSettings b/src/Bbt.Maybe.sln.DotSettings new file mode 100644 index 0000000..7cc51a4 --- /dev/null +++ b/src/Bbt.Maybe.sln.DotSettings @@ -0,0 +1,3 @@ + + DO_NOT_SHOW + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> \ No newline at end of file diff --git a/src/Bbt.Maybe/Bbt.Maybe.csproj b/src/Bbt.Maybe/Bbt.Maybe.csproj new file mode 100644 index 0000000..42486a8 --- /dev/null +++ b/src/Bbt.Maybe/Bbt.Maybe.csproj @@ -0,0 +1,33 @@ + + + + netstandard2.0 + BBT.Maybe + BBT Software AG + BBT.Maybe + An option type for .NET + Copyright © BBT Software AG + ..\Bbt.Maybe.ruleset + bin\$(Configuration)\Bbt.Maybe.XML + bin\$(Configuration)\ + true + + + + full + + + + pdbonly + + + + + all + + + all + + + + \ No newline at end of file diff --git a/src/Bbt.Maybe/Class1.cs b/src/Bbt.Maybe/Class1.cs new file mode 100644 index 0000000..5931eca --- /dev/null +++ b/src/Bbt.Maybe/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace Bbt.Maybe +{ + public class Class1 + { + } +} From 4a7c0f547d3a2d356eb4fc683902f5b147fd3875 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 24 Apr 2019 09:28:55 +0000 Subject: [PATCH 04/13] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 2.6.2 to 2.9.2 in /src Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 2.6.2 to 2.9.2. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v2.6.2...v2.9.2) Signed-off-by: dependabot[bot] --- src/Bbt.Maybe/Bbt.Maybe.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bbt.Maybe/Bbt.Maybe.csproj b/src/Bbt.Maybe/Bbt.Maybe.csproj index 42486a8..caa4186 100644 --- a/src/Bbt.Maybe/Bbt.Maybe.csproj +++ b/src/Bbt.Maybe/Bbt.Maybe.csproj @@ -22,7 +22,7 @@ - + all From e9dd7a4eea3cb596da6a9a975b13962e8e2cc4f0 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 24 Apr 2019 13:46:20 +0200 Subject: [PATCH 05/13] Add Cake files to gitignore --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3e759b7..e086e08 100644 --- a/.gitignore +++ b/.gitignore @@ -299,8 +299,8 @@ __pycache__/ *.pyc # Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config +tools/** +!tools/packages.config # Tabs Studio *.tss From 230876790f49b560550505af74339bb639922a9b Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 24 Apr 2019 12:36:50 +0200 Subject: [PATCH 06/13] Fix links to AppVeyor builds --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e70890d..ce585cb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ An option type for .NET. |Develop|Master| |:--:|:--:| -|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/develop?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/BBT.Maybe/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/master?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/BBT.Maybe/branch/master)| +|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/develop?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/bbt-maybe/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/vo6s6rr35xq9pk7h/branch/master?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/bbt-maybe/branch/master)| ## Code Coverage From 9231c20319aca8c410e0c7fb73d170460c8f36d7 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 24 Apr 2019 12:58:30 +0200 Subject: [PATCH 07/13] Add Wyam project --- .gitignore | 6 + docs/input/_Bottom.cshtml | 50 +++++++++ docs/input/_Footer.cshtml | 5 + docs/input/assets/css/override.less | 122 ++++++++++++++++++++ docs/input/assets/images/clippy.svg | 3 + docs/input/assets/js/anchor.min.js | 6 + docs/input/assets/js/clipboard.min.js | 7 ++ docs/input/docs/index.cshtml | 13 +++ docs/input/docs/usage/index.cshtml | 7 ++ docs/input/index.cshtml | 13 +++ docs/packages.xml | 153 ++++++++++++++++++++++++++ 11 files changed, 385 insertions(+) create mode 100644 docs/input/_Bottom.cshtml create mode 100644 docs/input/_Footer.cshtml create mode 100644 docs/input/assets/css/override.less create mode 100644 docs/input/assets/images/clippy.svg create mode 100644 docs/input/assets/js/anchor.min.js create mode 100644 docs/input/assets/js/clipboard.min.js create mode 100644 docs/input/docs/index.cshtml create mode 100644 docs/input/docs/usage/index.cshtml create mode 100644 docs/input/index.cshtml create mode 100644 docs/packages.xml diff --git a/.gitignore b/.gitignore index e086e08..b8056d3 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,9 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ + +# Project specific + +config.wyam.* +docs/input/tasks/ +BuildArtifacts/ \ No newline at end of file diff --git a/docs/input/_Bottom.cshtml b/docs/input/_Bottom.cshtml new file mode 100644 index 0000000..e8b81be --- /dev/null +++ b/docs/input/_Bottom.cshtml @@ -0,0 +1,50 @@ + + + + + diff --git a/docs/input/_Footer.cshtml b/docs/input/_Footer.cshtml new file mode 100644 index 0000000..6a324bc --- /dev/null +++ b/docs/input/_Footer.cshtml @@ -0,0 +1,5 @@ +

+ Copyright © BBT Software AG and contributors. +
+ Website generated by Wyam +

diff --git a/docs/input/assets/css/override.less b/docs/input/assets/css/override.less new file mode 100644 index 0000000..74d8ed4 --- /dev/null +++ b/docs/input/assets/css/override.less @@ -0,0 +1,122 @@ +/* Control the margin for bootstrap alert boxes */ +.alert > p { + margin-top: 0px; +} + +/* Control the look and feel of the copy box applied to code sections */ +.btn-copy[disabled] .clippy { + opacity: .3; +} +pre .btn-copy { + -webkit-transition: opacity 0.3s ease-in-out; + -o-transition: opacity 0.3s ease-in-out; + transition: opacity 0.3s ease-in-out; + opacity: 0; + padding: 2px 6px; + float: right; +} +pre:hover .btn-copy { + opacity: 1; +} +.tooltipped { + position: relative +} +.tooltipped:after { + position: absolute; + z-index: 1000000; + display: none; + padding: 5px 8px; + font: normal normal 11px/1.5 Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol"; + color: #fff; + text-align: center; + text-decoration: none; + text-shadow: none; + text-transform: none; + letter-spacing: normal; + word-wrap: break-word; + white-space: pre; + pointer-events: none; + content: attr(aria-label); + background: rgba(0, 0, 0, 0.8); + border-radius: 3px; + -webkit-font-smoothing: subpixel-antialiased +} +.tooltipped:before { + position: absolute; + z-index: 1000001; + display: none; + width: 0; + height: 0; + color: rgba(0, 0, 0, 0.8); + pointer-events: none; + content: ""; + border: 5px solid transparent +} +.tooltipped:hover:before, .tooltipped:hover:after, .tooltipped:active:before, .tooltipped:active:after, .tooltipped:focus:before, .tooltipped:focus:after { + display: inline-block; + text-decoration: none +} +.tooltipped-s:after, .tooltipped-se:after, .tooltipped-sw:after { + top: 100%; + right: 50%; + margin-top: 5px +} +.tooltipped-s:before, .tooltipped-se:before, .tooltipped-sw:before { + top: auto; + right: 50%; + bottom: -5px; + margin-right: -5px; + border-bottom-color: rgba(0, 0, 0, 0.8) +} + +@font-family-sans-serif: "Roboto", Helvetica, Arial, sans-serif; + +/* For Gitter and GitHub */ +.bottom-footer { + margin-bottom: 40px !important; // Make room for Gitter and GitHub buttons +} + +.gitter-open-chat-button { + background-color: #3c8dbc; + font-family: @font-family-sans-serif; + letter-spacing: normal; + right: 90px; +} + +.gitter-open-chat-button:focus, .gitter-open-chat-button:hover, +.github-button:focus, .github-button:hover, +{ + background-color: #4EABDD; + color: #fff; +} + +.gitter-chat-embed { + top: 49px; + border-top: 1px solid #000; + z-index: 10000; +} + +.github-button { + z-index: 100; + position: fixed; + bottom: 0px; + right: 240px; + padding: 1em 3em; + background-color: #367fa9; + border: 0; + border-top-left-radius: 0.5em; + border-top-right-radius: 0.5em; + font-family: sans-serif; + font-size: 9pt; + text-transform: uppercase; + text-align: center; + text-decoration: none; + cursor: pointer; + cursor: hand; + -webkit-transition: all .3s ease; + transition: all .3s ease; + color: #fff; + a, a:active, a:hover, a:focus { + color: #fff; + } +} \ No newline at end of file diff --git a/docs/input/assets/images/clippy.svg b/docs/input/assets/images/clippy.svg new file mode 100644 index 0000000..e1b1703 --- /dev/null +++ b/docs/input/assets/images/clippy.svg @@ -0,0 +1,3 @@ + + + diff --git a/docs/input/assets/js/anchor.min.js b/docs/input/assets/js/anchor.min.js new file mode 100644 index 0000000..7f34489 --- /dev/null +++ b/docs/input/assets/js/anchor.min.js @@ -0,0 +1,6 @@ +/** + * AnchorJS - v3.2.2 - 2016-10-05 + * https://github.com/bryanbraun/anchorjs + * Copyright (c) 2016 Bryan Braun; Licensed MIT + */ +!function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";function A(A){function e(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.class=A.hasOwnProperty("class")?A.class:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64}function t(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}function n(){if(null===document.head.querySelector("style.anchorjs")){var A,e=document.createElement("style"),t=" .anchorjs-link { opacity: 0; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }",n=" *:hover > .anchorjs-link, .anchorjs-link:focus { opacity: 1; }",i=' @font-face { font-family: "anchorjs-icons"; src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype"); }',o=" [data-anchorjs-icon]::after { content: attr(data-anchorjs-icon); }";e.className="anchorjs",e.appendChild(document.createTextNode("")),A=document.head.querySelector('[rel="stylesheet"], style'),void 0===A?document.head.appendChild(e):document.head.insertBefore(e,A),e.sheet.insertRule(t,e.sheet.cssRules.length),e.sheet.insertRule(n,e.sheet.cssRules.length),e.sheet.insertRule(o,e.sheet.cssRules.length),e.sheet.insertRule(i,e.sheet.cssRules.length)}}this.options=A||{},this.elements=[],e(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var i,o,s,c,r,a,h,l,u,d,f,p,w=[];if(e(this.options),p=this.options.visible,"touch"===p&&(p=this.isTouchDevice()?"always":"hover"),A||(A="h1, h2, h3, h4, h5, h6"),i=t(A),0===i.length)return!1;for(n(),o=document.querySelectorAll("[id]"),s=[].map.call(o,function(A){return A.id}),r=0;r-1,t=A.lastChild&&(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ")>-1;return e||t||!1}}return A}); diff --git a/docs/input/assets/js/clipboard.min.js b/docs/input/assets/js/clipboard.min.js new file mode 100644 index 0000000..1d7c5d5 --- /dev/null +++ b/docs/input/assets/js/clipboard.min.js @@ -0,0 +1,7 @@ +/*! + * clipboard.js v1.5.16 + * https://zenorocha.github.io/clipboard.js + * + * Licensed MIT © Zeno Rocha + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Clipboard=e()}}(function(){var e,t,n;return function e(t,n,i){function o(a,c){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,i)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function e(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function e(){var t=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var i=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.addEventListener("focus",window.scrollTo(0,i)),this.fakeElem.style.top=i+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,o.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function e(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function e(){this.selectedText=(0,o.default)(this.target),this.copyText()}},{key:"copyText",value:function e(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function e(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function e(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function e(){this.removeFake()}},{key:"action",set:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function e(){return this._action}},{key:"target",set:function e(t){if(void 0!==t){if(!t||"object"!==("undefined"==typeof t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function e(){return this._target}}]),e}();e.exports=c})},{select:5}],8:[function(t,n,i){!function(o,r){if("function"==typeof e&&e.amd)e(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof i)r(n,t("./clipboard-action"),t("tiny-emitter"),t("good-listener"));else{var a={exports:{}};r(a,o.clipboardAction,o.tinyEmitter,o.goodListener),o.clipboard=a.exports}}(this,function(e,t,n,i){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}var s=o(t),u=o(n),f=o(i),d=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText}},{key:"listenClick",value:function e(t){var n=this;this.listener=(0,f.default)(t,"click",function(e){return n.onClick(e)})}},{key:"onClick",value:function e(t){var n=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})}},{key:"defaultAction",value:function e(t){return l("action",t)}},{key:"defaultTarget",value:function e(t){var n=l("target",t);if(n)return document.querySelector(n)}},{key:"defaultText",value:function e(t){return l("text",t)}},{key:"destroy",value:function e(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}]),t}(u.default);e.exports=h})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)}); \ No newline at end of file diff --git a/docs/input/docs/index.cshtml b/docs/input/docs/index.cshtml new file mode 100644 index 0000000..0610eb5 --- /dev/null +++ b/docs/input/docs/index.cshtml @@ -0,0 +1,13 @@ +--- +Title: Documentation +--- +@foreach(IDocument child in Model.DocumentList(Keys.Children).OrderBy(x => x.Get(DocsKeys.Order, 1000))) +{ +

@(child.String(Keys.Title))

+ if(child.ContainsKey(DocsKeys.Description)) + { +

@Html.Raw(child.String(DocsKeys.Description))

+ } + + @Html.Partial("_ChildPages", child) +} \ No newline at end of file diff --git a/docs/input/docs/usage/index.cshtml b/docs/input/docs/usage/index.cshtml new file mode 100644 index 0000000..7848d32 --- /dev/null +++ b/docs/input/docs/usage/index.cshtml @@ -0,0 +1,7 @@ +--- +Order: 10 +Description: How to obtain, configure, and use BBT.Maybe. +--- +

@Html.Raw(Model.String(DocsKeys.Description))

+ +@Html.Partial("_ChildPages") \ No newline at end of file diff --git a/docs/input/index.cshtml b/docs/input/index.cshtml new file mode 100644 index 0000000..42d904e --- /dev/null +++ b/docs/input/index.cshtml @@ -0,0 +1,13 @@ +--- +Title: BBT.Maybe +NoSidebar: true +NoContainer: false +NoGutter: true +--- + +
+

What is it?

+

+ This NuGet package contains an option type for .NET. +

+
\ No newline at end of file diff --git a/docs/packages.xml b/docs/packages.xml new file mode 100644 index 0000000..d85bac4 --- /dev/null +++ b/docs/packages.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From defe71f03e6d98e888deb8d691256ac86778b8f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 24 Apr 2019 15:26:01 +0000 Subject: [PATCH 08/13] Bump Microsoft.NET.Test.Sdk from 15.9.0 to 16.0.1 in /src Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 15.9.0 to 16.0.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v15.9.0...v16.0.1) Signed-off-by: dependabot[bot] --- src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj index 356125f..cd869a2 100644 --- a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj +++ b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj @@ -20,7 +20,7 @@ - + all From 3beefe1405f30da87e358c1056b3dc5d70e0be81 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 24 Apr 2019 19:57:47 +0200 Subject: [PATCH 09/13] Disable documentation for tasks --- .gitignore | 1 - setup.cake | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b8056d3..d286e5d 100644 --- a/.gitignore +++ b/.gitignore @@ -332,5 +332,4 @@ ASALocalRun/ # Project specific config.wyam.* -docs/input/tasks/ BuildArtifacts/ \ No newline at end of file diff --git a/setup.cake b/setup.cake index 1c2eb13..8e751c3 100644 --- a/setup.cake +++ b/setup.cake @@ -11,7 +11,8 @@ BuildParameters.SetParameters( repositoryName: "BBT.Maybe", appVeyorAccountName: "BBTSoftwareAG", shouldPublishMyGet: false, - shouldRunCodecov: false); + shouldRunCodecov: false, + shouldDeployGraphDocumentation: false); BuildParameters.PrintParameters(Context); From e3683c632a3e6cf7dda6e561d5b85fbdeb17ac46 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 24 Apr 2019 20:14:16 +0200 Subject: [PATCH 10/13] Pin build script to Cake.Recipe 1.0.0 --- setup.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cake b/setup.cake index 8e751c3..f6adafa 100644 --- a/setup.cake +++ b/setup.cake @@ -1,4 +1,4 @@ -#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&prerelease +#load nuget:?package=Cake.Recipe&version=1.0.0 Environment.SetVariableNames(); From 5ca303745c1bb5c1c1191297ca59706258b3674b Mon Sep 17 00:00:00 2001 From: Stefan Lindegger Date: Wed, 24 Apr 2019 23:12:38 +0200 Subject: [PATCH 11/13] (GH-3) Implementation of initial version. --- setup.cake | 2 +- src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj | 1 + src/Bbt.Maybe.Tests/MaybeStructTests.cs | 154 +++++++++++++ src/Bbt.Maybe.Tests/MaybeTests.cs | 209 ++++++++++++++++++ src/Bbt.Maybe.Tests/NoneCaseTests.cs | 85 +++++++ src/Bbt.Maybe.Tests/TestData/BaseClass.cs | 9 + src/Bbt.Maybe.Tests/TestData/BaseStruct.cs | 9 + src/Bbt.Maybe.Tests/TestData/DerivedClass.cs | 9 + .../TestData/ReferencedClass.cs | 13 ++ .../TestData/ReferencedStruct.cs | 13 ++ src/Bbt.Maybe.Tests/UnitTest1.cs | 14 -- src/Bbt.Maybe.ruleset | 1 + src/Bbt.Maybe/Bbt.Maybe.csproj | 10 +- src/Bbt.Maybe/Class1.cs | 8 - src/Bbt.Maybe/Maybe.cs | 182 +++++++++++++++ src/Bbt.Maybe/MaybeFactory.cs | 45 ++++ src/Bbt.Maybe/MaybeStruct.cs | 180 +++++++++++++++ src/Bbt.Maybe/MaybeUtils.cs | 72 ++++++ src/Bbt.Maybe/NoneCase.cs | 89 ++++++++ 19 files changed, 1080 insertions(+), 25 deletions(-) create mode 100644 src/Bbt.Maybe.Tests/MaybeStructTests.cs create mode 100644 src/Bbt.Maybe.Tests/MaybeTests.cs create mode 100644 src/Bbt.Maybe.Tests/NoneCaseTests.cs create mode 100644 src/Bbt.Maybe.Tests/TestData/BaseClass.cs create mode 100644 src/Bbt.Maybe.Tests/TestData/BaseStruct.cs create mode 100644 src/Bbt.Maybe.Tests/TestData/DerivedClass.cs create mode 100644 src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs create mode 100644 src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs delete mode 100644 src/Bbt.Maybe.Tests/UnitTest1.cs delete mode 100644 src/Bbt.Maybe/Class1.cs create mode 100644 src/Bbt.Maybe/Maybe.cs create mode 100644 src/Bbt.Maybe/MaybeFactory.cs create mode 100644 src/Bbt.Maybe/MaybeStruct.cs create mode 100644 src/Bbt.Maybe/MaybeUtils.cs create mode 100644 src/Bbt.Maybe/NoneCase.cs diff --git a/setup.cake b/setup.cake index f6adafa..f0e86cf 100644 --- a/setup.cake +++ b/setup.cake @@ -19,7 +19,7 @@ BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings( context: Context, dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/BBT.Maybe.Tests/*.cs" }, - testCoverageFilter: "+[*]* -[xunit.*]* -[*.Tests]* ", + testCoverageFilter: "+[*]* -[xunit.*]* -[*.Tests]* -[Shouldly]*", testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); diff --git a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj index cd869a2..718365b 100644 --- a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj +++ b/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj @@ -21,6 +21,7 @@ + all diff --git a/src/Bbt.Maybe.Tests/MaybeStructTests.cs b/src/Bbt.Maybe.Tests/MaybeStructTests.cs new file mode 100644 index 0000000..4a3b606 --- /dev/null +++ b/src/Bbt.Maybe.Tests/MaybeStructTests.cs @@ -0,0 +1,154 @@ +namespace Bbt.Maybe.Tests +{ + using Bbt.Maybe; + using Bbt.Maybe.Tests.TestData; + using Shouldly; + using Xunit; + + public sealed class MaybeStructTests + { + public sealed class TheSomeStructMethod + { + [Fact] + public void ProjectToReferencingClass_ShouldReturnMaybeReferencingClass() + { + // Arrange + var lReferencedStruct = default(ReferencedStruct); + var lReferencingStruct = default(BaseStruct); + lReferencedStruct.ReferencingStruct = lReferencingStruct; + + // Act + var lMaybeReferencingStruct = Maybe.SomeStruct(lReferencedStruct) + .Some(aX => aX.ReferencingStruct); + + // Assert + lMaybeReferencingStruct.ShouldBe(Maybe.SomeStruct(lReferencingStruct)); + } + + [Fact] + public void None_ShouldReturnMaybeNone() + { + // Arrange + var lMaybeReferencedStruct = Maybe.NoneStruct(); + + // Act + var lMaybeReferencingStruct = lMaybeReferencedStruct.Some(aX => aX.ReferencingStruct); + + // Assert + lMaybeReferencingStruct.ShouldBe(Maybe.NoneStruct()); + } + } + + public sealed class TheDoMethod + { + [Fact] + public void MaybeValueNotSet_ActionNotCalled() + { + // Arrange + var lMaybeNone = Maybe.NoneStruct(); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => lCalled = true); + + // Assert + lCalled.ShouldBeFalse(); + } + + /// + /// Test that does call delegate if maybe represents not-null case. + /// + [Fact] + public void MaybeValueSet_ActionCalled() + { + // Arrange + var lMaybeNone = Maybe.SomeStruct(default(BaseStruct)); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => lCalled = true); + + // Assert + lCalled.ShouldBeTrue(); + } + } + + public sealed class TheDoIfNoneMethod + { + [Fact] + public void MaybeValueNotSet_DoIfNoneActionCalled() + { + // Arrange + var lMaybeNone = Maybe.NoneStruct(); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => { }).DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeTrue(); + } + + [Fact] + public void MaybeValueSet_ActionNotCalled() + { + // Arrange + var lMaybeNone = Maybe.SomeStruct(default(BaseStruct)); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => { }).DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeFalse(); + } + } + + public sealed class TheEqualsMethod + { + [Fact] + public void BothNone_ReturnsTrue() + { + // Arrange + var lMaybeNone = Maybe.NoneStruct(); + var lMaybeNone2 = Maybe.NoneStruct(); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void BothSameValue_ReturnsTrue() + { + // Arrange + var lBaseStruct = default(BaseStruct); + var lMaybeNone = Maybe.SomeStruct(lBaseStruct); + var lMaybeNone2 = Maybe.SomeStruct(lBaseStruct); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void NoneAndNotNone_ReturnsFalse() + { + // Arrange + var lStruct = default(BaseStruct); + var lMaybeNone = Maybe.SomeStruct(lStruct); + var lMaybeNone2 = Maybe.NoneStruct(); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + } + } +} diff --git a/src/Bbt.Maybe.Tests/MaybeTests.cs b/src/Bbt.Maybe.Tests/MaybeTests.cs new file mode 100644 index 0000000..f3252f4 --- /dev/null +++ b/src/Bbt.Maybe.Tests/MaybeTests.cs @@ -0,0 +1,209 @@ +namespace Bbt.Maybe.Tests +{ + using Bbt.Maybe; + using Bbt.Maybe.Tests.TestData; + using Shouldly; + using Xunit; + + public sealed class MaybeTests + { + public sealed class TheSomeMethod + { + [Fact] + public void DerivedCast_ShouldReturnMaybeBase() + { + // Arrange + var lDerivedClass = new DerivedClass(); + var lMaybeDerivedClass = Maybe.Some(lDerivedClass); + + // Act + var lMaybeBaseClass = lMaybeDerivedClass.Some(aX => aX); + + // Assert + lMaybeBaseClass.ShouldBe(Maybe.Some(lDerivedClass)); + } + + [Fact] + public void ProjectToReferencingClass_ShouldReturnMaybeReferencingClass() + { + // Arrange + var lReferencedClass = new ReferencedClass(); + var lReferencingClass = new BaseClass(); + lReferencedClass.ReferencingClass = lReferencingClass; + + // Act + var lMaybeReferencingClass = Maybe.Some(lReferencedClass).Some(aX => aX.ReferencingClass); + + // Assert + lMaybeReferencingClass.ShouldBe(Maybe.Some(lReferencingClass)); + } + + [Fact] + public void None_ShouldReturnMaybeNone() + { + // Arrange + var lMaybeReferencedClass = Maybe.None(); + + // Act + var lMaybeReferencingClass = lMaybeReferencedClass.Some(aX => aX.ReferencingClass); + + // Assert + lMaybeReferencingClass.ShouldBe(Maybe.None()); + } + } + + public sealed class TheDoMethod + { + [Fact] + public void MaybeValueNotSet_ActionNotCalled() + { + // Arrange + var lMaybeNone = Maybe.None(); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => lCalled = true); + + // Assert + lCalled.ShouldBeFalse(); + } + + [Fact] + public void MaybeValueSet_ActionCalled() + { + // Arrange + var lMaybeNone = Maybe.Some(new BaseClass()); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => lCalled = true); + + // Assert + lCalled.ShouldBeTrue(); + } + } + + public sealed class TheDoIfNoneMethod + { + [Fact] + public void MaybeValueNotSet_DoIfNoneActionCalled() + { + // Arrange + var lMaybeNone = Maybe.None(); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => { }).DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeTrue(); + } + + [Fact] + public void MaybeValueSet_ActionNotCalled() + { + // Arrange + var lMaybeNone = Maybe.Some(new BaseClass()); + var lCalled = false; + + // Act + lMaybeNone.Do(aX => { }).DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeFalse(); + } + } + + public sealed class TheEqualsMethod + { + [Fact] + public void BothNone_ReturnsTrue() + { + // Arrange + var lMaybeNone = Maybe.None(); + var lMaybeNone2 = Maybe.None(); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void BothNoneOfDerivedType_ReturnsFalse() + { + // Arrange + var lMaybeNone = Maybe.None(); + var lMaybeNone2 = Maybe.None(); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + + [Fact] + public void BothSameValue_ReturnsTrue() + { + // Arrange + var lBaseClass = new BaseClass(); + var lMaybeNone = Maybe.Some(lBaseClass); + var lMaybeNone2 = Maybe.Some(lBaseClass); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void BothSameValueButDerivedType_ReturnsFalse() + { + // Arrange + var lDerivedClass = new DerivedClass(); + var lMaybeNone = Maybe.Some(lDerivedClass); + var lMaybeNone2 = Maybe.Some(lDerivedClass); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + + [Fact] + public void BothNotSame_ReturnsFalse() + { + // Arrange + var lClass = new BaseClass(); + var lClass2 = new BaseClass(); + var lMaybeNone = Maybe.Some(lClass); + var lMaybeNone2 = Maybe.Some(lClass2); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + + [Fact] + public void NoneAndNotNone_ReturnsFalse() + { + // Arrange + var lClass = new BaseClass(); + var lMaybeNone = Maybe.Some(lClass); + var lMaybeNone2 = Maybe.None(); + + // Act + var lIsEqual = object.Equals(lMaybeNone, lMaybeNone2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + } + } +} diff --git a/src/Bbt.Maybe.Tests/NoneCaseTests.cs b/src/Bbt.Maybe.Tests/NoneCaseTests.cs new file mode 100644 index 0000000..3c2176b --- /dev/null +++ b/src/Bbt.Maybe.Tests/NoneCaseTests.cs @@ -0,0 +1,85 @@ +namespace Bbt.Maybe.Tests +{ + using Bbt.Maybe; + using Shouldly; + using Xunit; + + public sealed class NoneCaseTests + { + public sealed class TheDoIfNoneMethod + { + [Fact] + public void IsNotNoneCase_ISNotCalled() + { + // Arrange + var lNoneCase = new NoneCase(false); + var lCalled = false; + + // Act + lNoneCase.DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeFalse(); + } + + [Fact] + public void IsNotNoneCase_IsCalled() + { + // Arrange + var lNoneCase = new NoneCase(true); + var lCalled = false; + + // Act + lNoneCase.DoIfNone(() => lCalled = true); + + // Assert + lCalled.ShouldBeTrue(); + } + } + + public sealed class TheEqualsMethod + { + [Fact] + public void BothNoneCase_ReturnsTrue() + { + // Arrange + var lNoneCase = new NoneCase(true); + var lNoneCase2 = new NoneCase(true); + + // Act + var lIsEqual = object.Equals(lNoneCase, lNoneCase2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void BothNotNoneCase_ReturnsTrue() + { + // Arrange + var lNoneCase = new NoneCase(false); + var lNoneCase2 = new NoneCase(false); + + // Act + var lIsEqual = object.Equals(lNoneCase, lNoneCase2); + + // Assert + lIsEqual.ShouldBeTrue(); + } + + [Fact] + public void NoneAndNotNoneCase_ReturnsFalse() + { + // Arrange + var lNoneCase = new NoneCase(false); + var lNoneCase2 = new NoneCase(true); + + // Act + var lIsEqual = object.Equals(lNoneCase, lNoneCase2); + + // Assert + lIsEqual.ShouldBeFalse(); + } + } + } +} diff --git a/src/Bbt.Maybe.Tests/TestData/BaseClass.cs b/src/Bbt.Maybe.Tests/TestData/BaseClass.cs new file mode 100644 index 0000000..06cf52a --- /dev/null +++ b/src/Bbt.Maybe.Tests/TestData/BaseClass.cs @@ -0,0 +1,9 @@ +namespace Bbt.Maybe.Tests.TestData +{ + /// + /// Used for test purposes. + /// + public class BaseClass + { + } +} diff --git a/src/Bbt.Maybe.Tests/TestData/BaseStruct.cs b/src/Bbt.Maybe.Tests/TestData/BaseStruct.cs new file mode 100644 index 0000000..86eb678 --- /dev/null +++ b/src/Bbt.Maybe.Tests/TestData/BaseStruct.cs @@ -0,0 +1,9 @@ +namespace Bbt.Maybe.Tests.TestData +{ + /// + /// Used for test purposes. + /// + public struct BaseStruct + { + } +} diff --git a/src/Bbt.Maybe.Tests/TestData/DerivedClass.cs b/src/Bbt.Maybe.Tests/TestData/DerivedClass.cs new file mode 100644 index 0000000..4b8d1d3 --- /dev/null +++ b/src/Bbt.Maybe.Tests/TestData/DerivedClass.cs @@ -0,0 +1,9 @@ +namespace Bbt.Maybe.Tests.TestData +{ + /// + /// Used for test purposes. + /// + public class DerivedClass : BaseClass + { + } +} diff --git a/src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs b/src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs new file mode 100644 index 0000000..edfd2ab --- /dev/null +++ b/src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs @@ -0,0 +1,13 @@ +namespace Bbt.Maybe.Tests.TestData +{ + /// + /// Used for test purposes. + /// + public class ReferencedClass + { + /// + /// Gets or sets the owner of the 1-n relationship. + /// + public BaseClass ReferencingClass { get; set; } + } +} diff --git a/src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs b/src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs new file mode 100644 index 0000000..d3dae74 --- /dev/null +++ b/src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs @@ -0,0 +1,13 @@ +namespace Bbt.Maybe.Tests.TestData +{ + /// + /// Used for test purposes. + /// + public struct ReferencedStruct + { + /// + /// Gets or sets the owner of the 1-n relationship. + /// + public BaseStruct ReferencingStruct { get; set; } + } +} diff --git a/src/Bbt.Maybe.Tests/UnitTest1.cs b/src/Bbt.Maybe.Tests/UnitTest1.cs deleted file mode 100644 index c14b369..0000000 --- a/src/Bbt.Maybe.Tests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Bbt.Maybe.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} diff --git a/src/Bbt.Maybe.ruleset b/src/Bbt.Maybe.ruleset index d5812a1..2f35a52 100644 --- a/src/Bbt.Maybe.ruleset +++ b/src/Bbt.Maybe.ruleset @@ -237,5 +237,6 @@ + \ No newline at end of file diff --git a/src/Bbt.Maybe/Bbt.Maybe.csproj b/src/Bbt.Maybe/Bbt.Maybe.csproj index caa4186..e74aa43 100644 --- a/src/Bbt.Maybe/Bbt.Maybe.csproj +++ b/src/Bbt.Maybe/Bbt.Maybe.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -25,9 +25,15 @@ all - + all + + + + <_Parameter1>$(MSBuildProjectName).Tests + + \ No newline at end of file diff --git a/src/Bbt.Maybe/Class1.cs b/src/Bbt.Maybe/Class1.cs deleted file mode 100644 index 5931eca..0000000 --- a/src/Bbt.Maybe/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Bbt.Maybe -{ - public class Class1 - { - } -} diff --git a/src/Bbt.Maybe/Maybe.cs b/src/Bbt.Maybe/Maybe.cs new file mode 100644 index 0000000..4da87cb --- /dev/null +++ b/src/Bbt.Maybe/Maybe.cs @@ -0,0 +1,182 @@ +namespace Bbt.Maybe +{ + using System; + using System.Runtime.Serialization; + + /// + /// Represents a reference type which may be null or not null. + /// + /// + /// Implementation of the "maybe monad" pattern / Optional-pattern. + /// https://smellegantcode.wordpress.com/2008/12/11/the-maybe-monad-in-c/. + /// + /// The reference type. + [Serializable] + public struct Maybe : ISerializable, IEquatable> + where T : class + { + private readonly T mValue; + + /// + /// Initializes a new instance of the struct. + /// + /// The potentially nullable value. + internal Maybe(T aValueNullable) + { + this.mValue = aValueNullable; + } + + /// + /// Initializes a new instance of the struct. + /// Constructor used for deserialization. + /// + private Maybe(SerializationInfo aInfo, StreamingContext aContext) + { + MaybeUtils.CheckArgumentNotNull(aInfo, nameof(aInfo)); + this.mValue = MaybeUtils.GetDeserializedValue(aInfo, nameof(this.mValue)); + } + + /// + /// Gets a value indicating whether has a value (true) + /// or is representing the null case (false). + /// + public bool HasValue => this.mValue != null; + + /// + /// Checks whether the operands are equal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator ==(Maybe aA, Maybe aB) + { + return object.Equals(aA.mValue, aB.mValue); + } + + /// + /// Checks whether the operands are unequal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator !=(Maybe aA, Maybe aB) + { + return !(aA == aB); + } + + /// + /// Executes if value is not null. + /// + /// The action which is performed if maybe is not none. + /// The none case. + public NoneCase Do(Action aDoAction) + { + MaybeUtils.CheckArgumentNotNull(aDoAction, nameof(aDoAction)); + + if (this.mValue != null) + { + aDoAction(this.mValue); + return new NoneCase(false); + } + + return new NoneCase(true); + } + + /// + /// Gets the of the projection function . + /// + /// The type of the projected result. + /// The projection function. + /// The projected maybe. + public Maybe Some(Func aFunc) + where TResult : class + { + MaybeUtils.CheckArgumentNotNull(aFunc, nameof(aFunc)); + + var lMaybe = Maybe.None(); + this.Do(aX => lMaybe = Maybe.Some(aFunc(aX))); + + return lMaybe; + } + + /// + /// Returns the value in case it is initialized. + /// Otherwise throws an . + /// + /// The maybe reference used in error message. + /// Additional error message. + /// The value. + public T ThrowExceptionIfNone( + string aMaybeParameterName, + string aAdditionalMessage = "") + { + return MaybeUtils.CheckParameterNotNull(this.mValue, aMaybeParameterName, aAdditionalMessage); + } + + /// + /// See . + /// + /// The object to compare. + /// True if equal, false otherwise. + public override bool Equals(object aObj) + { + if (!(aObj is Maybe)) + { + return false; + } + + return this.Equals((Maybe)aObj); + } + + /// + /// See . + /// + /// The maybe to compare. + /// True if equal, false otherwise. + public bool Equals(Maybe aOther) + { + return this == aOther; + } + + /// + /// See . + /// + /// The hash code. + public override int GetHashCode() + { + if (this.HasValue) + { + this.mValue.GetHashCode(); + } + + return base.GetHashCode(); + } + + /// + /// See . + /// + /// The serialization info. + /// The streaming context. + public void GetObjectData(SerializationInfo aInfo, StreamingContext aContext) + { + if (aInfo == null) + { + throw new ArgumentNullException(nameof(aInfo)); + } + + aInfo.AddValue(nameof(this.mValue), this.mValue, typeof(T)); + } + + /// + /// See . + /// + /// The string representation. + public override string ToString() + { + if (this.HasValue) + { + return this.mValue.ToString(); + } + + return string.Empty; + } + } +} diff --git a/src/Bbt.Maybe/MaybeFactory.cs b/src/Bbt.Maybe/MaybeFactory.cs new file mode 100644 index 0000000..c705b5c --- /dev/null +++ b/src/Bbt.Maybe/MaybeFactory.cs @@ -0,0 +1,45 @@ +namespace Bbt.Maybe +{ + using System.Diagnostics.CodeAnalysis; + + /// + /// Factory methods. + /// + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:FileNameShouldMatchFirstTypeName", Justification = "Factory method should be called Maybe.")] + public static class Maybe + { + /// + /// Creates an instance of which may be null. + /// + /// The reference type. + /// The value which may be null. + /// The maybe. + public static Maybe Some(T aValue) + where T : class => new Maybe(aValue); + + /// + /// Creates an instance of Type which is null. + /// + /// The reference type. + /// The maybe representing none. + public static Maybe None() + where T : class => new Maybe(null); + + /// + /// Creates an instance of which may be null. + /// + /// The reference type. + /// The value which may be null. + /// The maybe. + public static MaybeStruct SomeStruct(T? aValue) + where T : struct => new MaybeStruct(aValue); + + /// + /// Creates an instance of Type which is null. + /// + /// The reference type. + /// The maybe representing null. + public static MaybeStruct NoneStruct() + where T : struct => new MaybeStruct(null); + } +} diff --git a/src/Bbt.Maybe/MaybeStruct.cs b/src/Bbt.Maybe/MaybeStruct.cs new file mode 100644 index 0000000..0cbc576 --- /dev/null +++ b/src/Bbt.Maybe/MaybeStruct.cs @@ -0,0 +1,180 @@ +namespace Bbt.Maybe +{ + using System; + using System.Runtime.Serialization; + + /// + /// Represents a nullable value type which may be null or not null. + /// + /// + /// Implementation of the "maybe monad" pattern / Optional-pattern. + /// https://smellegantcode.wordpress.com/2008/12/11/the-maybe-monad-in-c/. + /// + /// The value type. + [Serializable] + public struct MaybeStruct : ISerializable, IEquatable> + where T : struct + { + private readonly T? mValue; + + /// + /// Initializes a new instance of the struct. + /// + /// The potentially nullable value. + internal MaybeStruct(T? aValueNullable) + { + this.mValue = aValueNullable; + } + + /// + /// Initializes a new instance of the struct. + /// Constructor used for deserialization. + /// + private MaybeStruct(SerializationInfo aInfo, StreamingContext aContext) + { + MaybeUtils.CheckArgumentNotNull(aInfo, nameof(aInfo)); + this.mValue = MaybeUtils.GetDeserializedValue(aInfo, nameof(this.mValue)); + } + + /// + /// Gets a value indicating whether has a value (true) + /// or is representing the null case (false). + /// + public bool HasValue => this.mValue.HasValue; + + /// + /// Checks whether the operands are equal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator ==(MaybeStruct aA, MaybeStruct aB) + { + return object.Equals(aA.mValue, aB.mValue); + } + + /// + /// Checks whether the operands are unequal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator !=(MaybeStruct aA, MaybeStruct aB) + { + return !(aA == aB); + } + + /// + /// Starts if value is not null. + /// + /// The action which is performed if maybe is not none. + /// The none case. + public NoneCase Do(Action aDoAction) + { + MaybeUtils.CheckArgumentNotNull(aDoAction, nameof(aDoAction)); + + if (this.mValue.HasValue) + { + aDoAction(this.mValue.Value); + return new NoneCase(false); + } + + return new NoneCase(true); + } + + /// + /// Gets the of the projection function . + /// + /// The type of the projected result. + /// The projection function. + /// The projected maybe. + public MaybeStruct Some(Func aFunc) + where TResult : struct + { + MaybeUtils.CheckArgumentNotNull(aFunc, nameof(aFunc)); + + var lMaybe = Maybe.NoneStruct(); + this.Do(aX => lMaybe = Maybe.SomeStruct(aFunc(aX))); + + return lMaybe; + } + + /// + /// Returns the value in case it is initialized. + /// Otherwise throws an . + /// + /// The maybe reference used in error message. + /// Additional error message. + /// The value. + public T ThrowExceptionIfNone( + string aMaybeParameterName, + string aAdditionalMessage = "") + { + return MaybeUtils.CheckParameterNotNull(this.mValue, aMaybeParameterName, aAdditionalMessage) + .Value; + } + + /// + /// See . + /// + /// The maybe to compare. + /// True if equal, false otherwise. + public override bool Equals(object aObj) + { + if (!(aObj is MaybeStruct)) + { + return false; + } + + return this.Equals((MaybeStruct)aObj); + } + + /// + /// See . + /// + /// The value to compare. + /// True if equal, false otherwise. + public bool Equals(MaybeStruct aOther) + { + return this == aOther; + } + + /// + /// See . + /// + /// The hash code. + public override int GetHashCode() + { + if (this.mValue != null) + { + this.mValue.GetHashCode(); + } + + return base.GetHashCode(); + } + + /// + /// See . + /// + /// The serialization info. + /// The streaming context. + public void GetObjectData(SerializationInfo aInfo, StreamingContext aContext) + { + MaybeUtils.CheckArgumentNotNull(aInfo, nameof(aInfo)); + + aInfo.AddValue(nameof(this.mValue), this.mValue, typeof(T)); + } + + /// + /// See . + /// + /// The string representation. + public override string ToString() + { + if (this.HasValue) + { + return this.mValue.ToString(); + } + + return string.Empty; + } + } +} diff --git a/src/Bbt.Maybe/MaybeUtils.cs b/src/Bbt.Maybe/MaybeUtils.cs new file mode 100644 index 0000000..379e2d6 --- /dev/null +++ b/src/Bbt.Maybe/MaybeUtils.cs @@ -0,0 +1,72 @@ +namespace Bbt.Maybe +{ + using System; + using System.Globalization; + using System.Runtime.Serialization; + + /// + /// Provides utility methods for maybe. + /// + internal static class MaybeUtils + { + /// + /// Asserts that is not null. + /// In case of null an is thrown. + /// + /// The argument's type. + /// The argument. + /// The arguments name. + /// The argument. + internal static T CheckArgumentNotNull(T aArg, string aArgName) + where T : class + { + if (aArg == null) + { + throw new ArgumentNullException(aArgName); + } + + return aArg; + } + + /// + /// Asserts that is not null. + /// In case of null an is thrown. + /// + /// The parameter's type. + /// The parameter. + /// The parameter's name. + /// An optional additional error message. + /// The parameter. + internal static T CheckParameterNotNull( + T aParameter, string aParameterName, string aAdditionalMessage = "") + { + if (aParameter == null) + { + var lMsg = $"({aParameterName}) may not be null.".ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrEmpty(aAdditionalMessage)) + { + lMsg = lMsg + " " + aAdditionalMessage; + } + + throw new InvalidOperationException(lMsg); + } + + return aParameter; + } + + /// + /// Gets the casted value from + /// corresponding to . + /// + /// The value's type. + /// The serialization info. + /// The key. + /// The corresponding value. + internal static T GetDeserializedValue( + SerializationInfo aInfo, + string aKey) + { + return (T)aInfo.GetValue(aKey, typeof(T)); + } + } +} diff --git a/src/Bbt.Maybe/NoneCase.cs b/src/Bbt.Maybe/NoneCase.cs new file mode 100644 index 0000000..24dd4d2 --- /dev/null +++ b/src/Bbt.Maybe/NoneCase.cs @@ -0,0 +1,89 @@ +namespace Bbt.Maybe +{ + using System; + + /// + /// Used in context of . Used to provide method. + /// + public struct NoneCase : IEquatable + { + private readonly bool mIsNone; + + /// + /// Initializes a new instance of the struct. + /// + /// True if representing the none case, false if value is set. + internal NoneCase(bool aIsNone) + { + this.mIsNone = aIsNone; + } + + /// + /// Checks whether the operands are equal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator ==(NoneCase aA, NoneCase aB) + { + return aA.mIsNone.Equals(aB.mIsNone); + } + + /// + /// Checks whether the operands are unequal. + /// + /// Maybe to compare. + /// Maybe to compare. + public static bool operator !=(NoneCase aA, NoneCase aB) + { + return !(aA == aB); + } + + /// + /// The is called in none case. + /// + /// The action which is performed if maybe is none. + public void DoIfNone(Action aDoAction) + { + if (aDoAction == null) + { + throw new ArgumentNullException(nameof(aDoAction)); + } + + if (this.mIsNone) + { + aDoAction(); + } + } + + /// + /// See . + /// + /// The object to compare. + /// True if equal, false otherwise. + public override bool Equals(object aObj) + { + if (!(aObj is NoneCase)) + { + return false; + } + + return this.Equals((NoneCase)aObj); + } + + /// + /// See . + /// + /// The maybe to compare. + /// True if equal, false otherwise. + public bool Equals(NoneCase aOther) + { + return this == aOther; + } + + /// + /// See . + /// + /// The hash code. + public override int GetHashCode() => this.mIsNone.GetHashCode(); + } +} \ No newline at end of file From d31b657679c2a681c63ac10ae5600a7e51db55e0 Mon Sep 17 00:00:00 2001 From: Stefan Lindegger Date: Sun, 28 Apr 2019 15:25:01 +0200 Subject: [PATCH 12/13] (GH-3) Declare assembly CLSCompliant. Change casing of namespaces from Bbt to BBT. --- src/{Bbt.Maybe.Tests.ruleset => BBT.Maybe.Tests.ruleset} | 0 .../Bbt.Maybe.Tests.csproj | 2 +- .../MaybeStructTests.cs | 6 +++--- src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/MaybeTests.cs | 6 +++--- src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/NoneCaseTests.cs | 4 ++-- .../TestData/BaseClass.cs | 2 +- .../TestData/BaseStruct.cs | 2 +- .../TestData/DerivedClass.cs | 2 +- .../TestData/ReferencedClass.cs | 2 +- .../TestData/ReferencedStruct.cs | 2 +- src/{Bbt.Maybe.ruleset => BBT.Maybe.ruleset} | 0 src/{Bbt.Maybe.sln => BBT.Maybe.sln} | 4 ++-- ...{Bbt.Maybe.sln.DotSettings => BBT.Maybe.sln.DotSettings} | 0 src/BBT.Maybe/AssemblyInfo.cs | 1 + src/{Bbt.Maybe => BBT.Maybe}/Bbt.Maybe.csproj | 0 src/{Bbt.Maybe => BBT.Maybe}/Maybe.cs | 2 +- src/{Bbt.Maybe => BBT.Maybe}/MaybeFactory.cs | 2 +- src/{Bbt.Maybe => BBT.Maybe}/MaybeStruct.cs | 2 +- src/{Bbt.Maybe => BBT.Maybe}/MaybeUtils.cs | 2 +- src/{Bbt.Maybe => BBT.Maybe}/NoneCase.cs | 2 +- 20 files changed, 22 insertions(+), 21 deletions(-) rename src/{Bbt.Maybe.Tests.ruleset => BBT.Maybe.Tests.ruleset} (100%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/Bbt.Maybe.Tests.csproj (94%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/MaybeStructTests.cs (98%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/MaybeTests.cs (98%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/NoneCaseTests.cs (97%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/TestData/BaseClass.cs (74%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/TestData/BaseStruct.cs (75%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/TestData/DerivedClass.cs (76%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/TestData/ReferencedClass.cs (88%) rename src/{Bbt.Maybe.Tests => BBT.Maybe.Tests}/TestData/ReferencedStruct.cs (88%) rename src/{Bbt.Maybe.ruleset => BBT.Maybe.ruleset} (100%) rename src/{Bbt.Maybe.sln => BBT.Maybe.sln} (83%) rename src/{Bbt.Maybe.sln.DotSettings => BBT.Maybe.sln.DotSettings} (100%) create mode 100644 src/BBT.Maybe/AssemblyInfo.cs rename src/{Bbt.Maybe => BBT.Maybe}/Bbt.Maybe.csproj (100%) rename src/{Bbt.Maybe => BBT.Maybe}/Maybe.cs (99%) rename src/{Bbt.Maybe => BBT.Maybe}/MaybeFactory.cs (98%) rename src/{Bbt.Maybe => BBT.Maybe}/MaybeStruct.cs (99%) rename src/{Bbt.Maybe => BBT.Maybe}/MaybeUtils.cs (99%) rename src/{Bbt.Maybe => BBT.Maybe}/NoneCase.cs (99%) diff --git a/src/Bbt.Maybe.Tests.ruleset b/src/BBT.Maybe.Tests.ruleset similarity index 100% rename from src/Bbt.Maybe.Tests.ruleset rename to src/BBT.Maybe.Tests.ruleset diff --git a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj b/src/BBT.Maybe.Tests/Bbt.Maybe.Tests.csproj similarity index 94% rename from src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj rename to src/BBT.Maybe.Tests/Bbt.Maybe.Tests.csproj index 718365b..089a3fb 100644 --- a/src/Bbt.Maybe.Tests/Bbt.Maybe.Tests.csproj +++ b/src/BBT.Maybe.Tests/Bbt.Maybe.Tests.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/Bbt.Maybe.Tests/MaybeStructTests.cs b/src/BBT.Maybe.Tests/MaybeStructTests.cs similarity index 98% rename from src/Bbt.Maybe.Tests/MaybeStructTests.cs rename to src/BBT.Maybe.Tests/MaybeStructTests.cs index 4a3b606..0dfe1d2 100644 --- a/src/Bbt.Maybe.Tests/MaybeStructTests.cs +++ b/src/BBT.Maybe.Tests/MaybeStructTests.cs @@ -1,7 +1,7 @@ -namespace Bbt.Maybe.Tests +namespace BBT.Maybe.Tests { - using Bbt.Maybe; - using Bbt.Maybe.Tests.TestData; + using BBT.Maybe; + using BBT.Maybe.Tests.TestData; using Shouldly; using Xunit; diff --git a/src/Bbt.Maybe.Tests/MaybeTests.cs b/src/BBT.Maybe.Tests/MaybeTests.cs similarity index 98% rename from src/Bbt.Maybe.Tests/MaybeTests.cs rename to src/BBT.Maybe.Tests/MaybeTests.cs index f3252f4..b3a9ce7 100644 --- a/src/Bbt.Maybe.Tests/MaybeTests.cs +++ b/src/BBT.Maybe.Tests/MaybeTests.cs @@ -1,7 +1,7 @@ -namespace Bbt.Maybe.Tests +namespace BBT.Maybe.Tests { - using Bbt.Maybe; - using Bbt.Maybe.Tests.TestData; + using BBT.Maybe; + using BBT.Maybe.Tests.TestData; using Shouldly; using Xunit; diff --git a/src/Bbt.Maybe.Tests/NoneCaseTests.cs b/src/BBT.Maybe.Tests/NoneCaseTests.cs similarity index 97% rename from src/Bbt.Maybe.Tests/NoneCaseTests.cs rename to src/BBT.Maybe.Tests/NoneCaseTests.cs index 3c2176b..9cd8594 100644 --- a/src/Bbt.Maybe.Tests/NoneCaseTests.cs +++ b/src/BBT.Maybe.Tests/NoneCaseTests.cs @@ -1,6 +1,6 @@ -namespace Bbt.Maybe.Tests +namespace BBT.Maybe.Tests { - using Bbt.Maybe; + using BBT.Maybe; using Shouldly; using Xunit; diff --git a/src/Bbt.Maybe.Tests/TestData/BaseClass.cs b/src/BBT.Maybe.Tests/TestData/BaseClass.cs similarity index 74% rename from src/Bbt.Maybe.Tests/TestData/BaseClass.cs rename to src/BBT.Maybe.Tests/TestData/BaseClass.cs index 06cf52a..798c08b 100644 --- a/src/Bbt.Maybe.Tests/TestData/BaseClass.cs +++ b/src/BBT.Maybe.Tests/TestData/BaseClass.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe.Tests.TestData +namespace BBT.Maybe.Tests.TestData { /// /// Used for test purposes. diff --git a/src/Bbt.Maybe.Tests/TestData/BaseStruct.cs b/src/BBT.Maybe.Tests/TestData/BaseStruct.cs similarity index 75% rename from src/Bbt.Maybe.Tests/TestData/BaseStruct.cs rename to src/BBT.Maybe.Tests/TestData/BaseStruct.cs index 86eb678..c00e477 100644 --- a/src/Bbt.Maybe.Tests/TestData/BaseStruct.cs +++ b/src/BBT.Maybe.Tests/TestData/BaseStruct.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe.Tests.TestData +namespace BBT.Maybe.Tests.TestData { /// /// Used for test purposes. diff --git a/src/Bbt.Maybe.Tests/TestData/DerivedClass.cs b/src/BBT.Maybe.Tests/TestData/DerivedClass.cs similarity index 76% rename from src/Bbt.Maybe.Tests/TestData/DerivedClass.cs rename to src/BBT.Maybe.Tests/TestData/DerivedClass.cs index 4b8d1d3..af611b0 100644 --- a/src/Bbt.Maybe.Tests/TestData/DerivedClass.cs +++ b/src/BBT.Maybe.Tests/TestData/DerivedClass.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe.Tests.TestData +namespace BBT.Maybe.Tests.TestData { /// /// Used for test purposes. diff --git a/src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs b/src/BBT.Maybe.Tests/TestData/ReferencedClass.cs similarity index 88% rename from src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs rename to src/BBT.Maybe.Tests/TestData/ReferencedClass.cs index edfd2ab..5446654 100644 --- a/src/Bbt.Maybe.Tests/TestData/ReferencedClass.cs +++ b/src/BBT.Maybe.Tests/TestData/ReferencedClass.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe.Tests.TestData +namespace BBT.Maybe.Tests.TestData { /// /// Used for test purposes. diff --git a/src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs b/src/BBT.Maybe.Tests/TestData/ReferencedStruct.cs similarity index 88% rename from src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs rename to src/BBT.Maybe.Tests/TestData/ReferencedStruct.cs index d3dae74..6b83ed3 100644 --- a/src/Bbt.Maybe.Tests/TestData/ReferencedStruct.cs +++ b/src/BBT.Maybe.Tests/TestData/ReferencedStruct.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe.Tests.TestData +namespace BBT.Maybe.Tests.TestData { /// /// Used for test purposes. diff --git a/src/Bbt.Maybe.ruleset b/src/BBT.Maybe.ruleset similarity index 100% rename from src/Bbt.Maybe.ruleset rename to src/BBT.Maybe.ruleset diff --git a/src/Bbt.Maybe.sln b/src/BBT.Maybe.sln similarity index 83% rename from src/Bbt.Maybe.sln rename to src/BBT.Maybe.sln index 4fa705e..f776d7c 100644 --- a/src/Bbt.Maybe.sln +++ b/src/BBT.Maybe.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.271 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bbt.Maybe", "Bbt.Maybe\Bbt.Maybe.csproj", "{2F38B821-95F8-4560-B08E-9796C44D0C86}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBT.Maybe", "Bbt.Maybe\BBT.Maybe.csproj", "{2F38B821-95F8-4560-B08E-9796C44D0C86}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bbt.Maybe.Tests", "Bbt.Maybe.Tests\Bbt.Maybe.Tests.csproj", "{86D8402D-88CF-4887-A9BC-5662FC23BAFE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBT.Maybe.Tests", "Bbt.Maybe.Tests\BBT.Maybe.Tests.csproj", "{86D8402D-88CF-4887-A9BC-5662FC23BAFE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Bbt.Maybe.sln.DotSettings b/src/BBT.Maybe.sln.DotSettings similarity index 100% rename from src/Bbt.Maybe.sln.DotSettings rename to src/BBT.Maybe.sln.DotSettings diff --git a/src/BBT.Maybe/AssemblyInfo.cs b/src/BBT.Maybe/AssemblyInfo.cs new file mode 100644 index 0000000..b5249c5 --- /dev/null +++ b/src/BBT.Maybe/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: System.CLSCompliant(true)] diff --git a/src/Bbt.Maybe/Bbt.Maybe.csproj b/src/BBT.Maybe/Bbt.Maybe.csproj similarity index 100% rename from src/Bbt.Maybe/Bbt.Maybe.csproj rename to src/BBT.Maybe/Bbt.Maybe.csproj diff --git a/src/Bbt.Maybe/Maybe.cs b/src/BBT.Maybe/Maybe.cs similarity index 99% rename from src/Bbt.Maybe/Maybe.cs rename to src/BBT.Maybe/Maybe.cs index 4da87cb..01e654e 100644 --- a/src/Bbt.Maybe/Maybe.cs +++ b/src/BBT.Maybe/Maybe.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe +namespace BBT.Maybe { using System; using System.Runtime.Serialization; diff --git a/src/Bbt.Maybe/MaybeFactory.cs b/src/BBT.Maybe/MaybeFactory.cs similarity index 98% rename from src/Bbt.Maybe/MaybeFactory.cs rename to src/BBT.Maybe/MaybeFactory.cs index c705b5c..410c440 100644 --- a/src/Bbt.Maybe/MaybeFactory.cs +++ b/src/BBT.Maybe/MaybeFactory.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe +namespace BBT.Maybe { using System.Diagnostics.CodeAnalysis; diff --git a/src/Bbt.Maybe/MaybeStruct.cs b/src/BBT.Maybe/MaybeStruct.cs similarity index 99% rename from src/Bbt.Maybe/MaybeStruct.cs rename to src/BBT.Maybe/MaybeStruct.cs index 0cbc576..ef32f2d 100644 --- a/src/Bbt.Maybe/MaybeStruct.cs +++ b/src/BBT.Maybe/MaybeStruct.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe +namespace BBT.Maybe { using System; using System.Runtime.Serialization; diff --git a/src/Bbt.Maybe/MaybeUtils.cs b/src/BBT.Maybe/MaybeUtils.cs similarity index 99% rename from src/Bbt.Maybe/MaybeUtils.cs rename to src/BBT.Maybe/MaybeUtils.cs index 379e2d6..ce9f00e 100644 --- a/src/Bbt.Maybe/MaybeUtils.cs +++ b/src/BBT.Maybe/MaybeUtils.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe +namespace BBT.Maybe { using System; using System.Globalization; diff --git a/src/Bbt.Maybe/NoneCase.cs b/src/BBT.Maybe/NoneCase.cs similarity index 99% rename from src/Bbt.Maybe/NoneCase.cs rename to src/BBT.Maybe/NoneCase.cs index 24dd4d2..dff96a3 100644 --- a/src/Bbt.Maybe/NoneCase.cs +++ b/src/BBT.Maybe/NoneCase.cs @@ -1,4 +1,4 @@ -namespace Bbt.Maybe +namespace BBT.Maybe { using System; From 3d82efcf65f0bfdac84c12387f19110b13a1d851 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 28 Apr 2019 23:25:34 +0200 Subject: [PATCH 13/13] Remove Travis settings --- .travis.yml | 10 ------- README.md | 8 +----- build.sh | 82 ----------------------------------------------------- 3 files changed, 1 insertion(+), 99 deletions(-) delete mode 100644 .travis.yml delete mode 100644 build.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eb79eee..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: csharp -script: - - ./build.sh -v diagnostic -os: - - linux - - osx -cache: - directories: - - packages - - tools diff --git a/README.md b/README.md index ce585cb..e613417 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,4 @@ On Windows PowerShell run: ```powershell ./build -``` - -On OSX/Linux run: - -```bash -./build.sh -``` +``` \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index a541ec1..0000000 --- a/build.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash -############################################################### -# This is the Cake bootstrapper script that is responsible for -# downloading Cake and all specified tools from NuGet. -############################################################### - -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe - -# Define default arguments. -SCRIPT="setup.cake" -TARGET="Default" -CONFIGURATION="Release" -VERBOSITY="verbose" -DRYRUN= -SHOW_VERSION=false -SCRIPT_ARGUMENTS=() - -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - -t|--target) TARGET="$2"; shift ;; - -c|--configuration) CONFIGURATION="$2"; shift ;; - -v|--verbosity) VERBOSITY="$2"; shift ;; - -d|--dryrun) DRYRUN="-dryrun" ;; - --version) SHOW_VERSION=true ;; - --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; - *) SCRIPT_ARGUMENTS+=("$1") ;; - esac - shift -done - -# Make sure the tools folder exist. -if [ ! -d $TOOLS_DIR ]; then - mkdir $TOOLS_DIR -fi - -# Make sure that packages.config exist. -if [ ! -f $TOOLS_DIR/packages.config ]; then - echo "Downloading packages.config..." - curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occured while downloading packages.config." - exit 1 - fi -fi - -# Download NuGet if it does not exist. -if [ ! -f $NUGET_EXE ]; then - echo "Downloading NuGet..." - curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occured while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd $TOOLS_DIR >/dev/null -mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json -if [ $? -ne 0 ]; then - echo "Could not restore NuGet packages." - exit 1 -fi -popd >/dev/null - -# Make sure that Cake has been installed. -if [ ! -f $CAKE_EXE ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi - -# Start Cake -if $SHOW_VERSION; then - exec mono $CAKE_EXE -version -else - exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" -fi