@@ -413,25 +413,19 @@ protected Row(ResultSet resultSet)
413413 protected ResultSet ResultSet { get ; }
414414 protected MySqlConnection Connection => ResultSet . Connection ;
415415
416- protected static Guid CreateGuidFromBytes ( MySqlGuidFormat guidFormat , ReadOnlySpan < byte > bytes )
417- {
416+ protected unsafe static Guid CreateGuidFromBytes ( MySqlGuidFormat guidFormat , ReadOnlySpan < byte > bytes ) =>
417+ guidFormat switch
418+ {
418419#if NET45 || NET461 || NET471 || NETSTANDARD1_3 || NETSTANDARD2_0
419- if ( guidFormat == MySqlGuidFormat . Binary16 )
420- return new Guid ( new [ ] { bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 7 ] , bytes [ 6 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ;
421- if ( guidFormat == MySqlGuidFormat . TimeSwapBinary16 )
422- return new Guid ( new [ ] { bytes [ 7 ] , bytes [ 6 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ;
423- return new Guid ( bytes . ToArray ( ) ) ;
420+ MySqlGuidFormat . Binary16 => new Guid( new [ ] { bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 7 ] , bytes [ 6 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ,
421+ MySqlGuidFormat. TimeSwapBinary16 => new Guid( new [ ] { bytes [ 7 ] , bytes [ 6 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ,
422+ _ => new Guid( bytes . ToArray ( ) ) ,
424423#else
425- unsafe
426- {
427- if ( guidFormat == MySqlGuidFormat . Binary16 )
428- return new Guid ( stackalloc byte [ 16 ] { bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 7 ] , bytes [ 6 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ;
429- if ( guidFormat == MySqlGuidFormat . TimeSwapBinary16 )
430- return new Guid ( stackalloc byte [ 16 ] { bytes [ 7 ] , bytes [ 6 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ;
431- return new Guid ( bytes ) ;
432- }
424+ MySqlGuidFormat . Binary16 => new Guid( stackalloc byte [ 16 ] { bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 7 ] , bytes [ 6 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ,
425+ MySqlGuidFormat. TimeSwapBinary16 => new Guid( stackalloc byte [ 16 ] { bytes [ 7 ] , bytes [ 6 ] , bytes [ 5 ] , bytes [ 4 ] , bytes [ 3 ] , bytes [ 2 ] , bytes [ 1 ] , bytes [ 0 ] , bytes [ 8 ] , bytes [ 9 ] , bytes [ 10 ] , bytes [ 11 ] , bytes [ 12 ] , bytes [ 13 ] , bytes [ 14 ] , bytes [ 15 ] } ) ,
426+ _ => new Guid( bytes ) ,
433427#endif
434- }
428+ } ;
435429
436430 protected static object ReadBit( ReadOnlySpan < byte > data , ColumnDefinitionPayload columnDefinition )
437431 {
0 commit comments