diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimBaseAction.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimBaseAction.cs
index 939f6c047a5..a635e5ae765 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimBaseAction.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimBaseAction.cs
@@ -44,20 +44,7 @@ public virtual void Execute(CmdletOperationBase cmdlet)
/// , object.
///
///
- protected XOperationContextBase Context
- {
- get
- {
- return this.context;
- }
-
- set
- {
- this.context = value;
- }
- }
-
- private XOperationContextBase context;
+ protected XOperationContextBase Context { get; set; }
}
///
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs
index b138c01b806..4744e319c3e 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs
@@ -31,35 +31,19 @@ internal class ParameterDefinitionEntry
///
internal ParameterDefinitionEntry(string parameterSetName, bool mandatory)
{
- this.mandatory = mandatory;
- this.parameterSetName = parameterSetName;
+ this.IsMandatory = mandatory;
+ this.ParameterSetName = parameterSetName;
}
///
/// Property ParameterSetName.
///
- internal string ParameterSetName
- {
- get
- {
- return this.parameterSetName;
- }
- }
-
- private readonly string parameterSetName = null;
+ internal string ParameterSetName { get; } = null;
///
/// Whether the parameter is mandatory to the set.
///
- internal bool IsMandatory
- {
- get
- {
- return this.mandatory;
- }
- }
-
- private readonly bool mandatory = false;
+ internal bool IsMandatory { get; } = false;
}
///
@@ -75,8 +59,8 @@ internal class ParameterSetEntry
///
internal ParameterSetEntry(UInt32 mandatoryParameterCount)
{
- this.mandatoryParameterCount = mandatoryParameterCount;
- this.isDefaultParameterSet = false;
+ this.MandatoryParameterCount = mandatoryParameterCount;
+ this.IsDefaultParameterSet = false;
reset();
}
@@ -86,8 +70,8 @@ internal ParameterSetEntry(UInt32 mandatoryParameterCount)
///
internal ParameterSetEntry(ParameterSetEntry toClone)
{
- this.mandatoryParameterCount = toClone.MandatoryParameterCount;
- this.isDefaultParameterSet = toClone.IsDefaultParameterSet;
+ this.MandatoryParameterCount = toClone.MandatoryParameterCount;
+ this.IsDefaultParameterSet = toClone.IsDefaultParameterSet;
reset();
}
@@ -98,8 +82,8 @@ internal ParameterSetEntry(ParameterSetEntry toClone)
///
internal ParameterSetEntry(UInt32 mandatoryParameterCount, bool isDefault)
{
- this.mandatoryParameterCount = mandatoryParameterCount;
- this.isDefaultParameterSet = isDefault;
+ this.MandatoryParameterCount = mandatoryParameterCount;
+ this.IsDefaultParameterSet = isDefault;
reset();
}
@@ -108,107 +92,39 @@ internal ParameterSetEntry(UInt32 mandatoryParameterCount, bool isDefault)
///
internal void reset()
{
- this.setMandatoryParameterCount = this.setMandatoryParameterCountAtBeginProcess;
- this.isValueSet = this.isValueSetAtBeginProcess;
+ this.SetMandatoryParameterCount = this.SetMandatoryParameterCountAtBeginProcess;
+ this.IsValueSet = this.IsValueSetAtBeginProcess;
}
///
/// Property DefaultParameterSet
///
- internal bool IsDefaultParameterSet
- {
- get
- {
- return this.isDefaultParameterSet;
- }
- }
-
- private readonly bool isDefaultParameterSet = false;
+ internal bool IsDefaultParameterSet { get; } = false;
///
/// Property MandatoryParameterCount
///
- internal UInt32 MandatoryParameterCount
- {
- get
- {
- return this.mandatoryParameterCount;
- }
- }
-
- private readonly UInt32 mandatoryParameterCount = 0;
+ internal UInt32 MandatoryParameterCount { get; } = 0;
///
/// Property IsValueSet
///
- internal bool IsValueSet
- {
- get
- {
- return this.isValueSet;
- }
-
- set
- {
- this.isValueSet = value;
- }
- }
-
- private bool isValueSet = false;
+ internal bool IsValueSet { get; set; } = false;
///
/// Property IsValueSetAtBeginProcess
///
- internal bool IsValueSetAtBeginProcess
- {
- get
- {
- return this.isValueSetAtBeginProcess;
- }
-
- set
- {
- this.isValueSetAtBeginProcess = value;
- }
- }
-
- private bool isValueSetAtBeginProcess = false;
+ internal bool IsValueSetAtBeginProcess { get; set; } = false;
///
/// Property SetMandatoryParameterCount
///
- internal UInt32 SetMandatoryParameterCount
- {
- get
- {
- return this.setMandatoryParameterCount;
- }
-
- set
- {
- this.setMandatoryParameterCount = value;
- }
- }
-
- private UInt32 setMandatoryParameterCount = 0;
+ internal UInt32 SetMandatoryParameterCount { get; set; } = 0;
///
/// Property SetMandatoryParameterCountAtBeginProcess
///
- internal UInt32 SetMandatoryParameterCountAtBeginProcess
- {
- get
- {
- return this.setMandatoryParameterCountAtBeginProcess;
- }
-
- set
- {
- this.setMandatoryParameterCountAtBeginProcess = value;
- }
- }
-
- private UInt32 setMandatoryParameterCountAtBeginProcess = 0;
+ internal UInt32 SetMandatoryParameterCountAtBeginProcess { get; set; } = 0;
}
///
@@ -531,7 +447,7 @@ internal void CheckParameterSet()
{
try
{
- this.parameterSetName = this.parameterBinder.GetParameterSet();
+ this.ParameterSetName = this.parameterBinder.GetParameterSet();
}
finally
{
@@ -539,7 +455,7 @@ internal void CheckParameterSet()
}
}
- DebugHelper.WriteLog("current parameterset is: " + this.parameterSetName, 4);
+ DebugHelper.WriteLog("current parameterset is: " + this.ParameterSetName, 4);
}
///
@@ -689,13 +605,6 @@ protected virtual void DisposeInternal()
///
private readonly object myLock = new();
- ///
- ///
- /// parameter set name
- ///
- ///
- private string parameterSetName;
-
///
/// This flag is introduced to resolve the parameter set name
/// during process record
@@ -747,13 +656,7 @@ internal CimAsyncOperation AsyncOperation
/// Get current ParameterSetName of the cmdlet
///
///
- internal string ParameterSetName
- {
- get
- {
- return this.parameterSetName;
- }
- }
+ internal string ParameterSetName { get; private set; }
///
/// Gets/Sets cmdlet operation wrapper object.
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetCimClass.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetCimClass.cs
index 1901b12ed83..c8284051335 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetCimClass.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetCimClass.cs
@@ -30,10 +30,10 @@ internal CimGetCimClassContext(
string thePropertyName,
string theQualifierName)
{
- this.className = theClassName;
- this.methodName = theMethodName;
- this.propertyName = thePropertyName;
- this.qualifierName = theQualifierName;
+ this.ClassName = theClassName;
+ this.MethodName = theMethodName;
+ this.PropertyName = thePropertyName;
+ this.QualifierName = theQualifierName;
}
///
@@ -44,14 +44,7 @@ internal CimGetCimClassContext(
/// Wildcard expansion should be allowed.
///
///
- public string ClassName
- {
- get { return className; }
-
- set { className = value; }
- }
-
- private string className;
+ public string ClassName { get; set; }
///
///
@@ -60,12 +53,7 @@ public string ClassName
/// Then Filter the by given methodname
///
///
- internal string MethodName
- {
- get { return methodName; }
- }
-
- private readonly string methodName;
+ internal string MethodName { get; }
///
///
@@ -74,12 +62,7 @@ internal string MethodName
/// Filter the by given property name.
///
///
- internal string PropertyName
- {
- get { return propertyName; }
- }
-
- private readonly string propertyName;
+ internal string PropertyName { get; }
///
///
@@ -88,12 +71,7 @@ internal string PropertyName
/// Filter the by given methodname
///
///
- internal string QualifierName
- {
- get { return qualifierName; }
- }
-
- private readonly string qualifierName;
+ internal string QualifierName { get; }
}
///
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimIndicationWatcher.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimIndicationWatcher.cs
index f64316bd6c7..88f7cd3e89c 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimIndicationWatcher.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimIndicationWatcher.cs
@@ -45,15 +45,7 @@ public class CimIndicationEventExceptionEventArgs : CimIndicationEventArgs
/// Returns an exception
///
///
- public Exception Exception
- {
- get
- {
- return exception;
- }
- }
-
- private readonly Exception exception;
+ public Exception Exception { get; }
///
///
@@ -64,7 +56,7 @@ public Exception Exception
public CimIndicationEventExceptionEventArgs(Exception theException)
{
context = null;
- this.exception = theException;
+ this.Exception = theException;
}
}
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimInvokeCimMethod.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimInvokeCimMethod.cs
index 8030111fa90..3ebfe9f5a73 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimInvokeCimMethod.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimInvokeCimMethod.cs
@@ -40,36 +40,20 @@ internal CimInvokeCimMethodContext(string theNamespace,
CimSessionProxy theProxy)
{
this.proxy = theProxy;
- this.methodName = theMethodName;
- this.collection = theCollection;
+ this.MethodName = theMethodName;
+ this.ParametersCollection = theCollection;
this.nameSpace = theNamespace;
}
///
/// namespace
///
- internal string MethodName
- {
- get
- {
- return this.methodName;
- }
- }
-
- private readonly string methodName;
+ internal string MethodName { get; }
///
/// parameters collection
///
- internal CimMethodParametersCollection ParametersCollection
- {
- get
- {
- return this.collection;
- }
- }
-
- private readonly CimMethodParametersCollection collection;
+ internal CimMethodParametersCollection ParametersCollection { get; }
}
///
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimPromptUser.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimPromptUser.cs
index 98fb4ed3fc8..c70de0029b6 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimPromptUser.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimPromptUser.cs
@@ -27,7 +27,7 @@ internal sealed class CimPromptUser : CimSyncAction
public CimPromptUser(string message,
CimPromptType prompt)
{
- this.message = message;
+ this.Message = message;
this.prompt = prompt;
}
@@ -54,7 +54,7 @@ public override void Execute(CmdletOperationBase cmdlet)
// NOTES: prepare the whatif message and caption
try
{
- result = cmdlet.ShouldContinue(message, "caption", ref yestoall, ref notoall);
+ result = cmdlet.ShouldContinue(Message, "caption", ref yestoall, ref notoall);
if (yestoall)
{
this.responseType = CimResponseType.YesToAll;
@@ -87,7 +87,7 @@ public override void Execute(CmdletOperationBase cmdlet)
case CimPromptType.Normal:
try
{
- result = cmdlet.ShouldProcess(message);
+ result = cmdlet.ShouldProcess(Message);
if (result)
{
this.responseType = CimResponseType.Yes;
@@ -121,15 +121,7 @@ public override void Execute(CmdletOperationBase cmdlet)
///
/// Prompt message.
///
- public string Message
- {
- get
- {
- return message;
- }
- }
-
- private readonly string message;
+ public string Message { get; }
///
/// Prompt type -Normal or Critical.
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs
index ed547444adc..8dd054698a8 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs
@@ -47,15 +47,7 @@ internal class CimSubscriptionResultEventArgs : CimSubscriptionEventArgs
/// subscription result
///
///
- public CimSubscriptionResult Result
- {
- get
- {
- return result;
- }
- }
-
- private readonly CimSubscriptionResult result;
+ public CimSubscriptionResult Result { get; }
///
/// Constructor
@@ -65,7 +57,7 @@ public CimSubscriptionResultEventArgs(
CimSubscriptionResult theResult)
{
this.context = null;
- this.result = theResult;
+ this.Result = theResult;
}
}
@@ -81,15 +73,7 @@ internal class CimSubscriptionExceptionEventArgs : CimSubscriptionEventArgs
/// subscription result
///
///
- public Exception Exception
- {
- get
- {
- return exception;
- }
- }
-
- private readonly Exception exception;
+ public Exception Exception { get; }
///
/// Constructor
@@ -99,7 +83,7 @@ public CimSubscriptionExceptionEventArgs(
Exception theException)
{
this.context = null;
- this.exception = theException;
+ this.Exception = theException;
}
}
@@ -219,7 +203,7 @@ private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actio
CimWriteError cimWriteError = actionArgs.Action as CimWriteError;
if (cimWriteError != null)
{
- this.exception = cimWriteError.Exception;
+ this.Exception = cimWriteError.Exception;
if (!this.ackedEvent.IsSet)
{
// an exception happened
@@ -233,10 +217,10 @@ private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actio
{
DebugHelper.WriteLog("Raise an exception event", 2);
- temp(this, new CimSubscriptionExceptionEventArgs(this.exception));
+ temp(this, new CimSubscriptionExceptionEventArgs(this.Exception));
}
- DebugHelper.WriteLog("Got an exception: {0}", 2, exception);
+ DebugHelper.WriteLog("Got an exception: {0}", 2, Exception);
}
CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject;
@@ -276,7 +260,7 @@ private void WaitForAckMessage()
{
DebugHelper.WriteLogEx();
this.ackedEvent.Wait();
- if (this.exception != null)
+ if (this.Exception != null)
{
DebugHelper.WriteLogEx("error happened", 0);
if (this.Cmdlet != null)
@@ -285,14 +269,14 @@ private void WaitForAckMessage()
// throw terminating error
ErrorRecord errorRecord = ErrorToErrorRecord.ErrorRecordFromAnyException(
- new InvocationContext(this.TargetComputerName, null), this.exception, null);
+ new InvocationContext(this.TargetComputerName, null), this.Exception, null);
this.Cmdlet.ThrowTerminatingError(errorRecord);
}
else
{
DebugHelper.WriteLogEx("Throw exception", 1);
// throw exception out
- throw this.exception;
+ throw this.Exception;
}
}
@@ -363,15 +347,7 @@ private CimSessionProxy CreateSessionProxy(
///
/// Exception occurred while start the subscription.
///
- internal Exception Exception
- {
- get
- {
- return exception;
- }
- }
-
- private Exception exception;
+ internal Exception Exception { get; private set; }
#endregion
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs
index 19040bfa3e4..72f14982f2e 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs
@@ -37,21 +37,13 @@ internal class CimResultContext
///
internal CimResultContext(object ErrorSource)
{
- this.errorSource = ErrorSource;
+ this.ErrorSource = ErrorSource;
}
///
/// ErrorSource property.
///
- internal object ErrorSource
- {
- get
- {
- return this.errorSource;
- }
- }
-
- private readonly object errorSource;
+ internal object ErrorSource { get; }
}
#endregion
@@ -228,7 +220,7 @@ internal class CimResultObserver : IObserver
/// Operation that can be observed.
public CimResultObserver(CimSession session, IObservable