CodeFactor cleanup (#12251)

* Code cleanup

Signed-off-by: Reece Dunham <me@rdil.rocks>

* whoops

* Update src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionOperations.cs

Co-Authored-By: Travis Plunk <travis.plunk@microsoft.com>

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
This commit is contained in:
Reece Dunham 2020-04-14 17:34:53 -04:00 committed by GitHub
parent a29cffd49d
commit 8b3937ecfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 53 deletions

View file

@ -13,7 +13,7 @@ RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \ && apt-get -y install --no-install-recommends apt-utils 2>&1 \
# #
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git procps lsb-release \ && apt-get -y install --no-install-recommends git procps lsb-release \
# #
# Clean up # Clean up
&& apt-get autoremove -y \ && apt-get autoremove -y \

View file

@ -27,7 +27,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#region Constructor #region Constructor
/// <summary> /// <summary>
/// Constructor. /// The constructor.
/// </summary> /// </summary>
public CimAsyncOperation() public CimAsyncOperation()
{ {
@ -126,7 +126,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="cmdletOperation"> /// <param name="cmdletOperation">
/// wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details. /// Wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details.
/// </param> /// </param>
public void ProcessActions(CmdletOperationBase cmdletOperation) public void ProcessActions(CmdletOperationBase cmdletOperation)
{ {
@ -146,12 +146,12 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// process remaining actions until all operations are completed or /// Process remaining actions until all operations are completed or
/// current cmdlet is terminated by user. /// current cmdlet is terminated by user.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="cmdletOperation"> /// <param name="cmdletOperation">
/// wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details. /// Wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details.
/// </param> /// </param>
public void ProcessRemainActions(CmdletOperationBase cmdletOperation) public void ProcessRemainActions(CmdletOperationBase cmdletOperation)
{ {
@ -202,7 +202,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Add temporary <seealso cref="CimSessionProxy"/> object to cache. /// Add temporary <seealso cref="CimSessionProxy"/> object to cache.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="computerName">Computer name of the cimsession.</param>
/// <param name="sessionproxy">Cimsession wrapper object.</param> /// <param name="sessionproxy">Cimsession wrapper object.</param>
protected void AddCimSessionProxy(CimSessionProxy sessionproxy) protected void AddCimSessionProxy(CimSessionProxy sessionproxy)
{ {
@ -382,7 +381,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <param name="referenceType">Output the cimtype of the value, either Reference or ReferenceArray.</param> /// <param name="referenceType">Output the cimtype of the value, either Reference or ReferenceArray.</param>
/// <returns></returns> /// <returns>The object.</returns>
protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType) protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType)
{ {
PSReference cimReference = value as PSReference; PSReference cimReference = value as PSReference;
@ -496,7 +495,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Clean up managed resources /// Clean up managed resources.
/// </para> /// </para>
/// </summary> /// </summary>
private void Cleanup() private void Cleanup()
@ -585,7 +584,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#region protected members #region protected members
/// <summary> /// <summary>
/// Event to notify ps thread that either a ACK message sent back /// Event to notify ps thread that either a ACK message sent back
/// or a error happened. Currently only used by class /// or a error happened. Currently only used by
/// <see cref="CimRegisterCimIndication"/>. /// <see cref="CimRegisterCimIndication"/>.
/// </summary> /// </summary>
protected ManualResetEventSlim ackedEvent; protected ManualResetEventSlim ackedEvent;

View file

@ -69,7 +69,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
internal class CimSyncAction : CimBaseAction, IDisposable internal class CimSyncAction : CimBaseAction, IDisposable
{ {
/// <summary> /// <summary>
/// Constructor. /// The constructor.
/// </summary> /// </summary>
public CimSyncAction() public CimSyncAction()
{ {
@ -91,7 +91,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Set response result /// Set the response result.
/// </para> /// </para>
/// </summary> /// </summary>
internal CimResponseType ResponseType internal CimResponseType ResponseType
@ -102,7 +102,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Call this method when the action is completed or /// Call this method when the action is completed or
/// the operation is terminated /// the operation is terminated.
/// </para> /// </para>
/// </summary> /// </summary>
internal virtual void OnComplete() internal virtual void OnComplete()
@ -112,7 +112,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// block current thread. /// Block current thread.
/// </para> /// </para>
/// </summary> /// </summary>
protected virtual void Block() protected virtual void Block()

View file

@ -25,7 +25,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{ {
/// <summary> /// <summary>
/// <para> /// <para>
/// constructor /// The constructor.
/// </para> /// </para>
/// </summary> /// </summary>
public CimCmdletsAssemblyInitializer() public CimCmdletsAssemblyInitializer()
@ -56,18 +56,18 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// CimCmdlet alias entry /// CimCmdlet alias entry.
/// </para> /// </para>
/// </summary> /// </summary>
internal sealed class CimCmdletAliasEntry internal sealed class CimCmdletAliasEntry
{ {
/// <summary> /// <summary>
/// <para> /// <para>
/// Constructor /// The constructor.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name">The entry name.</param>
/// <param name="value"></param> /// <param name="value">The entry value.</param>
internal CimCmdletAliasEntry(string name, string value) internal CimCmdletAliasEntry(string name, string value)
{ {
this._name = name; this._name = name;

View file

@ -221,10 +221,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// session counter bound to current runspace. /// Session counter bound to current runspace.
/// </para> /// </para>
/// </summary> /// </summary>
private UInt32 sessionNameCounter; private uint sessionNameCounter;
/// <summary> /// <summary>
/// <para> /// <para>
@ -252,7 +252,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Dictionary used to holds all CimSessions in current runspace by session id. /// Dictionary used to holds all CimSessions in current runspace by session id.
/// </para> /// </para>
/// </summary> /// </summary>
private Dictionary<UInt32, CimSessionWrapper> curCimSessionsById; private Dictionary<uint, CimSessionWrapper> curCimSessionsById;
/// <summary> /// <summary>
/// <para> /// <para>
@ -265,7 +265,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// constructor /// The constructor.
/// </para> /// </para>
/// </summary> /// </summary>
internal CimSessionState() internal CimSessionState()
@ -297,7 +297,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </para> /// </para>
/// </summary> /// </summary>
/// <returns>Unique session id under current runspace.</returns> /// <returns>Unique session id under current runspace.</returns>
internal UInt32 GenerateSessionId() internal uint GenerateSessionId()
{ {
return this.sessionNameCounter++; return this.sessionNameCounter++;
} }
@ -305,7 +305,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Indicates whether this object was disposed or not /// Indicates whether this object was disposed or not.
/// </para> /// </para>
/// </summary> /// </summary>
private bool _disposed; private bool _disposed;
@ -381,17 +381,19 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Add new CimSession object to cache /// Add new CimSession object to cache.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="session"></param> /// <param name="session"></param>
/// <param name="sessionId"></param> /// <param name="sessionId"></param>
/// <param name="instanceId"></param> /// <param name="instanceId"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="computerName"></param>
/// <param name="protocol"></param>
/// <returns></returns> /// <returns></returns>
internal PSObject AddObjectToCache( internal PSObject AddObjectToCache(
CimSession session, CimSession session,
UInt32 sessionId, uint sessionId,
Guid instanceId, Guid instanceId,
string name, string name,
string computerName, string computerName,
@ -434,11 +436,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
string message = string.Empty; string message = string.Empty;
if (psObject.BaseObject is CimSession) if (psObject.BaseObject is CimSession)
{ {
UInt32 id = 0x0; uint id = 0x0;
Guid instanceId = Guid.Empty; Guid instanceId = Guid.Empty;
string name = string.Empty; string name = string.Empty;
string computerName = string.Empty; string computerName = string.Empty;
if (psObject.Properties[idPropName].Value is UInt32) if (psObject.Properties[idPropName].Value is uint)
{ {
id = Convert.ToUInt32(psObject.Properties[idPropName].Value, null); id = Convert.ToUInt32(psObject.Properties[idPropName].Value, null);
} }
@ -466,7 +468,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Remove given <see cref="PSObject"/> object from cache /// Remove given <see cref="PSObject"/> object from cache.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="psObject"></param> /// <param name="psObject"></param>
@ -482,7 +484,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Remove given <see cref="CimSession"/> object from cache /// Remove given <see cref="CimSession"/> object from cache.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="session"></param> /// <param name="session"></param>
@ -562,7 +564,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="ids"></param>
/// <returns>List of session wrapper objects.</returns> /// <returns>List of session wrapper objects.</returns>
internal IEnumerable<PSObject> QuerySession(IEnumerable<UInt32> ids, internal IEnumerable<PSObject> QuerySession(
IEnumerable<uint> ids,
out IEnumerable<ErrorRecord> errorRecords) out IEnumerable<ErrorRecord> errorRecords)
{ {
HashSet<PSObject> sessions = new HashSet<PSObject>(); HashSet<PSObject> sessions = new HashSet<PSObject>();
@ -570,7 +573,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
List<ErrorRecord> errRecords = new List<ErrorRecord>(); List<ErrorRecord> errRecords = new List<ErrorRecord>();
errorRecords = errRecords; errorRecords = errRecords;
// NOTES: use template function to implement this will save duplicate code // NOTES: use template function to implement this will save duplicate code
foreach (UInt32 id in ids) foreach (uint id in ids)
{ {
if (this.curCimSessionsById.ContainsKey(id)) if (this.curCimSessionsById.ContainsKey(id))
{ {
@ -594,7 +597,8 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// </summary> /// </summary>
/// <param name="instanceIds"></param> /// <param name="instanceIds"></param>
/// <returns>List of session wrapper objects.</returns> /// <returns>List of session wrapper objects.</returns>
internal IEnumerable<PSObject> QuerySession(IEnumerable<Guid> instanceIds, internal IEnumerable<PSObject> QuerySession(
IEnumerable<Guid> instanceIds,
out IEnumerable<ErrorRecord> errorRecords) out IEnumerable<ErrorRecord> errorRecords)
{ {
HashSet<PSObject> sessions = new HashSet<PSObject>(); HashSet<PSObject> sessions = new HashSet<PSObject>();
@ -781,7 +785,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#region constructor #region constructor
/// <summary> /// <summary>
/// Constructor. /// The constructor.
/// </summary> /// </summary>
public CimSessionBase() public CimSessionBase()
{ {
@ -814,7 +818,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Default runspace id /// Default runspace Id.
/// </para> /// </para>
/// </summary> /// </summary>
internal static Guid defaultRunspaceId = Guid.Empty; internal static Guid defaultRunspaceId = Guid.Empty;
@ -855,7 +859,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// clean up the dictionaries if the runspace is closed or broken. /// Clean up the dictionaries if the runspace is closed or broken.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="sender">Runspace.</param> /// <param name="sender">Runspace.</param>
@ -905,7 +909,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
{ {
/// <summary> /// <summary>
/// <para> /// <para>
/// Constructor /// The constructor.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="theProxy"></param> /// <param name="theProxy"></param>
@ -920,7 +924,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
} }
/// <summary> /// <summary>
/// <para>namespace</para> /// <para>Namespace</para>
/// </summary> /// </summary>
internal CimSessionWrapper CimSessionWrapper internal CimSessionWrapper CimSessionWrapper
{ {
@ -935,7 +939,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// constructor /// The constructor.
/// </para> /// </para>
/// </summary> /// </summary>
internal CimNewSession() : base() internal CimNewSession() : base()
@ -988,7 +992,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Add session to global cache /// Add session to global cache,
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="cimSession"></param> /// <param name="cimSession"></param>
@ -999,7 +1003,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
DebugHelper.WriteLogEx(); DebugHelper.WriteLogEx();
CimTestCimSessionContext testCimSessionContext = context as CimTestCimSessionContext; CimTestCimSessionContext testCimSessionContext = context as CimTestCimSessionContext;
UInt32 sessionId = this.sessionState.GenerateSessionId(); uint sessionId = this.sessionState.GenerateSessionId();
string originalSessionName = testCimSessionContext.CimSessionWrapper.Name; string originalSessionName = testCimSessionContext.CimSessionWrapper.Name;
string sessionName = (originalSessionName != null) ? originalSessionName : string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId); string sessionName = (originalSessionName != null) ? originalSessionName : string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId);
@ -1017,11 +1021,11 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// process all actions in the action queue /// Process all actions in the action queue.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="cmdletOperation"> /// <param name="cmdletOperation">
/// wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details /// Wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details.
/// </param> /// </param>
public void ProcessActions(CmdletOperationBase cmdletOperation) public void ProcessActions(CmdletOperationBase cmdletOperation)
{ {
@ -1030,12 +1034,12 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// process remaining actions until all operations are completed or /// Process remaining actions until all operations are completed or
/// current cmdlet is terminated by user /// current cmdlet is terminated by user.
/// </para> /// </para>
/// </summary> /// </summary>
/// <param name="cmdletOperation"> /// <param name="cmdletOperation">
/// wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details /// Wrapper of cmdlet, <seealso cref="CmdletOperationBase"/> for details.
/// </param> /// </param>
public void ProcessRemainActions(CmdletOperationBase cmdletOperation) public void ProcessRemainActions(CmdletOperationBase cmdletOperation)
{ {
@ -1055,7 +1059,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Indicates whether this object was disposed or not /// Indicates whether this object was disposed or not.
/// </para> /// </para>
/// </summary> /// </summary>
protected bool Disposed protected bool Disposed
@ -1120,13 +1124,13 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Get CimSession based on given id/instanceid/computername/name /// Get CimSession based on given id/instanceid/computername/name.
/// </para> /// </para>
/// </summary> /// </summary>
internal class CimGetSession : CimSessionBase internal class CimGetSession : CimSessionBase
{ {
/// <summary> /// <summary>
/// Constructor. /// The constructor.
/// </summary> /// </summary>
public CimGetSession() : base() public CimGetSession() : base()
{ {
@ -1197,7 +1201,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Get CimSession based on given id/instanceid/computername/name /// Get CimSession based on given id/instanceid/computername/name.
/// </para> /// </para>
/// </summary> /// </summary>
internal class CimRemoveSession : CimSessionBase internal class CimRemoveSession : CimSessionBase

View file

@ -44,7 +44,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// <para> /// <para>
/// Session proxy /// Session proxy.
/// </para> /// </para>
/// </summary> /// </summary>
internal CimSessionProxy Proxy internal CimSessionProxy Proxy
@ -60,7 +60,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// <summary> /// <summary>
/// Class provides all information regarding the /// Class provides all information regarding the
/// current invocation to .net api. /// current invocation to the .NET API.
/// </summary> /// </summary>
internal class InvocationContext internal class InvocationContext
{ {

View file

@ -1,5 +1,5 @@
# libpsl-native # libpsl-native
The code under `libpsl-native` is being migrated to [PowerShell-native](https://github.com/PowerShell/PowerShell-native) repository. The code under `libpsl-native` is being migrated to the [PowerShell-native](https://github.com/PowerShell/PowerShell-native) repository.
Please make PRs to the new repository. Please make PRs to the new repository.
Code under here will be removed once the move is complete. Code under here will be removed once the move is complete.