Skip to content

Commit

Permalink
Cleanup conditional compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson-tomo committed Jul 23, 2024
1 parent 70d6e85 commit 79ed818
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 84 deletions.
33 changes: 3 additions & 30 deletions src/Hazelcast.Net.Tests/DotNet/MemoryTests.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -148,33 +148,6 @@ private int ReadInt32B(ref ReadOnlySequence<byte> bytes)

return value;
}

#if NETCOREAPP3_1 // SequenceReader is n/a in 2.1
private int ReadInt32C(ref ReadOnlySequence<byte> 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<byte>(bytes);
reader.TryReadLittleEndian(out value);
}

// consume the slice
bytes = bytes.Slice(slice.End);

return value;
}
#endif
}

public static class Extensions
Expand Down
4 changes: 0 additions & 4 deletions src/Hazelcast.Net.Win32/Hazelcast.Net.Win32.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
<!-- ContinuousIntegrationBuild is set via a dotnet pack option -->
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Exceptions/StackTraceElement.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -92,7 +92,7 @@ private static bool EqualsN(StackTraceElement left, StackTraceElement right)
/// <inheritdoc />
public override int GetHashCode()
{
#if NETFRAMEWORK || NETSTANDARD2_0
#if NETSTANDARD2_0
unchecked
{
var hashCode = (ClassName != null ? ClassName.GetHashCode() : 0);
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/Index.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/NullableAttributes.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/Range.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/ReadOnlySequenceExtensions.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -36,7 +36,7 @@ internal static class ReadOnlySequenceExtensions
/// </remarks>
public static ReadOnlySpan<T> FirstSpan<T>(this ReadOnlySequence<T> sequence)
{
#if NET462 || NETSTANDARD2_0
#if NETSTANDARD2_0
return sequence.First.Span;
#else
return sequence.FirstSpan;
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/RuntimeHelpersEx.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Hazelcast.Net/Polyfills/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/Hazelcast.Net/Polyfills/TaskExtensions.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -48,7 +48,7 @@ public static bool IsCompletedSuccessfully(this Task task)
/// </remarks>
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;
Expand All @@ -65,7 +65,7 @@ public static bool IsCompletedSuccessfully(this ValueTask task)
/// </remarks>
public static bool IsCompletedSuccessfully<T>(this ValueTask<T> task)
{
#if NETFRAMEWORK || NETSTANDARD2_0
#if NETSTANDARD2_0
return task.IsCompleted && !(task.IsFaulted || task.IsCanceled);
#else
return task.IsCompletedSuccessfully;
Expand Down
14 changes: 5 additions & 9 deletions src/Hazelcast.Net/Polyfills/ZLib/ZlibConstants.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -42,7 +42,7 @@ internal static class ZlibConstants
public const int Z_STREAM_END = 1;

/// <summary>
/// The operation ended in need of a dictionary.
/// The operation ended in need of a dictionary.
/// </summary>
public const int Z_NEED_DICT = 2;

Expand All @@ -64,11 +64,7 @@ internal static class ZlibConstants
/// <summary>
/// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.
/// </summary>
#if NETCF
public const int WorkingBufferSizeDefault = 8192;
#else
public const int WorkingBufferSizeDefault = 16384;
#endif
public const int WorkingBufferSizeDefault = 16384;
/// <summary>
/// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes.
/// </summary>
Expand Down
10 changes: 3 additions & 7 deletions src/Hazelcast.Net/Projection/MultiAttributeProjection.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit 79ed818

Please sign in to comment.