Skip to content

Commit e29d565

Browse files
#889 optimise dependencies [API-2338] (#960)
Closes #889 --------- Co-authored-by: Emre Yigit <emre.yigit@hazelcast.com>
1 parent 1613f8f commit e29d565

File tree

12 files changed

+48
-80
lines changed

12 files changed

+48
-80
lines changed

src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -147,33 +147,6 @@ private int ReadInt32B(ref ReadOnlySequence<byte> bytes)
147147

148148
return value;
149149
}
150-
151-
#if NETCOREAPP3_1 // SequenceReader is n/a in 2.1
152-
private int ReadInt32C(ref ReadOnlySequence<byte> bytes)
153-
{
154-
if (bytes.Length < 4)
155-
throw new ArgumentException("Not enough bytes.", nameof(bytes));
156-
157-
var slice = bytes.Slice(bytes.Start, 4); // slice the required bytes
158-
int value;
159-
if (slice.IsSingleSegment)
160-
{
161-
var span = slice.FirstSpan();
162-
value = span.ReadInt32();
163-
}
164-
else
165-
{
166-
// use a reader
167-
var reader = new SequenceReader<byte>(bytes);
168-
reader.TryReadLittleEndian(out value);
169-
}
170-
171-
// consume the slice
172-
bytes = bytes.Slice(slice.End);
173-
174-
return value;
175-
}
176-
#endif
177150
}
178151

179152
public static class Extensions

src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
<!-- ContinuousIntegrationBuild is set via a dotnet pack option -->
4444
</PropertyGroup>
4545

46-
<ItemGroup>
46+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
4747
<PackageReference Include="System.Memory" Version="4.6.3" />
48+
</ItemGroup>
49+
50+
<ItemGroup>
4851
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
4952
</ItemGroup>
5053

src/Hazelcast.Net/Exceptions/StackTraceElement.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -91,7 +91,7 @@ private static bool EqualsN(StackTraceElement left, StackTraceElement right)
9191
/// <inheritdoc />
9292
public override int GetHashCode()
9393
{
94-
#if NETFRAMEWORK || NETSTANDARD2_0
94+
#if NETSTANDARD2_0
9595
unchecked
9696
{
9797
var hashCode = (ClassName != null ? ClassName.GetHashCode() : 0);

src/Hazelcast.Net/Polyfills/Index.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
1717
// The .NET Foundation licenses this file to you under the MIT license.
1818
// See the LICENSE file in the project root for more information.
1919

20-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
20+
#if NETSTANDARD2_0
2121

2222
// brings C# 8 index & range to netstandard 2.0
2323
// see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm

src/Hazelcast.Net/Polyfills/NullableAttributes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,7 @@
1919

2020
#pragma warning disable MA0048 // File name must match type name
2121
#define INTERNAL_NULLABLE_ATTRIBUTES
22-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
22+
#if NETSTANDARD2_0
2323

2424
// brings C# 8 nullable attributes to netstandard 2.0
2525
// see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm

src/Hazelcast.Net/Polyfills/Range.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
1717
// The .NET Foundation licenses this file to you under the MIT license.
1818
// See the LICENSE file in the project root for more information.
1919

20-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
20+
#if NETSTANDARD2_0
2121

2222
// brings C# 8 index & range to netstandard 2.0
2323
// see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm

src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ internal static class ReadOnlySequenceExtensions
3636
/// </remarks>
3737
public static ReadOnlySpan<T> FirstSpan<T>(this ReadOnlySequence<T> sequence)
3838
{
39-
#if NET462 || NETSTANDARD2_0
39+
#if NETSTANDARD2_0
4040
return sequence.First.Span;
4141
#else
4242
return sequence.FirstSpan;

src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
1717
// The .NET Foundation licenses this file to you under the MIT license.
1818
// See the LICENSE file in the project root for more information.
1919

20-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
20+
#if NETSTANDARD2_0
2121

2222
// brings C# 8 index & range to netstandard 2.0
2323
// see https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm

src/Hazelcast.Net/Polyfills/StringExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,7 @@ public static string TrimEnd(this string s, string trim)
2222
=> s.EndsWith(trim) ? s.Substring(0, s.Length - trim.Length) : s;
2323
#pragma warning restore CA1310 // Specify StringComparison for correctness
2424

25-
#if NETFRAMEWORK || NETSTANDARD2_0
25+
#if NETSTANDARD2_0
2626
#pragma warning disable CA1801 // Review unused parameters - we need them
2727
#pragma warning disable IDE0060 // Remove unused parameter
2828

src/Hazelcast.Net/Polyfills/TaskExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
1+
// Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ internal static class TaskExtensions
3131
public static bool IsCompletedSuccessfully(this Task task)
3232
{
3333
if (task == null) throw new ArgumentNullException(nameof(task));
34-
#if NETFRAMEWORK || NETSTANDARD2_0
34+
#if NETSTANDARD2_0
3535
return task.IsCompleted && !(task.IsFaulted || task.IsCanceled);
3636
#else
3737
return task.IsCompletedSuccessfully;
@@ -48,7 +48,7 @@ public static bool IsCompletedSuccessfully(this Task task)
4848
/// </remarks>
4949
public static bool IsCompletedSuccessfully(this ValueTask task)
5050
{
51-
#if NETFRAMEWORK || NETSTANDARD2_0
51+
#if NETSTANDARD2_0
5252
return task.IsCompleted && !(task.IsFaulted || task.IsCanceled);
5353
#else
5454
return task.IsCompletedSuccessfully;
@@ -65,7 +65,7 @@ public static bool IsCompletedSuccessfully(this ValueTask task)
6565
/// </remarks>
6666
public static bool IsCompletedSuccessfully<T>(this ValueTask<T> task)
6767
{
68-
#if NETFRAMEWORK || NETSTANDARD2_0
68+
#if NETSTANDARD2_0
6969
return task.IsCompleted && !(task.IsFaulted || task.IsCanceled);
7070
#else
7171
return task.IsCompletedSuccessfully;

0 commit comments

Comments
 (0)