@@ -31,7 +31,7 @@ public enum TestSystemRequirements
3131 // Add more as needed
3232 }
3333
34- public class FactOnSystemRequirementAttribute : FactAttribute
34+ private sealed class FactOnSystemRequirementAttribute : FactAttribute
3535 {
3636 private TestSystemRequirements RequiredSystems ;
3737
@@ -62,7 +62,7 @@ private bool IsSystemSupported(TestSystemRequirements requiredSystems)
6262 }
6363
6464
65- public class TestIfCondition : FactAttribute
65+ public sealed class TestIfCondition : FactAttribute
6666 {
6767 public TestIfCondition ( Func < bool > condition , string skipReason )
6868 {
@@ -1034,6 +1034,7 @@ public void BruteForceTestArm64()
10341034 // credit: based on code from Google Fuchsia (Apache Licensed)
10351035 public static bool ValidateUtf8Fuschia ( byte [ ] data )
10361036 {
1037+ if ( data == null ) return false ;
10371038 int pos = 0 ;
10381039 int len = data . Length ;
10391040 uint codePoint ;
@@ -1104,13 +1105,14 @@ private bool InvalidateUtf8(byte[] utf8, int badindex,Utf8ValidationDelegate utf
11041105 int utf16CodeUnitCountAdjustment , scalarCountAdjustment ;
11051106 byte * dotnetResult = DotnetRuntime . Utf8Utility . GetPointerToFirstInvalidByte ( pInput , utf8 . Length , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
11061107 int dotnetOffset = ( int ) ( dotnetResult - pInput ) ;
1108+ var message = "Suprisingly, scalarResult != simdResult {0} != {1}, badindex = {2}, length = {3}" ;
11071109 if ( scalarOffset != simdOffset )
11081110 {
1109- Console . WriteLine ( "Suprisingly, scalarResult != simdResult {0} != {1}, badindex = {2}, length = {3}" , scalarOffset , simdOffset , badindex , utf8 . Length ) ;
1111+ Console . WriteLine ( message , scalarOffset , simdOffset , badindex , utf8 . Length ) ;
11101112 }
11111113 if ( dotnetOffset != simdOffset )
11121114 {
1113- Console . WriteLine ( "Suprisingly, dotnetOffset != simdResult {0} != {1}, badindex = {2}, length = {3}" , dotnetOffset , simdOffset , badindex , utf8 . Length ) ;
1115+ Console . WriteLine ( message , dotnetOffset , simdOffset , badindex , utf8 . Length ) ;
11141116 }
11151117 return ( scalarResult == simdResult ) && ( simdResult == dotnetResult ) ;
11161118 }
@@ -1151,7 +1153,7 @@ private bool ValidateUtf8(byte[] utf8,Utf8ValidationDelegate utf8ValidationDeleg
11511153 }
11521154
11531155 // Helper method to calculate the actual offset and length from a Range
1154- private ( int offset , int length ) GetOffsetAndLength ( int totalLength , Range range )
1156+ private static ( int offset , int length ) GetOffsetAndLength ( int totalLength , Range range )
11551157 {
11561158 var start = range . Start . GetOffset ( totalLength ) ;
11571159 var end = range . End . GetOffset ( totalLength ) ;
@@ -1167,6 +1169,10 @@ public bool ValidateCount(byte[] utf8, Utf8ValidationDelegate utf8ValidationDele
11671169{
11681170 int dotnetUtf16Adjustment , dotnetScalarCountAdjustment ;
11691171 int simdUnicodeUtf16Adjustment , simdUnicodeScalarCountAdjustment ;
1172+ if ( utf8 == null || utf8ValidationDelegate == null )
1173+ {
1174+ return false ;
1175+ }
11701176
11711177 var isDefaultRange = range . Equals ( default ( Range ) ) ;
11721178 var ( offset , length ) = isDefaultRange ? ( 0 , utf8 . Length ) : GetOffsetAndLength ( utf8 . Length , range ) ;
0 commit comments