@@ -123,7 +123,7 @@ internal ClassProperty ReadClassProperty()
123
123
return new ClassProperty { Name = name , PropertyType = propertyType , Value = propsInType } ;
124
124
}
125
125
126
- internal EnumProperty ReadEnumProperty ( )
126
+ internal IProperty ReadEnumProperty ( )
127
127
{
128
128
var name = _reader . GetRequiredAttribute ( "name" ) ;
129
129
var propertyType = _reader . GetRequiredAttribute ( "propertytype" ) ;
@@ -132,25 +132,22 @@ internal EnumProperty ReadEnumProperty()
132
132
"string" => PropertyType . String ,
133
133
"int" => PropertyType . Int ,
134
134
_ => throw new XmlException ( "Invalid property type" )
135
- } ) ?? PropertyType . String ;
135
+ } ) . GetValueOr ( PropertyType . String ) ;
136
136
var customTypeDef = _customTypeResolver ( propertyType ) ;
137
137
138
138
// If the custom enum definition is not found,
139
139
// we assume an empty enum definition.
140
140
if ( ! customTypeDef . HasValue )
141
141
{
142
- if ( typeInXml == PropertyType . String )
142
+ #pragma warning disable CS8509 // The switch expression does not handle all possible values of its input type (it is not exhaustive).
143
+ #pragma warning disable IDE0072 // Add missing cases
144
+ return typeInXml switch
143
145
{
144
- var value = _reader . GetRequiredAttribute ( "value" ) ;
145
- var values = value . Split ( ',' ) . Select ( v => v . Trim ( ) ) . ToHashSet ( ) ;
146
- return new EnumProperty { Name = name , PropertyType = propertyType , Value = values } ;
147
- }
148
- else
149
- {
150
- var value = _reader . GetRequiredAttributeParseable < int > ( "value" ) ;
151
- var values = new HashSet < string > { value . ToString ( CultureInfo . InvariantCulture ) } ;
152
- return new EnumProperty { Name = name , PropertyType = propertyType , Value = values } ;
153
- }
146
+ PropertyType . String => new StringProperty { Name = name , Value = _reader . GetRequiredAttribute ( "value" ) } ,
147
+ PropertyType . Int => new IntProperty { Name = name , Value = _reader . GetRequiredAttributeParseable < int > ( "value" ) } ,
148
+ } ;
149
+ #pragma warning restore IDE0072 // Add missing cases
150
+ #pragma warning restore CS8509 // The switch expression does not handle all possible values of its input type (it is not exhaustive).
154
151
}
155
152
156
153
if ( customTypeDef . Value is not CustomEnumDefinition ced )
0 commit comments