Skip to content

Commit

Permalink
Merge pull request #12 from Authenticom/master
Browse files Browse the repository at this point in the history
.NET standard 2 support
  • Loading branch information
nblumhardt authored Dec 6, 2017
2 parents e99dbe9 + 807ab50 commit e628aa7
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 206 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/
.vs/
99 changes: 31 additions & 68 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,85 +1,48 @@
param(
[String] $majorMinor = "0.0", # 2.0
[String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
[String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
[Switch] $notouch,
[String] $sln # e.g serilog-sink-name
)
echo "build: Build started"

function Set-AssemblyVersions($informational, $assembly)
{
(Get-Content assets/CommonAssemblyInfo.cs) |
ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
Set-Content assets/CommonAssemblyInfo.cs
}
Push-Location $PSScriptRoot

function Install-NuGetPackages($solution)
{
nuget restore $solution
if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

function Invoke-MSBuild($solution, $customLogger)
{
if ($customLogger)
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
}
else
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release
}
}
& dotnet restore --no-cache

function Invoke-NuGetPackProj($csproj)
{
nuget pack -Prop Configuration=Release -Symbols $csproj
}
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

function Invoke-NuGetPackSpec($nuspec, $version)
{
nuget pack $nuspec -Version $version -OutputDirectory ..\..\
}
echo "build: Package version suffix is $suffix"
echo "build: Build version suffix is $buildSuffix"

function Invoke-NuGetPack($version)
{
ls src/**/*.csproj |
Where-Object { -not ($_.Name -like "*net40*") } |
ForEach-Object { Invoke-NuGetPackProj $_ }
}

function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln)
{
$package="$majorMinor.$patch"
$slnfile = "$sln.sln"

Write-Output "$sln $package"
foreach ($src in ls src/*) {
Push-Location $src

if (-not $notouch)
{
$assembly = "$majorMinor.0.0"
echo "build: Packaging project in $src"

Write-Output "Assembly version will be set to $assembly"
Set-AssemblyVersions $package $assembly
& dotnet build -c Release --version-suffix=$buildSuffix
if ($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts --no-build
}
if($LASTEXITCODE -ne 0) { exit 1 }

Install-NuGetPackages $slnfile

Invoke-MSBuild $slnfile $customLogger

Invoke-NuGetPack $package
Pop-Location
}

$ErrorActionPreference = "Stop"
foreach ($test in ls test/*.Tests) {
Push-Location $test

echo "build: Testing project in $test"

if (-not $sln)
{
$slnfull = ls *.sln |
Where-Object { -not ($_.Name -like "*net40*") } |
Select -first 1
& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 3 }

$sln = $slnfull.BaseName
Pop-Location
}

Invoke-Build $majorMinor $patch $customLogger $notouch $sln
Pop-Location
25 changes: 25 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
build_script:
- ps: ./Build.ps1
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
deploy:
- provider: NuGet
api_key:
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
skip_symbols: true
on:
branch: /^(master|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
tag: v$(appveyor_build_version)
on:
branch: master
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public static class LoggerConfigurationRaygunExtensions
public static LoggerConfiguration Raygun(
this LoggerSinkConfiguration loggerConfiguration,
string applicationKey,
IEnumerable<Type> wrapperExceptions = null, string userNameProperty = "UserName", string applicationVersionProperty = "ApplicationVersion",
IEnumerable<Type> wrapperExceptions = null,
string userNameProperty = "UserName",
string applicationVersionProperty = "ApplicationVersion",
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Error,
IFormatProvider formatProvider = null,
IEnumerable<string> tags = null,
Expand Down
12 changes: 0 additions & 12 deletions src/Serilog.Sinks.Raygun/Properties/AssemblyInfo.cs

This file was deleted.

109 changes: 30 additions & 79 deletions src/Serilog.Sinks.Raygun/Serilog.Sinks.Raygun.csproj
Original file line number Diff line number Diff line change
@@ -1,84 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B4EEC1AD-6E2B-49F6-A4C0-A9D39E9C4EFA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Serilog</RootNamespace>
<AssemblyName>Serilog.Sinks.Raygun</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Michiel van Oudheusden</Authors>
<Company>Serilog</Company>
<Product>Serilog.Sinks.Raygun</Product>
<Description>Send log events to custom topics in Azure Event Grid</Description>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-raygun</RepositoryUrl>
<PackageTags>serilog sink raygun</PackageTags>
<Copyright>Copyright © Serilog Contributors 2017</Copyright>
<Description>Serilog event sink that writes to the Raygun.io service.</Description>
<Version>3.0.0</Version>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Serilog.Sinks.Raygun.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Serilog.Sinks.Raygun.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\assets\Serilog.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mindscape.Raygun4Net, Version=5.4.1.0, Culture=neutral, PublicKeyToken=20dddfb3684a7aa5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mindscape.Raygun4Net.Signed.5.4.1\lib\net40\Mindscape.Raygun4Net.dll</HintPath>
</Reference>
<Reference Include="Mindscape.Raygun4Net4, Version=5.4.1.0, Culture=neutral, PublicKeyToken=002e1b57394fa9b9, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mindscape.Raygun4Net.Signed.5.4.1\lib\net40\Mindscape.Raygun4Net4.dll</HintPath>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.2.3.0\lib\net46\Serilog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Mindscape.Raygun4Net" Version="5.5.2" />
</ItemGroup>
<ItemGroup>
<Compile Include="LoggerConfigurationRaygunExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\..\assets\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Sinks\Raygun\RaygunPropertyFormatter.cs" />
<Compile Include="Sinks\Raygun\RaygunSink.cs" />

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="mindscape.Raygun4Net.AspNetCore" Version="5.5.0" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Serilog.Sinks.Raygun.nuspec">
<SubType>Designer</SubType>
</None>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.6.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>
21 changes: 0 additions & 21 deletions src/Serilog.Sinks.Raygun/Serilog.Sinks.Raygun.nuspec

This file was deleted.

12 changes: 4 additions & 8 deletions src/Serilog.Sinks.Raygun/Sinks/Raygun/RaygunPropertyFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ static class RaygunPropertyFormatter
/// <returns>A simplified representation.</returns>
public static object Simplify(LogEventPropertyValue value)
{
var scalar = value as ScalarValue;
if (scalar != null)
if (value is ScalarValue scalar)
return SimplifyScalar(scalar.Value);

var dict = value as DictionaryValue;
if (dict != null)
if (value is DictionaryValue dict)
{
var result = new Dictionary<object, object>();
foreach (var element in dict.Elements)
Expand All @@ -68,12 +66,10 @@ public static object Simplify(LogEventPropertyValue value)
return result;
}

var seq = value as SequenceValue;
if (seq != null)
if (value is SequenceValue seq)
return seq.Elements.Select(Simplify).ToArray();

var str = value as StructureValue;
if (str != null)
if (value is StructureValue str)
{
var props = str.Properties.ToDictionary(p => p.Name, p => Simplify(p.Value));
if (str.TypeTag != null)
Expand Down
19 changes: 7 additions & 12 deletions src/Serilog.Sinks.Raygun/Sinks/Raygun/RaygunSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void Emit(LogEvent logEvent)
raygunMessage.Details.Error = RaygunErrorMessageBuilder.Build(logEvent.Exception);

// Add user when requested
if (!String.IsNullOrWhiteSpace(_userNameProperty) &&
if (!string.IsNullOrWhiteSpace(_userNameProperty) &&
logEvent.Properties.ContainsKey(_userNameProperty) &&
logEvent.Properties[_userNameProperty] != null)
{
Expand All @@ -127,27 +127,22 @@ public void Emit(LogEvent logEvent)
raygunMessage.Details.MachineName = Environment.MachineName;

// Add the custom group key when provided
object customKey;
if (properties.TryGetValue(_groupKeyProperty, out customKey))
if (properties.TryGetValue(_groupKeyProperty, out var customKey))
raygunMessage.Details.GroupingKey = customKey.ToString();

// Add additional custom tags
object eventTags;
if (properties.TryGetValue(_tagsProperty, out eventTags) && eventTags is object[])
if (properties.TryGetValue(_tagsProperty, out var eventTags) && eventTags is object[])
{
foreach (var tag in (object[])eventTags)
raygunMessage.Details.Tags.Add(tag.ToString());
}

if (HttpContext.Current != null)
{
// Request message is built here instead of raygunClient.Send so RequestMessageOptions have to be constructed here
var requestMessageOptions = new RaygunRequestMessageOptions(_ignoredFormFieldNames, Enumerable.Empty<string>(), Enumerable.Empty<string>(), Enumerable.Empty<string>());
raygunMessage.Details.Request = RaygunRequestMessageBuilder.Build(HttpContext.Current.Request, requestMessageOptions);
}

// Submit
#if NETSTANDARD2_0
_client.Send(raygunMessage).Wait();
#else
_client.Send(raygunMessage);
#endif
}
}
}
5 changes: 0 additions & 5 deletions src/Serilog.Sinks.Raygun/packages.config

This file was deleted.

Empty file added test/.gitkeep
Empty file.

0 comments on commit e628aa7

Please sign in to comment.