From b3ef0ff6ed0fe5722f9b886cc1565dc3903efb3d Mon Sep 17 00:00:00 2001 From: Nathan Ferreira <14365254+nathan130200@users.noreply.github.com> Date: Mon, 6 May 2024 09:21:29 -0300 Subject: [PATCH] Fix CodeQA warnings. --- XmppSharp/XmppParser.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/XmppSharp/XmppParser.cs b/XmppSharp/XmppParser.cs index 0065d22..c4ae2df 100644 --- a/XmppSharp/XmppParser.cs +++ b/XmppSharp/XmppParser.cs @@ -15,9 +15,9 @@ public sealed class XmppParser : IDisposable private readonly bool _leaveOpen; - private readonly Func _streamFactory; + private Func _streamFactory; private Stream _baseStream; - private bool _isFromFactory; + private readonly bool _isFromFactory; private readonly Encoding _encoding; private readonly int _bufferSize; @@ -58,8 +58,8 @@ public XmppParser(Func streamFactory, Encoding? encoding = default, int { Require.NotNull(streamFactory); - this._streamFactory = streamFactory; this._isFromFactory = true; + this._streamFactory = streamFactory; Reset(); } @@ -89,7 +89,9 @@ public void Dispose() this._disposed = true; - if (!this._isFromFactory) + if (this._isFromFactory) + this._streamFactory = null; + else { if (!this._leaveOpen) this._baseStream?.Dispose();