Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorMitchell Hwang <mitchhwang1418@gmail.com>2020-04-23 16:00:35 +0300
committerGitHub <noreply@github.com>2020-04-23 16:00:35 +0300
commit946a479729fa218ddbfca3f3e19a97a1a3a2ac1a (patch)
tree31f7ca2c31d309333b3b94d4781efc213d5ac463 /mcs
parent72b3c27759c10053d191ed275092031bfdc1a3ac (diff)
[System.Runtime.Serialization] Work around `specified cast is not valid` error (#19620)
During json serialization, if the key was an enum type, then it would fail trying to cast into an XmlDictionaryString. The fix is to treat the enum value like a string.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Runtime.Serialization/ReferenceSources/JsonFormatWriterGenerator_static.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/mcs/class/System.Runtime.Serialization/ReferenceSources/JsonFormatWriterGenerator_static.cs b/mcs/class/System.Runtime.Serialization/ReferenceSources/JsonFormatWriterGenerator_static.cs
index 90f038bccd2..b9c0e7886cc 100644
--- a/mcs/class/System.Runtime.Serialization/ReferenceSources/JsonFormatWriterGenerator_static.cs
+++ b/mcs/class/System.Runtime.Serialization/ReferenceSources/JsonFormatWriterGenerator_static.cs
@@ -423,8 +423,10 @@ namespace System.Runtime.Serialization.Json
XmlDictionaryString namespaceLocal = null;
if (nameLocal != null && nameLocal is string)
writer.WriteStartElement ((string) name, null);
- else
+ else if (name is XmlDictionaryString)
writer.WriteStartElement ((XmlDictionaryString) name, null);
+ else
+ writer.WriteStartElement (name.ToString(), null);
}
void WriteEndElement ()