Skip to content

Update to lts 31 #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matrix:
- os: linux
dist: trusty
sudo: required
dotnet: 2.1.4
dotnet: 3.1.101
group: edge
script:
- ./build.sh
- ./build.sh
24 changes: 12 additions & 12 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
echo "build: Build started"
Write-Output "build: Build started"

Push-Location $PSScriptRoot

if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Write-Output "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

& dotnet restore --no-cache

$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];
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$null -ne $env:APPVEYOR_REPO_BRANCH ];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$null -ne $env:APPVEYOR_BUILD_NUMBER];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]

echo "build: Version suffix is $suffix"
Write-Output "build: Version suffix is $suffix"

foreach ($src in ls src/*) {
foreach ($src in Get-ChildItem "src/*") {
Push-Location $src

echo "build: Packaging project in $src"
Write-Output "build: Packaging project in $src"

& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --include-source
if($LASTEXITCODE -ne 0) { exit 1 }
if($LASTEXITCODE -ne 0) { exit 1 }

Pop-Location
}

foreach ($test in ls test/*.PerformanceTests) {
foreach ($test in Get-ChildItem "test/*.PerformanceTests") {
Push-Location $test

echo "build: Building performance test project in $test"
Write-Output "build: Building performance test project in $test"

& dotnet build -c Release
if($LASTEXITCODE -ne 0) { exit 2 }

Pop-Location
}

foreach ($test in ls test/*.Tests) {
foreach ($test in Get-ChildItem "test/*.Tests") {
Push-Location $test

echo "build: Testing project in $test"
Write-Output "build: Testing project in $test"

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 3 }
Expand Down
11 changes: 11 additions & 0 deletions Setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$ErrorActionPreference = "Stop"

$RequiredDotnetVersion = $(Get-Content ./global.json | convertfrom-json).sdk.version

mkdir "./build"

Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./build/installcli.ps1"
& ./build/installcli.ps1 -InstallDir "$pwd/.dotnetcli" -NoPath -Version $RequiredDotnetVersion
if ($LASTEXITCODE) { exit 1 }

$env:Path = "$pwd/.dotnetcli;$env:Path"
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
image: Visual Studio 2019
configuration: Release
install:
- ps: ./Setup.ps1
build_script:
- ps: ./Build.ps1
test: off
Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.101"
}
}
27 changes: 16 additions & 11 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup>
<LatestVersion>[*, 9999.0)</LatestVersion>
</PropertyGroup>


<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
<PreserveCompilationContext>false</PreserveCompilationContext>
</PropertyGroup>
Expand All @@ -13,21 +18,21 @@
<ProjectReference Include="..\..\src\Serilog.Settings.Configuration\Serilog.Settings.Configuration.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.1" />
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.Async" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="2.0.0" />
<PackageReference Include="Serilog.Filters.Expressions" Version="1.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="$(LatestVersion)" />
<PackageReference Include="Serilog.Sinks.Console" Version="$(LatestVersion)" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="$(LatestVersion)" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="$(LatestVersion)" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="$(LatestVersion)" />
<PackageReference Include="Serilog.Filters.Expressions" Version="$(LatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Settings.Configuration</PackageId>
<PackageTags>serilog;json</PackageTags>
<PackageIcon>serilog-extension-nuget.png</PackageIcon>
<PackageIconUrl>https://serilog.net/images/serilog-configuration-nuget.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/serilog/serilog-settings-configuration</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand All @@ -21,20 +22,35 @@
<RootNamespace>Serilog</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Include="images/serilog-extension-nuget.png" Pack="true" PackagePath="/" />
</ItemGroup>

<PropertyGroup>
<LatestVersion>[*, 9999.0)</LatestVersion>
</PropertyGroup>

<PropertyGroup Condition="('$(TargetFramework)' == 'net451') Or ('$(TargetFramework)' == 'net461')">
<DefineConstants>$(DefineConstants);PRIVATE_BIN</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="$(LatestVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.*" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.4" />
<PackageReference Include="Serilog" Version="2.6.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.4" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" />
</ItemGroup>

<ItemGroup Condition="('$(TargetFramework)' == 'netstandard2.0') Or ('$(TargetFramework)' == 'net461')">
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
</ItemGroup>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ConfigurationReaderTests
public ConfigurationReaderTests()
{
_configurationReader = new ConfigurationReader(
JsonStringConfigSource.LoadSection(@"{ 'Serilog': { } }", "Serilog"),
JsonStringConfigSource.LoadSection(@"{ ""Serilog"": { } }", "Serilog"),
Copy link
Contributor

@sungam3r sungam3r Jan 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be helpful.

And then

  public override void Load()
            {
                Load(StringToStream(_json.ToValidJson()));
            }

Still waiting for merge :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did not saw that PR ;)
Also the double quote seems fine for all TFM, do we want to have different JSON delimiter since one works for all ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interest was to keep the number of changes in PR to a minimum. I achieved this with a few lines of code instead of a lot of refactoring. As a result, the tests work on both platforms. In addition, you will simply stop testing a single quote syntax. This is degradation of the test coverage.

AssemblyFinder.ForSource(ConfigurationAssemblySource.UseLoadedAssemblies));
}

Expand All @@ -23,44 +23,44 @@ public void WriteToSupportSimplifiedSyntax()
{
var json = @"
{
'WriteTo': [ 'LiterateConsole', 'DiagnosticTrace' ]
""WriteTo"": [ ""LiterateConsole"", ""DiagnosticTrace"" ]
}";

var result = _configurationReader.GetMethodCalls(JsonStringConfigSource.LoadSection(json, "WriteTo"));
Assert.Equal(2, result.Count);
Assert.True(result.Contains("LiterateConsole"));
Assert.True(result.Contains("DiagnosticTrace"));

Assert.Equal(1, result["LiterateConsole"].Count());
Assert.Equal(1, result["DiagnosticTrace"].Count());
Assert.Single(result["LiterateConsole"]);
Assert.Single(result["DiagnosticTrace"]);
}

[Fact]
public void WriteToSupportExpandedSyntaxWithoutArgs()
{
var json = @"
{
'WriteTo': [ {
'Name': 'LiterateConsole'
""WriteTo"": [ {
""Name"": ""LiterateConsole""
}]
}";

var result = _configurationReader.GetMethodCalls(JsonStringConfigSource.LoadSection(json, "WriteTo"));
Assert.Equal(1, result.Count);
Assert.True(result.Contains("LiterateConsole"));

Assert.Equal(1, result["LiterateConsole"].Count());
Assert.Single(result["LiterateConsole"]);
}

[Fact]
public void WriteToSupportExpandedSyntaxWithArgs()
{
var json = @"
{
'WriteTo': [ {
'Name': 'LiterateConsole',
'Args': {
'outputTemplate': '{Message}'
""WriteTo"": [ {
""Name"": ""LiterateConsole"",
""Args"": {
""outputTemplate"": ""{Message}""
},
}]
}";
Expand All @@ -70,11 +70,11 @@ public void WriteToSupportExpandedSyntaxWithArgs()
Assert.Equal(1, result.Count);
Assert.True(result.Contains("LiterateConsole"));

Assert.Equal(1, result["LiterateConsole"].Count());
Assert.Single(result["LiterateConsole"]);

var args = result["LiterateConsole"].Single().ToArray();

Assert.Equal(1, args.Length);
Assert.Single(args);
Assert.Equal("outputTemplate", args[0].Key);
Assert.Equal("{Message}", args[0].Value.ConvertTo(typeof(string), new ResolutionContext()));
}
Expand All @@ -84,25 +84,25 @@ public void WriteToSupportMultipleSinksOfTheSameKind()
{
var json = @"
{
'WriteTo': [
""WriteTo"": [
{
'Name': 'LiterateConsole',
'Args': {
'outputTemplate': '{Message}'
""Name"": ""LiterateConsole"",
""Args"": {
""outputTemplate"": ""{Message}""
},
},
'DiagnosticTrace'
""DiagnosticTrace""
],
'WriteTo:File1': {
'Name': 'File',
'Args': {
'outputTemplate': '{Message}'
""WriteTo:File1"": {
""Name"": ""File"",
""Args"": {
""outputTemplate"": ""{Message}""
},
},
'WriteTo:File2': {
'Name': 'File',
'Args': {
'outputTemplate': '{Message}'
""WriteTo:File2"": {
""Name"": ""File"",
""Args"": {
""outputTemplate"": ""{Message}""
},
}
}";
Expand All @@ -114,8 +114,8 @@ public void WriteToSupportMultipleSinksOfTheSameKind()
Assert.True(result.Contains("DiagnosticTrace"));
Assert.True(result.Contains("File"));

Assert.Equal(1, result["LiterateConsole"].Count());
Assert.Equal(1, result["DiagnosticTrace"].Count());
Assert.Single(result["LiterateConsole"]);
Assert.Single(result["DiagnosticTrace"]);
Assert.Equal(2, result["File"].Count());
}

Expand All @@ -124,7 +124,7 @@ public void Enrich_SupportSimplifiedSyntax()
{
var json = @"
{
'Enrich': [ 'FromLogContext', 'WithMachineName', 'WithThreadId' ]
""Enrich"": [ ""FromLogContext"", ""WithMachineName"", ""WithThreadId"" ]
}";

var result = _configurationReader.GetMethodCalls(JsonStringConfigSource.LoadSection(json, "Enrich"));
Expand All @@ -133,9 +133,9 @@ public void Enrich_SupportSimplifiedSyntax()
Assert.True(result.Contains("WithMachineName"));
Assert.True(result.Contains("WithThreadId"));

Assert.Equal(1, result["FromLogContext"].Count());
Assert.Equal(1, result["WithMachineName"].Count());
Assert.Equal(1, result["WithThreadId"].Count());
Assert.Single(result["FromLogContext"]);
Assert.Single(result["WithMachineName"]);
Assert.Single(result["WithThreadId"]);
}

[Fact]
Expand Down
Loading