This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-client-csharp.git
The following commit(s) were added to refs/heads/main by this push:
new f494ac2 ByteBuffer: replace LINQ reversals with Array.Reverse for
compatibility (#41)
f494ac2 is described below
commit f494ac296f43b1586afbbd05bcd17c3e0e8053be
Author: CritasWang <[email protected]>
AuthorDate: Wed Jan 7 17:11:03 2026 +0800
ByteBuffer: replace LINQ reversals with Array.Reverse for compatibility
(#41)
---
.github/workflows/pre-commit-format.yml | 11 ++++--
src/Apache.IoTDB/DataStructure/ByteBuffer.cs | 59 +++++++++++++++++++++-------
2 files changed, 51 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/pre-commit-format.yml
b/.github/workflows/pre-commit-format.yml
index 226cfd3..de31eb7 100644
--- a/.github/workflows/pre-commit-format.yml
+++ b/.github/workflows/pre-commit-format.yml
@@ -4,9 +4,9 @@ on:
workflow_dispatch:
pull_request:
branches:
- - '**'
+ - "**"
merge_group:
- branches: [ main ]
+ branches: [main]
# schedule:
# - cron: "0 0 * * *"
@@ -17,6 +17,9 @@ concurrency:
jobs:
formatting-checks:
runs-on: ubuntu-22.04
+ env:
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
+ DOTNET_CLI_TELEMETRY_OPTOUT: 1
steps:
- uses: actions/checkout@v4
@@ -24,12 +27,12 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
- dotnet-version: '9.0.x'
+ dotnet-version: "9.0.x"
- name: Setup Python environment (for pre-commit)
uses: actions/setup-python@v5
with:
- python-version: '3.10'
+ python-version: "3.10"
- name: Clean dotnet temporary folder
run: |
diff --git a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs
b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs
index a66a7ac..471f651 100644
--- a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs
+++ b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs
@@ -18,7 +18,6 @@
*/
using System;
-using System.Linq;
using System.Text;
namespace Apache.IoTDB.DataStructure
@@ -70,9 +69,12 @@ namespace Apache.IoTDB.DataStructure
public int GetInt()
{
var intBuff = _buffer[_readPos..(_readPos + 4)];
- if (_isLittleEndian) intBuff = intBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(intBuff);
+ }
#if NET461_OR_GREATER || NETSTANDARD2_0
- var intValue = BitConverter.ToInt32(intBuff,0);
+ var intValue = BitConverter.ToInt32(intBuff, 0);
#else
var intValue = BitConverter.ToInt32(intBuff);
#endif
@@ -85,9 +87,12 @@ namespace Apache.IoTDB.DataStructure
{
var longBuff = _buffer[_readPos..(_readPos + 8)];
- if (_isLittleEndian) longBuff = longBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(longBuff);
+ }
#if NET461_OR_GREATER || NETSTANDARD2_0
- var longValue = BitConverter.ToInt64(longBuff,0);
+ var longValue = BitConverter.ToInt64(longBuff, 0);
#else
var longValue = BitConverter.ToInt64(longBuff);
#endif
@@ -100,9 +105,12 @@ namespace Apache.IoTDB.DataStructure
{
var floatBuff = _buffer[_readPos..(_readPos + 4)];
- if (_isLittleEndian) floatBuff = floatBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(floatBuff);
+ }
#if NET461_OR_GREATER || NETSTANDARD2_0
- var floatValue = BitConverter.ToSingle(floatBuff,0);
+ var floatValue = BitConverter.ToSingle(floatBuff, 0);
#else
var floatValue = BitConverter.ToSingle(floatBuff);
#endif
@@ -114,9 +122,12 @@ namespace Apache.IoTDB.DataStructure
{
var doubleBuff = _buffer[_readPos..(_readPos + 8)];
- if (_isLittleEndian) doubleBuff = doubleBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(doubleBuff);
+ }
#if NET461_OR_GREATER || NETSTANDARD2_0
- var doubleValue = BitConverter.ToDouble(doubleBuff,0);
+ var doubleValue = BitConverter.ToDouble(doubleBuff, 0);
#else
var doubleValue = BitConverter.ToDouble(doubleBuff);
#endif
@@ -173,7 +184,10 @@ namespace Apache.IoTDB.DataStructure
{
var boolBuffer = BitConverter.GetBytes(value);
- if (_isLittleEndian) boolBuffer = boolBuffer.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(boolBuffer);
+ }
ExtendBuffer(boolBuffer.Length);
boolBuffer.CopyTo(_buffer, _writePos);
@@ -184,7 +198,10 @@ namespace Apache.IoTDB.DataStructure
{
var intBuff = BitConverter.GetBytes(value);
- if (_isLittleEndian) intBuff = intBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(intBuff);
+ }
ExtendBuffer(intBuff.Length);
intBuff.CopyTo(_buffer, _writePos);
@@ -195,7 +212,10 @@ namespace Apache.IoTDB.DataStructure
{
var longBuff = BitConverter.GetBytes(value);
- if (_isLittleEndian) longBuff = longBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(longBuff);
+ }
ExtendBuffer(longBuff.Length);
longBuff.CopyTo(_buffer, _writePos);
@@ -206,7 +226,10 @@ namespace Apache.IoTDB.DataStructure
{
var floatBuff = BitConverter.GetBytes(value);
- if (_isLittleEndian) floatBuff = floatBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(floatBuff);
+ }
ExtendBuffer(floatBuff.Length);
floatBuff.CopyTo(_buffer, _writePos);
@@ -217,7 +240,10 @@ namespace Apache.IoTDB.DataStructure
{
var doubleBuff = BitConverter.GetBytes(value);
- if (_isLittleEndian) doubleBuff = doubleBuff.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(doubleBuff);
+ }
ExtendBuffer(doubleBuff.Length);
doubleBuff.CopyTo(_buffer, _writePos);
@@ -248,7 +274,10 @@ namespace Apache.IoTDB.DataStructure
{
var charBuf = BitConverter.GetBytes(value);
- if (_isLittleEndian) charBuf = charBuf.Reverse().ToArray();
+ if (_isLittleEndian)
+ {
+ Array.Reverse(charBuf);
+ }
ExtendBuffer(charBuf.Length);
charBuf.CopyTo(_buffer, _writePos);