Closed
Description
Description
We initialized hashset with case insensitive in object, we used system.text.json deserialize content from json file to object.
Noticed that Hashset was case sensitive, not insensitive as expected
Reproduction Steps
public class Config
{
public HashSet<string>Set {get; set;}
public Config(){
Set = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
}
// json contains a list of string.
public class initialize
{
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
Config config = JsonSerializer.Deserialize<Config>(json, options);
}
Expected behavior
expected to be case insensitive.
Actual behavior
HashSet is case sensitive
Regression?
No response
Known Workarounds
public class Config
{
public HashSet<string>Set {get;}
public Config(HashSet<string> set){
Set = new HashSet<string>(set, StringComparer.OrdinalIgnoreCase);
}
// json contains a list of string.
public class initialize
{
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
Config config = JsonSerializer.Deserialize<Config>(json, options);
}
Configuration
No response
Other information
No response