@@ -538,7 +538,14 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
538538 yield return new object [ ] { "1:1:1.00001" , CultureInfo . InvariantCulture , new TimeSpan ( 36610000100 ) } ;
539539 yield return new object [ ] { "1:1:1.000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36610000010 ) } ;
540540 yield return new object [ ] { "1:1:1.0000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36610000001 ) } ;
541- yield return new object [ ] { "1:1:1.00000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36610000001 ) } ;
541+
542+ if ( PlatformDetection . IsFullFramework )
543+ {
544+ // Full framework can produce some incorrect results in some cases involving leading zeros when
545+ // parsing fraction more than 7 digits. we test the expected full framework results here and we have
546+ // have more net core tests to validate the correct the results.
547+ yield return new object [ ] { "1:1:1.00000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36610000001 ) } ;
548+ }
542549
543550 // DD.HH:MM:SS
544551 yield return new object [ ] { "1.12:24:02" , null , new TimeSpan ( 1 , 12 , 24 , 2 , 0 ) } ;
@@ -560,7 +567,14 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
560567 yield return new object [ ] { "1:1:.00001" , CultureInfo . InvariantCulture , new TimeSpan ( 36600000100 ) } ;
561568 yield return new object [ ] { "1:1:.000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36600000010 ) } ;
562569 yield return new object [ ] { "1:1:.0000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36600000001 ) } ;
563- yield return new object [ ] { "1:1:.00000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36600000001 ) } ;
570+
571+ if ( PlatformDetection . IsFullFramework )
572+ {
573+ // Full framework can produce some incorrect results in some cases involving leading zeros when
574+ // parsing fraction more than 7 digits. we test the expected full framework results here and we have
575+ // have more net core tests to validate the correct the results.
576+ yield return new object [ ] { "1:1:.00000001" , CultureInfo . InvariantCulture , new TimeSpan ( 36600000001 ) } ;
577+ }
564578
565579 // Just below overflow on various components
566580 yield return new object [ ] { "10675199" , null , new TimeSpan ( 9223371936000000000 ) } ;
@@ -625,7 +639,16 @@ public static IEnumerable<object[]> Parse_Invalid_TestData()
625639
626640 // OverflowExceptions
627641 yield return new object [ ] { "1:1:1.99999999" , null , typeof ( OverflowException ) } ; // overflowing fraction
628- yield return new object [ ] { "1:1:1.000000001" , null , typeof ( OverflowException ) } ; // too many leading zeroes in fraction
642+
643+ if ( PlatformDetection . IsFullFramework )
644+ {
645+ // on non full framework we now succeed parsing the fraction .000000001
646+ // Full framework can produce some incorrect results in some cases involving leading zeros when
647+ // parsing fraction more than 7 digits. we test the expected full framework results here and we have
648+ // have more net core tests to validate the correct the results.
649+ yield return new object [ ] { "1:1:1.000000001" , null , typeof ( OverflowException ) } ; // too many leading zeroes in fraction
650+ }
651+
629652 yield return new object [ ] { "2147483647" , null , typeof ( OverflowException ) } ; // overflowing value == int.MaxValue
630653 yield return new object [ ] { "2147483648" , null , typeof ( OverflowException ) } ; // overflowing value == int.MaxValue + 1
631654 yield return new object [ ] { "10675200" , null , typeof ( OverflowException ) } ; // overflowing number of days
@@ -809,15 +832,15 @@ public static void ParseExactTest_Invalid(string input, string format, Type exce
809832 {
810833 Assert . Throws ( exceptionType , ( ) => TimeSpan . ParseExact ( input , format , new CultureInfo ( "en-US" ) ) ) ;
811834 Assert . Throws ( exceptionType , ( ) => TimeSpan . ParseExact ( input , format , new CultureInfo ( "en-US" ) , TimeSpanStyles . None ) ) ;
812-
835+
813836 Type exceptionTypeMultiple = exceptionType == typeof ( OverflowException ) || string . IsNullOrEmpty ( format ) ? typeof ( FormatException ) : exceptionType ;
814837 Assert . Throws ( exceptionTypeMultiple , ( ) => TimeSpan . ParseExact ( input , new string [ ] { format } , new CultureInfo ( "en-US" ) ) ) ;
815838 Assert . Throws ( exceptionTypeMultiple , ( ) => TimeSpan . ParseExact ( input , new string [ ] { format } , new CultureInfo ( "en-US" ) , TimeSpanStyles . None ) ) ;
816-
839+
817840 TimeSpan result ;
818841 Assert . False ( TimeSpan . TryParseExact ( input , format , new CultureInfo ( "en-US" ) , out result ) ) ;
819842 Assert . Equal ( TimeSpan . Zero , result ) ;
820-
843+
821844 Assert . False ( TimeSpan . TryParseExact ( input , format , new CultureInfo ( "en-US" ) , TimeSpanStyles . None , out result ) ) ;
822845 Assert . Equal ( TimeSpan . Zero , result ) ;
823846
0 commit comments