@@ -8,7 +8,7 @@ public class PesterConfigurationDeserializer : PSTypeConverter
88{
99 public override bool CanConvertFrom ( object sourceValue , Type destinationType )
1010 {
11- if ( ! ( sourceValue is PSObject ) )
11+ if ( sourceValue is not PSObject )
1212 return false ;
1313
1414 return ( ( PSObject ) sourceValue ) . TypeNames . Contains ( "Deserialized.PesterConfiguration" ) ;
@@ -31,15 +31,15 @@ public override object ConvertTo(object sourceValue, Type destinationType, IForm
3131
3232 private PesterConfiguration ConvertToPesterConfiguration ( object sourceValue )
3333 {
34- if ( sourceValue is IDictionary )
35- return new PesterConfiguration ( ( IDictionary ) sourceValue ) ;
34+ if ( sourceValue is IDictionary dictionary )
35+ return new PesterConfiguration ( dictionary ) ;
3636
3737 return new PesterConfiguration ( ConvertToConfigurationHashtable ( ( PSObject ) sourceValue ) ) ;
3838 }
3939
4040 private Hashtable ConvertToConfigurationHashtable ( PSObject sourceConfiguration )
4141 {
42- Hashtable configuration = new Hashtable ( ) ;
42+ Hashtable configuration = new ( ) ;
4343
4444 foreach ( var property in sourceConfiguration . Properties )
4545 {
@@ -57,18 +57,18 @@ private Hashtable ConvertToConfigurationHashtable(PSObject sourceConfiguration)
5757
5858 private Hashtable ConvertToSectionHashtable ( PSObject sourceSection , string sectionName )
5959 {
60- Hashtable configurationSection = new Hashtable ( ) ;
60+ Hashtable configurationSection = new ( ) ;
6161
6262 foreach ( var property in sourceSection . Properties )
6363 {
6464 var IsModified = ( ( PSObject ) property . Value ) . Properties [ "IsModified" ] ;
65-
65+
6666 // Doing this instead of IsModified -> Add to be compatible with saved PesterConfigurations from previous versions
6767 // Consider rewriting in next major release
6868 if ( IsModified != null && ! ( ( bool ) IsModified . Value ) ) {
6969 continue ;
7070 }
71-
71+
7272 configurationSection . Add (
7373 property . Name ,
7474 GetPropertyValue (
@@ -86,8 +86,8 @@ private object GetPropertyValue(PSObject sourceItem, string sectionName, string
8686 {
8787 var value = sourceItem . Properties [ "Value" ] . Value ;
8888
89- if ( value is PSObject )
90- value = ( ( PSObject ) value ) . BaseObject ;
89+ if ( value is PSObject pso )
90+ value = pso . BaseObject ;
9191
9292 if ( value == null )
9393 return null ;
@@ -96,7 +96,7 @@ private object GetPropertyValue(PSObject sourceItem, string sectionName, string
9696
9797 if ( expectedType == typeof ( ScriptBlock [ ] ) )
9898 {
99- ArrayList scriptBlocks = new ArrayList ( ) ;
99+ ArrayList scriptBlocks = new ( ) ;
100100 foreach ( string scriptBlock in ( ArrayList ) value )
101101 {
102102 scriptBlocks . Add ( ScriptBlock . Create ( scriptBlock ) ) ;
@@ -106,7 +106,7 @@ private object GetPropertyValue(PSObject sourceItem, string sectionName, string
106106
107107 if ( expectedType == typeof ( ContainerInfo [ ] ) )
108108 {
109- ArrayList containers = new ArrayList ( ) ;
109+ ArrayList containers = new ( ) ;
110110 foreach ( PSObject container in ( ArrayList ) value )
111111 {
112112 var containerInfo = Pester . ContainerInfo . Create ( ) ;
@@ -119,8 +119,8 @@ private object GetPropertyValue(PSObject sourceItem, string sectionName, string
119119 value = containers ;
120120 }
121121
122- if ( value is ArrayList )
123- value = ( ( ArrayList ) value ) . ToArray ( ) ;
122+ if ( value is ArrayList list )
123+ value = list . ToArray ( ) ;
124124
125125 return value ;
126126 }
0 commit comments