Skip to content

Commit 83494f0

Browse files
authored
Fixed obsolete warning in MessageBoxTarget that blocks for NLog 5 (#104)
1 parent bd50e8d commit 83494f0

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

NLog.Windows.Forms/MessageBoxTarget.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Text;
34
using System.Windows.Forms;
45
using NLog.Common;
@@ -65,7 +66,7 @@ protected override void Write(LogEventInfo logEvent)
6566
{
6667
try
6768
{
68-
MessageBox.Show(this.Layout.Render(logEvent), this.Caption.Render(logEvent));
69+
MessageBox.Show(RenderLogEvent(this.Layout, logEvent), RenderLogEvent(this.Caption, logEvent));
6970
}
7071
catch (Exception ex)
7172
{
@@ -85,26 +86,25 @@ protected override void Write(LogEventInfo logEvent)
8586
/// </summary>
8687
/// <param name="logEvents">The array of logging events.</param>
8788
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions",
88-
Justification = "This is just debugging output.")]
89-
[Obsolete("Instead override Write(IList<AsyncLogEventInfo> logEvents. Marked obsolete on NLog 4.5")]
90-
protected override void Write(AsyncLogEventInfo[] logEvents)
89+
Justification = "This is just debugging output.")]
90+
protected override void Write(IList<AsyncLogEventInfo> logEvents)
9191
{
92-
if (logEvents.Length == 0)
92+
if (logEvents.Count == 0)
9393
{
9494
return;
9595
}
9696

9797
var sb = new StringBuilder();
98-
var lastLogEvent = logEvents[logEvents.Length - 1];
98+
var lastLogEvent = logEvents[logEvents.Count - 1];
9999
foreach (var ev in logEvents)
100100
{
101-
sb.Append(this.Layout.Render(ev.LogEvent));
101+
sb.Append(RenderLogEvent(this.Layout, ev.LogEvent));
102102
sb.Append("\n");
103103
}
104104

105-
MessageBox.Show(sb.ToString(), this.Caption.Render(lastLogEvent.LogEvent));
105+
MessageBox.Show(sb.ToString(), RenderLogEvent(this.Caption, lastLogEvent.LogEvent));
106106

107-
for (int i = 0; i < logEvents.Length; ++i)
107+
for (int i = 0; i < logEvents.Count; ++i)
108108
{
109109
logEvents[i].Continuation(null);
110110
}

NLog.Windows.Forms/NLog.Windows.Forms.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net35;netcoreapp3.1;net5.0-windows</TargetFrameworks>
44
<AssemblyTitle>NLog.Windows.Forms</AssemblyTitle>
@@ -12,7 +12,7 @@
1212
<PackageIcon>N.png</PackageIcon>
1313
<PackageId>NLog.Windows.Forms</PackageId>
1414
<PackageProjectUrl>https://nlog-project.org</PackageProjectUrl>
15-
<PackageTags>nlog target forms windows richtextbox</PackageTags>
15+
<PackageTags>nlog target forms windows richtextbox winforms</PackageTags>
1616
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1717
<IncludeSymbols>true</IncludeSymbols>
1818
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
@@ -26,7 +26,7 @@
2626
<AssemblyVersion>4.0.0.0</AssemblyVersion>
2727

2828
<PackageReleaseNotes>
29-
Added support for .NET Core 3.1 and .NET 5 (#42) (@weltkante, @304NotModified)
29+
Fixed obsolete warning in MessageBoxTarget that blocks NLog 5
3030
</PackageReleaseNotes>
3131
</PropertyGroup>
3232

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 4.5.0.{build}
1+
version: 4.6.0.{build}
22
image: Visual Studio 2019
33
clone_folder: c:\projects\nlog
44
configuration: Release

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# creates NuGet package at \artifacts
33
dotnet --version
44

5-
$versionPrefix = "4.5.0" # Also update version for minor versions in appveyor.yml
5+
$versionPrefix = "4.6.0" # Also update version for minor versions in appveyor.yml
66
$versionSuffix = ""
77
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
88
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {

0 commit comments

Comments
 (0)