Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Don't re-use XmlSchemaSet - it's not threadsafe. #74564

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ internal class SchemaUtils
static XmlWriterSettings writerSettings = new XmlWriterSettings() { Indent = true };

#region Test Data
internal static XmlSchemaSet PositiveSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
new string[] {
private static string[] _positiveSchemas = new string[] {
@"<?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'>
<complexType name='ValidType'><sequence><element name='member' nillable='true' type='string' /></sequence></complexType>
<element name='ValidType' nillable='true' type='tns:ValidType' />
Expand All @@ -30,10 +29,10 @@ internal class SchemaUtils
<complexType name='NonAttributedSquare'><sequence><element minOccurs='0' name='Length' type='int' /></sequence></complexType>
<element name='NonAttributedSquare' nillable='true' type='tns:NonAttributedSquare' />
</schema>",
});
};
internal static XmlSchemaSet PositiveSchemas => ReadStringsIntoSchemaSet(_positiveSchemas);

internal static XmlSchemaSet IsReferenceSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
new string[] {
private static string[] _isReferenceSchemas = new string[] {
@"<?xml version='1.0' encoding='utf-8'?>
<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'>
<xs:import namespace='http://schemas.microsoft.com/2003/10/Serialization/' />
Expand All @@ -53,10 +52,10 @@ internal class SchemaUtils
</xs:sequence>
</xs:complexType>
</xs:schema>",
});
};
internal static XmlSchemaSet IsReferenceSchemas => ReadStringsIntoSchemaSet(_isReferenceSchemas);

internal static XmlSchemaSet MixedSchemas = SchemaUtils.ReadStringsIntoSchemaSet(
new string[] {
private static string[] _mixedSchemas = new string[] {
@"<?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'>
<complexType name='InvalidType'><all /></complexType>
<element name='InvalidType' nillable='true' type='tns:InvalidType' />
Expand All @@ -67,7 +66,8 @@ internal class SchemaUtils
<complexType name='AnotherValidType'><sequence><element name='member' nillable='true' type='string' minOccurs='0' /></sequence></complexType>
<element name='AnotherValidType' nillable='true' type='tns:AnotherValidType' />
</schema>",
});
};
internal static XmlSchemaSet MixedSchemas => ReadStringsIntoSchemaSet(_mixedSchemas);

internal static string[] NegativeSchemaStrings =
new string[] {
Expand Down