Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: RehanSaeed/Serilog.Exceptions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7.0.0
Choose a base ref
...
head repository: RehanSaeed/Serilog.Exceptions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.1.0
Choose a head ref

Commits on Jun 15, 2021

  1. Copy the full SHA
    7b6441b View commit details

Commits on Jun 16, 2021

  1. Fix benchmark project

    krajek committed Jun 16, 2021
    Copy the full SHA
    0972319 View commit details
  2. Copy the full SHA
    8c11cfd View commit details
  3. Use GetOrAdd

    krajek authored and RehanSaeed committed Jun 16, 2021
    Copy the full SHA
    aea4add View commit details
  4. Copy the full SHA
    3ffca19 View commit details

Commits on Jun 18, 2021

  1. Copy the full SHA
    399a4d2 View commit details

Commits on Jun 28, 2021

  1. Copy the full SHA
    7a28d22 View commit details

Commits on Jun 30, 2021

  1. Copy the full SHA
    35b00ec View commit details

Commits on Jul 21, 2021

  1. Copy the full SHA
    6faf6e3 View commit details

Commits on Aug 11, 2021

  1. Copy the full SHA
    f377faf View commit details
  2. Copy the full SHA
    1f83d5b View commit details
  3. Copy the full SHA
    ddbcf7c View commit details

Commits on Aug 13, 2021

  1. Copy the full SHA
    160a06b View commit details
  2. Copy the full SHA
    05ff95f View commit details
  3. Copy the full SHA
    9e8bc9c View commit details

Commits on Aug 23, 2021

  1. Copy the full SHA
    73bf12e View commit details

Commits on Sep 14, 2021

  1. Copy the full SHA
    4a10139 View commit details

Commits on Sep 15, 2021

  1. Copy the full SHA
    fb7d916 View commit details
  2. Format yml files

    RehanSaeed committed Sep 15, 2021
    Copy the full SHA
    45ae575 View commit details

Commits on Sep 24, 2021

  1. Copy the full SHA
    bd21760 View commit details

Commits on Sep 28, 2021

  1. Copy the full SHA
    62163c8 View commit details
  2. Removed unrequired InternalsVisibleTo from Serilog.Exception.Refit pr…

    …oject.
    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    3effa73 View commit details
  3. Make destructure of HTTP content optional.

    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    e3d1235 View commit details
  4. Disable reflection based destructurer for tests.

    Complete tests for optional parameters in ApiExceptionDestructurer constructor.
    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    2820f58 View commit details
  5. Revert to VS version 17 in .sln file

    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    e678a79 View commit details
  6. Correct documentation

    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    b869deb View commit details
  7. Removed necessary assignment.

    heath authored and RehanSaeed committed Sep 28, 2021
    Copy the full SHA
    90519e8 View commit details
  8. Copy the full SHA
    7d2b58b View commit details
Showing with 562 additions and 302 deletions.
  1. +8 −5 .editorconfig
  2. +2 −2 .github/FUNDING.yml
  3. +0 −24 .github/ISSUE_TEMPLATE/BUG_REPORT.md
  4. +30 −0 .github/ISSUE_TEMPLATE/BUG_REPORT.yml
  5. +0 −11 .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
  6. +11 −0 .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
  7. +25 −25 .github/release-drafter.yml
  8. +35 −35 .github/workflows/build.yml
  9. +27 −27 .github/workflows/codeql-analysis.yml
  10. +3 −3 Benchmarks/Serilog.Exceptions.Benchmark/DestructuringBenchmark.cs
  11. +5 −0 Benchmarks/Serilog.Exceptions.Benchmark/Properties/AssemblyInfo.cs
  12. +1 −1 Benchmarks/Serilog.Exceptions.Benchmark/Serilog.Exceptions.Benchmark.csproj
  13. +3 −2 Directory.Build.props
  14. +48 −6 README.md
  15. +11 −5 Serilog.Exceptions.sln
  16. +0 −4 Source/Serilog.Exceptions.EntityFrameworkCore/Destructurers/DbUpdateExceptionDestructurer.cs
  17. +4 −2 Source/Serilog.Exceptions.EntityFrameworkCore/Properties/AssemblyInfo.cs
  18. +4 −2 Source/Serilog.Exceptions.MsSqlServer/Properties/AssemblyInfo.cs
  19. +71 −0 Source/Serilog.Exceptions.Refit/Destructurers/ApiExceptionDestructurer.cs
  20. +3 −0 Source/Serilog.Exceptions.Refit/Properties/AssemblyInfo.cs
  21. +21 −0 Source/Serilog.Exceptions.Refit/Serilog.Exceptions.Refit.csproj
  22. +4 −2 Source/Serilog.Exceptions.SqlServer/Properties/AssemblyInfo.cs
  23. +0 −4 Source/Serilog.Exceptions/Destructurers/TaskCanceledExceptionDestructurer.cs
  24. +2 −0 Source/Serilog.Exceptions/Filters/CompositeExceptionPropertyFilter.cs
  25. +4 −2 Source/Serilog.Exceptions/Properties/AssemblyInfo.cs
  26. +3 −15 Source/Serilog.Exceptions/Reflection/ReflectionInfoExtractor.cs
  27. +2 −0 Source/Serilog.Exceptions/Reflection/ReflectionPropertyInfo.cs
  28. +1 −1 Source/Serilog.Exceptions/TypeExtensions.cs
  29. +3 −3 Tests/Directory.Build.props
  30. +100 −0 Tests/Serilog.Exceptions.Test/Destructurers/ApiExceptionDestructurerTest.cs
  31. +4 −4 Tests/Serilog.Exceptions.Test/Destructurers/LogJsonOutputUtils.cs
  32. +12 −13 Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs
  33. +5 −0 Tests/Serilog.Exceptions.Test/Properties/AssemblyInfo.cs
  34. +2 −1 Tests/Serilog.Exceptions.Test/Serilog.Exceptions.Test.csproj
  35. +5 −0 Tools/ExceptionFinderTool/Properties/AssemblyInfo.cs
  36. +32 −32 appveyor.yml
  37. +70 −70 azure-pipelines.yml
  38. +1 −1 global.json
13 changes: 8 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version: 2.1.0 (Using https://semver.org/)
# Updated: 2021-03-03
# Version: 3.0.0 (Using https://semver.org/)
# Updated: 2021-08-09
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -48,7 +48,7 @@ indent_size = 2
trim_trailing_whitespace = false

# Web Files
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}]
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}]
indent_size = 2

# Batch Files
@@ -97,7 +97,7 @@ dotnet_style_readonly_field = true:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
# Expression-level preferences
dotnet_style_object_initializer = true:warning
dotnet_style_collection_initializer = true:warning
@@ -121,7 +121,10 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match.
# dotnet_diagnostic.SA1636.severity = none
# Undocumented
dotnet_style_operator_placement_when_wrapping = end_of_line
dotnet_style_operator_placement_when_wrapping = end_of_line:warning
csharp_style_prefer_null_check_over_type_check = true:warning
dotnet_style_namespace_match_folder = true:suggestion
dotnet_diagnostic.IDE0130.severity = suggestion

# C# Style Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github: [RehanSaeed,krajek]
github: [RehanSaeed, krajek]
open_collective: serilog-exceptions
patreon: rehansaeed
custom: ['https://paypal.me/MuhammadRehanSaeed']
custom: ["https://paypal.me/MuhammadRehanSaeed"]
24 changes: 0 additions & 24 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md

This file was deleted.

30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Bug Report"
description: "Create a report to help us improve"
labels: [bug]
body:
- type: textarea
id: describe-the-bug
attributes:
label: "Describe the bug"
description: "A clear and concise description of what the bug is."
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: "Steps to reproduce"
description: "A link to some code to reproduce the bug can speed up a fix. Alternatively, show steps to reproduce the behaviour."
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: "Expected behaviour"
description: "A clear and concise description of what you expected to happen."
validations:
required: true
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md

This file was deleted.

11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Feature Request"
description: "Suggest an idea for this project"
labels: [enhancement]
body:
- type: textarea
id: describe-the-bug
attributes:
label: "Describe the feature"
description: "A clear and concise description of what the feature is."
validations:
required: true
50 changes: 25 additions & 25 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
change-template: '- $TITLE by @$AUTHOR (#$NUMBER)'
no-changes-template: '- No changes'
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
change-template: "- $TITLE by @$AUTHOR (#$NUMBER)"
no-changes-template: "- No changes"
categories:
- title: '📚 Documentation'
- title: "📚 Documentation"
labels:
- 'documentation'
- title: '🚀 New Features'
- "documentation"
- title: "🚀 New Features"
labels:
- 'enhancement'
- title: '🐛 Bug Fixes'
- "enhancement"
- title: "🐛 Bug Fixes"
labels:
- 'bug'
- title: '🧰 Maintenance'
- "bug"
- title: "🧰 Maintenance"
labels:
- 'maintenance'
- "maintenance"
version-resolver:
major:
labels:
- 'major'
- "major"
minor:
labels:
- 'minor'
- "minor"
patch:
labels:
- 'patch'
- "patch"
default: patch
template: |
$CHANGES
@@ -33,16 +33,16 @@ template: |
$CONTRIBUTORS
autolabeler:
- label: 'documentation'
- label: "documentation"
files:
- '**/*.md'
- label: 'enhancement'
- "**/*.md"
- label: "enhancement"
files:
- 'Source/**/*'
- label: 'maintenance'
- "Source/**/*"
- label: "maintenance"
files:
- '.github/**/*'
- 'Benchmarks/**/*'
- 'Images/**/*'
- 'Tests/**/*'
- 'Tools/**/*'
- ".github/**/*"
- "Benchmarks/**/*"
- "Images/**/*"
- "Tests/**/*"
- "Tools/**/*"
70 changes: 35 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -28,67 +28,67 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4
with:
lfs: true
fetch-depth: 0
- name: 'Install .NET Core SDK'
uses: actions/setup-dotnet@v1.8.0
- name: 'Dotnet Tool Restore'
run: dotnet tool restore
shell: pwsh
- name: 'Dotnet Cake Build'
run: dotnet cake --target=Build
shell: pwsh
- name: 'Dotnet Cake Test'
run: dotnet cake --target=Test
shell: pwsh
- name: 'Dotnet Cake Pack'
run: dotnet cake --target=Pack
shell: pwsh
- name: 'Publish Artefacts'
uses: actions/upload-artifact@v2.2.3
with:
name: ${{matrix.os}}
path: './Artefacts'
- name: "Checkout"
uses: actions/checkout@v2.3.4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET Core SDK"
uses: actions/setup-dotnet@v1.8.2
- name: "Dotnet Tool Restore"
run: dotnet tool restore
shell: pwsh
- name: "Dotnet Cake Build"
run: dotnet cake --target=Build
shell: pwsh
- name: "Dotnet Cake Test"
run: dotnet cake --target=Test
shell: pwsh
- name: "Dotnet Cake Pack"
run: dotnet cake --target=Pack
shell: pwsh
- name: "Publish Artefacts"
uses: actions/upload-artifact@v2.2.4
with:
name: ${{matrix.os}}
path: "./Artefacts"

push-github-packages:
name: 'Push GitHub Packages'
name: "Push GitHub Packages"
needs: build
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
environment:
name: 'GitHub Packages'
name: "GitHub Packages"
url: https://github.com/RehanSaeed/Serilog.Exceptions/packages
permissions:
packages: write
runs-on: windows-latest
steps:
- name: 'Download Artefact'
- name: "Download Artefact"
uses: actions/download-artifact@v2
with:
name: 'windows-latest'
- name: 'Dotnet NuGet Add Source'
name: "windows-latest"
- name: "Dotnet NuGet Add Source"
run: dotnet nuget add source https://nuget.pkg.github.com/RehanSaeed/index.json --name GitHub --username RehanSaeed --password ${{secrets.GITHUB_TOKEN}}
shell: pwsh
- name: 'Dotnet NuGet Push'
- name: "Dotnet NuGet Push"
run: dotnet nuget push .\*.nupkg --api-key ${{ github.token }} --source GitHub --skip-duplicate
shell: pwsh

push-nuget:
name: 'Push NuGet Packages'
name: "Push NuGet Packages"
needs: build
if: github.event_name == 'release'
environment:
name: 'NuGet'
name: "NuGet"
url: https://www.nuget.org/packages?q=Serilog.Exceptions
runs-on: windows-latest
steps:
- name: 'Download Artefact'
- name: "Download Artefact"
uses: actions/download-artifact@v2
with:
name: 'windows-latest'
- name: 'Dotnet NuGet Push'
name: "windows-latest"
- name: "Dotnet NuGet Push"
run: |
Get-ChildItem .\ -Filter *.nupkg |
Where-Object { !$_.Name.Contains('preview') } |
54 changes: 27 additions & 27 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ on:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '0 4 * * 0'
- cron: "0 4 * * 0"
workflow_dispatch:

jobs:
@@ -27,40 +27,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
language: ["csharp"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2.3.4
- name: Checkout repository
uses: actions/checkout@v2.3.4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ namespace Serilog.Exceptions.Benchmark
[CsvMeasurementsExporter]
[RPlotExporter]
[SimpleJob(RuntimeMoniker.Net472)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.Net50)]
public class DestructuringBenchmark
{
private readonly ReflectionBasedDestructurer reflectionBasedDestructurer = new(10);
@@ -46,7 +46,7 @@ public void Setup()
this.reflectionBasedDestructurer.Destructure(
ex,
bag,
null!);
_ => new Dictionary<string, object?>());

return bag.GetResultDictionary();
}
@@ -62,7 +62,7 @@ public void Setup()
this.benchmarkExceptionDestructurer.Destructure(
ex,
bag,
null!);
_ => new Dictionary<string, object?>());

return bag.GetResultDictionary();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup Label="Package References">
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.1" />
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
<PropertyGroup Label="Build">
<LangVersion>latest</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<Nullable>enable</Nullable>
<NeutralLanguage>en-GB</NeutralLanguage>
@@ -24,9 +25,9 @@

<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="All" Version="16.10.56" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="All" Version="17.0.63" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.5.0" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.2.0-beta.333" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.2.0-beta.354" />
</ItemGroup>

</Project>
54 changes: 48 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Schema.NET Banner](Images/Banner.png)
![Serilog.Exceptions Banner](Images/Banner.png)

[![NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.svg)](https://www.nuget.org/packages/Serilog.Exceptions/) [![Serilog.Exceptions package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/212043f6-5fe5-4c79-949e-162156b89894/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=212043f6-5fe5-4c79-949e-162156b89894&preferRelease=true) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/RehanSaeedUK) [![Twitter Follow](https://img.shields.io/twitter/follow/rehansaeeduk.svg?style=social&label=Follow)](https://twitter.com/RehanSaeedUK)
[![Serilog.Exceptions NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.svg)](https://www.nuget.org/packages/Serilog.Exceptions/) [![Serilog.Exceptions package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/212043f6-5fe5-4c79-949e-162156b89894/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=212043f6-5fe5-4c79-949e-162156b89894&preferRelease=true) [![Serilog.Exceptions NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Exceptions)](https://www.nuget.org/packages/Serilog.Exceptions) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/RehanSaeedUK) [![Twitter Follow](https://img.shields.io/twitter/follow/rehansaeeduk.svg?style=social&label=Follow)](https://twitter.com/RehanSaeedUK)

Serilog.Exceptions is an add-on to [Serilog](https://serilog.net) to log exception details and custom properties that are not output in `Exception.ToString()`.

@@ -95,7 +95,7 @@ This library has custom code to deal with extra properties on most common except

### Serilog.Exceptions.SqlServer

[![NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.SqlServer.svg)](https://www.nuget.org/packages/Serilog.Exceptions.SqlServer/) [![Serilog.Exceptions.SqlServer package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/67be830c-2c0f-4df8-be30-771d817b382f/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=67be830c-2c0f-4df8-be30-771d817b382f&preferRelease=true)
[![Serilog.Exceptions.SqlServer NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.SqlServer.svg)](https://www.nuget.org/packages/Serilog.Exceptions.SqlServer/) [![Serilog.Exceptions.SqlServer package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/67be830c-2c0f-4df8-be30-771d817b382f/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=67be830c-2c0f-4df8-be30-771d817b382f&preferRelease=true) [![Serilog.Exceptions.SqlServer NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Exceptions.SqlServer)](https://www.nuget.org/packages/Serilog.Exceptions.SqlServer)

Add the [Serilog.Exceptions.SqlServer](https://www.nuget.org/packages/Serilog.Exceptions.SqlServer/) NuGet package to your project to avoid the reflection based destructurer for `SqlException` when using [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient/):

@@ -112,8 +112,8 @@ Add the `SqlExceptionDestructurer` during setup:

### Serilog.Exceptions.MsSqlServer

[![NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.MsSqlServer.svg)](https://www.nuget.org/packages/Serilog.Exceptions.MsSqlServer/)
[![Serilog.Exceptions.MsSqlServer package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/dce98084-312a-4939-b879-07bc25734572/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=dce98084-312a-4939-b879-07bc25734572&preferRelease=true)
[![Serilog.Exceptions.MsSqlServer NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.MsSqlServer.svg)](https://www.nuget.org/packages/Serilog.Exceptions.MsSqlServer/)
[![Serilog.Exceptions.MsSqlServer package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/dce98084-312a-4939-b879-07bc25734572/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=dce98084-312a-4939-b879-07bc25734572&preferRelease=true) [![Serilog.Exceptions.MsSqlServer NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Exceptions.MsSqlServer)](https://www.nuget.org/packages/Serilog.Exceptions.MsSqlServer)

Add the [Serilog.Exceptions.MsSqlServer](https://www.nuget.org/packages/Serilog.Exceptions.MsSqlServer/) NuGet package to your project to avoid the reflection based destructurer for `SqlException` when using [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient/):

@@ -130,7 +130,7 @@ Add the `SqlExceptionDestructurer` during setup:

### Serilog.Exceptions.EntityFrameworkCore

[![NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Serilog.Exceptions.EntityFrameworkCore/) [![Serilog.Exceptions.EntityFrameworkCore package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/ee2cd6f8-4c93-4774-9398-23c49ba41928/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=ee2cd6f8-4c93-4774-9398-23c49ba41928&preferRelease=true)
[![Serilog.Exceptions.EntityFrameworkCore NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Serilog.Exceptions.EntityFrameworkCore/) [![Serilog.Exceptions.EntityFrameworkCore package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/ee2cd6f8-4c93-4774-9398-23c49ba41928/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=ee2cd6f8-4c93-4774-9398-23c49ba41928&preferRelease=true) [![Serilog.Exceptions.EntityFrameworkCore NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Exceptions.EntityFrameworkCore)](https://www.nuget.org/packages/Serilog.Exceptions.EntityFrameworkCore)

> **WARNING**: If you are using EntityFrameworkCore with Serilog.Exceptions you must add this, otherwise in certain cases your entire database will be logged! This is because the exceptions in Entity Framework Core have properties that link to the entire database schema in them (See [#100](https://github.com/RehanSaeed/Serilog.Exceptions/issues/100), [aspnet/EntityFrameworkCore#15214](https://github.com/aspnet/EntityFrameworkCore/issues/15214))
@@ -147,6 +147,48 @@ Add the `DbUpdateExceptionDestructurer` during setup:
.WithDestructurers(new[] { new DbUpdateExceptionDestructurer() }))
```

### Serilog.Exceptions.Refit

[![Serilog.Exceptions.Refit NuGet Package](https://img.shields.io/nuget/v/Serilog.Exceptions.Refit.svg)](https://www.nuget.org/packages/Serilog.Exceptions.Refit/)
[![Serilog.Exceptions.Refit package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/dce98084-312a-4939-b879-07bc25734572/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Exceptions/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=dce98084-312a-4939-b879-07bc25734572&preferRelease=true) [![Serilog.Exceptions.Refit NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Exceptions.Refit)](https://www.nuget.org/packages/Serilog.Exceptions.Refit)

Add the [Serilog.Exceptions.Refit](https://www.nuget.org/packages/Serilog.Exceptions.Refit/) NuGet package to your project to provide detailed logging for the `ApiException` when using [Refit](https://www.nuget.org/packages/Refit/):

```
Install-Package Serilog.Exceptions.Refit
```

Add the `ApiExceptionDestructurer` during setup:
```csharp
.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new[] { new ApiExceptionDestructurer() }))
```

Depending on your Serilog setup, common `System.Exception` properties may already be logged. To omit the logging of these properties, use the overloaded
constructor as follows:

```csharp
.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new[] { new ApiExceptionDestructurer(destructureCommonExceptionProperties: false) }))
```

The default configuration logs the following properties of an `ApiException`:

- `Uri`
- `StatusCode`

In addition, the `ApiException.Content` property can be logged with the following setup:

```csharp
.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new[] { new ApiExceptionDestructurer(destructureHttpContent: true) }))
```

Be careful with this option as the HTTP body could be very large and/or contain sensitive information.

## Custom Exception Destructurers

You may want to add support for destructuring your own exceptions without relying on reflection. To do this, create your own destructuring class implementing `ExceptionDestructurer` (You can take a look at [this](https://github.com/RehanSaeed/Serilog.Exceptions/blob/main/Source/Serilog.Exceptions/Destructurers/ArgumentExceptionDestructurer.cs) for `ArgumentException`), then simply add it like so:
16 changes: 11 additions & 5 deletions Serilog.Exceptions.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
# Visual Studio Version 17
VisualStudioVersion = 17.0.31423.177
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{76FBEEA2-0F88-487E-99C3-5D865CBE79B6}"
ProjectSection(SolutionItems) = preProject
@@ -63,9 +63,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{6C1260
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{25698817-D59E-4F85-9B44-59FD50E9ED4B}"
ProjectSection(SolutionItems) = preProject
.github\ISSUE_TEMPLATE\BUG_REPORT.md = .github\ISSUE_TEMPLATE\BUG_REPORT.md
.github\ISSUE_TEMPLATE\FEATURE_REQUEST.md = .github\ISSUE_TEMPLATE\FEATURE_REQUEST.md
.github\ISSUE_TEMPLATE\QUESTION.md = .github\ISSUE_TEMPLATE\QUESTION.md
.github\ISSUE_TEMPLATE\BUG_REPORT.yml = .github\ISSUE_TEMPLATE\BUG_REPORT.yml
.github\ISSUE_TEMPLATE\FEATURE_REQUEST.yml = .github\ISSUE_TEMPLATE\FEATURE_REQUEST.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{C50E9892-B2DF-43A6-9E00-BA2952933FA4}"
@@ -91,6 +90,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Exceptions.MsSqlServer", "Source\Serilog.Exceptions.MsSqlServer\Serilog.Exceptions.MsSqlServer.csproj", "{0A21D2AD-024B-4F3D-95F4-BAEFEEE95945}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Exceptions.Refit", "Source\Serilog.Exceptions.Refit\Serilog.Exceptions.Refit.csproj", "{0EABF22F-F070-4F8D-B165-DD4C4AB62820}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -125,6 +126,10 @@ Global
{0A21D2AD-024B-4F3D-95F4-BAEFEEE95945}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A21D2AD-024B-4F3D-95F4-BAEFEEE95945}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A21D2AD-024B-4F3D-95F4-BAEFEEE95945}.Release|Any CPU.Build.0 = Release|Any CPU
{0EABF22F-F070-4F8D-B165-DD4C4AB62820}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EABF22F-F070-4F8D-B165-DD4C4AB62820}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EABF22F-F070-4F8D-B165-DD4C4AB62820}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EABF22F-F070-4F8D-B165-DD4C4AB62820}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -141,6 +146,7 @@ Global
{2C245036-D7F6-4F7C-9BB6-5AFBCCE480F7} = {76FBEEA2-0F88-487E-99C3-5D865CBE79B6}
{4F089B23-3121-4935-B24E-7A9A497BD9FE} = {2C245036-D7F6-4F7C-9BB6-5AFBCCE480F7}
{0A21D2AD-024B-4F3D-95F4-BAEFEEE95945} = {C5508012-7216-4ABE-AB2F-B166ED5FF94F}
{0EABF22F-F070-4F8D-B165-DD4C4AB62820} = {C5508012-7216-4ABE-AB2F-B166ED5FF94F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BE74AFAC-AC6F-4B80-860F-15C22BEE1A38}
Original file line number Diff line number Diff line change
@@ -28,14 +28,10 @@ public override void Destructure(
var dbUpdateException = (DbUpdateException)exception;
var entriesValue = dbUpdateException.Entries?
.Select(
#pragma warning disable IDE0050 // Convert to tuple
e => new
#pragma warning restore IDE0050 // Convert to tuple
{
EntryProperties = e.Properties.Select(
#pragma warning disable IDE0050 // Convert to tuple
p => new
#pragma warning restore IDE0050 // Convert to tuple
{
PropertyName = p.Metadata.Name,
p.OriginalValue,
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
namespace Serilog.Exceptions.Refit.Destructurers
{
using System;
using System.Collections.Generic;
using global::Refit;
using Serilog.Exceptions.Core;
using Serilog.Exceptions.Destructurers;

/// <summary>
/// A destructurer for the Refit <see cref="ApiException"/>.
/// </summary>
/// <seealso cref="ExceptionDestructurer" />
public class ApiExceptionDestructurer : ExceptionDestructurer
{
private readonly bool destructureCommonExceptionProperties;
private readonly bool destructureHttpContent;

/// <summary>
/// Initializes a new instance of the <see cref="ApiExceptionDestructurer"/> class.
/// </summary>
/// <param name="destructureCommonExceptionProperties">Destructure common public Exception properties or not.</param>
/// <param name="destructureHttpContent">Destructure the HTTP body. This is left optional due to possible security and log size concerns.</param>
public ApiExceptionDestructurer(bool destructureCommonExceptionProperties = true, bool destructureHttpContent = false)
{
this.destructureCommonExceptionProperties = destructureCommonExceptionProperties;
this.destructureHttpContent = destructureHttpContent;
}

/// <inheritdoc cref="IExceptionDestructurer.TargetTypes"/>
public override Type[] TargetTypes => new[] { typeof(ApiException) };

/// <inheritdoc />
public override void Destructure(Exception exception, IExceptionPropertiesBag propertiesBag, Func<Exception, IReadOnlyDictionary<string, object?>?> destructureException)
{
if (this.destructureCommonExceptionProperties)
{
base.Destructure(exception, propertiesBag, destructureException);
}
else
{
// Argument checks are usually done in <see cref="ExceptionDestructurer.Destructure"/>
// but as we didn't call this method we need to do the checks here.
if (exception is null)
{
throw new ArgumentNullException(nameof(propertiesBag));
}

if (propertiesBag is null)
{
throw new ArgumentNullException(nameof(propertiesBag));
}

if (destructureException is null)
{
throw new ArgumentNullException(nameof(destructureException));
}
}

#pragma warning disable CA1062 // Validate arguments of public methods
var apiException = (ApiException)exception;
if (this.destructureHttpContent)
{
propertiesBag.AddProperty(nameof(ApiException.Content), apiException.Content);
}

propertiesBag.AddProperty(nameof(ApiException.Uri), apiException.Uri);
propertiesBag.AddProperty(nameof(ApiException.StatusCode), apiException.StatusCode);
#pragma warning restore CA1062 // Validate arguments of public methods
}
}
}
3 changes: 3 additions & 0 deletions Source/Serilog.Exceptions.Refit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System;

[assembly: CLSCompliant(true)]
21 changes: 21 additions & 0 deletions Source/Serilog.Exceptions.Refit/Serilog.Exceptions.Refit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Label="Package">
<Product>Serilog Exceptions Refit</Product>
<Description>Log exception details and custom properties that are not output in Exception.ToString(). Contains custom destructurers for Refit exceptions.</Description>
<PackageTags>Serilog;Exception;Log;Logging;Detail;Details;Refit</PackageTags>
</PropertyGroup>

<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Source\Serilog.Exceptions\Serilog.Exceptions.csproj" />
</ItemGroup>

<ItemGroup Label="Package References">
<PackageReference Include="Refit" Version="6.0.15" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
Original file line number Diff line number Diff line change
@@ -54,9 +54,7 @@ internal static object DestructureTask(

if (task.IsFaulted && task.Exception is not null)
{
#pragma warning disable IDE0050 // Convert to tuple
return new
#pragma warning restore IDE0050 // Convert to tuple
{
task.Id,
Status = taskStatus,
@@ -65,9 +63,7 @@ internal static object DestructureTask(
};
}

#pragma warning disable IDE0050 // Convert to tuple
return new
#pragma warning restore IDE0050 // Convert to tuple
{
task.Id,
Status = taskStatus,
Original file line number Diff line number Diff line change
@@ -19,7 +19,9 @@ public class CompositeExceptionPropertyFilter : IExceptionPropertyFilter
/// <exception cref="ArgumentException">filters was empty or filter at index {i} is <c>null</c>.</exception>
public CompositeExceptionPropertyFilter(params IExceptionPropertyFilter[] filters)
{
#pragma warning disable CA1508 // This warning should not occur and is fixed in .NET 6.
if (filters is null)
#pragma warning restore CA1508 // This warning should not occur and is fixed in .NET 6.
{
throw new ArgumentNullException(nameof(filters));
}
6 changes: 4 additions & 2 deletions Source/Serilog.Exceptions/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
18 changes: 3 additions & 15 deletions Source/Serilog.Exceptions/Reflection/ReflectionInfoExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Serilog.Exceptions.Reflection
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
@@ -12,8 +13,7 @@ namespace Serilog.Exceptions.Reflection
/// </summary>
internal class ReflectionInfoExtractor
{
private readonly object lockObj = new();
private readonly Dictionary<Type, ReflectionInfo> reflectionInfoCache = new();
private readonly ConcurrentDictionary<Type, ReflectionInfo> reflectionInfoCache = new();
private readonly IList<PropertyInfo> baseExceptionPropertiesForDestructuring;

/// <summary>
@@ -27,19 +27,7 @@ internal class ReflectionInfoExtractor
/// </summary>
/// <param name="valueType">The type for which properties are to be analyzed.</param>
/// <returns>The reflection info for relevant properties of <paramref name="valueType"/>.</returns>
public ReflectionInfo GetOrCreateReflectionInfo(Type valueType)
{
lock (this.lockObj)
{
if (!this.reflectionInfoCache.TryGetValue(valueType, out var reflectionInfo))
{
reflectionInfo = this.GenerateReflectionInfoForType(valueType);
this.reflectionInfoCache.Add(valueType, reflectionInfo);
}

return reflectionInfo;
}
}
public ReflectionInfo GetOrCreateReflectionInfo(Type valueType) => this.reflectionInfoCache.GetOrAdd(valueType, valueFactory: this.GenerateReflectionInfoForType);

private static Func<object, object> GenerateFastGetterForProperty(Type type, PropertyInfo property)
{
Original file line number Diff line number Diff line change
@@ -95,7 +95,9 @@ public void MarkNameWithTypeNameIfRedefinesThatProperty(ReflectionPropertyInfo o
}
}

#pragma warning disable CA1801 // This warning should not occur and is fixed in .NET 6.
private static bool IsSubTypeOf(Type possibleSubType, Type possibleBaseType) =>
#pragma warning restore CA1801 // This warning should not occur and is fixed in .NET 6.
#if NETSTANDARD1_3 || NETSTANDARD1_6
possibleBaseType.GetTypeInfo().IsSubclassOf(possibleBaseType);
#else
2 changes: 1 addition & 1 deletion Source/Serilog.Exceptions/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -94,4 +94,4 @@ public static TypeCode GetTypeCode(this Type type)
public static TypeCode GetTypeCode(this Type type) => Type.GetTypeCode(type);
#endif
}
}
}
6 changes: 3 additions & 3 deletions Tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<ItemGroup Label="Package References">
<PackageReference Include="coverlet.collector" PrivateAssets="All" Version="3.0.3">
<PackageReference Include="coverlet.collector" PrivateAssets="All" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeCoverage" PrivateAssets="All" Version="16.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Microsoft.CodeCoverage" PrivateAssets="All" Version="16.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" Version="2.4.3">
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
namespace Serilog.Exceptions.Test.Destructurers
{
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using global::Refit;
using Serilog.Exceptions.Core;
using Serilog.Exceptions.Refit.Destructurers;
using Xunit;
using static LogJsonOutputUtils;

public class ApiExceptionDestructurerTest
{
[Fact]
public async Task ApiException_HttpStatusCodeIsLoggedAsPropertyAsync()
{
using var message = new HttpRequestMessage(HttpMethod.Get, new Uri("https://foobar.com"));
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer() });
var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

Test_LoggedExceptionContainsProperty(apiException, nameof(ApiException.StatusCode), nameof(HttpStatusCode.InternalServerError), options);
}

[Fact]
public async Task ApiException_UriIsLoggedAsPropertyAsync()
{
var requestUri = new Uri("https://foobar.com");
using var message = new HttpRequestMessage(HttpMethod.Get, requestUri);
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer() });
var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

Test_LoggedExceptionContainsProperty(apiException, nameof(ApiException.Uri), requestUri.ToString(), options);
}

[Fact]
public async Task ApiException_ByDefaultContentIsNotLoggedAsPropertyAsync()
{
var requestUri = new Uri("https://foobar.com");
using var message = new HttpRequestMessage(HttpMethod.Get, requestUri);
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer() });
response.Content = JsonContent.Create("hello");

var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(ApiException.Content), options);
}

[Fact]
public async Task ApiException_WhenSpecifiedContentIsLoggedAsPropertyAsync()
{
var requestUri = new Uri("https://foobar.com");
using var message = new HttpRequestMessage(HttpMethod.Get, requestUri);
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer(destructureHttpContent: true) });
response.Content = JsonContent.Create("hello");

var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

Test_LoggedExceptionContainsProperty(apiException, nameof(ApiException.Content), "\"hello\"", options);
}

[Fact]
public async Task ApiException_ByDefaultCommonPropertiesLoggedAsPropertiesAsync()
{
var requestUri = new Uri("https://foobar.com");
using var message = new HttpRequestMessage(HttpMethod.Get, requestUri);
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer() });
var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

// No need to test all properties, just a handful is sufficient
Test_LoggedExceptionContainsProperty(apiException, nameof(Exception.StackTrace), apiException.StackTrace, options);
Test_LoggedExceptionContainsProperty(apiException, nameof(Exception.Message), apiException.Message, options);
Test_LoggedExceptionContainsProperty(apiException, nameof(Type), apiException.GetType().ToString(), options);
}

[Fact]
public async Task ApiException_WhenSpecifiedCommonPropertiesNotLoggedAsPropertiesAsync()
{
var requestUri = new Uri("https://foobar.com");
using var message = new HttpRequestMessage(HttpMethod.Get, requestUri);
using var response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
var options = new DestructuringOptionsBuilder().WithDestructurers(new[] { new ApiExceptionDestructurer(destructureCommonExceptionProperties: false) });
var apiException = await ApiException.Create(message, HttpMethod.Get, response, new RefitSettings()).ConfigureAwait(false);

Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.StackTrace), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.Message), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.InnerException), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.HelpLink), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.Data), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Exception.HResult), options);
Test_LoggedExceptionDoesNotContainProperty(apiException, nameof(Type), options);
}
}
}
Original file line number Diff line number Diff line change
@@ -36,15 +36,15 @@ public static JObject LogAndDestructureException(
return rootObject;
}

public static void Test_LoggedExceptionContainsProperty(Exception exception, string propertyKey, string? propertyValue)
public static void Test_LoggedExceptionContainsProperty(Exception exception, string propertyKey, string? propertyValue, IDestructuringOptions? destructuringOptions = null)
{
var rootObject = LogAndDestructureException(exception);
var rootObject = LogAndDestructureException(exception, destructuringOptions);
Assert_JObjectContainsPropertiesExceptionDetailsWithProperty(rootObject, propertyKey, propertyValue);
}

public static void Test_LoggedExceptionDoesNotContainProperty(Exception exception, string propertyKey)
public static void Test_LoggedExceptionDoesNotContainProperty(Exception exception, string propertyKey, IDestructuringOptions? destructuringOptions = null)
{
var rootObject = LogAndDestructureException(exception);
var rootObject = LogAndDestructureException(exception, destructuringOptions);
Assert_JObjectContainsPropertiesExceptionDetailsWithoutProperty(rootObject, propertyKey);
}

Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ namespace Serilog.Exceptions.Test.Destructurers
using Serilog.Exceptions.Core;
using Serilog.Exceptions.Destructurers;
using Xunit;
using Xunit.Abstractions;
using static LogJsonOutputUtils;

public class ReflectionBasedDestructurerTest
@@ -103,10 +102,10 @@ public async Task CanDestructureTaskAsync()
var destructuredTaskProperties = Assert.IsAssignableFrom<IDictionary<string, object>>(destructuredTaskObject);
destructuredTaskProperties.Should().ContainKey(nameof(Task.Id));
destructuredTaskProperties.Should().ContainKey(nameof(Task.Status))
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Be(nameof(TaskStatus.Canceled));
destructuredTaskProperties.Should().ContainKey(nameof(Task.CreationOptions))
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Contain(nameof(TaskCreationOptions.None));
}

@@ -125,23 +124,23 @@ public void CanDestructureFaultedTask()
var destructuredTaskProperties = Assert.IsAssignableFrom<IDictionary<string, object>>(destructuredTaskObject);
destructuredTaskProperties.Should().ContainKey(nameof(Task.Id));
destructuredTaskProperties.Should().ContainKey(nameof(Task.Status))
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Be(nameof(TaskStatus.Faulted));
destructuredTaskProperties.Should().ContainKey(nameof(Task.CreationOptions))
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Be(nameof(TaskCreationOptions.None));
var taskFirstLevelExceptionDictionary = destructuredTaskProperties.Should().ContainKey(nameof(Task.Exception))
.WhichValue.Should().BeAssignableTo<IDictionary<string, object>>()
.WhoseValue.Should().BeAssignableTo<IDictionary<string, object>>()
.Which;
taskFirstLevelExceptionDictionary.Should().ContainKey("Message")
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Contain("One or more errors occurred.", "task's first level exception is aggregate exception");
taskFirstLevelExceptionDictionary.Should().ContainKey("InnerExceptions")
.WhichValue.Should().BeAssignableTo<IReadOnlyCollection<object>>()
.WhoseValue.Should().BeAssignableTo<IReadOnlyCollection<object>>()
.Which.Should().ContainSingle()
.Which.Should().BeAssignableTo<IDictionary<string, object>>()
.Which.Should().ContainKey("Message")
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Be("INNER EXCEPTION MESSAGE");
}

@@ -343,16 +342,16 @@ public void WhenObjectContainsCyclicReferencesInTask_ThenRecursiveDestructureIsI
var resultsDictionary = result.GetResultDictionary();
var destructuredTask = resultsDictionary[nameof(CyclicTaskException.Task)].Should().BeAssignableTo<IDictionary<string, object>>().Which;
var destructuredCyclicException = destructuredTask.Should().ContainKey(nameof(Task.Exception))
.WhichValue.Should().BeAssignableTo<IDictionary<string, object>>()
.WhoseValue.Should().BeAssignableTo<IDictionary<string, object>>()
.Which.Should().ContainKey(nameof(AggregateException.InnerExceptions))
.WhichValue.Should().BeAssignableTo<IReadOnlyCollection<object>>()
.WhoseValue.Should().BeAssignableTo<IReadOnlyCollection<object>>()
.Which.Should().ContainSingle()
.Which.Should().BeAssignableTo<IDictionary<string, object>>().Which;
destructuredCyclicException.Should().ContainKey(nameof(Exception.Message))
.WhichValue.Should().BeOfType<string>()
.WhoseValue.Should().BeOfType<string>()
.Which.Should().Contain(nameof(CyclicTaskException));
destructuredCyclicException.Should().ContainKey(nameof(CyclicTaskException.Task))
.WhichValue.Should().BeAssignableTo<IDictionary<string, object>>()
.WhoseValue.Should().BeAssignableTo<IDictionary<string, object>>()
.Which.Should().ContainKey("$ref", "task was already destructured, so inner task should just contain ref");
}

5 changes: 5 additions & 0 deletions Tests/Serilog.Exceptions.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
3 changes: 2 additions & 1 deletion Tests/Serilog.Exceptions.Test/Serilog.Exceptions.Test.csproj
Original file line number Diff line number Diff line change
@@ -11,11 +11,12 @@

<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Source\Serilog.Exceptions.EntityFrameworkCore\Serilog.Exceptions.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\Source\Serilog.Exceptions.Refit\Serilog.Exceptions.Refit.csproj" />
<ProjectReference Include="..\..\Source\Serilog.Exceptions\Serilog.Exceptions.csproj" />
</ItemGroup>

<ItemGroup Label="Package References">
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
5 changes: 5 additions & 0 deletions Tools/ExceptionFinderTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Serilog.Exceptions.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001007320f17cde01a37b8b3dff91961943f76893c63352544608de15974586e17739e0b232cdc8cc8762b40d988a21522024abca8116605ed1c8958f350bc6ca4594aa1ca61c1906d85ee76df8d9b404ffd65a5f6efeddd486bddd5b74ff9a7449af0dc9d43da753a3023b20ca616e8313e82a18719b6551f37c45c8d8e4e4cf9bac")]
64 changes: 32 additions & 32 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# AppVeyor documentation https://www.appveyor.com/docs

version: '{build}'
version: "{build}"

image:
- macOS
- Ubuntu
- Visual Studio 2019
- macOS
- Ubuntu
- Visual Studio 2019

environment:
# Disable the .NET logo in the console output.
@@ -18,36 +18,36 @@ environment:
MINVERBUILDMETADATA: build.%APPVEYOR_BUILD_NUMBER%

build_script:
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
- pwsh: |
if ($isWindows) {
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1"
./dotnet-install.ps1 -JSonFile global.json -InstallDir 'C:\Program Files\dotnet'
}
else {
Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./dotnet-install.sh"
sudo chmod u+x dotnet-install.sh
if ($isMacOS) {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/local/share/dotnet'
} else {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/share/dotnet'
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
- pwsh: |
if ($isWindows) {
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1"
./dotnet-install.ps1 -JSonFile global.json -InstallDir 'C:\Program Files\dotnet'
}
}
- pwsh: dotnet tool restore
- pwsh: dotnet cake --target=Build
- pwsh: dotnet cake --target=Test
- pwsh: dotnet cake --target=Pack
else {
Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./dotnet-install.sh"
sudo chmod u+x dotnet-install.sh
if ($isMacOS) {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/local/share/dotnet'
} else {
sudo ./dotnet-install.sh --jsonfile global.json --install-dir '/usr/share/dotnet'
}
}
- pwsh: dotnet tool restore
- pwsh: dotnet cake --target=Build
- pwsh: dotnet cake --target=Test
- pwsh: dotnet cake --target=Pack

test: off

artifacts:
- name: NuGet Packages
path: ./Artefacts/**/*.nupkg
- name: NuGet Symbol Packages
path: ./Artefacts/**/*.snupkg
- name: xUnit XML Test Results
path: ./Artefacts/**/*.xml
- name: xUnit HTML Test Results
path: ./Artefacts/**/*.html
- name: Code Coverage
path: ./Artefacts/**/*.cobertura.xml
- name: NuGet Packages
path: ./Artefacts/**/*.nupkg
- name: NuGet Symbol Packages
path: ./Artefacts/**/*.snupkg
- name: xUnit XML Test Results
path: ./Artefacts/**/*.xml
- name: xUnit HTML Test Results
path: ./Artefacts/**/*.html
- name: Code Coverage
path: ./Artefacts/**/*.cobertura.xml
140 changes: 70 additions & 70 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@
trigger:
branches:
include:
- 'main'
- "main"
tags:
include:
- '*'
- "*"
pr:
branches:
include:
- '*'
- "*"

variables:
# Disable the .NET logo in the console output.
@@ -23,71 +23,71 @@ variables:
MINVERBUILDMETADATA: build.$(Build.BuildId)

stages:
- stage: Build
jobs:
- job: Build
strategy:
matrix:
Linux:
matrixName: Ubuntu
vmImageName: ubuntu-latest
Mac:
matrixName: Mac
vmImageName: macos-latest
Windows:
matrixName: Windows
vmImageName: windows-latest
pool:
vmImage: $(vmImageName)
timeoutInMinutes: 10
steps:
- checkout: self
lfs: true
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
packageType: 'sdk'
useGlobalJson: true
- pwsh: 'dotnet tool restore'
displayName: 'Dotnet Tool Restore'
failOnStderr: true
- pwsh: 'dotnet cake --target=Build'
displayName: 'Dotnet Cake Build'
failOnStderr: true
- pwsh: 'dotnet cake --target=Test'
displayName: 'Dotnet Cake Test'
failOnStderr: true
- pwsh: 'dotnet cake --target=Pack'
displayName: 'Dotnet Cake Pack'
failOnStderr: true
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/*.trx'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: cobertura
summaryFileLocation: '**/*.cobertura.xml'
- publish: './Artefacts'
artifact: $(matrixName)
displayName: 'Publish Artefacts'
- stage: Deploy
jobs:
- deployment: AzureArtefacts
displayName: 'Azure Artefacts'
condition: ne(variables['Build.Reason'], 'PullRequest')
pool:
vmImage: windows-latest
environment: 'Azure Artefacts'
strategy:
runOnce:
deploy:
steps:
- task: NuGetToolInstaller@1
displayName: 'NuGet Install'
- task: NuGetAuthenticate@0
displayName: 'NuGet Authenticate'
- pwsh: nuget push $(Agent.BuildDirectory)\Windows\*.nupkg -Source https://pkgs.dev.azure.com/serilog-exceptions/_packaging/serilog-exceptions/nuget/v3/index.json -ApiKey AzureArtifacts -SkipDuplicate
displayName: 'NuGet Push'
- stage: Build
jobs:
- job: Build
strategy:
matrix:
Linux:
matrixName: Ubuntu
vmImageName: ubuntu-latest
Mac:
matrixName: Mac
vmImageName: macos-latest
Windows:
matrixName: Windows
vmImageName: windows-latest
pool:
vmImage: $(vmImageName)
timeoutInMinutes: 10
steps:
- checkout: self
lfs: true
- task: UseDotNet@2
displayName: "Install .NET Core SDK"
inputs:
packageType: "sdk"
useGlobalJson: true
- pwsh: "dotnet tool restore"
displayName: "Dotnet Tool Restore"
failOnStderr: true
- pwsh: "dotnet cake --target=Build"
displayName: "Dotnet Cake Build"
failOnStderr: true
- pwsh: "dotnet cake --target=Test"
displayName: "Dotnet Cake Test"
failOnStderr: true
- pwsh: "dotnet cake --target=Pack"
displayName: "Dotnet Cake Pack"
failOnStderr: true
- task: PublishTestResults@2
displayName: "Publish Test Results"
inputs:
testResultsFormat: "VSTest"
testResultsFiles: "**/*.trx"
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: cobertura
summaryFileLocation: "**/*.cobertura.xml"
- publish: "./Artefacts"
artifact: $(matrixName)
displayName: "Publish Artefacts"
- stage: Deploy
jobs:
- deployment: AzureArtefacts
displayName: "Azure Artefacts"
condition: ne(variables['Build.Reason'], 'PullRequest')
pool:
vmImage: windows-latest
environment: "Azure Artefacts"
strategy:
runOnce:
deploy:
steps:
- task: NuGetToolInstaller@1
displayName: "NuGet Install"
- task: NuGetAuthenticate@0
displayName: "NuGet Authenticate"
- pwsh: nuget push $(Agent.BuildDirectory)\Windows\*.nupkg -Source https://pkgs.dev.azure.com/serilog-exceptions/_packaging/serilog-exceptions/nuget/v3/index.json -ApiKey AzureArtifacts -SkipDuplicate
displayName: "NuGet Push"
failOnStderr: true
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"rollForward": "latestMajor",
"version": "5.0.301"
"version": "5.0.401"
}
}