Skip to content

Commit

Permalink
Code/test port to .NET Core RC2
Browse files Browse the repository at this point in the history
  • Loading branch information
nblumhardt committed May 16, 2016
1 parent 03c8dfb commit 975bddd
Show file tree
Hide file tree
Showing 23 changed files with 213 additions and 150 deletions.
7 changes: 7 additions & 0 deletions Serilog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog", "src\Serilog\Seri
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Tests", "test\Serilog.Tests\Serilog.Tests.xproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestDummies", "test\TestDummies\TestDummies.xproj", "{2BB12CE5-C867-43BD-AE5D-253FE3248C7F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -35,12 +37,17 @@ Global
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.Build.0 = Release|Any CPU
{2BB12CE5-C867-43BD-AE5D-253FE3248C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BB12CE5-C867-43BD-AE5D-253FE3248C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BB12CE5-C867-43BD-AE5D-253FE3248C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BB12CE5-C867-43BD-AE5D-253FE3248C7F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C} = {037440DE-440B-4129-9F7A-09B42D00397E}
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
{2BB12CE5-C867-43BD-AE5D-253FE3248C7F} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-final"
}
"sdk": {
"version": "1.0.0-preview1-002702"
}
}
4 changes: 4 additions & 0 deletions src/Serilog/Context/ImmutableStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
using System.Runtime.Serialization;
#endif

// General-purpose type; not all features are used here.
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable MemberCanBeProtected.Global

namespace Serilog.Context
{
// Needed because of the shallow-copying behaviour of
Expand Down
1 change: 1 addition & 0 deletions src/Serilog/Core/Pipeline/SilentLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void Error(Exception exception, string messageTemplate, params object[] p
{
}

[MessageTemplateFormatMethod("messageTemplate")]
public void Fatal(string messageTemplate, params object[] propertyValues)
{
}
Expand Down
20 changes: 4 additions & 16 deletions src/Serilog/Serilog.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,10 @@
<PropertyGroup Label="Globals">
<ProjectGuid>803cd13a-d54b-4cec-a55f-e22ae3d93b3c</ProjectGuid>
<RootNamespace>Serilog</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> </PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
<ProjectExtensions>
<VisualStudio>
<UserProperties project_1json__JSONSchema="http://json.schemastore.org/project" />
</VisualStudio>
</ProjectExtensions>
</Project>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
81 changes: 39 additions & 42 deletions src/Serilog/project.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,54 @@
{
"version": "2.0.0-beta-*",
"version": "2.0.0-rc-*",
"description": "Simple .NET logging with fully-structured events",
"authors": [ "Serilog Contributors" ],
"tags": [ "serilog", "logging", "semantic", "structured" ],
"projectUrl": "http://serilog.net",
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"iconUrl": "http://serilog.net/images/serilog-nuget.png",
"compilationOptions": {
"keyFile": "../../assets/Serilog.snk"
"packOptions": {
"tags": [ "serilog", "logging", "semantic", "structured" ],
"projectUrl": "http://serilog.net",
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"iconUrl": "http://serilog.net/images/serilog-nuget.png"
},
"buildOptions": {
"keyFile": "../../assets/Serilog.snk",
"xmlDoc": true
},
"frameworks": {
"net45": {
"compilationOptions": {
"define": [ "PROCESS", "REMOTING", "APPDOMAIN" ]
"net4.5": {
"buildOptions": {
"define": [ "REMOTING" ]
}
},
"dotnet5.1": {
"netstandard1.0": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Diagnostics.TraceSource": "4.0.0-beta-23516",
"System.Globalization": "4.0.11-beta-23516",
"System.IO": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23516",
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.Text.RegularExpressions": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.Threading.Thread": "4.0.0-beta-23516"
"Microsoft.CSharp": "4.0.1-rc2-24027",
"System.Collections": "4.0.11-rc2-24027",
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
"System.Globalization": "4.0.11-rc2-24027",
"System.Linq": "4.1.0-rc2-24027",
"System.Reflection": "4.1.0-rc2-24027",
"System.Reflection.Extensions": "4.0.1-rc2-24027",
"System.Runtime": "4.1.0-rc2-24027",
"System.Runtime.Extensions": "4.1.0-rc2-24027",
"System.Text.RegularExpressions": "4.0.12-rc2-24027",
"System.Threading": "4.0.11-rc2-24027"
}
},
"dotnet5.4": {
"compilationOptions": {
"define": [ "ASYNCLOCAL", "PROCESS", "USERNAMEFROMENV" ]

"netstandard1.3": {
"buildOptions": {
"define": [ "ASYNCLOCAL" ]
},
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections.Concurrent": "4.0.11-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Diagnostics.Process": "4.1.0-beta-23516",
"System.Diagnostics.TraceSource": "4.0.0-beta-23516",
"System.Globalization": "4.0.11-beta-23516",
"System.IO": "4.0.11-beta-23516",
"System.IO.FileSystem": "4.0.1-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23516",
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.Text.RegularExpressions": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.Threading.Thread": "4.0.0-beta-23516"
"Microsoft.CSharp": "4.0.1-rc2-24027",
"System.Collections": "4.0.11-rc2-24027",
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
"System.Globalization": "4.0.11-rc2-24027",
"System.Linq": "4.1.0-rc2-24027",
"System.Reflection": "4.1.0-rc2-24027",
"System.Reflection.Extensions": "4.0.1-rc2-24027",
"System.Runtime": "4.1.0-rc2-24027",
"System.Runtime.Extensions": "4.1.0-rc2-24027",
"System.Text.RegularExpressions": "4.0.12-rc2-24027",
"System.Threading": "4.0.11-rc2-24027"
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions test/Serilog.Tests/Context/LogContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public LogContextTests()
{
#if REMOTING
LogContext.PermitCrossAppDomainCalls = false;
#endif
#if !ASYNCLOCAL
CallContext.LogicalSetData(typeof(LogContext).FullName, null);
#endif
}
Expand Down Expand Up @@ -219,10 +217,10 @@ public class RemotelyCallable : MarshalByRefObject
{
public bool IsCallable()
{
var sw = new StringWriter();
var sw = new StringSink(outputTemplate: "{Anything}{Number}");

var log = new LoggerConfiguration()
.WriteTo.TextWriter(sw, outputTemplate: "{Anything}{Number}")
.WriteTo.Sink(sw)
.Enrich.FromLogContext()
.CreateLogger();

Expand Down
2 changes: 1 addition & 1 deletion test/Serilog.Tests/Core/LoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void AnExceptionThrownByAnEnricherIsNotPropagated()
var thrown = false;

var l = new LoggerConfiguration()
.WriteTo.TextWriter(new StringWriter())
.WriteTo.Sink(new StringSink())
.Enrich.With(new DelegatingEnricher((le, pf) => {
thrown = true;
throw new Exception("No go, pal."); }))
Expand Down
6 changes: 1 addition & 5 deletions test/Serilog.Tests/Core/MessageTemplateTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if INTERNAL_TESTS

using System;
using System;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -167,5 +165,3 @@ public void MissingPositionalParametersRenderAsTextLikeStandardFormats()
}
}
}

#endif
6 changes: 1 addition & 5 deletions test/Serilog.Tests/Core/SafeAggregateSinkTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if INTERNAL_TESTS

using System;
using System;
using Xunit;
using Serilog.Core.Sinks;
using Serilog.Tests.Support;
Expand Down Expand Up @@ -41,5 +39,3 @@ public void WhenASinkThrowsOtherSinksAreStillInvoked()
}
}
}

#endif
4 changes: 0 additions & 4 deletions test/Serilog.Tests/Events/LogEventPropertyValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if INTERNAL_TESTS

using System;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -77,5 +75,3 @@ public void WhenDestructuringAKnownLiteralTypeIsScalar()
}
}
}

#endif
6 changes: 1 addition & 5 deletions test/Serilog.Tests/LogTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if INTERNAL_TESTS

using System;
using System;
using Xunit;
using Serilog.Core.Pipeline;
using Serilog.Tests.Support;
Expand Down Expand Up @@ -47,5 +45,3 @@ private static IDisposable SwappedLogger(ILogger logger)
}
}
}

#endif
6 changes: 1 addition & 5 deletions test/Serilog.Tests/LoggerConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public void DisposableSinksAreNotDisposedAlongWithContextualLoggers()
Assert.False(sink.IsDisposed);
}

#if INTERNAL_TESTS

[Fact]
public void AFilterPreventsMatchedEventsFromPassingToTheSink()
{
Expand All @@ -81,8 +79,6 @@ public void AFilterPreventsMatchedEventsFromPassingToTheSink()
Assert.True(events.Contains(included));
}

#endif

// ReSharper disable UnusedMember.Local, UnusedAutoPropertyAccessor.Local
class AB
{
Expand Down Expand Up @@ -241,7 +237,7 @@ public void EnrichersExecuteInConfigurationOrder()
var enrichedPropertySeen = false;

var logger = new LoggerConfiguration()
.WriteTo.TextWriter(new StringWriter())
.WriteTo.Sink(new StringSink())
.Enrich.With(new DelegatingEnricher((e, f) => e.AddPropertyIfAbsent(property)))
.Enrich.With(new DelegatingEnricher((e, f) => enrichedPropertySeen = e.Properties.ContainsKey(property.Name)))
.CreateLogger();
Expand Down
7 changes: 3 additions & 4 deletions test/Serilog.Tests/Parameters/PropertyValueConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if INTERNAL_TESTS

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -170,13 +168,15 @@ public void SurvivesDestructuringASystemType()
Assert.Equal(typeof(string), pv.LiteralValue());
}

#if GETCURRENTMETHOD
[Fact]
public void SurvivesDestructuringMethodBase()
{
var theMethod = System.Reflection.MethodBase.GetCurrentMethod();
var pv = _converter.CreatePropertyValue(theMethod, Destructuring.Destructure);
Assert.Equal(theMethod, pv.LiteralValue());
}
#endif

public class BaseWithProps
{
Expand Down Expand Up @@ -255,4 +255,3 @@ public void CSharpAnonymousTypesAreRecognizedWhenDestructuring()
}
}

#endif
16 changes: 3 additions & 13 deletions test/Serilog.Tests/Serilog.Tests.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@
<PropertyGroup Label="Globals">
<ProjectGuid>3c2d8e01-5580-426a-bdd9-ec59cd98e618</ProjectGuid>
<RootNamespace>Serilog.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
6 changes: 3 additions & 3 deletions test/Serilog.Tests/Settings/KeyValuePairSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Xunit;
using Serilog.Events;
using Serilog.Settings.KeyValuePairs;
using Serilog.Sinks.RollingFile;
using Serilog.Tests.Support;
using Serilog.Enrichers;
using TestDummies;

namespace Serilog.Tests.AppSettings.Tests
{
Expand Down Expand Up @@ -63,15 +63,15 @@ public void FindsEventEnrichersWithinAnAssembly()
.FindEventEnricherConfigurationMethods(new[]
{
typeof(Log).GetTypeInfo().Assembly,
typeof(ThreadIdEnricher).GetTypeInfo().Assembly
typeof(DummyThreadIdEnricher).GetTypeInfo().Assembly
})
.Select(m => m.Name)
.Distinct()
.ToList();


Assert.True(eventEnrichers.Contains("FromLogContext"));
Assert.True(eventEnrichers.Contains("WithThreadId"));
Assert.True(eventEnrichers.Contains("WithDummyThreadId"));
}

[Fact]
Expand Down
Loading

0 comments on commit 975bddd

Please sign in to comment.