From e5bf9713072c2014c4d052501f914940bbee3311 Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Wed, 19 Jun 2019 10:59:46 -0400 Subject: [PATCH 1/2] Style fixes for CimAsyncOperations --- .../CimAsyncOperation.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs index e721735afc6..d5b4c045bd7 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs @@ -6,9 +6,9 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Globalization; using System.Management.Automation; using System.Threading; -using System.Globalization; #endregion @@ -81,14 +81,14 @@ protected void NewCmdletActionHandler(object cimSession, CmdletActionEventArgs a /// /// /// - /// object raised the event + /// object raised the event. /// /// Event argument. protected void OperationCreatedHandler(object cimSession, OperationEventArgs actionArgs) { DebugHelper.WriteLogEx(); - lock (this.myLock) + lock (this.a_lock) { this.operationCount++; } @@ -101,14 +101,14 @@ protected void OperationCreatedHandler(object cimSession, OperationEventArgs act /// /// /// - /// object raised the event + /// object raised the event. /// /// Event argument. protected void OperationDeletedHandler(object cimSession, OperationEventArgs actionArgs) { DebugHelper.WriteLogEx(); - lock (this.myLock) + lock (this.a_lock) { this.operationCount--; if (this.operationCount == 0) @@ -126,7 +126,7 @@ protected void OperationDeletedHandler(object cimSession, OperationEventArgs act /// /// /// - /// wrapper of cmdlet, for details + /// wrapper of cmdlet, for details. /// public void ProcessActions(CmdletOperationBase cmdletOperation) { @@ -147,11 +147,11 @@ public void ProcessActions(CmdletOperationBase cmdletOperation) /// /// /// process remaining actions until all operations are completed or - /// current cmdlet is terminated by user + /// current cmdlet is terminated by user. /// /// /// - /// wrapper of cmdlet, for details + /// wrapper of cmdlet, for details. /// public void ProcessRemainActions(CmdletOperationBase cmdletOperation) { @@ -187,7 +187,7 @@ public void ProcessRemainActions(CmdletOperationBase cmdletOperation) /// /// - /// Get action object from action queue + /// Get action object from action queue. /// /// /// Next action to execute. @@ -296,8 +296,7 @@ protected CimSessionProxy CreateCimSessionProxy(string computerName) /// /// /// - protected CimSessionProxy CreateCimSessionProxy(string computerName, - CimInstance cimInstance) + protected CimSessionProxy CreateCimSessionProxy(string computerName, CimInstance cimInstance) { CimSessionProxy proxy = new CimSessionProxy(computerName, cimInstance); this.SubscribeEventAndAddProxytoCache(proxy); @@ -445,7 +444,7 @@ protected bool Disposed { get { - return (Interlocked.Read(ref this._disposed) == 1); + return Interlocked.Read(ref this._disposed) == 1; } } @@ -461,6 +460,7 @@ protected bool Disposed public void Dispose() { Dispose(true); + // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SuppressFinalize to // take this object off the finalization queue @@ -525,6 +525,7 @@ private void Cleanup() temporaryProxy = new List(this.cimSessionProxyCache); this.cimSessionProxyCache.Clear(); } + // clean up all proxy objects foreach (CimSessionProxy proxy in temporaryProxy) { @@ -549,12 +550,12 @@ private void Cleanup() /// /// Lock object. /// - private readonly object myLock = new object(); + private readonly object a_lock = new object(); /// /// Number of active operations. /// - private UInt32 operationCount = 0; + private uint operationCount = 0; /// /// Event to notify ps thread that more action is available. @@ -594,6 +595,5 @@ private void Cleanup() internal const string ComputerNameArgument = @"ComputerName"; internal const string CimSessionArgument = @"CimSession"; #endregion - } } From cc63c26e985094c95372e6d279ac7e3f8c31cefd Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Wed, 19 Jun 2019 11:32:03 -0400 Subject: [PATCH 2/2] ok codacy --- .../CimAsyncOperation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs index d5b4c045bd7..b7e418e05b6 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs @@ -555,7 +555,7 @@ private void Cleanup() /// /// Number of active operations. /// - private uint operationCount = 0; + private uint operationCount; /// /// Event to notify ps thread that more action is available.