-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Tracking issue: Fix CA2213: Disposable fields should be disposed and remove suppressions.
In #15805, each rule violation will be suppressed like so:
#pragma warning disable CA2213 // Disposable fields should be disposed
private Timer _timer;
#pragma warning restore CA2213 // https://github.com/PowerShell/PowerShell/issues/15803We need to review every case and either fix as bug or suppress with description why it is not bug and maybe add more info in (XML) docs.
Some of the rule violations may be false positives/unfixable/breaking change if the disposable has been injected via a property, etc.
TODO: after reviewing and fixing all violations listed here, please re-open #15805 to enable the CA2213 rule so as to make sure no violations in future.
Rule violations
- 1.
Line 169 in a4181ab
private Timer _sleepAndRetryTimer; - 2.
PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Line 2186 in a4181ab
private StreamWriter _outputWriter; - 3.
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
Line 27 in a4181ab
private readonly Stream _originalStreamToProxy; - 4.
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs
Line 673 in a4181ab
internal XmlReader _xr; - 5.
private readonly ConsoleTextWriter _consoleWriter; - 6.
internal Pipeline runningCmd; - 7.
PowerShell/src/System.Management.Automation/FormatAndOutput/common/BaseCommand.cs
Line 231 in a4181ab
internal ImplementationCommandBase implementation = null; - 8.
private IEnumerator<CmdletInfo>? _matchingCmdlet; - 9.
private CommandPathSearch? _pathSearcher; - 10.
private IEnumerator<AliasInfo>? _matchingAlias; - 11.
private IEnumerator<CommandInfo?>? _matchingFunctionEnumerator; - 12.
private IEnumerator<DscResourceInfo> _matchingResource = null; - 13.
private PSTaskJob _taskJob; - 14.
private readonly PipelineProcessor _pp = null; - 15.
private IEnumerator<PSClassInfo> _matchingClass = null; - 16.
private PowerShell _psDebuggerCommand; - 17.
internal ManualResetEventSlim RunspaceOpening = new ManualResetEventSlim(false); - 18.
private Pipeline _currentlyRunningPipeline = null; - 19.
private RunspacePool _runspacePool = null; - 20.
private readonly RemotePipeline _remotePipeline = null; - 21.
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 22.
PowerShell/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs
Line 47 in a4181ab
private InvokeCommandCommand _currentInvokeCommand = null; - 23.
PowerShell/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs
Line 1796 in a4181ab
private PowerShell _psDebuggerCommand; - 24.
PowerShell/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs
Line 2021 in a4181ab
private SteppablePipeline _steppablePipeline; - 25.
PowerShell/src/System.Management.Automation/engine/remoting/commands/ReceiveJob.cs
Line 317 in a4181ab
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 26.
PowerShell/src/System.Management.Automation/engine/remoting/common/RemoteSessionHyperVSocket.cs
Line 141 in a4181ab
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 27.
PowerShell/src/System.Management.Automation/engine/remoting/common/RemoteSessionHyperVSocket.cs
Line 340 in a4181ab
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 28.
PowerShell/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Line 344 in a4181ab
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 29.
PowerShell/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Line 1010 in a4181ab
private readonly PowerShellTraceSource _tracer = PowerShellTraceSourceFactory.GetTraceSource(); - 30.
PowerShell/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
Line 482 in a4181ab
protected PowerShellTraceSource _tracer; - 31.
PowerShell/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
Line 1595 in a4181ab
private Timer _connectionTimer; - 32.
private readonly PSDataCollectionEnumerator<T> _enumerator;