Skip to content

Commit 74b09e8

Browse files
authored
Merge pull request #130 from nblumhardt/netcoreapp30
.NET Core App 3.0 target; misc clean-up
2 parents a015038 + 849ad79 commit 74b09e8

File tree

8 files changed

+35
-50
lines changed

8 files changed

+35
-50
lines changed

example/Sample/Sample.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@
1717
<Reference Include="Microsoft.CSharp" />
1818
</ItemGroup>
1919

20-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
21-
</ItemGroup>
22-
2320
</Project>
2421

serilog-sinks-file.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Filenames/@EntryIndexedValue">True</s:Boolean>
23
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/Serilog.Sinks.File/Serilog.Sinks.File.csproj

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>Write Serilog events to text files in plain or JSON format.</Description>
55
<VersionPrefix>5.0.0</VersionPrefix>
66
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>net45;netstandard1.3;netstandard2.0;netcoreapp3.0</TargetFrameworks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
1010
<SignAssembly>true</SignAssembly>
@@ -18,21 +18,15 @@
1818
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1919
<RootNamespace>Serilog</RootNamespace>
2020
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
21-
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
21+
<DisableImplicitFrameworkReferences Condition=" '$(TargetFramework)' == 'netstandard1.3' ">true</DisableImplicitFrameworkReferences>
2222
<EnableSourceLink Condition="'$(EnableSourceLink)' == ''">false</EnableSourceLink>
2323
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2424
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2525
</PropertyGroup>
2626

2727
<ItemGroup>
2828
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
29-
<PackageReference Include="Serilog" Version="2.5.0" />
30-
</ItemGroup>
31-
32-
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
33-
<Reference Include="System" />
34-
<Reference Include="System.Core" />
35-
<Reference Include="Microsoft.CSharp" />
29+
<PackageReference Include="Serilog" Version="2.9.0" />
3630
</ItemGroup>
3731

3832
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
@@ -43,23 +37,23 @@
4337
<DefineConstants>$(DefineConstants);OS_MUTEX</DefineConstants>
4438
</PropertyGroup>
4539

46-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
40+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.0' ">
4741
<DefineConstants>$(DefineConstants);OS_MUTEX</DefineConstants>
4842
</PropertyGroup>
4943

5044
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
51-
<PackageReference Include="System.IO" Version="4.1.0" />
52-
<PackageReference Include="System.IO.FileSystem" Version="4.0.1" />
53-
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.0.1" />
54-
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.0.11" />
55-
<PackageReference Include="System.Threading.Timer" Version="4.0.1" />
56-
<PackageReference Include="System.Threading" Version="4.0.11" />
57-
<PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
45+
<PackageReference Include="System.IO" Version="4.3.0" />
46+
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
47+
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
48+
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
49+
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
50+
<PackageReference Include="System.Threading" Version="4.3.0" />
51+
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
5852
</ItemGroup>
5953

6054
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
61-
<PackageReference Include="System.IO.FileSystem" Version="4.0.1" />
62-
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.0.11" />
63-
<PackageReference Include="System.Threading.Timer" Version="4.0.1" />
55+
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
56+
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
57+
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
6458
</ItemGroup>
6559
</Project>

test/Serilog.Sinks.File.Tests/FileSinkTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void WhenLimitIsSpecifiedAndEncodingHasNoPreambleDataIsCorrectlyAppendedT
130130
long? maxBytes = 5000;
131131
var encoding = new UTF8Encoding(false);
132132

133-
Assert.Equal(0, encoding.GetPreamble().Length);
133+
Assert.Empty(encoding.GetPreamble());
134134
WriteTwoEventsAndCheckOutputFileLength(maxBytes, encoding);
135135
}
136136

@@ -139,7 +139,7 @@ public void WhenLimitIsNotSpecifiedAndEncodingHasNoPreambleDataIsCorrectlyAppend
139139
{
140140
var encoding = new UTF8Encoding(false);
141141

142-
Assert.Equal(0, encoding.GetPreamble().Length);
142+
Assert.Empty(encoding.GetPreamble());
143143
WriteTwoEventsAndCheckOutputFileLength(null, encoding);
144144
}
145145

test/Serilog.Sinks.File.Tests/RollingFileSinkTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ public void WhenStreamWrapperSpecifiedIsUsedForRolledFiles()
227227
textStream.Position = 0;
228228
var lines = textStream.ReadAllLines();
229229

230-
Assert.Equal(1, lines.Count);
231-
Assert.True(lines[0].EndsWith(logEvents[i].MessageTemplate.Text));
230+
Assert.Single(lines);
231+
Assert.EndsWith(logEvents[i].MessageTemplate.Text, lines[0]);
232232
}
233233
}
234234
}

test/Serilog.Sinks.File.Tests/Serilog.Sinks.File.Tests.csproj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
4+
<TargetFrameworks>net47;netcoreapp3.1</TargetFrameworks>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
<AssemblyName>Serilog.Sinks.File.Tests</AssemblyName>
77
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
88
<SignAssembly>true</SignAssembly>
99
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
10-
<PackageId>Serilog.Sinks.RollingFile.Tests</PackageId>
1110
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
1211
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
1312
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
@@ -18,9 +17,9 @@
1817
</ItemGroup>
1918

2019
<ItemGroup>
21-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
23-
<PackageReference Include="xunit" Version="2.2.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
22+
<PackageReference Include="xunit" Version="2.4.1" />
2423
</ItemGroup>
2524

2625
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
@@ -32,5 +31,4 @@
3231
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
3332
</ItemGroup>
3433

35-
3634
</Project>

test/Serilog.Sinks.File.Tests/Support/Some.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
43
using System.Linq;
54
using System.Threading;
65
using Serilog.Events;
76
using Serilog.Parsing;
87
using Xunit.Sdk;
98

9+
// ReSharper disable UnusedMember.Global
10+
1011
namespace Serilog.Sinks.File.Tests.Support
1112
{
1213
static class Some
@@ -46,10 +47,8 @@ public static DateTimeOffset OffsetInstant()
4647
public static LogEvent LogEvent(string messageTemplate, params object[] propertyValues)
4748
{
4849
var log = new LoggerConfiguration().CreateLogger();
49-
MessageTemplate template;
50-
IEnumerable<LogEventProperty> properties;
5150
#pragma warning disable Serilog004 // Constant MessageTemplate verifier
52-
if (!log.BindMessageTemplate(messageTemplate, propertyValues, out template, out properties))
51+
if (!log.BindMessageTemplate(messageTemplate, propertyValues, out var template, out var properties))
5352
#pragma warning restore Serilog004 // Constant MessageTemplate verifier
5453
{
5554
throw new XunitException("Template could not be bound.");
@@ -65,7 +64,7 @@ public static LogEvent LogEvent(DateTimeOffset? timestamp = null, LogEventLevel
6564

6665
public static LogEvent InformationEvent(DateTimeOffset? timestamp = null)
6766
{
68-
return LogEvent(timestamp, LogEventLevel.Information);
67+
return LogEvent(timestamp);
6968
}
7069

7170
public static LogEvent DebugEvent(DateTimeOffset? timestamp = null)

test/Serilog.Sinks.File.Tests/TemplatedPathRollerTests.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public void TheLogFileIncludesDateToken()
1212
{
1313
var roller = new PathRoller(Path.Combine("Logs", "log-.txt"), RollingInterval.Day);
1414
var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
15-
string path;
16-
roller.GetLogFilePath(now, null, out path);
15+
roller.GetLogFilePath(now, null, out var path);
1716
AssertEqualAbsolute(Path.Combine("Logs", "log-20130714.txt"), path);
1817
}
1918

@@ -22,8 +21,7 @@ public void ANonZeroIncrementIsIncludedAndPadded()
2221
{
2322
var roller = new PathRoller(Path.Combine("Logs", "log-.txt"), RollingInterval.Day);
2423
var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
25-
string path;
26-
roller.GetLogFilePath(now, 12, out path);
24+
roller.GetLogFilePath(now, 12, out var path);
2725
AssertEqualAbsolute(Path.Combine("Logs", "log-20130714_012.txt"), path);
2826
}
2927

@@ -46,8 +44,7 @@ public void TheLogFileIsNotRequiredToIncludeAnExtension()
4644
{
4745
var roller = new PathRoller(Path.Combine("Logs", "log-"), RollingInterval.Day);
4846
var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
49-
string path;
50-
roller.GetLogFilePath(now, null, out path);
47+
roller.GetLogFilePath(now, null, out var path);
5148
AssertEqualAbsolute(Path.Combine("Logs", "log-20130714"), path);
5249
}
5350

@@ -56,19 +53,18 @@ public void TheLogFileIsNotRequiredToIncludeADirectory()
5653
{
5754
var roller = new PathRoller("log-", RollingInterval.Day);
5855
var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
59-
string path;
60-
roller.GetLogFilePath(now, null, out path);
56+
roller.GetLogFilePath(now, null, out var path);
6157
AssertEqualAbsolute("log-20130714", path);
6258
}
6359

6460
[Fact]
65-
public void MatchingExcludesSimilarButNonmatchingFiles()
61+
public void MatchingExcludesSimilarButNonMatchingFiles()
6662
{
6763
var roller = new PathRoller("log-.txt", RollingInterval.Day);
6864
const string similar1 = "log-0.txt";
69-
const string similar2 = "log-helloyou.txt";
65+
const string similar2 = "log-hello.txt";
7066
var matched = roller.SelectMatches(new[] { similar1, similar2 });
71-
Assert.Equal(0, matched.Count());
67+
Assert.Empty(matched);
7268
}
7369

7470
[Fact]
@@ -86,7 +82,7 @@ public void MatchingSelectsFiles(string template, string zeroth, string thirtyFi
8682
var roller = new PathRoller(template, interval);
8783
var matched = roller.SelectMatches(new[] { zeroth, thirtyFirst }).ToArray();
8884
Assert.Equal(2, matched.Length);
89-
Assert.Equal(null, matched[0].SequenceNumber);
85+
Assert.Null(matched[0].SequenceNumber);
9086
Assert.Equal(31, matched[1].SequenceNumber);
9187
}
9288

0 commit comments

Comments
 (0)