From 714c84b107a7c375d49e7836bcaef649bec95ced Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sat, 27 Apr 2024 09:25:13 +1000 Subject: [PATCH 1/6] #889 Only include system.memory on framework --- src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj index 001489132..fe17918c0 100644 --- a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj +++ b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1;net6.0;net8.0 @@ -43,8 +43,11 @@ - + + + + From 6aac4490c31810ce53098a459f21f5dace92fa35 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Mon, 29 Apr 2024 19:41:32 +1000 Subject: [PATCH 2/6] Cleanup conditional compilation --- src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs | 33 ++----------------- .../Hazelcast.Net.Win32.csproj | 4 --- .../Exceptions/StackTraceElement.cs | 8 ++--- src/Hazelcast.Net/Polyfills/Index.cs | 8 ++--- .../Polyfills/NullableAttributes.cs | 8 ++--- src/Hazelcast.Net/Polyfills/Range.cs | 8 ++--- .../Polyfills/ReadOnlySequenceExtensions.cs | 8 ++--- .../Polyfills/RuntimeHelpersEx.cs | 8 ++--- .../Polyfills/StringExtensions.cs | 8 ++--- src/Hazelcast.Net/Polyfills/TaskExtensions.cs | 12 +++---- .../Polyfills/ZLib/ZlibConstants.cs | 14 +++----- .../Projection/MultiAttributeProjection.cs | 10 ++---- 12 files changed, 45 insertions(+), 84 deletions(-) diff --git a/src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs b/src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs index 9b01495a6..9a35a3949 100644 --- a/src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs +++ b/src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -148,33 +148,6 @@ private int ReadInt32B(ref ReadOnlySequence bytes) return value; } - -#if NETCOREAPP3_1 // SequenceReader is n/a in 2.1 - private int ReadInt32C(ref ReadOnlySequence bytes) - { - if (bytes.Length < 4) - throw new ArgumentException("Not enough bytes.", nameof(bytes)); - - var slice = bytes.Slice(bytes.Start, 4); // slice the required bytes - int value; - if (slice.IsSingleSegment) - { - var span = slice.FirstSpan(); - value = span.ReadInt32(); - } - else - { - // use a reader - var reader = new SequenceReader(bytes); - reader.TryReadLittleEndian(out value); - } - - // consume the slice - bytes = bytes.Slice(slice.End); - - return value; - } -#endif } public static class Extensions diff --git a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj index fe17918c0..f89d77fdd 100644 --- a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj +++ b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj @@ -43,10 +43,6 @@ - - - - diff --git a/src/Hazelcast.Net/Exceptions/StackTraceElement.cs b/src/Hazelcast.Net/Exceptions/StackTraceElement.cs index eff79b03b..14bafdd3b 100644 --- a/src/Hazelcast.Net/Exceptions/StackTraceElement.cs +++ b/src/Hazelcast.Net/Exceptions/StackTraceElement.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -92,7 +92,7 @@ private static bool EqualsN(StackTraceElement left, StackTraceElement right) /// public override int GetHashCode() { -#if NETFRAMEWORK || NETSTANDARD2_0 +#if NETSTANDARD2_0 unchecked { var hashCode = (ClassName != null ? ClassName.GetHashCode() : 0); diff --git a/src/Hazelcast.Net/Polyfills/Index.cs b/src/Hazelcast.Net/Polyfills/Index.cs index 8f55f0840..c8784594d 100644 --- a/src/Hazelcast.Net/Polyfills/Index.cs +++ b/src/Hazelcast.Net/Polyfills/Index.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 +#if NETSTANDARD2_0 // brings C# 8 index & range to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm diff --git a/src/Hazelcast.Net/Polyfills/NullableAttributes.cs b/src/Hazelcast.Net/Polyfills/NullableAttributes.cs index db95d43d2..78d40d90b 100644 --- a/src/Hazelcast.Net/Polyfills/NullableAttributes.cs +++ b/src/Hazelcast.Net/Polyfills/NullableAttributes.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ #pragma warning disable MA0048 // File name must match type name #define INTERNAL_NULLABLE_ATTRIBUTES -#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 +#if NETSTANDARD2_0 // brings C# 8 nullable attributes to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm diff --git a/src/Hazelcast.Net/Polyfills/Range.cs b/src/Hazelcast.Net/Polyfills/Range.cs index e9c6e9e87..5d0e87c73 100644 --- a/src/Hazelcast.Net/Polyfills/Range.cs +++ b/src/Hazelcast.Net/Polyfills/Range.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 +#if NETSTANDARD2_0 // brings C# 8 index & range to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm diff --git a/src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs b/src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs index 136fd3ddf..d9c8372b3 100644 --- a/src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs +++ b/src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,7 @@ internal static class ReadOnlySequenceExtensions /// public static ReadOnlySpan FirstSpan(this ReadOnlySequence sequence) { -#if NET462 || NETSTANDARD2_0 +#if NETSTANDARD2_0 return sequence.First.Span; #else return sequence.FirstSpan; diff --git a/src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs b/src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs index 8b42e4b48..1e598ee6b 100644 --- a/src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs +++ b/src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 +#if NETSTANDARD2_0 // brings C# 8 index & range to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm diff --git a/src/Hazelcast.Net/Polyfills/StringExtensions.cs b/src/Hazelcast.Net/Polyfills/StringExtensions.cs index afad3f1a7..90eba1205 100644 --- a/src/Hazelcast.Net/Polyfills/StringExtensions.cs +++ b/src/Hazelcast.Net/Polyfills/StringExtensions.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ public static string TrimEnd(this string s, string trim) => s.EndsWith(trim) ? s.Substring(0, s.Length - trim.Length) : s; #pragma warning restore CA1310 // Specify StringComparison for correctness -#if NETFRAMEWORK || NETSTANDARD2_0 +#if NETSTANDARD2_0 #pragma warning disable CA1801 // Review unused parameters - we need them #pragma warning disable IDE0060 // Remove unused parameter diff --git a/src/Hazelcast.Net/Polyfills/TaskExtensions.cs b/src/Hazelcast.Net/Polyfills/TaskExtensions.cs index c1c319ddd..ed92bcafa 100644 --- a/src/Hazelcast.Net/Polyfills/TaskExtensions.cs +++ b/src/Hazelcast.Net/Polyfills/TaskExtensions.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ internal static class TaskExtensions public static bool IsCompletedSuccessfully(this Task task) { if (task == null) throw new ArgumentNullException(nameof(task)); -#if NETFRAMEWORK || NETSTANDARD2_0 +#if NETSTANDARD2_0 return task.IsCompleted && !(task.IsFaulted || task.IsCanceled); #else return task.IsCompletedSuccessfully; @@ -48,7 +48,7 @@ public static bool IsCompletedSuccessfully(this Task task) /// public static bool IsCompletedSuccessfully(this ValueTask task) { -#if NETFRAMEWORK || NETSTANDARD2_0 +#if NETSTANDARD2_0 return task.IsCompleted && !(task.IsFaulted || task.IsCanceled); #else return task.IsCompletedSuccessfully; @@ -65,7 +65,7 @@ public static bool IsCompletedSuccessfully(this ValueTask task) /// public static bool IsCompletedSuccessfully(this ValueTask task) { -#if NETFRAMEWORK || NETSTANDARD2_0 +#if NETSTANDARD2_0 return task.IsCompleted && !(task.IsFaulted || task.IsCanceled); #else return task.IsCompletedSuccessfully; diff --git a/src/Hazelcast.Net/Polyfills/ZLib/ZlibConstants.cs b/src/Hazelcast.Net/Polyfills/ZLib/ZlibConstants.cs index 51cc111b8..cff59b64a 100644 --- a/src/Hazelcast.Net/Polyfills/ZLib/ZlibConstants.cs +++ b/src/Hazelcast.Net/Polyfills/ZLib/ZlibConstants.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ internal static class ZlibConstants public const int Z_STREAM_END = 1; /// - /// The operation ended in need of a dictionary. + /// The operation ended in need of a dictionary. /// public const int Z_NEED_DICT = 2; @@ -64,11 +64,7 @@ internal static class ZlibConstants /// /// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes. /// -#if NETCF - public const int WorkingBufferSizeDefault = 8192; -#else - public const int WorkingBufferSizeDefault = 16384; -#endif + public const int WorkingBufferSizeDefault = 16384; /// /// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes. /// diff --git a/src/Hazelcast.Net/Projection/MultiAttributeProjection.cs b/src/Hazelcast.Net/Projection/MultiAttributeProjection.cs index 9b2c5d5c8..79cf7a12e 100644 --- a/src/Hazelcast.Net/Projection/MultiAttributeProjection.cs +++ b/src/Hazelcast.Net/Projection/MultiAttributeProjection.cs @@ -1,11 +1,11 @@ // Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,11 +40,7 @@ public MultiAttributeProjection(string[] attributePaths) { if (string.IsNullOrWhiteSpace(attributePath)) throw new ArgumentException("No attribute path can be null nor empty.", nameof(attributePaths)); -#if NETFRAMEWORK - if (attributePath.Contains("[any]")) -#else if (attributePath.Contains("[any]", StringComparison.OrdinalIgnoreCase)) -#endif throw new ArgumentException("No attribute path can contain the '[any]' operator.", nameof(attributePaths)); } From 7ff090da648115c9be06f84e7e0a0b58efad919e Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sun, 11 May 2025 03:43:11 +1000 Subject: [PATCH 3/6] Update Hazelcast.Net.Win32.csproj --- src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj index f89d77fdd..0aa5780e1 100644 --- a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj +++ b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1;net6.0;net8.0 @@ -43,7 +43,11 @@ + + + + From 2206b7708a7e68ceec0a6f21538c3000e4de1e62 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sun, 11 May 2025 03:43:43 +1000 Subject: [PATCH 4/6] Update Hazelcast.Net.Win32.csproj --- src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj index 0aa5780e1..52d62a0b9 100644 --- a/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj +++ b/src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj @@ -45,9 +45,9 @@ - - + + From d170b4e89ec4f6b049de729554af92cf49f53893 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sun, 11 May 2025 03:48:40 +1000 Subject: [PATCH 5/6] Update Index.cs --- src/Hazelcast.Net/Polyfills/Index.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hazelcast.Net/Polyfills/Index.cs b/src/Hazelcast.Net/Polyfills/Index.cs index 59cb04155..eab375990 100644 --- a/src/Hazelcast.Net/Polyfills/Index.cs +++ b/src/Hazelcast.Net/Polyfills/Index.cs @@ -17,7 +17,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETSTANDARD2_0 +#if NETSTANDARD2_0 || NET6 // brings C# 8 index & range to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm From 30c230110c3e2c5ca21aca881a57d477832617e2 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sun, 11 May 2025 03:53:22 +1000 Subject: [PATCH 6/6] Update Index.cs --- src/Hazelcast.Net/Polyfills/Index.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hazelcast.Net/Polyfills/Index.cs b/src/Hazelcast.Net/Polyfills/Index.cs index eab375990..59cb04155 100644 --- a/src/Hazelcast.Net/Polyfills/Index.cs +++ b/src/Hazelcast.Net/Polyfills/Index.cs @@ -17,7 +17,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETSTANDARD2_0 || NET6 +#if NETSTANDARD2_0 // brings C# 8 index & range to netstandard 2.0 // see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm