[ 
https://issues.apache.org/jira/browse/THRIFT-5010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16975812#comment-16975812
 ] 

Edward Zhuravlov commented on THRIFT-5010:
------------------------------------------

Test case reque RISC-based processor computer :)

It small improverment to make avaible run code on other processor 
architectures, then x86 & ARM.

 blob/master/lib/netstd/Thrift/Transport/TFramedTransport.cs
{code:java}
private static void EncodeFrameSize(int frameSize, byte[] buf)
  {
 /*    
     buf[0] = (byte) (0xff & (frameSize >> 24));
     buf[1] = (byte) (0xff & (frameSize >> 16));
     buf[2] = (byte) (0xff & (frameSize >> 8));
     buf[3] = (byte) (0xff & (frameSize)); 
*/
     System.Buffers.Binary.BinaryPrimitives.WriteInt32BigEndian(buf, frameSize);
  }
      
private static int DecodeFrameSize(byte[] buf)
  {
/*
    return
    ((buf[0] & 0xff) << 24) |
    ((buf[1] & 0xff) << 16) |
    ((buf[2] & 0xff) << 8) |
     (buf[3] & 0xff);
*/
    return System.Buffers.Binary.BinaryPrimitives.ReadInt32BigEndian(buf);
  }      
        {code}
Class System.Buffers.Binary.BinaryPrinitives avaible as extension for 
netstandard 2.0 in nuget package System.Memory.

 

> NetStd: TFramedTransport - bigEndianConversion incorrect
> --------------------------------------------------------
>
>                 Key: THRIFT-5010
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5010
>             Project: Thrift
>          Issue Type: Improvement
>          Components: netstd - Library
>    Affects Versions: 0.13.0
>            Reporter: Edward Zhuravlov
>            Priority: Major
>              Labels: features
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Conversion -should be- _from/to TCP protocol format (always big-Endian) to 
> execution engine_ based on processor architecture. See System.BitConverter 
> class ():
> [https://docs.microsoft.com/en-us/dotnet/api/system.bitconverter?view=netstandard-2.0]
>  ??The endianness of an architecture is indicated by the 
> [IsLittleEndian|https://docs.microsoft.com/en-us/dotnet/api/system.bitconverter.islittleendian?view=netframework-4.8]
>  property, which returns {{true}} on little-endian systems and {{false}} on 
> big-endian systems. On little-endian systems, lower-order bytes precede 
> higher-order bytes. On big-endian system, higher-order bytes precede 
> lower-order bytes. ??
> Recomended use BinaryPrimitives.WriteInt32BigEndian/ReadInt32BigEndian class 
> from nuget System.Memory by Microsoft for NetStandard 2.0.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to