Skip to content
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

Introduced NET6 since NET5 is no longer supported #629

Merged
merged 1 commit into from
Oct 22, 2022
Merged
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 appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ test_script:
- nuget.exe install OpenCover -ExcludeVersion -DependencyVersion Ignore
- OpenCover\tools\OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net461 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net5.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net461 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net5.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- pip install codecov
- codecov -f "coverage.xml"
- set JAVA_HOME=C:\Program Files\Java\jdk16
Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ if (-Not $LastExitCode -eq 0) {
exit $LastExitCode
}

msbuild /t:Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net461;netstandard1.3;netstandard1.5;netstandard2.0;netcoreapp3.1;net5.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
msbuild /t:Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net461;netstandard1.3;netstandard1.5;netstandard2.0;netstandard2.1;net6.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
if (-Not $LastExitCode -eq 0) {
exit $LastExitCode
}

msbuild /t:Pack .\src\NLog.Extensions.Hosting\ /p:targetFrameworks='"netstandard2.0;netcoreapp3.1;net5.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
msbuild /t:Pack .\src\NLog.Extensions.Hosting\ /p:targetFrameworks='"netstandard2.0;netstandard2.1;net6.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
if (-Not $LastExitCode -eq 0) {
exit $LastExitCode
}
Expand Down
8 changes: 4 additions & 4 deletions src/NLog.Extensions.Hosting/NLog.Extensions.Hosting.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -40,12 +40,12 @@ Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHAN
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET5_0
#if NET6_0

using System.Diagnostics;

Expand Down
19 changes: 11 additions & 8 deletions src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<string, ob
{
scopePropertyList = ExcludeOriginalFormatProperty(scopePropertyList);
}
else if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
else
{
scopePropertyList = IncludeActivityIdsProperties(scopePropertyList);
}
Expand All @@ -68,19 +68,22 @@ private IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<string, ob
return ScopeContext.PushNestedStateProperties(scopeObject, scopePropertyList);
}

#if !NET5_0
#if !NET6_0
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
{
return scopePropertyList;
return scopePropertyList; // Not supported
}
#else
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
private IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
{
if (scopePropertyList.Count > 1 && "RequestPath".Equals(scopePropertyList[1].Key))
if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
{
var activty = System.Diagnostics.Activity.Current;
if (activty != null)
return new ScopePropertiesWithActivityIds(scopePropertyList, activty);
if (scopePropertyList.Count > 1 && "RequestPath".Equals(scopePropertyList[1].Key))
{
var activty = System.Diagnostics.Activity.Current;
if (activty != null)
return new ScopePropertiesWithActivityIds(scopePropertyList, activty);
}
}

return scopePropertyList;
Expand Down
3 changes: 2 additions & 1 deletion src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class NLogProviderOptions
/// </summary>
public bool AutoShutdown { get; set; }

#if NET5_0
#if NET6_0
/// <summary>
/// Automatically include <see cref="System.Diagnostics.Activity.SpanId"/>, <see cref="System.Diagnostics.Activity.TraceId"/> and <see cref="System.Diagnostics.Activity.ParentId"/>
/// </summary>
Expand All @@ -73,6 +73,7 @@ public class NLogProviderOptions
///
/// Consider using <a href="https://www.nuget.org/packages/NLog.DiagnosticSource/">${activity}</a> as alternative
/// </remarks>
[Obsolete("Only supported with NET6 (or newer)")]
#endif
public bool IncludeActivityIdsWithBeginScope { get; set; }

Expand Down
18 changes: 9 additions & 9 deletions src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard1.3;netstandard1.5;netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard1.3;netstandard1.5;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -57,12 +57,12 @@ List of major changes in NLog 5.0: https://nlog-project.org/2021/08/25/nlog-5-0-
<Title>NLog.Extensions.Logging for .NET Standard 2.0</Title>
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<Title>NLog.Extensions.Logging for .NET Core 3.1</Title>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<Title>NLog.Extensions.Logging for .NET Standard 2.1</Title>
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<Title>NLog.Extensions.Logging for .NET 5.0</Title>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<Title>NLog.Extensions.Logging for .NET 6</Title>
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand Down Expand Up @@ -91,13 +91,13 @@ List of major changes in NLog 5.0: https://nlog-project.org/2021/08/25/nlog-5-0-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
<DebugType>full</DebugType>
Expand All @@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId(
AssertSingleMessage(memoryTarget, $"{expectedEventInLog} - test message with 1 arg");
}

#if NET5_0
#if NET6_0
[Fact]
public void AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net461;net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net461;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
<DebugType>Full</DebugType>
Expand Down Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
</ItemGroup>
Expand Down