├── .gitattributes
├── .gitignore
├── License.txt
├── Problem.sln
├── ReleaseNotes.md
├── appveyor.yml
├── build.cake
├── build.cmd
├── build.ps1
├── build.sh
├── build
├── Build.proj
└── Tavis.Problem.nuspec
├── readme.md
└── src
├── Problem
├── HttpContentProblemExtensions.cs
├── Problem.csproj
├── ProblemContent.cs
└── ProblemDocument.cs
└── ProblemTests
├── BasicTests.cs
└── ProblemTests.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | .vs/
50 |
51 | [Bb]in/
52 | [Oo]bj/
53 | artifacts/
54 |
55 | # MSTest test Results
56 | [Tt]est[Rr]esult*/
57 | [Bb]uild[Ll]og.*
58 |
59 | *_i.c
60 | *_p.c
61 | *.ilk
62 | *.meta
63 | *.obj
64 | *.pch
65 | *.pdb
66 | *.pgc
67 | *.pgd
68 | *.rsp
69 | *.sbr
70 | *.tlb
71 | *.tli
72 | *.tlh
73 | *.tmp
74 | *.tmp_proj
75 | *.log
76 | *.vspscc
77 | *.vssscc
78 | .builds
79 | *.pidb
80 | *.log
81 | *.scc
82 |
83 | # Visual C++ cache files
84 | ipch/
85 | *.aps
86 | *.ncb
87 | *.opensdf
88 | *.sdf
89 | *.cachefile
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | *.ncrunch*
111 | .*crunch*.local.xml
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.Publish.xml
131 | *.pubxml
132 |
133 | # NuGet Packages Directory
134 | packages/
135 |
136 | # Windows Azure Build Output
137 | csx
138 | *.build.csdef
139 |
140 | # Windows Store app package directory
141 | AppPackages/
142 |
143 | # Others
144 | sql/
145 | *.Cache
146 | ClientBin/
147 | [Ss]tyle[Cc]op.*
148 | ~$*
149 | *~
150 | *.dbmdl
151 | *.[Pp]ublish.xml
152 | *.pfx
153 | *.publishsettings
154 | .idea
155 | .vscode
156 | tools/
157 | package/
158 |
159 | # RIA/Silverlight projects
160 | Generated_Code/
161 |
162 | # Backup & report files from converting an old project file to a newer
163 | # Visual Studio version. Backup files are not needed, because we have git ;-)
164 | _UpgradeReport_Files/
165 | Backup*/
166 | UpgradeLog*.XML
167 | UpgradeLog*.htm
168 |
169 | # SQL Server files
170 | App_Data/*.mdf
171 | App_Data/*.ldf
172 |
173 | #############
174 | ## Windows detritus
175 | #############
176 |
177 | # Windows image file caches
178 | Thumbs.db
179 | ehthumbs.db
180 |
181 | # Folder config file
182 | Desktop.ini
183 |
184 | # Recycle Bin used on file shares
185 | $RECYCLE.BIN/
186 |
187 | # Mac crap
188 | .DS_Store
189 |
190 |
191 | #############
192 | ## Python
193 | #############
194 |
195 | *.py[co]
196 |
197 | # Packages
198 | *.egg
199 | *.egg-info
200 | dist/
201 |
202 | eggs/
203 | parts/
204 | var/
205 | sdist/
206 | develop-eggs/
207 | .installed.cfg
208 |
209 | # Installer logs
210 | pip-log.txt
211 |
212 | # Unit test / coverage reports
213 | .coverage
214 | .tox
215 |
216 | #Translations
217 | *.mo
218 |
219 | #Mr Developer
220 | .mr.developer.cfg
221 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 |
180 | Copyright 2012 Tavis Software Inc.
181 |
182 | Licensed under the Apache License, Version 2.0 (the "License");
183 | you may not use this file except in compliance with the License.
184 | You may obtain a copy of the License at
185 |
186 | http://www.apache.org/licenses/LICENSE-2.0
187 |
188 | Unless required by applicable law or agreed to in writing, software
189 | distributed under the License is distributed on an "AS IS" BASIS,
190 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191 | See the License for the specific language governing permissions and
192 | limitations under the License.
--------------------------------------------------------------------------------
/Problem.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 15
3 | VisualStudioVersion = 15.0.26124.0
4 | MinimumVisualStudioVersion = 15.0.26124.0
5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5CEB4B59-47CE-445C-90A7-909AF34740EF}"
6 | EndProject
7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem", "src\Problem\Problem.csproj", "{53A31923-AAA7-4CEF-A11D-D4EA786CC695}"
8 | EndProject
9 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProblemTests", "src\ProblemTests\ProblemTests.csproj", "{AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}"
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug|Any CPU = Debug|Any CPU
14 | Debug|x64 = Debug|x64
15 | Debug|x86 = Debug|x86
16 | Release|Any CPU = Release|Any CPU
17 | Release|x64 = Release|x64
18 | Release|x86 = Release|x86
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|x64.ActiveCfg = Debug|Any CPU
24 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|x64.Build.0 = Debug|Any CPU
25 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|x86.ActiveCfg = Debug|Any CPU
26 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Debug|x86.Build.0 = Debug|Any CPU
27 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|x64.ActiveCfg = Release|Any CPU
30 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|x64.Build.0 = Release|Any CPU
31 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|x86.ActiveCfg = Release|Any CPU
32 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695}.Release|x86.Build.0 = Release|Any CPU
33 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|x64.ActiveCfg = Debug|Any CPU
36 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|x64.Build.0 = Debug|Any CPU
37 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|x86.ActiveCfg = Debug|Any CPU
38 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Debug|x86.Build.0 = Debug|Any CPU
39 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|x64.ActiveCfg = Release|Any CPU
42 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|x64.Build.0 = Release|Any CPU
43 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|x86.ActiveCfg = Release|Any CPU
44 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3}.Release|x86.Build.0 = Release|Any CPU
45 | EndGlobalSection
46 | GlobalSection(SolutionProperties) = preSolution
47 | HideSolutionNode = FALSE
48 | EndGlobalSection
49 | GlobalSection(NestedProjects) = preSolution
50 | {53A31923-AAA7-4CEF-A11D-D4EA786CC695} = {5CEB4B59-47CE-445C-90A7-909AF34740EF}
51 | {AE36D818-8682-4B59-BA0D-9C6A7DBBBAF3} = {5CEB4B59-47CE-445C-90A7-909AF34740EF}
52 | EndGlobalSection
53 | GlobalSection(ExtensibilityGlobals) = postSolution
54 | SolutionGuid = {4E5D3FD3-AEA5-45B4-8601-7B8AF4BD10D3}
55 | EndGlobalSection
56 | EndGlobal
57 |
--------------------------------------------------------------------------------
/ReleaseNotes.md:
--------------------------------------------------------------------------------
1 | # Tavis.Home #
2 |
3 | ##1.0.0
4 | - Updated ProblemInstance behaviour to comply with RFC7807
5 | ##0.9.6
6 | - Updated dependencies
7 | - Set Content Type header in ProblemContent
8 | - Removed dependency on System.Net.Http Nuget for .net45 Portable library
9 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.0.{build}
2 | image: Visual Studio 2017
3 | build_script:
4 | - cmd: PowerShell -Version 2.0 .\build.cmd
5 | test: off
6 | artifacts:
7 | - path: artifacts\*.nupkg
8 | name: Nuget
--------------------------------------------------------------------------------
/build.cake:
--------------------------------------------------------------------------------
1 | #tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
2 | //////////////////////////////////////////////////////////////////////
3 | // ARGUMENTS
4 | //////////////////////////////////////////////////////////////////////
5 |
6 | var target = Argument("target", "Default");
7 | var configuration = Argument("configuration", "Release");
8 |
9 | //////////////////////////////////////////////////////////////////////
10 | // PREPARATION
11 | //////////////////////////////////////////////////////////////////////
12 |
13 | // Define directories.
14 | var buildDir = Directory("./src/Problem/bin") + Directory(configuration);
15 |
16 | //////////////////////////////////////////////////////////////////////
17 | // TASKS
18 | //////////////////////////////////////////////////////////////////////
19 |
20 | Task("Clean")
21 | .Does(() =>
22 | {
23 | CleanDirectory(buildDir);
24 | });
25 |
26 | Task("Restore-NuGet-Packages")
27 | .IsDependentOn("Clean")
28 | .Does(() =>
29 | {
30 | NuGetRestore("./Problem.sln");
31 | });
32 |
33 | Task("Build")
34 | .IsDependentOn("Restore-NuGet-Packages")
35 | .Does(() =>
36 | {
37 | MSBuild("./Problem.sln", settings =>
38 | settings.SetConfiguration(configuration));
39 | });
40 |
41 | Task("Run-Unit-Tests")
42 | .IsDependentOn("Build")
43 | .Does(() =>
44 | {
45 | DotNetCoreTest("./src/ProblemTests/ProblemTests.csproj", new DotNetCoreTestSettings
46 | {
47 | Configuration = "Release"
48 | });
49 | });
50 |
51 | //////////////////////////////////////////////////////////////////////
52 | // TASK TARGETS
53 | //////////////////////////////////////////////////////////////////////
54 |
55 | Task("Default")
56 | .IsDependentOn("Run-Unit-Tests");
57 |
58 | //////////////////////////////////////////////////////////////////////
59 | // EXECUTION
60 | //////////////////////////////////////////////////////////////////////
61 |
62 | RunTarget(target);
63 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | SET PROJ=%~dp0src\Problem\Problem.csproj
2 | dotnet restore
3 | dotnet build
4 | dotnet pack %PROJ% -c release -o %~dp0artifacts
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | ##########################################################################
2 | # This is the Cake bootstrapper script for PowerShell.
3 | # This file was downloaded from https://github.com/cake-build/resources
4 | # Feel free to change this file to fit your needs.
5 | ##########################################################################
6 |
7 | <#
8 |
9 | .SYNOPSIS
10 | This is a Powershell script to bootstrap a Cake build.
11 |
12 | .DESCRIPTION
13 | This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
14 | and execute your Cake build script with the parameters you provide.
15 |
16 | .PARAMETER Script
17 | The build script to execute.
18 | .PARAMETER Target
19 | The build script target to run.
20 | .PARAMETER Configuration
21 | The build configuration to use.
22 | .PARAMETER Verbosity
23 | Specifies the amount of information to be displayed.
24 | .PARAMETER Experimental
25 | Tells Cake to use the latest Roslyn release.
26 | .PARAMETER WhatIf
27 | Performs a dry run of the build script.
28 | No tasks will be executed.
29 | .PARAMETER Mono
30 | Tells Cake to use the Mono scripting engine.
31 | .PARAMETER SkipToolPackageRestore
32 | Skips restoring of packages.
33 | .PARAMETER ScriptArgs
34 | Remaining arguments are added here.
35 |
36 | .LINK
37 | https://cakebuild.net
38 |
39 | #>
40 |
41 | [CmdletBinding()]
42 | Param(
43 | [string]$Script = "build.cake",
44 | [string]$Target = "Default",
45 | [ValidateSet("Release", "Debug")]
46 | [string]$Configuration = "Release",
47 | [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
48 | [string]$Verbosity = "Verbose",
49 | [switch]$Experimental,
50 | [Alias("DryRun","Noop")]
51 | [switch]$WhatIf,
52 | [switch]$Mono,
53 | [switch]$SkipToolPackageRestore,
54 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
55 | [string[]]$ScriptArgs
56 | )
57 |
58 | [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
59 | function MD5HashFile([string] $filePath)
60 | {
61 | if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
62 | {
63 | return $null
64 | }
65 |
66 | [System.IO.Stream] $file = $null;
67 | [System.Security.Cryptography.MD5] $md5 = $null;
68 | try
69 | {
70 | $md5 = [System.Security.Cryptography.MD5]::Create()
71 | $file = [System.IO.File]::OpenRead($filePath)
72 | return [System.BitConverter]::ToString($md5.ComputeHash($file))
73 | }
74 | finally
75 | {
76 | if ($file -ne $null)
77 | {
78 | $file.Dispose()
79 | }
80 | }
81 | }
82 |
83 | Write-Host "Preparing to run build script..."
84 |
85 | if(!$PSScriptRoot){
86 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
87 | }
88 |
89 | $TOOLS_DIR = Join-Path $PSScriptRoot "tools"
90 | $NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
91 | $CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
92 | $NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
93 | $PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
94 | $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
95 |
96 | # Should we use mono?
97 | $UseMono = "";
98 | if($Mono.IsPresent) {
99 | Write-Verbose -Message "Using the Mono based scripting engine."
100 | $UseMono = "-mono"
101 | }
102 |
103 | # Should we use the new Roslyn?
104 | $UseExperimental = "";
105 | if($Experimental.IsPresent -and !($Mono.IsPresent)) {
106 | Write-Verbose -Message "Using experimental version of Roslyn."
107 | $UseExperimental = "-experimental"
108 | }
109 |
110 | # Is this a dry run?
111 | $UseDryRun = "";
112 | if($WhatIf.IsPresent) {
113 | $UseDryRun = "-dryrun"
114 | }
115 |
116 | # Make sure tools folder exists
117 | if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
118 | Write-Verbose -Message "Creating tools directory..."
119 | New-Item -Path $TOOLS_DIR -Type directory | out-null
120 | }
121 |
122 | # Make sure that packages.config exist.
123 | if (!(Test-Path $PACKAGES_CONFIG)) {
124 | Write-Verbose -Message "Downloading packages.config..."
125 | try { (New-Object System.Net.WebClient).DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
126 | Throw "Could not download packages.config."
127 | }
128 | }
129 |
130 | # Try find NuGet.exe in path if not exists
131 | if (!(Test-Path $NUGET_EXE)) {
132 | Write-Verbose -Message "Trying to find nuget.exe in PATH..."
133 | $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
134 | $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
135 | if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
136 | Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
137 | $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
138 | }
139 | }
140 |
141 | # Try download NuGet.exe if not exists
142 | if (!(Test-Path $NUGET_EXE)) {
143 | Write-Verbose -Message "Downloading NuGet.exe..."
144 | try {
145 | (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
146 | } catch {
147 | Throw "Could not download NuGet.exe."
148 | }
149 | }
150 |
151 | # Save nuget.exe path to environment to be available to child processed
152 | $ENV:NUGET_EXE = $NUGET_EXE
153 |
154 | # Restore tools from NuGet?
155 | if(-Not $SkipToolPackageRestore.IsPresent) {
156 | Push-Location
157 | Set-Location $TOOLS_DIR
158 |
159 | # Check for changes in packages.config and remove installed tools if true.
160 | [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
161 | if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
162 | ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
163 | Write-Verbose -Message "Missing or changed package.config hash..."
164 | Remove-Item * -Recurse -Exclude packages.config,nuget.exe
165 | }
166 |
167 | Write-Verbose -Message "Restoring tools from NuGet..."
168 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
169 |
170 | if ($LASTEXITCODE -ne 0) {
171 | Throw "An error occured while restoring NuGet tools."
172 | }
173 | else
174 | {
175 | $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
176 | }
177 | Write-Verbose -Message ($NuGetOutput | out-string)
178 | Pop-Location
179 | }
180 |
181 | # Make sure that Cake has been installed.
182 | if (!(Test-Path $CAKE_EXE)) {
183 | Throw "Could not find Cake.exe at $CAKE_EXE"
184 | }
185 |
186 | # Start Cake
187 | Write-Host "Running build script..."
188 | Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
189 | exit $LASTEXITCODE
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##########################################################################
4 | # This is the Cake bootstrapper script for Linux and OS X.
5 | # This file was downloaded from https://github.com/cake-build/resources
6 | # Feel free to change this file to fit your needs.
7 | ##########################################################################
8 |
9 | # Define directories.
10 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
11 | TOOLS_DIR=$SCRIPT_DIR/tools
12 | NUGET_EXE=$TOOLS_DIR/nuget.exe
13 | CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
14 | PACKAGES_CONFIG=$TOOLS_DIR/packages.config
15 | PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
16 |
17 | # Define md5sum or md5 depending on Linux/OSX
18 | MD5_EXE=
19 | if [[ "$(uname -s)" == "Darwin" ]]; then
20 | MD5_EXE="md5 -r"
21 | else
22 | MD5_EXE="md5sum"
23 | fi
24 |
25 | # Define default arguments.
26 | SCRIPT="build.cake"
27 | TARGET="Default"
28 | CONFIGURATION="Release"
29 | VERBOSITY="verbose"
30 | DRYRUN=
31 | SHOW_VERSION=false
32 | SCRIPT_ARGUMENTS=()
33 |
34 | # Parse arguments.
35 | for i in "$@"; do
36 | case $1 in
37 | -s|--script) SCRIPT="$2"; shift ;;
38 | -t|--target) TARGET="$2"; shift ;;
39 | -c|--configuration) CONFIGURATION="$2"; shift ;;
40 | -v|--verbosity) VERBOSITY="$2"; shift ;;
41 | -d|--dryrun) DRYRUN="-dryrun" ;;
42 | --version) SHOW_VERSION=true ;;
43 | --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
44 | *) SCRIPT_ARGUMENTS+=("$1") ;;
45 | esac
46 | shift
47 | done
48 |
49 | # Make sure the tools folder exist.
50 | if [ ! -d "$TOOLS_DIR" ]; then
51 | mkdir "$TOOLS_DIR"
52 | fi
53 |
54 | # Make sure that packages.config exist.
55 | if [ ! -f "$TOOLS_DIR/packages.config" ]; then
56 | echo "Downloading packages.config..."
57 | curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages
58 | if [ $? -ne 0 ]; then
59 | echo "An error occured while downloading packages.config."
60 | exit 1
61 | fi
62 | fi
63 |
64 | # Download NuGet if it does not exist.
65 | if [ ! -f "$NUGET_EXE" ]; then
66 | echo "Downloading NuGet..."
67 | curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
68 | if [ $? -ne 0 ]; then
69 | echo "An error occured while downloading nuget.exe."
70 | exit 1
71 | fi
72 | fi
73 |
74 | # Restore tools from NuGet.
75 | pushd "$TOOLS_DIR" >/dev/null
76 | if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then
77 | find . -type d ! -name . | xargs rm -rf
78 | fi
79 |
80 | mono "$NUGET_EXE" install -ExcludeVersion
81 | if [ $? -ne 0 ]; then
82 | echo "Could not restore NuGet packages."
83 | exit 1
84 | fi
85 |
86 | $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5
87 |
88 | popd >/dev/null
89 |
90 | # Make sure that Cake has been installed.
91 | if [ ! -f "$CAKE_EXE" ]; then
92 | echo "Could not find Cake.exe at '$CAKE_EXE'."
93 | exit 1
94 | fi
95 |
96 | # Start Cake
97 | if $SHOW_VERSION; then
98 | exec mono "$CAKE_EXE" -version
99 | else
100 | exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
101 | fi
--------------------------------------------------------------------------------
/build/Build.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildProjectDirectory)\..
4 | Release
5 | $(BaseDir)\artifacts
6 | $(BaseDir)\build
7 | $(BuildDir)\Packages
8 |
9 | $(BaseDir)\src\Problem\Problem.csproj
10 | Problem
11 | $(BaseDir)\src\$(Project)\bin\$(Configuration)
12 | $(BaseDir)
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/build/Tavis.Problem.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Tavis.Problem
5 | 1.0.1
6 | Darrel Miller
7 | Darrel Miller
8 | https://github.com/tavis-software/Tavis.Problem
9 | false
10 | Implementation of a application/problem+json
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Tavis.Problem
2 |
3 | This library provides .Net support for the media type `application/problem+json` defined in [RFC 7807](https://tools.ietf.org/html/rfc7807)
4 |
5 |
6 |
7 |
8 | var problem = new ProblemDocument
9 | {
10 | ProblemType = new Uri("http://example.org"),
11 | Title = "Houston we have a problem",
12 | StatusCode = HttpStatusCode.BadGateway,
13 | ProblemInstance = new Uri("http://foo")
14 | };
15 |
16 | problem.Extensions.Add("bar", new JValue("100"));
17 |
18 | var response = new HttpResponseMessage(HttpStatusCode.BadGateway)
19 | {
20 | Content = new ProblemContent(problem)
21 | };
22 |
--------------------------------------------------------------------------------
/src/Problem/HttpContentProblemExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.Threading.Tasks;
4 |
5 | namespace Tavis
6 | {
7 | ///
8 | /// Extension methods to support reading ProblemDocument intstances from HttpContent objects
9 | ///
10 | public static class HttpContentProblemExtensions
11 | {
12 |
13 | ///
14 | /// Reading ProblemDocument intstance from HttpContent
15 | ///
16 | ///
17 | ///
18 | public static Task ReadAsProblemAsync(this HttpContent content)
19 | {
20 | if (content.Headers.ContentType.MediaType.ToLowerInvariant() != "application/problem+json")
21 | {
22 | throw new ArgumentException("Cannot process HttpContent with media type " + content.Headers.ContentType.MediaType);
23 | }
24 |
25 | return content.ReadAsStreamAsync().ContinueWith(t => ProblemDocument.Parse(t.Result));
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Problem/Problem.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard1.3
4 | Tavis.Problem
5 | Tavis.Problem
6 | problem+json;problem
7 | Tavis.Problem
8 | 2.0.0
9 | Darrel Miller
10 | Darrel Miller
11 | false
12 | Implementation of a application/problem+json
13 | https://github.com/tavis-software/Tavis.Problem
14 | https://github.com/tavis-software/Tavis.Problem/blob/master/License.txt
15 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Problem/ProblemContent.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Net.Http;
6 | using System.Net.Http.Headers;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Tavis
11 | {
12 | ///
13 | /// Convert ProblemDocument instance into a HttpContent object for sending across the wire
14 | ///
15 | public class ProblemContent : HttpContent
16 | {
17 | private readonly MemoryStream _problemStream;
18 |
19 | ///
20 | /// Create a instance of a ProblemContent object from a ProblemDocument
21 | ///
22 | ///
23 | public ProblemContent(ProblemDocument problemDocument)
24 | {
25 | // Problem documents tend to be small so we should serialize them immediately so that we can return the length of the stream.
26 | // This should prevent the host from inadverently chunking the response because it doesn't know the size of the response.
27 | _problemStream = new MemoryStream();
28 | problemDocument.Save(_problemStream);
29 | _problemStream.Position = 0;
30 | Headers.ContentType = new MediaTypeHeaderValue("application/problem+json");
31 | }
32 |
33 | protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
34 | {
35 | _problemStream.CopyTo(stream); // Because this is likely a small document there is no advantage to switching threads to do this copy.
36 | var tcs = new TaskCompletionSource