From f590357340b5b6da5f1ab7ca7b1de25ad4dc59f2 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 20 Mar 2020 13:31:49 -0600 Subject: [PATCH 01/33] Added test for Issue 30218, use of resource Sch_MinLengthGtBaseMinLength --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 80842b9b2d4ad..c44e6c5bda90e 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -176,5 +176,48 @@ public void FractionDigitsMismatch_Throws() Assert.Contains("fractionDigits", ex.Message); Assert.DoesNotContain("totalDigits", ex.Message); } + + /// + /// Test for issue #30218, resource Sch_MinLengthGtBaseMinLength + /// + [Fact] + public void MinLengthGtBaseMinLength_Throws() + { + string schema = @" + + + + + + + + + + + + +"; + + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception exception; + + try + { + ss.Compile(); + exception = null; + } + catch (Exception ex) + { + exception = ex; + } + + Assert.NotNull(exception); + Assert.IsType(exception); + Assert.Equal("Error: 'minLength' is among the facets of {0} and its value ({1}) is less than the value ({2}) of the parent 'minLength'.", + exception.Message); + } } } From 048e2ce775949387492ad2fe463dc4770e92567d Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 20 Mar 2020 14:36:56 -0600 Subject: [PATCH 02/33] Reworded error message to remove the invalid formatters. Issue #30218 --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index e2042282f456a..17f2470ead86e 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1723,7 +1723,7 @@ It is an error if 'length' is among the members of {facets} of {base type definition} and {value} is greater than the {value} of the parent 'length'. - It is an error if 'minLength' is among the members of {facets} of {base type definition} and {value} is less than the {value} of the parent 'minLength'. + It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value. It is an error if 'maxLength' is among the members of {facets} of {base type definition} and {value} is greater than the {value} of the parent 'maxLength'. diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index c44e6c5bda90e..18c634fc2ad75 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -216,7 +216,7 @@ public void MinLengthGtBaseMinLength_Throws() Assert.NotNull(exception); Assert.IsType(exception); - Assert.Equal("Error: 'minLength' is among the facets of {0} and its value ({1}) is less than the value ({2}) of the parent 'minLength'.", + Assert.Equal("It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value.", exception.Message); } } From 0c1c84c7741f42e77d06a378f62bd3618a2155f3 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 30 Mar 2020 06:57:29 -0600 Subject: [PATCH 03/33] Updated check of message from the exception to be more amenable to potential internationalization. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 18c634fc2ad75..7ddaab3258039 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -216,8 +216,7 @@ public void MinLengthGtBaseMinLength_Throws() Assert.NotNull(exception); Assert.IsType(exception); - Assert.Equal("It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value.", - exception.Message); + Assert.Contains("minLength", exception.Message); } } } From ee5bccdf965e564b6cc62ba5da3e199dd2268bdf Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 30 Mar 2020 12:07:12 -0600 Subject: [PATCH 04/33] Reworded resource Sch_MaxLengthGtBaseMaxLength and added unit test for same. --- .../src/Resources/Strings.resx | 4 +- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 17f2470ead86e..a9e65fd222180 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1726,7 +1726,7 @@ It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value. - It is an error if 'maxLength' is among the members of {facets} of {base type definition} and {value} is greater than the {value} of the parent 'maxLength'. + It is an error if the derived 'maxLength' facet value is greater than the parent 'maxLength' facet value. It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of {facets}, unless they are specified in different derivation steps. In which case the following must be true: the {value} of 'minLength' <= the {value} of 'length' <= the {value} of 'maxLength'. @@ -3456,4 +3456,4 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Compiling JScript/CSharp scripts is not supported - + \ No newline at end of file diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 7ddaab3258039..3d8b9186bdad8 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -218,5 +218,47 @@ public void MinLengthGtBaseMinLength_Throws() Assert.IsType(exception); Assert.Contains("minLength", exception.Message); } + + /// + /// Test for issue #30218, resource Sch_MaxLengthGtBaseMaxLength + /// + [Fact] + public void MaxLengthGtBaseMaxLength_Throws() + { + string schema = @" + + + + + + + + + + + + +"; + + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception exception; + + try + { + ss.Compile(); + exception = null; + } + catch (Exception ex) + { + exception = ex; + } + + Assert.NotNull(exception); + Assert.IsType(exception); + Assert.Contains("maxLength", exception.Message); + } } } From 9730c1af691e42797cbb54c3540b25abf3b16982 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 31 Mar 2020 09:42:29 -0600 Subject: [PATCH 05/33] Simplified test code per feedback from Dan Moseley, PR#33890. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 3d8b9186bdad8..bf2e2c075132a 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -202,21 +202,8 @@ public void MinLengthGtBaseMinLength_Throws() XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(null, XmlReader.Create(new StringReader(schema))); - Exception exception; - - try - { - ss.Compile(); - exception = null; - } - catch (Exception ex) - { - exception = ex; - } - - Assert.NotNull(exception); - Assert.IsType(exception); - Assert.Contains("minLength", exception.Message); + Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("minLength", ex.Message); } /// @@ -244,21 +231,8 @@ public void MaxLengthGtBaseMaxLength_Throws() XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(null, XmlReader.Create(new StringReader(schema))); - Exception exception; - - try - { - ss.Compile(); - exception = null; - } - catch (Exception ex) - { - exception = ex; - } - - Assert.NotNull(exception); - Assert.IsType(exception); - Assert.Contains("maxLength", exception.Message); + Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("maxLength", ex.Message); } } } From f883e851c0ce02c436def7c6bf9081e16e2b339c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 31 Mar 2020 15:15:38 -0600 Subject: [PATCH 06/33] Tests to increase code coverage. The ones that are failing trigger resource string Sch_MaxMinLengthBaseLength to be used as the Exception message. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 380 ++++++++++++++++++ 1 file changed, 380 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index bf2e2c075132a..f31d646baf792 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -6,6 +6,8 @@ using Xunit.Abstractions; using System.IO; using System.Xml.Schema; +using System.Collections.Generic; +using System.Text.RegularExpressions; namespace System.Xml.Tests { @@ -234,5 +236,383 @@ public void MaxLengthGtBaseMaxLength_Throws() Exception ex = Assert.Throws(() => ss.Compile()); Assert.Contains("maxLength", ex.Message); } + + #region "Testing presence of minLength or maxLength and Length" + + public static IEnumerable MaxMinLengthBaseLength_ThrowsData + { + get + { + return new List() + { + new object[] + { // minLength and length specified in same derivation step. + @" + + + + + + + + +" + }, + new object[] + { // maxLength and length specified in same derivation step. + @" + + + + + + + + +" + }, + new object[] + { // base type has minLength; derived type has lesser length + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has maxLength; derived type has greater length + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has length; derived type has lesser maxLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has length; derived type has greater minLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has maxLength; derived type has greater length + @" + + + + + + + + + + + + +" + } + }; + } + } + + [Theory] + [MemberData(nameof(MaxMinLengthBaseLength_ThrowsData))] + public void MaxMinLengthBaseLength_Throws(string schema) + { + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("length", ex.Message); + Assert.Contains("minLength", ex.Message); + Assert.Contains("maxLength", ex.Message); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + } + + [Fact] + public void MinLengthGtMaxLength_Throws() + { + string schema = @" + + + + + + + + +"; + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + // The thrown error message has an upper case 'M' in both + // minLength and maxLength. + Assert.Contains("minlength", ex.Message.ToLower()); + Assert.Contains("maxlength", ex.Message.ToLower()); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{[0-9]*[a-zA-Z ]+[^\}]*\}"); + Assert.Empty(rx.Matches(ex.Message)); + } + + public static IEnumerable MaxMinLengthBaseLength_TestData + { + get + { + return new List() + { + new object[] + { // base type has length; derived type has equal maxLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has length; derived type has greater maxLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has length; derived type has equal minLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has length; derived type has lesser minLength + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has minLength; derived type has equal length + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has minLength; derived type has greater length + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has maxLength; derived type has equal length + @" + + + + + + + + + + + + +" + }, + new object[] + { // base type has maxLength; derived type has lesser length + @" + + + + + + + + + + + + +" + }, + new object[] + { // minLength is equal to maxLength + @" + + + + + + + + +" + }, + new object[] + { // minLength is less than maxLength + @" + + + + + + + + +" + } + }; + } + } + + [Theory] + [MemberData(nameof(MaxMinLengthBaseLength_TestData))] + public void MaxMinLengthBaseLength_Test(string schema) + { + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception exception; + try + { + ss.Compile(); + exception = null; + } catch (Exception ex) + { + exception = ex; + } + Assert.Null(exception); + } + + #endregion } } From c008edbfaf50e10dbae772d4b0c340e5e97ce664 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 31 Mar 2020 15:21:06 -0600 Subject: [PATCH 07/33] Removed invalid formatters from the resource string Sch_MaxMinLengthBaseLength. Failing tests from the previous commit now pass. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index a9e65fd222180..4131a54d0934a 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1729,7 +1729,7 @@ It is an error if the derived 'maxLength' facet value is greater than the parent 'maxLength' facet value. - It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of {facets}, unless they are specified in different derivation steps. In which case the following must be true: the {value} of 'minLength' <= the {value} of 'length' <= the {value} of 'maxLength'. + It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of facets, unless they are specified in different derivation steps. In which case the following must be true: the value of 'minLength' <= the value of 'length' <= the value of 'maxLength'. It is an error if the derived 'maxInclusive' facet value is greater than the parent 'maxInclusive' facet value. From ab3244f885d5fa531df162ccf5d75a101d8d091f Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 1 Apr 2020 10:27:33 -0600 Subject: [PATCH 08/33] Added test for the Exception using string resource Sch_LengthGtBaseLength as its message. This covers a source line and branch not previously covered. This test fails due to the invalid formatters. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index f31d646baf792..3ea6e6a9d3fd7 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -612,7 +612,39 @@ public void MaxMinLengthBaseLength_Test(string schema) } Assert.Null(exception); } - #endregion + + /// + /// Test for issue #30218, resource Sch_LengthGtBaseLength + /// + [Fact] + public void LengthGtBaseLength_Throws() + { + string schema = @" + + + + + + + + + + + + +"; + + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("length", ex.Message); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + } } } From 0166ce3c7bcefadb34e8a6604984863aabe598a8 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 1 Apr 2020 10:33:00 -0600 Subject: [PATCH 09/33] Reworded string resource Sch_LengthGtBaseLength to remove the invalid formatters. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 4131a54d0934a..5ae507837d039 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1720,7 +1720,7 @@ Cannot load the schema from the location '{0}' - {1} - It is an error if 'length' is among the members of {facets} of {base type definition} and {value} is greater than the {value} of the parent 'length'. + It is an error if 'length' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'length'. It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value. From 6fe8ecca7853be321522886a48f403860d68a7cd Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 11:16:21 -0600 Subject: [PATCH 10/33] Added unit tests for uses of string resource Sch_FacetBaseFixed. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 306 ++++++++++++++++++ 1 file changed, 306 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 3ea6e6a9d3fd7..da56d4eb1c649 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -646,5 +646,311 @@ public void LengthGtBaseLength_Throws() Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); Assert.Empty(rx.Matches(ex.Message)); } + + #region FacetBaseFixed tests + public static IEnumerable FacetBaseFixed_Throws_TestData + { + get{ + return new List() + { + new object[] + { // length, derived type has larger value. + @" + + + + + + + + + + + + +" + }, + new object[] + { // length, derived type has smaller value + @" + + + + + + + + + + + + +" + }, + new object[] + { // minLength, derived type has larger value. + @" + + + + + + + + + + + + +" + }, + new object[] + { // minLength, derived type has smaller value. + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxLength, derived type has larger value. + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxLength, derived type has larger value. + @" + + + + + + + + + + + + +" + }, + new object[] + { // whiteSpace + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxInclusive, derived type with larger value + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxInclusive, derived type with smaller value + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxExclusive, derived type has larger value + @" + + + + + + + + + + + + +" + }, + new object[] + { // maxExclusive, derived type has smaller value + @" + + + + + + + + + + + + +" + }, + new object[] + { // minExclusive, derived type has larger value + @" + + + + + + + + + + + + +" + }, + new object[] + { // minExclusive, derived type has smaller value + @" + + + + + + + + + + + + +" + }, + new object[] + { // minInclusive, derived type has larger value + @" + + + + + + + + + + + + +" + }, + new object[] + { // minInclusive, derived type has smaller value + @" + + + + + + + + + + + + +" + } + // NOTE: the cases of totalDigits, with larger and smaller + // values are not tested here as Issue 34426 was found + // and will be addressed separately. + // NOTE: the case of fractionDigits with a larger + // value is not tested here as Issue 34413 was found, + // and will be addressed separately. + // NOTE: the case of fractionDigits with a smaller + // value is not tested here as Issue 34418 was found, + // and will be addressed separately. + }; + } + } + + [Theory] + [MemberData(nameof(FacetBaseFixed_Throws_TestData))] + public void FacetBaseFixed_Throws(string schema) + { + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("fixed", ex.Message); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + + } + #endregion } } From 1fe921be1c1568a8f1a7c34b866c84b2a5ca33af Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 11:20:33 -0600 Subject: [PATCH 11/33] Made test for the message containing "fixed" more specific. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index da56d4eb1c649..6c188d1046fe3 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -944,7 +944,7 @@ public void FacetBaseFixed_Throws(string schema) ss.Add(null, XmlReader.Create(new StringReader(schema))); Exception ex = Assert.Throws(() => ss.Compile()); - Assert.Contains("fixed", ex.Message); + Assert.Contains("fixed='true'", ex.Message); // Issue 30218: invalid formatters Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); From 74e4c6fd2c513298125f611665c707f3b9fdb1cb Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 11:21:14 -0600 Subject: [PATCH 12/33] Reworded string resource Sch_FacetBaseFixed to remove the invalid formatter. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 5ae507837d039..982e5e9814885 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1768,7 +1768,7 @@ It is an error if the derived 'fractionDigits' facet value is greater than the parent 'fractionDigits' facet value. - Values that are declared as {fixed} in a base type can not be changed in a derived type. + Values that are declared with fixed='true' in a base type can not be changed in a derived type. It is an error if 'whiteSpace' is among the members of {facets} of {base type definition}, {value} is 'replace' or 'preserve', and the {value} of the parent 'whiteSpace' is 'collapse'. From dca3b45679fc62315a460b96d7f72b63d8873aa0 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 12:33:03 -0600 Subject: [PATCH 13/33] Added unit test to cover usage of string resource Sch_InvalidAllMax. A second usage of this string resource is not covered as it is in a class marked Obsolete. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 6c188d1046fe3..afae8ffe3f551 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -952,5 +952,31 @@ public void FacetBaseFixed_Throws(string schema) } #endregion + + [Fact] + public void InvalidAllMax_Throws() + { + string schema = @" + + + + + + + + +"; + XmlReader xr; + xr = XmlReader.Create(new StringReader(schema)); + XmlSchemaSet ss = new XmlSchemaSet(); + + Exception ex = Assert.Throws(() => ss.Add(null, xr)); + Assert.Contains("all", ex.Message); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + } } } From f848965c184e341f6ee0289d44326c68f2f095e3 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 12:37:54 -0600 Subject: [PATCH 14/33] Reworded string resource Sch_InvalidAllMax to remove the invalid formatter. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 982e5e9814885..2d10a4c28a078 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1396,7 +1396,7 @@ 'all' must have 'minOccurs' value of 0 or 1. - 'all' must have {max occurs}=1. + 'all' must have a 'maxOccurs' value of 1. The 'value' attribute must be present in facet. From 892c60773cc4cc3fc7cbca53188716b643255541 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 12:46:01 -0600 Subject: [PATCH 15/33] Added unit test for String Resource Sch_InvalidAllElementMax - invalid formatter. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index afae8ffe3f551..f1e95bd12721b 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -978,5 +978,33 @@ public void InvalidAllMax_Throws() Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); Assert.Empty(rx.Matches(ex.Message)); } + + [Fact] + public void InvalidAllElementMax_Throws() + { + string schema = @" + + + + + + + + +"; + XmlReader xr; + xr = XmlReader.Create(new StringReader(schema)); + XmlSchemaSet ss = new XmlSchemaSet(); + + Exception ex = Assert.Throws(() => ss.Add(null, xr)); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + + Assert.Contains("all", ex.Message); + Assert.Contains("maxOccurs", ex.Message); + } } } From caa875c9304cf48f836e38cb38dc8957f7417203 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 12:54:17 -0600 Subject: [PATCH 16/33] Reworded string resource Sch_InvalidAllElementMax to remove the invalid formatter. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 2d10a4c28a078..8a3afaff5891a 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1501,7 +1501,7 @@ Duplicate ID attribute. - The {max occurs} of all the particles in the {particles} of an all group must be 0 or 1. + The 'maxOccurs' attribute of all the particles of an 'all' group must be 0 or 1. Invalid namespace in 'any'. @@ -3456,4 +3456,4 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Compiling JScript/CSharp scripts is not supported - \ No newline at end of file + From 1a1ae36f78c468f5512ad2020b20765a27e2bc1e Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 14:46:23 -0600 Subject: [PATCH 17/33] Added unit test which causes an XmlSchemaException using string resource Sch_InvalidExemplar as its message. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index f1e95bd12721b..f14b206471f69 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -1006,5 +1006,37 @@ public void InvalidAllElementMax_Throws() Assert.Contains("all", ex.Message); Assert.Contains("maxOccurs", ex.Message); } + + [Fact] + public void InvalidExemplar_Throws() + { + string schema = @" + + + + + + + + + + +"; + + XmlReader xr; + xr = XmlReader.Create(new StringReader(schema)); + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, xr); + + Exception ex = Assert.Throws(() => ss.Compile()); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); + Assert.Empty(rx.Matches(ex.Message)); + + Assert.Contains("substitutionGroup", ex.Message); + Assert.Contains("person", ex.Message); + } } } From f8a23396800649909214042d97e605e1dfd8b0cc Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 2 Apr 2020 14:48:33 -0600 Subject: [PATCH 18/33] Reworded Sch_InvalidExemplar to remove the invalid formatter. Also, added the name of the element which cannot be used as the substitution group affiliation. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- .../src/System/Xml/Schema/SchemaCollectionCompiler.cs | 2 +- .../src/System/Xml/Schema/SchemaSetCompiler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 8a3afaff5891a..33bfc38b08872 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1510,7 +1510,7 @@ The value of the namespace attribute of the element or attribute wildcard is invalid - {0} - Cannot be nominated as the {substitution group affiliation} of any other declaration. + Element '{0}' cannot be nominated as the 'substitutionGroup' of any other declaration. Reference to undeclared substitution group affiliation. diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs index 079a6e20f1343..56766e67a3d9f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs @@ -437,7 +437,7 @@ private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroupV1Compat substit { if (examplar.FinalResolved == XmlSchemaDerivationMethod.All) { - SendValidationEvent(SR.Sch_InvalidExamplar, examplar); + SendValidationEvent(SR.Sch_InvalidExamplar, examplar.Name, examplar); } for (int i = 0; i < substitutionGroup.Members.Count; ++i) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaSetCompiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaSetCompiler.cs index db6b8b075f6b3..3f794a9dc5490 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaSetCompiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaSetCompiler.cs @@ -487,7 +487,7 @@ private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGro { if (examplar.FinalResolved == XmlSchemaDerivationMethod.All) { - SendValidationEvent(SR.Sch_InvalidExamplar, examplar); + SendValidationEvent(SR.Sch_InvalidExamplar, examplar.Name, examplar); } //Build transitive members ArrayList newMembers = null; From 1a004967e48fe364e5ccc65498fbfd899426e0ee Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Apr 2020 12:48:01 -0600 Subject: [PATCH 19/33] Added unit test that causes an XmlSchemaException to be thrown using string resource Sch_GroupBaseRestNotEmptiable as its message. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index f14b206471f69..615b2c2c09c1b 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -1038,5 +1038,52 @@ public void InvalidExemplar_Throws() Assert.Contains("substitutionGroup", ex.Message); Assert.Contains("person", ex.Message); } + + [Fact] + public void GroupBaseRestNotEmptiable_Throws() + { + string schema = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{[a-zA-Z ]+[^\}]*\}"); + Assert.Empty(rx.Matches(ex.Message)); + + Assert.Contains("particle", ex.Message); + } } } From 0ae6b0431bf8104f87f7f24bb3c5914adff04359 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Apr 2020 12:48:47 -0600 Subject: [PATCH 20/33] Removed the curly braces so there are no longer any invalid formatters. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 33bfc38b08872..be29e48d352c4 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1636,7 +1636,7 @@ The derived particle cannot have more members than the base particle - All:All,Sequence:Sequence -- Recurse Rule 2 / Choice:Choice -- RecurseLax. - All particles in the {particles} of the base particle which are not mapped to by any particle in the {particles} of the derived particle should be emptiable - All:All,Sequence:Sequence -- Recurse Rule 2 / Choice:Choice -- RecurseLax. + All particles in the particles of the base particle which are not mapped to by any particle in the particles of the derived particle should be emptiable - All:All,Sequence:Sequence -- Recurse Rule 2 / Choice:Choice -- RecurseLax. The derived sequence particle at ({0}, {1}) is not a valid restriction of the base all particle at ({2}, {3}) according to Sequence:All -- RecurseUnordered. @@ -3456,4 +3456,4 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Compiling JScript/CSharp scripts is not supported - + \ No newline at end of file From 962ecee9b32d1b2b6ada902414e11c9fc676b487 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Apr 2020 13:36:53 -0600 Subject: [PATCH 21/33] Added unit tests that cause an XmlSchemaException to be thrown using string resource Sch_AllRefMinMax as its message. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 615b2c2c09c1b..f293fbec1beb1 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -1085,5 +1085,73 @@ public void GroupBaseRestNotEmptiable_Throws() Assert.Contains("particle", ex.Message); } + + #region test throwing of XmlSchemaException with message Sch_AllRefMinMax + public static IEnumerable AllRefMinMax_Throws_TestData + { + get + { + return new List() + { + new object[] + { // invalid value for minOccurs and maxOccurs +@" + + + + + + + + + + + + + +" + }, + new object[] + { // maxOccurs too large +@" + + + + + + + + + + + + + +" + } + }; + } + } + + [Theory] + [MemberData(nameof(AllRefMinMax_Throws_TestData))] + public void AllRefMinMax_Throws(string schema) + { + XmlSchemaSet ss = new XmlSchemaSet(); + ss.Add(null, XmlReader.Create(new StringReader(schema))); + + Exception ex = Assert.Throws(() => ss.Compile()); + + // Issue 30218: invalid formatters + Regex rx = new Regex(@"\{[a-zA-Z ]+[^\}]*\}"); + Assert.Empty(rx.Matches(ex.Message)); + + Assert.Contains("all", ex.Message); + Assert.Contains("minOccurs", ex.Message); + Assert.Contains("maxOccurs", ex.Message); + } + #endregion } } From 0f742267e95536e4b5959046ac3d53244408b728 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Apr 2020 13:37:17 -0600 Subject: [PATCH 22/33] Changed string resource Sch_AllRefMinMax to remove the invalid formatters. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index be29e48d352c4..234d33ca12d19 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1654,7 +1654,7 @@ The group ref to 'all' is not the root particle, or it is being used as an extension. - The group ref to 'all' must have {min occurs}= 0 or 1 and {max occurs}=1. + The group ref to 'all' must have 'minOccurs' = 0 or 1 and 'maxOccurs' = 1. 'all' is not the only particle in a group, or is being used as an extension. @@ -3456,4 +3456,4 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Compiling JScript/CSharp scripts is not supported - \ No newline at end of file + From 6690162b66312d1ec04d2b4dd7621e3ed17edd1c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 7 Apr 2020 15:27:22 -0600 Subject: [PATCH 23/33] reworded Sch_MinLengthGtBaseMinLength and Sch_MaxLengthGtBaseMaxLength similarly to Sch_LengthGtBaseLength --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 234d33ca12d19..2d2912fb7a010 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1723,10 +1723,10 @@ It is an error if 'length' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'length'. - It is an error if the derived 'minLength' facet value is less than the parent 'minLength' facet value. + It is an error if 'minLength' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'minLength'. - It is an error if the derived 'maxLength' facet value is greater than the parent 'maxLength' facet value. + It is an error if 'maxLength' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'maxLength'. It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of facets, unless they are specified in different derivation steps. In which case the following must be true: the value of 'minLength' <= the value of 'length' <= the value of 'maxLength'. From 6886472e0537d7272b74156130bb3ade6b7b5f01 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 14:46:56 -0600 Subject: [PATCH 24/33] Corrected error "greater than" to "less than". --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 2d2912fb7a010..a09eaf730e39f 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1723,7 +1723,7 @@ It is an error if 'length' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'length'. - It is an error if 'minLength' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'minLength'. + It is an error if 'minLength' is among the members of the facets of the base type definition and its value is less than the value of the parent 'minLength'. It is an error if 'maxLength' is among the members of the facets of the base type definition and its value is greater than the value of the parent 'maxLength'. @@ -3456,4 +3456,4 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Compiling JScript/CSharp scripts is not supported - + \ No newline at end of file From f92530343ff2e10353fdd2ce271c4bd98a118f2b Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 14:51:48 -0600 Subject: [PATCH 25/33] Changed name of test to more accurately reflect its purpose. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index f293fbec1beb1..2bb44088beb24 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -183,7 +183,7 @@ public void FractionDigitsMismatch_Throws() /// Test for issue #30218, resource Sch_MinLengthGtBaseMinLength /// [Fact] - public void MinLengthGtBaseMinLength_Throws() + public void MinLengthLtBaseMinLength_Throws() { string schema = @" Date: Thu, 9 Apr 2020 14:58:37 -0600 Subject: [PATCH 26/33] Changed casing of MinLength and MaxLength to match their XML facets. Removed redundant ToLower call and comment. --- src/libraries/System.Private.Xml/src/Resources/Strings.resx | 2 +- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index a09eaf730e39f..73ea65d48d848 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -1120,7 +1120,7 @@ It is an error for both length and minLength or maxLength to be present. - MinLength is greater than MaxLength. + minLength is greater than maxLength. FractionDigits is greater than TotalDigits. diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 2bb44088beb24..845b3af4f2f2a 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -402,10 +402,8 @@ public void MinLengthGtMaxLength_Throws() ss.Add(null, XmlReader.Create(new StringReader(schema))); Exception ex = Assert.Throws(() => ss.Compile()); - // The thrown error message has an upper case 'M' in both - // minLength and maxLength. - Assert.Contains("minlength", ex.Message.ToLower()); - Assert.Contains("maxlength", ex.Message.ToLower()); + Assert.Contains("minLength", ex.Message); + Assert.Contains("maxLength", ex.Message); // Issue 30218: invalid formatters Regex rx = new Regex(@"\{[0-9]*[a-zA-Z ]+[^\}]*\}"); From 129ff7ad3bbd156cc18ecd950611ace229983b9c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 15:05:53 -0600 Subject: [PATCH 27/33] Removed all Regex used to find invalid formatters. --- .../XmlSchemaSet/TC_SchemaSet_Compile.cs | 42 ++----------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 845b3af4f2f2a..8a54dea59f021 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -7,7 +7,6 @@ using System.IO; using System.Xml.Schema; using System.Collections.Generic; -using System.Text.RegularExpressions; namespace System.Xml.Tests { @@ -375,13 +374,10 @@ public void MaxMinLengthBaseLength_Throws(string schema) ss.Add(null, XmlReader.Create(new StringReader(schema))); Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("length", ex.Message); Assert.Contains("minLength", ex.Message); Assert.Contains("maxLength", ex.Message); - - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); } [Fact] @@ -402,12 +398,9 @@ public void MinLengthGtMaxLength_Throws() ss.Add(null, XmlReader.Create(new StringReader(schema))); Exception ex = Assert.Throws(() => ss.Compile()); + Assert.Contains("minLength", ex.Message); Assert.Contains("maxLength", ex.Message); - - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{[0-9]*[a-zA-Z ]+[^\}]*\}"); - Assert.Empty(rx.Matches(ex.Message)); } public static IEnumerable MaxMinLengthBaseLength_TestData @@ -638,11 +631,8 @@ public void LengthGtBaseLength_Throws() ss.Add(null, XmlReader.Create(new StringReader(schema))); Exception ex = Assert.Throws(() => ss.Compile()); - Assert.Contains("length", ex.Message); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); + Assert.Contains("length", ex.Message); } #region FacetBaseFixed tests @@ -943,11 +933,6 @@ public void FacetBaseFixed_Throws(string schema) Exception ex = Assert.Throws(() => ss.Compile()); Assert.Contains("fixed='true'", ex.Message); - - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); - } #endregion @@ -970,11 +955,8 @@ public void InvalidAllMax_Throws() XmlSchemaSet ss = new XmlSchemaSet(); Exception ex = Assert.Throws(() => ss.Add(null, xr)); - Assert.Contains("all", ex.Message); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); + Assert.Contains("all", ex.Message); } [Fact] @@ -997,10 +979,6 @@ public void InvalidAllElementMax_Throws() Exception ex = Assert.Throws(() => ss.Add(null, xr)); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); - Assert.Contains("all", ex.Message); Assert.Contains("maxOccurs", ex.Message); } @@ -1029,10 +1007,6 @@ public void InvalidExemplar_Throws() Exception ex = Assert.Throws(() => ss.Compile()); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{.*[a-zA-Z ]+.*\}"); - Assert.Empty(rx.Matches(ex.Message)); - Assert.Contains("substitutionGroup", ex.Message); Assert.Contains("person", ex.Message); } @@ -1077,10 +1051,6 @@ public void GroupBaseRestNotEmptiable_Throws() Exception ex = Assert.Throws(() => ss.Compile()); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{[a-zA-Z ]+[^\}]*\}"); - Assert.Empty(rx.Matches(ex.Message)); - Assert.Contains("particle", ex.Message); } @@ -1142,10 +1112,6 @@ public void AllRefMinMax_Throws(string schema) Exception ex = Assert.Throws(() => ss.Compile()); - // Issue 30218: invalid formatters - Regex rx = new Regex(@"\{[a-zA-Z ]+[^\}]*\}"); - Assert.Empty(rx.Matches(ex.Message)); - Assert.Contains("all", ex.Message); Assert.Contains("minOccurs", ex.Message); Assert.Contains("maxOccurs", ex.Message); From e560d7db8a6486329510c7bee0d6c6c44f4a67e7 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 15:10:01 -0600 Subject: [PATCH 28/33] renamed MaxMinLengthBaseLength_TestData to indicate that this is testing the successful case. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 8a54dea59f021..6372200087ddb 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -403,7 +403,7 @@ public void MinLengthGtMaxLength_Throws() Assert.Contains("maxLength", ex.Message); } - public static IEnumerable MaxMinLengthBaseLength_TestData + public static IEnumerable MaxMinLengthBaseLength_Success_TestData { get { @@ -586,7 +586,7 @@ public static IEnumerable MaxMinLengthBaseLength_TestData } [Theory] - [MemberData(nameof(MaxMinLengthBaseLength_TestData))] + [MemberData(nameof(MaxMinLengthBaseLength_Success_TestData))] public void MaxMinLengthBaseLength_Test(string schema) { XmlSchemaSet ss = new XmlSchemaSet(); From c5fe335452b605e450bf422a01a04e5729454d29 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 15:13:11 -0600 Subject: [PATCH 29/33] Removed suppression of exception so that we will see the exception if one is thrown. --- .../XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 6372200087ddb..cd54643162fcc 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -592,16 +592,9 @@ public void MaxMinLengthBaseLength_Test(string schema) XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(null, XmlReader.Create(new StringReader(schema))); - Exception exception; - try - { - ss.Compile(); - exception = null; - } catch (Exception ex) - { - exception = ex; - } - Assert.Null(exception); + ss.Compile(); + + Assert.True(true); } #endregion From 8a7d0d7cb9327c5f75b80bb98025551db6ac2605 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Thu, 9 Apr 2020 15:16:15 -0600 Subject: [PATCH 30/33] Removed comments as there are issues tracking these. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index cd54643162fcc..1ffe69dc1888b 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -904,15 +904,6 @@ public static IEnumerable FacetBaseFixed_Throws_TestData " } - // NOTE: the cases of totalDigits, with larger and smaller - // values are not tested here as Issue 34426 was found - // and will be addressed separately. - // NOTE: the case of fractionDigits with a larger - // value is not tested here as Issue 34413 was found, - // and will be addressed separately. - // NOTE: the case of fractionDigits with a smaller - // value is not tested here as Issue 34418 was found, - // and will be addressed separately. }; } } From ca16c1c0d44862b0e1de9fd731783ce41225ad44 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 13 Apr 2020 12:15:36 -0600 Subject: [PATCH 31/33] Fixed comment larger -> lower. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 1ffe69dc1888b..180cca82ea17f 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -707,7 +707,7 @@ public static IEnumerable FacetBaseFixed_Throws_TestData " }, new object[] - { // maxLength, derived type has larger value. + { // maxLength, derived type has lower value. @" From 36c94c3daf290da20dd3f4351a3ff0e5bcf3a774 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 13 Apr 2020 12:21:13 -0600 Subject: [PATCH 32/33] Removed XML comments on test methods. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index 180cca82ea17f..fd71df43ef053 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -207,9 +207,6 @@ public void MinLengthLtBaseMinLength_Throws() Assert.Contains("minLength", ex.Message); } - /// - /// Test for issue #30218, resource Sch_MaxLengthGtBaseMaxLength - /// [Fact] public void MaxLengthGtBaseMaxLength_Throws() { @@ -598,9 +595,6 @@ public void MaxMinLengthBaseLength_Test(string schema) } #endregion - /// - /// Test for issue #30218, resource Sch_LengthGtBaseLength - /// [Fact] public void LengthGtBaseLength_Throws() { From 45f9837077c19150b39806177b75855b529cf610 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 14 Apr 2020 13:04:51 -0600 Subject: [PATCH 33/33] Removal of XML comment that was missed. --- .../tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs index fd71df43ef053..122239cc26f04 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Compile.cs @@ -178,9 +178,6 @@ public void FractionDigitsMismatch_Throws() Assert.DoesNotContain("totalDigits", ex.Message); } - /// - /// Test for issue #30218, resource Sch_MinLengthGtBaseMinLength - /// [Fact] public void MinLengthLtBaseMinLength_Throws() {