Skip to content

.NET Core App 3.0 target; misc clean-up #130

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

Merged
merged 2 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions example/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
</ItemGroup>

</Project>

1 change: 1 addition & 0 deletions serilog-sinks-file.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<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">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Filenames/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
34 changes: 14 additions & 20 deletions src/Serilog.Sinks.File/Serilog.Sinks.File.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>Write Serilog events to text files in plain or JSON format.</Description>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -18,21 +18,15 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<RootNamespace>Serilog</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<DisableImplicitFrameworkReferences Condition=" '$(TargetFramework)' == 'netstandard1.3' ">true</DisableImplicitFrameworkReferences>
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to make this change to get the .NET 4.5 target building with the current tools 🤔

Copy link

@danielchalmers danielchalmers Apr 11, 2020

Choose a reason for hiding this comment

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

you should be able to safely remove DisableImplicitFrameworkReferences altogether along with the System* package references since the targeted frameworks already have implicit references to all those packages (>= 4.3.0)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the note. This was added originally to prevent an explosion of dependencies on .NET Framework when installing packages that targeted .NET Standard 1.x - the exact issues elude me know, and I'd love to be able to remove it, but probably best in a separate/more carefully-considered PR. Thanks!

<EnableSourceLink Condition="'$(EnableSourceLink)' == ''">false</EnableSourceLink>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Serilog" Version="2.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Serilog" Version="2.9.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand All @@ -43,23 +37,23 @@
<DefineConstants>$(DefineConstants);OS_MUTEX</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.0' ">
<DefineConstants>$(DefineConstants);OS_MUTEX</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.IO" Version="4.1.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.0.1" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.0.1" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.0.11" />
<PackageReference Include="System.Threading.Timer" Version="4.0.1" />
<PackageReference Include="System.Threading" Version="4.0.11" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.IO.FileSystem" Version="4.0.1" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.0.11" />
<PackageReference Include="System.Threading.Timer" Version="4.0.1" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/Serilog.Sinks.File.Tests/FileSinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void WhenLimitIsSpecifiedAndEncodingHasNoPreambleDataIsCorrectlyAppendedT
long? maxBytes = 5000;
var encoding = new UTF8Encoding(false);

Assert.Equal(0, encoding.GetPreamble().Length);
Assert.Empty(encoding.GetPreamble());
WriteTwoEventsAndCheckOutputFileLength(maxBytes, encoding);
}

Expand All @@ -139,7 +139,7 @@ public void WhenLimitIsNotSpecifiedAndEncodingHasNoPreambleDataIsCorrectlyAppend
{
var encoding = new UTF8Encoding(false);

Assert.Equal(0, encoding.GetPreamble().Length);
Assert.Empty(encoding.GetPreamble());
WriteTwoEventsAndCheckOutputFileLength(null, encoding);
}

Expand Down
4 changes: 2 additions & 2 deletions test/Serilog.Sinks.File.Tests/RollingFileSinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public void WhenStreamWrapperSpecifiedIsUsedForRolledFiles()
textStream.Position = 0;
var lines = textStream.ReadAllLines();

Assert.Equal(1, lines.Count);
Assert.True(lines[0].EndsWith(logEvents[i].MessageTemplate.Text));
Assert.Single(lines);
Assert.EndsWith(logEvents[i].MessageTemplate.Text, lines[0]);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions test/Serilog.Sinks.File.Tests/Serilog.Sinks.File.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0;netcoreapp3.1</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>Serilog.Sinks.File.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.RollingFile.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
Expand All @@ -18,9 +17,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
Expand Down
9 changes: 4 additions & 5 deletions test/Serilog.Sinks.File.Tests/Support/Some.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Serilog.Events;
using Serilog.Parsing;
using Xunit.Sdk;

// ReSharper disable UnusedMember.Global

namespace Serilog.Sinks.File.Tests.Support
{
static class Some
Expand Down Expand Up @@ -46,10 +47,8 @@ public static DateTimeOffset OffsetInstant()
public static LogEvent LogEvent(string messageTemplate, params object[] propertyValues)
{
var log = new LoggerConfiguration().CreateLogger();
MessageTemplate template;
IEnumerable<LogEventProperty> properties;
#pragma warning disable Serilog004 // Constant MessageTemplate verifier
if (!log.BindMessageTemplate(messageTemplate, propertyValues, out template, out properties))
if (!log.BindMessageTemplate(messageTemplate, propertyValues, out var template, out var properties))
#pragma warning restore Serilog004 // Constant MessageTemplate verifier
{
throw new XunitException("Template could not be bound.");
Expand All @@ -65,7 +64,7 @@ public static LogEvent LogEvent(DateTimeOffset? timestamp = null, LogEventLevel

public static LogEvent InformationEvent(DateTimeOffset? timestamp = null)
{
return LogEvent(timestamp, LogEventLevel.Information);
return LogEvent(timestamp);
}

public static LogEvent DebugEvent(DateTimeOffset? timestamp = null)
Expand Down
20 changes: 8 additions & 12 deletions test/Serilog.Sinks.File.Tests/TemplatedPathRollerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public void TheLogFileIncludesDateToken()
{
var roller = new PathRoller(Path.Combine("Logs", "log-.txt"), RollingInterval.Day);
var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
string path;
roller.GetLogFilePath(now, null, out path);
roller.GetLogFilePath(now, null, out var path);
AssertEqualAbsolute(Path.Combine("Logs", "log-20130714.txt"), path);
}

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

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

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

[Fact]
public void MatchingExcludesSimilarButNonmatchingFiles()
public void MatchingExcludesSimilarButNonMatchingFiles()
{
var roller = new PathRoller("log-.txt", RollingInterval.Day);
const string similar1 = "log-0.txt";
const string similar2 = "log-helloyou.txt";
const string similar2 = "log-hello.txt";
var matched = roller.SelectMatches(new[] { similar1, similar2 });
Assert.Equal(0, matched.Count());
Assert.Empty(matched);
}

[Fact]
Expand All @@ -86,7 +82,7 @@ public void MatchingSelectsFiles(string template, string zeroth, string thirtyFi
var roller = new PathRoller(template, interval);
var matched = roller.SelectMatches(new[] { zeroth, thirtyFirst }).ToArray();
Assert.Equal(2, matched.Length);
Assert.Equal(null, matched[0].SequenceNumber);
Assert.Null(matched[0].SequenceNumber);
Assert.Equal(31, matched[1].SequenceNumber);
}

Expand Down