Skip to content

Commit 706bfa1

Browse files
author
Dave Wyatt
committed
Weak references, more ReSharper
HostIoInterceptor's _subscribers field is now a list of weak references to IHostIoSubscriber objects. This avoids a situation where someone might either forget to detach a log file, or have a script crash before that line executes, resulting in all of the remaining session's output being captured. Help files have been updated to reflect that the calling script must hold a reference to the LogFile or ScriptBlockOutputSubscriber objects to keep them alive. Once the garbage collector comes along, that's all she wrote. Also removed the WriteHost method from IHostIoSubscriber, since it wasn't being called by HostIoInterceptor anyway (that gets sent through WriteOutput).
1 parent d44c597 commit 706bfa1

10 files changed

Lines changed: 338 additions & 174 deletions

Commands/Cmdlets.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using System.Management.Automation;
22

3+
// ReSharper disable MemberCanBePrivate.Global
4+
// ReSharper disable UnusedAutoPropertyAccessor.Global
5+
// ReSharper disable UnusedMember.Global
6+
37
namespace PSLogging.Commands
48
{
59
[Cmdlet(VerbsCommon.Add, "LogFile")]
@@ -246,3 +250,7 @@ protected override void EndProcessing()
246250
}
247251
} // End DisableOutputSubscriberCommand class
248252
}
253+
254+
// ReSharper restore MemberCanBePrivate.Global
255+
// ReSharper restore UnusedAutoPropertyAccessor.Global
256+
// ReSharper restore UnusedMember.Global

Common.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22

3+
// ReSharper disable UnusedMember.Global
4+
35
namespace PSLogging
46
{
57
[Flags]
@@ -14,3 +16,5 @@ public enum StreamType
1416
All = Output | Verbose | Warning | Error | Debug
1517
}
1618
}
19+
20+
// ReSharper restore UnusedMember.Global

0 commit comments

Comments
 (0)