Skip to content

Commit 71b27a5

Browse files
Don't re-use XmlSchemaSet - it's not threadsafe. (#74564)
Co-authored-by: Steve Molloy <smolloy@microsoft.com>
1 parent f170c1a commit 71b27a5

File tree

1 file changed

+9
-9
lines changed
  • src/libraries/System.Runtime.Serialization.Schema/tests/System/Runtime/Serialization/Schema

1 file changed

+9
-9
lines changed

src/libraries/System.Runtime.Serialization.Schema/tests/System/Runtime/Serialization/Schema/SchemaUtils.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ internal class SchemaUtils
1414
static XmlWriterSettings writerSettings = new XmlWriterSettings() { Indent = true };
1515

1616
#region Test Data
17-
internal static XmlSchemaSet PositiveSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
18-
new string[] {
17+
private static string[] _positiveSchemas = new string[] {
1918
@"<?xml version='1.0' encoding='utf-8'?><schema elementFormDefault='qualified' targetNamespace='http://schemas.datacontract.org/2004/07/fooNs' xmlns:tns='http://schemas.datacontract.org/2004/07/fooNs' xmlns:ser='http://schemas.microsoft.com/2003/10/Serialization/' xmlns='http://www.w3.org/2001/XMLSchema'>
2019
<complexType name='ValidType'><sequence><element name='member' nillable='true' type='string' /></sequence></complexType>
2120
<element name='ValidType' nillable='true' type='tns:ValidType' />
@@ -30,10 +29,10 @@ internal class SchemaUtils
3029
<complexType name='NonAttributedSquare'><sequence><element minOccurs='0' name='Length' type='int' /></sequence></complexType>
3130
<element name='NonAttributedSquare' nillable='true' type='tns:NonAttributedSquare' />
3231
</schema>",
33-
});
32+
};
33+
internal static XmlSchemaSet PositiveSchemas => ReadStringsIntoSchemaSet(_positiveSchemas);
3434

35-
internal static XmlSchemaSet IsReferenceSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
36-
new string[] {
35+
private static string[] _isReferenceSchemas = new string[] {
3736
@"<?xml version='1.0' encoding='utf-8'?>
3837
<xs:schema xmlns:tns='http://schemas.datacontract.org/2004/07/Suites.SchemaImport.ReferencedTypes' xmlns:ser='http://schemas.microsoft.com/2003/10/Serialization/' elementFormDefault='qualified' targetNamespace='http://schemas.datacontract.org/2004/07/Suites.SchemaImport.ReferencedTypes' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
3938
<xs:import namespace='http://schemas.microsoft.com/2003/10/Serialization/' />
@@ -53,10 +52,10 @@ internal class SchemaUtils
5352
</xs:sequence>
5453
</xs:complexType>
5554
</xs:schema>",
56-
});
55+
};
56+
internal static XmlSchemaSet IsReferenceSchemas => ReadStringsIntoSchemaSet(_isReferenceSchemas);
5757

58-
internal static XmlSchemaSet MixedSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
59-
new string[] {
58+
private static string[] _mixedSchemas = new string[] {
6059
@"<?xml version='1.0' encoding='utf-8'?><schema elementFormDefault='qualified' targetNamespace='http://schemas.datacontract.org/2004/07/fooNs' xmlns:tns='http://schemas.datacontract.org/2004/07/fooNs' xmlns:ser='http://schemas.microsoft.com/2003/10/Serialization/' xmlns='http://www.w3.org/2001/XMLSchema'>
6160
<complexType name='InvalidType'><all /></complexType>
6261
<element name='InvalidType' nillable='true' type='tns:InvalidType' />
@@ -67,7 +66,8 @@ internal class SchemaUtils
6766
<complexType name='AnotherValidType'><sequence><element name='member' nillable='true' type='string' minOccurs='0' /></sequence></complexType>
6867
<element name='AnotherValidType' nillable='true' type='tns:AnotherValidType' />
6968
</schema>",
70-
});
69+
};
70+
internal static XmlSchemaSet MixedSchemas => ReadStringsIntoSchemaSet(_mixedSchemas);
7171

7272
internal static string[] NegativeSchemaStrings =
7373
new string[] {

0 commit comments

Comments
 (0)