IGNITE-4045 .NET: Support DML API - fix code analysis warnings
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7b711a32 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7b711a32 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7b711a32 Branch: refs/heads/ignite-gg-11810-1 Commit: 7b711a3248b0dafdcea195766b50be4d44656f7f Parents: b7908d7 Author: Pavel Tupitsyn <ptupit...@apache.org> Authored: Mon Jan 16 19:50:35 2017 +0300 Committer: Pavel Tupitsyn <ptupit...@apache.org> Committed: Mon Jan 16 19:50:35 2017 +0300 ---------------------------------------------------------------------- .../Apache.Ignite.Core.csproj | 1 + .../Binary/BinaryArrayEqualityComparer.cs | 2 +- .../Binary/BinaryEqualityComparerSerializer.cs | 2 +- .../Impl/Binary/DateTimeHolder.cs | 22 +++++++++++- .../Impl/Binary/Io/IBinaryStream.cs | 16 --------- .../Impl/Binary/Io/IBinaryStreamProcessor.cs | 36 ++++++++++++++++++++ 6 files changed, 60 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj index 42ccdd4..d58c872 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -185,6 +185,7 @@ <Compile Include="Common\IgniteGuid.cs" /> <Compile Include="Common\Package-Info.cs" /> <Compile Include="Impl\Binary\DateTimeSerializer.cs" /> + <Compile Include="Impl\Binary\IO\IBinaryStreamProcessor.cs" /> <Compile Include="Impl\Binary\SerializableSerializer.cs" /> <Compile Include="Impl\Binary\BinaryWriterExtensions.cs" /> <Compile Include="Impl\Cache\Affinity\AffinityFunctionBase.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs index 09f7f0f..4e29a91 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs @@ -26,7 +26,7 @@ namespace Apache.Ignite.Core.Binary /// <summary> /// Compares binary object equality using underlying byte array. /// </summary> - public class BinaryArrayEqualityComparer : IEqualityComparer<IBinaryObject>, IBinaryEqualityComparer, + public sealed class BinaryArrayEqualityComparer : IEqualityComparer<IBinaryObject>, IBinaryEqualityComparer, IBinaryStreamProcessor<KeyValuePair<int,int>, int> { /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs index aa4795e..bb26076 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs @@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Impl.Binary }; default: - throw new ArgumentOutOfRangeException(); + throw new ArgumentOutOfRangeException("reader", type, "Invalid EqualityComparer type code"); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs index 6adb847..21c56a9 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs @@ -69,7 +69,7 @@ namespace Apache.Ignite.Core.Impl.Binary public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; - return obj is DateTimeHolder && _item.Equals(((DateTimeHolder) obj)._item); + return obj is DateTimeHolder && Equals((DateTimeHolder) obj); } /** <inheritDoc /> */ @@ -77,5 +77,25 @@ namespace Apache.Ignite.Core.Impl.Binary { return _item.GetHashCode(); } + + /** <inheritDoc /> */ + public static bool operator ==(DateTimeHolder left, DateTimeHolder right) + { + return left.Equals(right); + } + + /** <inheritDoc /> */ + public static bool operator !=(DateTimeHolder left, DateTimeHolder right) + { + return !left.Equals(right); + } + + /// <summary> + /// Checks equality. + /// </summary> + private bool Equals(DateTimeHolder other) + { + return _item.Equals(other._item); + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs index 3a46515..80c1a74 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs @@ -15,7 +15,6 @@ * limitations under the License. */ - namespace Apache.Ignite.Core.Impl.Binary.IO { using System; @@ -329,19 +328,4 @@ namespace Apache.Ignite.Core.Impl.Binary.IO /// </summary> void Flush(); } - - /// <summary> - /// Binary stream processor. - /// </summary> - [CLSCompliant(false)] - public unsafe interface IBinaryStreamProcessor<in TArg, out T> - { - /// <summary> - /// Invokes the processor. - /// </summary> - /// <param name="data">Data.</param> - /// <param name="arg">Argument.</param> - /// <returns>Result.</returns> - T Invoke(byte* data, TArg arg); - } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7b711a32/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStreamProcessor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStreamProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStreamProcessor.cs new file mode 100644 index 0000000..3b8bd8b --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStreamProcessor.cs @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Impl.Binary.IO +{ + using System; + + /// <summary> + /// Binary stream processor. + /// </summary> + [CLSCompliant(false)] + public unsafe interface IBinaryStreamProcessor<in TArg, out T> + { + /// <summary> + /// Invokes the processor. + /// </summary> + /// <param name="data">Data.</param> + /// <param name="arg">Argument.</param> + /// <returns>Result.</returns> + T Invoke(byte* data, TArg arg); + } +} \ No newline at end of file