You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/30 09:28:52 UTC
[2/3] ignite git commit: IGNITE-1282: Added FxCop warnings
suppression.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
index cadc58d..e9795c0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Impl.Cache
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cache;
/// <summary>
@@ -110,6 +111,8 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
public void Dispose()
{
if (!_disposed)
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
index d8d014b..b292a13 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
{
using System;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Event;
using Apache.Ignite.Core.Cache.Query;
@@ -185,6 +186,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
public void Dispose()
{
lock (this)
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 382ab1e..6b08a6f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -103,7 +103,6 @@ namespace Apache.Ignite.Core.Impl.Cluster
private readonly Func<IClusterNode, bool> _pred;
/** Topology version. */
- [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")]
private long _topVer = TopVerInit;
/** Nodes for the given topology version. */
@@ -132,6 +131,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
/// <param name="marsh">Marshaller.</param>
/// <param name="ignite">Grid.</param>
/// <param name="pred">Predicate.</param>
+ [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")]
public ClusterGroupImpl(IUnmanagedTarget proc, IUnmanagedTarget target, PortableMarshaller marsh,
Ignite ignite, Func<IClusterNode, bool> pred)
: base(target, marsh)
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
index 664a1f1..52d5236 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
@@ -82,7 +82,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
NonHeapMemoryCommitted = reader.ReadLong();
NonHeapMemoryMaximum = reader.ReadLong();
NonHeapMemoryTotal = reader.ReadLong();
- UpTime = reader.ReadLong();
+ Uptime = reader.ReadLong();
DateTime? startTime0 = reader.ReadDate();
@@ -184,7 +184,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
/** <inheritDoc /> */
public long TotalBusyTime
{
- get { return UpTime - TotalIdleTime; }
+ get { return Uptime - TotalIdleTime; }
}
/** <inheritDoc /> */
@@ -202,7 +202,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
/** <inheritDoc /> */
public float IdleTimePercentage
{
- get { return TotalIdleTime / (float) UpTime; }
+ get { return TotalIdleTime / (float) Uptime; }
}
/** <inheritDoc /> */
@@ -248,7 +248,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
public long NonHeapMemoryTotal { get; private set; }
/** <inheritDoc /> */
- public long UpTime { get; private set; }
+ public long Uptime { get; private set; }
/** <inheritDoc /> */
public DateTime StartTime { get; private set; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
index bd7e895..2adb021 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
@@ -18,10 +18,12 @@
namespace Apache.Ignite.Core.Impl.Collections
{
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
/// <summary>
/// Multiple-values-per-key dictionary.
/// </summary>
+ [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public class MultiValueDictionary<TKey, TValue>
{
/** Inner dictionary */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
index 14195fd..febe969 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
@@ -29,20 +29,9 @@ namespace Apache.Ignite.Core.Impl.Common
"to the client, and IAsyncResult is not IDisposable.")]
public class CompletedAsyncResult : IAsyncResult
{
- /** Singleton instance. */
- public static readonly IAsyncResult Instance = new CompletedAsyncResult();
-
/** */
private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true);
- /// <summary>
- /// Prevents a default instance of the <see cref="CompletedAsyncResult"/> class from being created.
- /// </summary>
- private CompletedAsyncResult()
- {
- // No-op.
- }
-
/** <inheritdoc /> */
public bool IsCompleted
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
index fa785b2..918bbd1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
@@ -19,11 +19,13 @@ namespace Apache.Ignite.Core.Impl.Common
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
/// <summary>
/// Concurrent dictionary with CopyOnWrite mechanism inside.
/// Good for frequent reads / infrequent writes scenarios.
/// </summary>
+ [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public class CopyOnWriteConcurrentDictionary<TKey, TValue>
{
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index 8d7cb3a..5460037 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Common
{
using System;
+ using System.Globalization;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
@@ -191,9 +192,8 @@ namespace Apache.Ignite.Core.Impl.Common
private static void ThrowIfMultipleInterfaces(object check, Type userType, Type interfaceType)
{
if (check != null)
- throw new InvalidOperationException(
- string.Format("Not Supported: Type {0} implements interface {1} multiple times.", userType,
- interfaceType));
+ throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
+ "Not Supported: Type {0} implements interface {1} multiple times.", userType, interfaceType));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index 92b4fce..a25bada 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -165,7 +165,7 @@ namespace Apache.Ignite.Core.Impl.Common
/** <inheritdoc/> */
public IAsyncResult ToAsyncResult()
{
- return _done ? CompletedAsyncResult.Instance : new AsyncResult(this);
+ return _done ? (IAsyncResult) new CompletedAsyncResult() : new AsyncResult(this);
}
/** <inheritdoc/> */
@@ -193,6 +193,7 @@ namespace Apache.Ignite.Core.Impl.Common
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public void OnResult(IPortableStream stream)
{
try
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
index 0beff04..c9f1555 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
@@ -17,9 +17,12 @@
namespace Apache.Ignite.Core.Impl.Common
{
+ using System.Diagnostics.CodeAnalysis;
+
/// <summary>
/// Future types.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification = "Interoperability")]
public enum FutureType
{
/** Future type: byte. */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
index e94c577..a633291 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Common
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
/// <summary>
/// Arguments check helpers.
@@ -44,8 +45,8 @@ namespace Apache.Ignite.Core.Impl.Common
public static void NotNullOrEmpty(string arg, string argName)
{
if (string.IsNullOrEmpty(arg))
- throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
- argName);
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+ "'{0}' argument should not be null or empty.", argName), argName);
}
/// <summary>
@@ -56,8 +57,8 @@ namespace Apache.Ignite.Core.Impl.Common
public static void NotNullOrEmpty<T>(ICollection<T> collection, string argName)
{
if (collection == null || collection.Count == 0)
- throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
- argName);
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+ "'{0}' argument should not be null or empty.", argName), argName);
}
/// <summary>
@@ -69,8 +70,8 @@ namespace Apache.Ignite.Core.Impl.Common
public static void Ensure(bool condition, string argName, string message)
{
if (!condition)
- throw new ArgumentException(string.Format("'{0}' argument is invalid: {1}", argName, message),
- argName);
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+ "'{0}' argument is invalid: {1}", argName, message), argName);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
index d0dd2a9..2d4936f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Common
{
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
/// <summary>
@@ -34,6 +35,8 @@ namespace Apache.Ignite.Core.Impl.Common
/// <typeparam name="TFrom">Source type to cast from.</typeparam>
/// <param name="obj">The object to cast.</param>
/// <returns>Casted object.</returns>
+ [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes",
+ Justification = "Intended usage to leverage compiler caching.")]
public static T Cast<TFrom>(TFrom obj)
{
return Casters<TFrom>.Caster(obj);
@@ -47,6 +50,10 @@ namespace Apache.Ignite.Core.Impl.Common
/// <summary>
/// Compiled caster delegate.
/// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields",
+ Justification = "Incorrect warning")]
+ [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes",
+ Justification = "Intended usage to leverage compiler caching.")]
internal static readonly Func<TFrom, T> Caster = Compile();
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
index 199afc2..26c9bf4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.Compute
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
using System.Threading;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
@@ -76,8 +77,9 @@ namespace Apache.Ignite.Core.Impl.Compute
if (fut0 == null)
throw new InvalidOperationException(
- string.Format("Requested future type {0} is incompatible with current future type {1}",
- typeof(IFuture<TResult>), fut.GetType()));
+ string.Format(CultureInfo.InvariantCulture,
+ "Requested future type {0} is incompatible with current future type {1}",
+ typeof (IFuture<TResult>), fut.GetType()));
_curFut.Value = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
index cbd26dd..49cbc5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
@@ -181,6 +181,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
/// <summary>
/// Await completion of current and all previous loads.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public void AwaitCompletion()
{
DataStreamerBatch<TK, TV> curBatch = this;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
index bf11397..9894e93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Datastream;
@@ -523,6 +524,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
protected override void Dispose(bool disposing)
{
if (disposing)
@@ -671,12 +673,18 @@ namespace Apache.Ignite.Core.Impl.Datastream
private const int StateStopped = 2;
/** Data streamer. */
+ [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields",
+ Justification = "Incorrect warning")]
private readonly WeakReference _ldrRef;
/** Finish flag. */
+ [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields",
+ Justification = "Incorrect warning")]
private int _state;
/** Flush frequency. */
+ [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields",
+ Justification = "Incorrect warning")]
private long _freq;
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
index 066f345..ea109ba 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl
using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
@@ -55,6 +56,8 @@ namespace Apache.Ignite.Core.Impl
/// <summary>
/// Static initializer.
/// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",
+ Justification = "Readability")]
static ExceptionUtils()
{
// Common Java exceptions mapped to common .Net exceptions.
@@ -129,6 +132,7 @@ namespace Apache.Ignite.Core.Impl
/// <param name="msg">Message.</param>
/// <param name="reader">Reader.</param>
/// <returns></returns>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
private static Exception ProcessCachePartialUpdateException(string msg, PortableReaderImpl reader)
{
if (reader == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
index 9c8178f..1979086 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.Handle
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
@@ -197,6 +198,7 @@ namespace Apache.Ignite.Core.Impl.Handle
/// </summary>
/// <param name="target">Target.</param>
/// <param name="quiet">Whether release must be quiet or not.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
private static void Release0(object target, bool quiet)
{
IHandle target0 = target as IHandle;
@@ -316,7 +318,8 @@ namespace Apache.Ignite.Core.Impl.Handle
/// <summary>
/// Gets a snapshot of currently referenced objects list.
/// </summary>
- public List<KeyValuePair<long, object>> GetItems()
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+ public IList<KeyValuePair<long, object>> GetItems()
{
Thread.MemoryBarrier();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 5f764c1..5fdbe06 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Impl
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cluster;
@@ -299,6 +300,10 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
+ [SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_proxy",
+ Justification = "Proxy does not need to be disposed.")]
public void Dispose()
{
Ignition.Stop(Name, true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index d0ddefb..af2557c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -63,20 +64,12 @@ namespace Apache.Ignite.Core.Impl
private static PlatformMemoryManager _mem;
/// <summary>
- /// Static initializer.
- /// </summary>
- static IgniteManager()
- {
- // No-op.
- }
-
- /// <summary>
/// Create JVM.
/// </summary>
/// <param name="cfg">Configuration.</param>
/// <param name="cbs">Callbacks.</param>
/// <returns>Context.</returns>
- internal static void* GetContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
+ internal static void CreateJvmContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
{
lock (SyncRoot)
{
@@ -106,8 +99,6 @@ namespace Apache.Ignite.Core.Impl
_jvmCfg = jvmCfg;
_mem = new PlatformMemoryManager(1024);
}
-
- return ctx;
}
}
@@ -195,10 +186,10 @@ namespace Apache.Ignite.Core.Impl
// JvmInitialMemoryMB / JvmMaxMemoryMB have lower priority than CMD_JVM_OPT
if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMinMemJava, StringComparison.OrdinalIgnoreCase)))
- jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMinMemJava, cfg.JvmInitialMemoryMb));
+ jvmOpts.Add(string.Format(CultureInfo.InvariantCulture, "{0}{1}m", CmdJvmMinMemJava, cfg.JvmInitialMemoryMb));
if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMaxMemJava, StringComparison.OrdinalIgnoreCase)))
- jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMaxMemJava, cfg.JvmMaxMemoryMb));
+ jvmOpts.Add(string.Format(CultureInfo.InvariantCulture, "{0}{1}m", CmdJvmMaxMemJava, cfg.JvmMaxMemoryMb));
return jvmOpts;
}
@@ -248,12 +239,14 @@ namespace Apache.Ignite.Core.Impl
if (string.IsNullOrWhiteSpace(home))
home = Environment.GetEnvironmentVariable(EnvIgniteHome);
else if (!IsIgniteHome(new DirectoryInfo(home)))
- throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home));
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture,
+ "IgniteConfiguration.IgniteHome is not valid: '{0}'", home));
if (string.IsNullOrWhiteSpace(home))
home = ResolveIgniteHome();
else if (!IsIgniteHome(new DirectoryInfo(home)))
- throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home));
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture,
+ "{0} is not valid: '{1}'", EnvIgniteHome, home));
return home;
}
@@ -330,7 +323,7 @@ namespace Apache.Ignite.Core.Impl
{
cpStr.Append(cfg.JvmClasspath);
- if (!cfg.JvmClasspath.EndsWith(";"))
+ if (!cfg.JvmClasspath.EndsWith(";", StringComparison.Ordinal))
cpStr.Append(';');
}
@@ -364,7 +357,7 @@ namespace Apache.Ignite.Core.Impl
{
foreach (string dir in Directory.EnumerateDirectories(ggLibs))
{
- if (!dir.EndsWith("optional"))
+ if (!dir.EndsWith("optional", StringComparison.OrdinalIgnoreCase))
AppendJars(dir, cpStr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 2e01a5b..3e26791 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
@@ -210,6 +211,8 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
public void Dispose()
{
_ignite.Dispose();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 265fd0d..88ab75f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -189,7 +190,7 @@ namespace Apache.Ignite.Core.Impl
if (errCode == 0)
return;
- messages.Add(string.Format("[option={0}, path={1}, errorCode={2}]",
+ messages.Add(string.Format(CultureInfo.InvariantCulture, "[option={0}, path={1}, errorCode={2}]",
dllPath.Key, dllPath.Value, errCode));
if (dllPath.Value == configJvmDllPath)
@@ -197,13 +198,18 @@ namespace Apache.Ignite.Core.Impl
}
if (!messages.Any()) // not loaded and no messages - everything was null
- messages.Add(string.Format("Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
+ messages.Add(string.Format(CultureInfo.InvariantCulture,
+ "Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
if (messages.Count == 1)
- throw new IgniteException(string.Format("Failed to load {0} ({1})", FileJvmDll, messages[0]));
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0} ({1})",
+ FileJvmDll, messages[0]));
- var combinedMessage = messages.Aggregate((x, y) => string.Format("{0}\n{1}", x, y));
- throw new IgniteException(string.Format("Failed to load {0}:\n{1}", FileJvmDll, combinedMessage));
+ var combinedMessage =
+ messages.Aggregate((x, y) => string.Format(CultureInfo.InvariantCulture, "{0}\n{1}", x, y));
+
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0}:\n{1}",
+ FileJvmDll, combinedMessage));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
index 3a9ed26..fb53abc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
@@ -26,7 +26,7 @@ namespace Apache.Ignite.Core.Impl.Memory
public abstract class PlatformMemory : IPlatformMemory
{
/** Memory pointer. */
- protected readonly long MemPtr;
+ private readonly long _memPtr;
/// <summary>
/// Constructor.
@@ -34,7 +34,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <param name="memPtr">Memory pointer.</param>
protected PlatformMemory(long memPtr)
{
- MemPtr = memPtr;
+ _memPtr = memPtr;
}
/** <inheritdoc /> */
@@ -47,26 +47,26 @@ namespace Apache.Ignite.Core.Impl.Memory
/** <inheritdoc /> */
public long Pointer
{
- get { return MemPtr; }
+ get { return _memPtr; }
}
/** <inheritdoc /> */
public long Data
{
- get { return PlatformMemoryUtils.Data(MemPtr); }
+ get { return PlatformMemoryUtils.GetData(_memPtr); }
}
/** <inheritdoc /> */
public int Capacity
{
- get { return PlatformMemoryUtils.Capacity(MemPtr); }
+ get { return PlatformMemoryUtils.GetCapacity(_memPtr); }
}
/** <inheritdoc /> */
public int Length
{
- get { return PlatformMemoryUtils.Length(MemPtr); }
- set { PlatformMemoryUtils.Length(MemPtr, value); }
+ get { return PlatformMemoryUtils.GetLength(_memPtr); }
+ set { PlatformMemoryUtils.SetLength(_memPtr, value); }
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
index b280140..dccf8ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <returns>Memory.</returns>
public IPlatformMemory Get(long memPtr)
{
- int flags = PlatformMemoryUtils.Flags(memPtr);
+ int flags = PlatformMemoryUtils.GetFlags(memPtr);
return PlatformMemoryUtils.IsExternal(flags) ? GetExternalMemory(memPtr)
: PlatformMemoryUtils.IsPooled(flags) ? Pool().Get(memPtr) : new PlatformUnpooledMemory(memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
index 75e8965..18b44b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
@@ -61,7 +61,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <param name="cap">Minimum capacity.</param>
- public void Reallocate(long memPtr, int cap)
+ public static void Reallocate(long memPtr, int cap)
{
PlatformMemoryUtils.ReallocatePooled(memPtr, cap);
}
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// Release pooled memory chunk.
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
- public void Release(long memPtr)
+ public static void Release(long memPtr)
{
PlatformMemoryUtils.ReleasePooled(memPtr);
}
@@ -85,12 +85,12 @@ namespace Apache.Ignite.Core.Impl.Memory
long delta = memPtr - handle.ToInt64();
if (delta == PlatformMemoryUtils.PoolHdrOffMem1)
- return _mem1 ?? (_mem1 = new PlatformPooledMemory(this, memPtr));
+ return _mem1 ?? (_mem1 = new PlatformPooledMemory(memPtr));
if (delta == PlatformMemoryUtils.PoolHdrOffMem2)
- return _mem2 ?? (_mem2 = new PlatformPooledMemory(this, memPtr));
+ return _mem2 ?? (_mem2 = new PlatformPooledMemory(memPtr));
- return _mem3 ?? (_mem3 = new PlatformPooledMemory(this, memPtr));
+ return _mem3 ?? (_mem3 = new PlatformPooledMemory(memPtr));
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
index 71da18f..0df4cb9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Memory
{
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -26,6 +27,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// Platform memory stream.
/// </summary>
[CLSCompliant(false)]
+ [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public unsafe class PlatformMemoryStream : IPortableStream
{
/** Length: 1 byte. */
@@ -53,7 +55,7 @@ namespace Apache.Ignite.Core.Impl.Memory
private readonly IPlatformMemory _mem;
/** Actual data. */
- protected byte* Data;
+ private byte* _data;
/** CalculateCapacity. */
private int _cap;
@@ -72,7 +74,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
_mem = mem;
- Data = (byte*)mem.Data;
+ _data = (byte*)mem.Data;
_cap = mem.Capacity;
_len = mem.Length;
}
@@ -84,7 +86,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len1);
- *(Data + curPos) = val;
+ *(_data + curPos) = val;
}
/** <inheritdoc /> */
@@ -116,7 +118,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len2);
- *((short*)(Data + curPos)) = val;
+ *((short*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
@@ -133,7 +135,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len2);
- *((char*)(Data + curPos)) = val;
+ *((char*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
@@ -150,15 +152,16 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len4);
- *((int*)(Data + curPos)) = val;
+ *((int*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "writePos+4")]
public virtual void WriteInt(int writePos, int val)
{
EnsureWriteCapacity(writePos + 4);
- *((int*)(Data + writePos)) = val;
+ *((int*)(_data + writePos)) = val;
}
/** <inheritdoc /> */
@@ -175,7 +178,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len8);
- *((long*)(Data + curPos)) = val;
+ *((long*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
@@ -192,7 +195,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len4);
- *((float*)(Data + curPos)) = val;
+ *((float*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
@@ -209,7 +212,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(Len8);
- *((double*)(Data + curPos)) = val;
+ *((double*)(_data + curPos)) = val;
}
/** <inheritdoc /> */
@@ -222,11 +225,11 @@ namespace Apache.Ignite.Core.Impl.Memory
}
/** <inheritdoc /> */
- public int WriteString(char* chars, int charCnt, int byteCnt, Encoding enc)
+ public int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding)
{
int curPos = EnsureWriteCapacityAndShift(byteCnt);
- return enc.GetBytes(chars, charCnt, Data + curPos, byteCnt);
+ return encoding.GetBytes(chars, charCnt, _data + curPos, byteCnt);
}
/** <inheritdoc /> */
@@ -253,7 +256,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len1);
- return *(Data + curPos);
+ return *(_data + curPos);
}
/** <inheritdoc /> */
@@ -266,7 +269,7 @@ namespace Apache.Ignite.Core.Impl.Memory
fixed (byte* res0 = res)
{
- PlatformMemoryUtils.CopyMemory(Data + curPos, res0, cnt);
+ PlatformMemoryUtils.CopyMemory(_data + curPos, res0, cnt);
}
return res;
@@ -296,7 +299,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len2);
- return *((short*)(Data + curPos));
+ return *((short*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -317,7 +320,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len2);
- return *((char*)(Data + curPos));
+ return *((char*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -338,7 +341,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len4);
- return *((int*)(Data + curPos));
+ return *((int*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -359,7 +362,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len8);
- return *((long*)(Data + curPos));
+ return *((long*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -380,7 +383,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len4);
- return *((float*)(Data + curPos));
+ return *((float*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -401,7 +404,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(Len8);
- return *((double*)(Data + curPos));
+ return *((double*)(_data + curPos));
}
/** <inheritdoc /> */
@@ -464,7 +467,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
public void SynchronizeInput()
{
- Data = (byte*)_mem.Data;
+ _data = (byte*)_mem.Data;
_cap = _mem.Capacity;
_len = _mem.Length;
}
@@ -482,7 +485,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
public void Reuse()
{
- Data = (byte*)_mem.Data;
+ _data = (byte*)_mem.Data;
_cap = _mem.Capacity;
_len = _mem.Length;
_pos = 0;
@@ -553,7 +556,7 @@ namespace Apache.Ignite.Core.Impl.Memory
_mem.Reallocate(reqCap);
- Data = (byte*)_mem.Data;
+ _data = (byte*)_mem.Data;
_cap = _mem.Capacity;
}
}
@@ -585,7 +588,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureReadCapacityAndShift(cnt);
- PlatformMemoryUtils.CopyMemory(Data + curPos, dest, cnt);
+ PlatformMemoryUtils.CopyMemory(_data + curPos, dest, cnt);
}
/// <summary>
@@ -597,7 +600,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
int curPos = EnsureWriteCapacityAndShift(cnt);
- PlatformMemoryUtils.CopyMemory(src, Data + curPos, cnt);
+ PlatformMemoryUtils.CopyMemory(src, _data + curPos, cnt);
}
/// <summary>
@@ -638,11 +641,34 @@ namespace Apache.Ignite.Core.Impl.Memory
/** <inheritdoc /> */
public void Dispose()
{
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ /** <inheritdoc /> */
+ ~PlatformMemoryStream()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ protected virtual void Dispose(bool disposing)
+ {
SynchronizeOutput();
_mem.Release();
}
-
+
+ /// <summary>
+ /// Gets the data.
+ /// </summary>
+ protected byte* Data
+ {
+ get { return _data; }
+ }
+
#endregion
#region ARRAYS
@@ -660,7 +686,7 @@ namespace Apache.Ignite.Core.Impl.Memory
fixed (byte* res0 = res)
{
- PlatformMemoryUtils.CopyMemory(Data, res0, res.Length);
+ PlatformMemoryUtils.CopyMemory(_data, res0, res.Length);
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
index dd53281..a991b3d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <returns>Data pointer.</returns>
- public static long Data(long memPtr)
+ public static long GetData(long memPtr)
{
return *((long*)memPtr);
}
@@ -82,7 +82,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <returns>CalculateCapacity.</returns>
- public static int Capacity(long memPtr)
+ public static int GetCapacity(long memPtr)
{
return *((int*)(memPtr + MemHdrOffCap));
}
@@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <param name="cap">CalculateCapacity.</param>
- public static void Capacity(long memPtr, int cap)
+ public static void SetCapacity(long memPtr, int cap)
{
*((int*)(memPtr + MemHdrOffCap)) = cap;
}
@@ -102,7 +102,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <returns>Length.</returns>
- public static int Length(long memPtr)
+ public static int GetLength(long memPtr)
{
return *((int*)(memPtr + MemHdrOffLen));
}
@@ -112,7 +112,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <param name="len">Length.</param>
- public static void Length(long memPtr, int len)
+ public static void SetLength(long memPtr, int len)
{
*((int*)(memPtr + MemHdrOffLen)) = len;
}
@@ -122,7 +122,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <returns>Flags.</returns>
- public static int Flags(long memPtr)
+ public static int GetFlags(long memPtr)
{
return *((int*)(memPtr + MemHdrOffFlags));
}
@@ -132,7 +132,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
/// <param name="flags">Flags.</param>
- public static void Flags(long memPtr, int flags)
+ public static void SetFlags(long memPtr, int flags)
{
*((int*)(memPtr + MemHdrOffFlags)) = flags;
}
@@ -144,7 +144,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <returns><c>True</c> if owned by Java.</returns>
public static bool IsExternal(long memPtr)
{
- return IsExternal(Flags(memPtr));
+ return IsExternal(GetFlags(memPtr));
}
/// <summary>
@@ -164,7 +164,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <returns><c>True</c> if pooled.</returns>
public static bool IsPooled(long memPtr)
{
- return IsPooled(Flags(memPtr));
+ return IsPooled(GetFlags(memPtr));
}
/// <summary>
@@ -184,7 +184,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <returns><c>True</c> if acquired.</returns>
public static bool IsAcquired(long memPtr)
{
- return IsAcquired(Flags(memPtr));
+ return IsAcquired(GetFlags(memPtr));
}
/// <summary>
@@ -228,7 +228,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <returns></returns>
public static void ReallocateUnpooled(long memPtr, int cap)
{
- long dataPtr = Data(memPtr);
+ long dataPtr = GetData(memPtr);
long newDataPtr = Marshal.ReAllocHGlobal((IntPtr)dataPtr, (IntPtr)cap).ToInt64();
@@ -244,7 +244,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <param name="memPtr">Memory pointer.</param>
public static void ReleaseUnpooled(long memPtr)
{
- Marshal.FreeHGlobal((IntPtr)Data(memPtr));
+ Marshal.FreeHGlobal((IntPtr)GetData(memPtr));
Marshal.FreeHGlobal((IntPtr)memPtr);
}
@@ -266,9 +266,9 @@ namespace Apache.Ignite.Core.Impl.Memory
*((long*)(poolPtr + i)) = 0;
// 3. Set flags for memory chunks.
- Flags(poolPtr + PoolHdrOffMem1, FlagExt | FlagPooled);
- Flags(poolPtr + PoolHdrOffMem2, FlagExt | FlagPooled);
- Flags(poolPtr + PoolHdrOffMem3, FlagExt | FlagPooled);
+ SetFlags(poolPtr + PoolHdrOffMem1, FlagExt | FlagPooled);
+ SetFlags(poolPtr + PoolHdrOffMem2, FlagExt | FlagPooled);
+ SetFlags(poolPtr + PoolHdrOffMem3, FlagExt | FlagPooled);
return poolPtr;
}
@@ -349,7 +349,7 @@ namespace Apache.Ignite.Core.Impl.Memory
}
else {
// Ensure that we have enough capacity.
- int curCap = Capacity(memPtr);
+ int curCap = GetCapacity(memPtr);
if (cap > curCap) {
data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
@@ -359,7 +359,7 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- Flags(memPtr, FlagExt | FlagPooled | FlagAcquired);
+ SetFlags(memPtr, FlagExt | FlagPooled | FlagAcquired);
}
/// <summary>
@@ -371,7 +371,7 @@ namespace Apache.Ignite.Core.Impl.Memory
{
long data = *((long*)memPtr);
- int curCap = Capacity(memPtr);
+ int curCap = GetCapacity(memPtr);
if (cap > curCap) {
data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
@@ -387,7 +387,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/// <param name="memPtr">Memory pointer.</param>
public static void ReleasePooled(long memPtr)
{
- Flags(memPtr, Flags(memPtr) ^ FlagAcquired);
+ SetFlags(memPtr, GetFlags(memPtr) ^ FlagAcquired);
}
#endregion
@@ -401,12 +401,14 @@ namespace Apache.Ignite.Core.Impl.Memory
private static readonly MemCopy Memcpy;
/** Whether src and dest arguments are inverted. */
+ [SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
private static readonly bool MemcpyInverted;
/// <summary>
/// Static initializer.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static PlatformMemoryUtils()
{
Type type = typeof(Buffer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
index 206df4b..8428be7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
@@ -22,20 +22,16 @@ namespace Apache.Ignite.Core.Impl.Memory
/// </summary>
internal class PlatformPooledMemory : PlatformMemory
{
- /** Pool. */
- private readonly PlatformMemoryPool _pool;
-
/** Cached stream. */
private PlatformMemoryStream _stream;
/// <summary>
/// Constructor.
/// </summary>
- /// <param name="pool">Pool.</param>
/// <param name="memPtr">Memory pointer.</param>
- public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) : base(memPtr)
+ public PlatformPooledMemory(long memPtr) : base(memPtr)
{
- _pool = pool;
+ // No-op.
}
/** <inheritdoc /> */
@@ -53,18 +49,18 @@ namespace Apache.Ignite.Core.Impl.Memory
public override void Reallocate(int cap)
{
// Try doubling capacity to avoid excessive allocations.
- int doubledCap = PlatformMemoryUtils.Capacity(MemPtr) << 1;
+ int doubledCap = PlatformMemoryUtils.GetCapacity(Pointer) << 1;
if (doubledCap > cap)
cap = doubledCap;
- _pool.Reallocate(MemPtr, cap);
+ PlatformMemoryPool.Reallocate(Pointer, cap);
}
/** <inheritdoc /> */
public override void Release()
{
- _pool.Release(MemPtr); // Return to the pool.
+ PlatformMemoryPool.Release(Pointer); // Return to the pool.
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
index 26c1bc1..e3da868 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
@@ -35,18 +35,18 @@ namespace Apache.Ignite.Core.Impl.Memory
public override void Reallocate(int cap)
{
// Try doubling capacity to avoid excessive allocations.
- int doubledCap = ((PlatformMemoryUtils.Capacity(MemPtr) + 16) << 1) - 16;
+ int doubledCap = ((PlatformMemoryUtils.GetCapacity(Pointer) + 16) << 1) - 16;
if (doubledCap > cap)
cap = doubledCap;
- PlatformMemoryUtils.ReallocateUnpooled(MemPtr, cap);
+ PlatformMemoryUtils.ReallocateUnpooled(Pointer, cap);
}
/** <inheritdoc /> */
public override void Release()
{
- PlatformMemoryUtils.ReleaseUnpooled(MemPtr);
+ PlatformMemoryUtils.ReleaseUnpooled(Pointer);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
index 8111117..73d5a51 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
@@ -19,6 +19,7 @@
namespace Apache.Ignite.Core.Impl.Portable.IO
{
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
@@ -26,6 +27,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// Stream capable of working with portable objects.
/// </summary>
[CLSCompliant(false)]
+ [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public unsafe interface IPortableStream : IDisposable
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
index 648d754..f84b5a3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
@@ -37,16 +37,17 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
private static readonly MemCopy Memcpy;
/** Whether src and dest arguments are inverted. */
+ [SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
private static readonly bool MemcpyInverted;
/** Byte: zero. */
- protected const byte ByteZero = 0;
+ private const byte ByteZero = 0;
/** Byte: one. */
- protected const byte ByteOne = 1;
+ private const byte ByteOne = 1;
/** LITTLE_ENDIAN flag. */
- protected static readonly bool LittleEndian = BitConverter.IsLittleEndian;
+ private static readonly bool LittleEndian = BitConverter.IsLittleEndian;
/** Position. */
protected int Pos;
@@ -58,6 +59,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// Static initializer.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static PortableAbstractStream()
{
Type type = typeof(Buffer);
@@ -109,7 +111,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="val">Byte array.</param>
/// <param name="data">Data pointer.</param>
- protected void WriteByteArray0(byte[] val, byte* data)
+ protected static void WriteByteArray0(byte[] val, byte* data)
{
fixed (byte* val0 = val)
{
@@ -132,7 +134,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="len">Array length.</param>
/// <param name="data">Data pointer.</param>
/// <returns>Byte array</returns>
- protected byte[] ReadByteArray0(int len, byte* data)
+ protected static byte[] ReadByteArray0(int len, byte* data)
{
byte[] res = new byte[len];
@@ -175,7 +177,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="val">Bool array.</param>
/// <param name="data">Data pointer.</param>
- protected void WriteBoolArray0(bool[] val, byte* data)
+ protected static void WriteBoolArray0(bool[] val, byte* data)
{
fixed (bool* val0 = val)
{
@@ -198,7 +200,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="len">Array length.</param>
/// <param name="data">Data pointer.</param>
/// <returns>Bool array</returns>
- protected bool[] ReadBoolArray0(int len, byte* data)
+ protected static bool[] ReadBoolArray0(int len, byte* data)
{
bool[] res = new bool[len];
@@ -221,7 +223,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="val">Short value.</param>
/// <param name="data">Data pointer.</param>
- protected void WriteShort0(short val, byte* data)
+ protected static void WriteShort0(short val, byte* data)
{
if (LittleEndian)
*((short*)data) = val;
@@ -247,7 +249,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="data">Data pointer.</param>
/// <returns>Short value</returns>
- protected short ReadShort0(byte* data)
+ protected static short ReadShort0(byte* data)
{
short val;
@@ -276,7 +278,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Short array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteShortArray0(short[] val, byte* data, int cnt)
+ protected static void WriteShortArray0(short[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -317,7 +319,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Short array</returns>
- protected short[] ReadShortArray0(int len, byte* data, int cnt)
+ protected static short[] ReadShortArray0(int len, byte* data, int cnt)
{
short[] res = new short[len];
@@ -380,7 +382,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Char array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteCharArray0(char[] val, byte* data, int cnt)
+ protected static void WriteCharArray0(char[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -421,7 +423,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Char array</returns>
- protected char[] ReadCharArray0(int len, byte* data, int cnt)
+ protected static char[] ReadCharArray0(int len, byte* data, int cnt)
{
char[] res = new char[len];
@@ -468,7 +470,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="val">Int value.</param>
/// <param name="data">Data pointer.</param>
- protected void WriteInt0(int val, byte* data)
+ protected static void WriteInt0(int val, byte* data)
{
if (LittleEndian)
*((int*)data) = val;
@@ -496,7 +498,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="data">Data pointer.</param>
/// <returns>Int value</returns>
- protected int ReadInt0(byte* data) {
+ protected static int ReadInt0(byte* data) {
int val;
if (LittleEndian)
@@ -526,7 +528,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Int array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteIntArray0(int[] val, byte* data, int cnt)
+ protected static void WriteIntArray0(int[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -569,7 +571,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Int array</returns>
- protected int[] ReadIntArray0(int len, byte* data, int cnt)
+ protected static int[] ReadIntArray0(int len, byte* data, int cnt)
{
int[] res = new int[len];
@@ -636,7 +638,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Int array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteFloatArray0(float[] val, byte* data, int cnt)
+ protected static void WriteFloatArray0(float[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -679,7 +681,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Float array</returns>
- protected float[] ReadFloatArray0(int len, byte* data, int cnt)
+ protected static float[] ReadFloatArray0(int len, byte* data, int cnt)
{
float[] res = new float[len];
@@ -721,7 +723,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="val">Long value.</param>
/// <param name="data">Data pointer.</param>
- protected void WriteLong0(long val, byte* data)
+ protected static void WriteLong0(long val, byte* data)
{
if (LittleEndian)
*((long*)data) = val;
@@ -753,7 +755,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// </summary>
/// <param name="data">Data pointer.</param>
/// <returns>Long value</returns>
- protected long ReadLong0(byte* data)
+ protected static long ReadLong0(byte* data)
{
long val;
@@ -788,7 +790,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Long array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteLongArray0(long[] val, byte* data, int cnt)
+ protected static void WriteLongArray0(long[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -835,7 +837,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Long array</returns>
- protected long[] ReadLongArray0(int len, byte* data, int cnt)
+ protected static long[] ReadLongArray0(int len, byte* data, int cnt)
{
long[] res = new long[len];
@@ -906,7 +908,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="val">Double array.</param>
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
- protected void WriteDoubleArray0(double[] val, byte* data, int cnt)
+ protected static void WriteDoubleArray0(double[] val, byte* data, int cnt)
{
if (LittleEndian)
{
@@ -953,7 +955,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="data">Data pointer.</param>
/// <param name="cnt">Bytes count.</param>
/// <returns>Double array</returns>
- protected double[] ReadDoubleArray0(int len, byte* data, int cnt)
+ protected static double[] ReadDoubleArray0(int len, byte* data, int cnt)
{
double[] res = new double[len];
@@ -1009,7 +1011,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="enc">Encoding.</param>
/// <param name="data">Data.</param>
/// <returns>Amount of bytes written.</returns>
- protected int WriteString0(char* chars, int charCnt, int byteCnt, Encoding enc, byte* data)
+ protected static int WriteString0(char* chars, int charCnt, int byteCnt, Encoding enc, byte* data)
{
return enc.GetBytes(chars, charCnt, data, byteCnt);
}
@@ -1253,7 +1255,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// Shift position due to read.
/// </summary>
/// <param name="cnt">Bytes count.</param>
- protected void ShiftRead(int cnt)
+ private void ShiftRead(int cnt)
{
Pos += cnt;
}
@@ -1287,7 +1289,7 @@ namespace Apache.Ignite.Core.Impl.Portable.IO
/// <param name="src">Source.</param>
/// <param name="dest">Destination.</param>
/// <param name="len">Length.</param>
- public static void CopyMemory(byte* src, byte* dest, int len)
+ private static void CopyMemory(byte* src, byte* dest, int len)
{
if (MemcpyInverted)
Memcpy.Invoke(dest, src, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 7ea565b..d18434a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -66,6 +67,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Static initializer.
/// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static PortableBuilderImpl()
{
TypeIds = new Dictionary<Type, int>();
@@ -112,18 +114,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Constructor.
/// </summary>
/// <param name="portables">Portables.</param>
- /// <param name="obj">Initial portable object.</param>
- /// <param name="desc">Type descriptor.</param>
- public PortableBuilderImpl(PortablesImpl portables, PortableUserObject obj,
- IPortableTypeDescriptor desc) : this(portables, null, obj, desc)
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="portables">Portables.</param>
/// <param name="parent">Parent builder.</param>
/// <param name="obj">Initial portable object.</param>
/// <param name="desc">Type descriptor.</param>
@@ -220,7 +210,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <returns>Child builder.</returns>
public PortableBuilderImpl Child(PortableUserObject obj)
{
- return _portables.ChildBuilder(_parent, obj);
+ var desc = _portables.Marshaller.Descriptor(true, obj.TypeId);
+
+ return new PortableBuilderImpl(_portables, null, obj, desc);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index f41962d..c7a0b7b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
using System.Linq;
using Apache.Ignite.Core.Impl.Cache;
using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
@@ -533,7 +534,7 @@ namespace Apache.Ignite.Core.Impl.Portable
var args = type.GetGenericArguments().Select(GetTypeName).Aggregate((x, y) => x + "," + y);
- return string.Format("{0}[{1}]", type.Name, args);
+ return string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", type.Name, args);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index 4e67370..c02c457 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -70,9 +71,11 @@ namespace Apache.Ignite.Core.Impl.Portable
public static readonly PortableSystemWriteDelegate WriteHndGenericDictionary =
WriteGenericDictionary;
- /**
- * <summary>Static initializer.</summary>
- */
+ /// <summary>
+ /// Initializes the <see cref="PortableSystemHandlers"/> class.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",
+ Justification = "Readability.")]
static PortableSystemHandlers()
{
// 1. Primitives.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index 546ccaa..2344db2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
@@ -1543,7 +1544,7 @@ namespace Apache.Ignite.Core.Impl.Portable
if (Enum.GetUnderlyingType(val.GetType()) == TypInt)
{
stream.WriteInt(ObjTypeId);
- stream.WriteInt(Convert.ToInt32(val));
+ stream.WriteInt((int) (object) val);
}
else
throw new PortableException("Only Int32 underlying type is supported for enums: " +
@@ -1610,7 +1611,8 @@ namespace Apache.Ignite.Core.Impl.Portable
public static string CleanFieldName(string fieldName)
{
- if (fieldName.StartsWith("<") && fieldName.EndsWith(">k__BackingField"))
+ if (fieldName.StartsWith("<", StringComparison.Ordinal)
+ && fieldName.EndsWith(">k__BackingField", StringComparison.Ordinal))
return fieldName.Substring(1, fieldName.IndexOf(">", StringComparison.Ordinal) - 1);
return fieldName;
@@ -1934,6 +1936,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="writer">Writer.</param>
/// <param name="success">Success flag.</param>
/// <param name="res">Result.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public static void WriteWrappedInvocationResult(PortableWriterImpl writer, bool success, object res)
{
var pos = writer.Stream.Position;
@@ -1976,6 +1979,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="writer">Writer.</param>
/// <param name="success">Success flag.</param>
/// <param name="res">Result.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public static void WriteInvocationResult(PortableWriterImpl writer, bool success, object res)
{
var pos = writer.Stream.Position;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
index f769e3f..b120041 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
@@ -147,19 +147,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
- /// Create child builder.
- /// </summary>
- /// <param name="parent">Parent builder.</param>
- /// <param name="obj">Portable object.</param>
- /// <returns></returns>
- internal PortableBuilderImpl ChildBuilder(PortableBuilderImpl parent, PortableUserObject obj)
- {
- IPortableTypeDescriptor desc = _marsh.Descriptor(true, obj.TypeId);
-
- return Builder0(null, obj, desc);
- }
-
- /// <summary>
/// Marshaller.
/// </summary>
internal PortableMarshaller Marshaller
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
index 0785f4a..8a738c2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
@@ -118,7 +119,8 @@ namespace Apache.Ignite.Core.Impl.Portable
return null;
var genericType = ResolveNonGenericType(assemblyName,
- string.Format("{0}`{1}", match.Groups[1].Value, genericArgs.Length), assemblies);
+ string.Format(CultureInfo.InvariantCulture, "{0}`{1}", match.Groups[1].Value, genericArgs.Length),
+ assemblies);
if (genericType == null)
return null;
@@ -131,7 +133,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
private static string TrimBrackets(string s)
{
- return s.StartsWith("[") && s.EndsWith("]") ? s.Substring(1, s.Length - 2) : s;
+ return s.StartsWith("[", StringComparison.Ordinal) && s.EndsWith("]", StringComparison.Ordinal)
+ ? s.Substring(1, s.Length - 2)
+ : s;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
index fa5da17..9cf173b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
@@ -20,6 +20,8 @@ namespace Apache.Ignite.Core.Impl.Services
using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
using System.Linq;
using System.Reflection;
@@ -36,6 +38,7 @@ namespace Apache.Ignite.Core.Impl.Services
/// <param name="methodName">Name of the method.</param>
/// <param name="arguments">Arguments.</param>
/// <returns>Pair of method return value and invocation exception.</returns>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public static KeyValuePair<object, Exception> InvokeServiceMethod(object svc, string methodName,
object[] arguments)
{
@@ -75,8 +78,8 @@ namespace Apache.Ignite.Core.Impl.Services
if (methods.Length == 0)
throw new InvalidOperationException(
- string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}'",
- methodName, svcType));
+ string.Format(CultureInfo.InvariantCulture,
+ "Failed to invoke proxy: there is no method '{0}' in type '{1}'", methodName, svcType));
// 2) There is more than 1 method with specified name - resolve with argument types.
methods = methods.Where(m => AreMethodArgsCompatible(arguments, m.GetParameters())).ToArray();
@@ -93,12 +96,14 @@ namespace Apache.Ignite.Core.Impl.Services
if (methods.Length == 0)
throw new InvalidOperationException(
- string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}' with {2} arguments",
- methodName, svcType, argsString));
+ string.Format(CultureInfo.InvariantCulture,
+ "Failed to invoke proxy: there is no method '{0}' in type '{1}' with {2} arguments",
+ methodName, svcType, argsString));
throw new InvalidOperationException(
- string.Format("Failed to invoke proxy: there are {2} methods '{0}' in type '{1}' with {3} " +
- "arguments, can't resolve ambiguity.", methodName, svcType, methods.Length, argsString));
+ string.Format(CultureInfo.InvariantCulture,
+ "Failed to invoke proxy: there are {2} methods '{0}' in type '{1}' with {3} " +
+ "arguments, can't resolve ambiguity.", methodName, svcType, methods.Length, argsString));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
index 47c9f93..35dad92 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Transactions
{
using System;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Transactions;
@@ -39,6 +40,8 @@ namespace Apache.Ignite.Core.Impl.Transactions
}
/** <inheritDoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
public void Dispose()
{
Tx.Dispose();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9256a1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
index 9e71181..3d1e57d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Transactions
{
using System;
+ using System.Globalization;
using System.Threading;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Common;
@@ -26,7 +27,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <summary>
/// Grid cache transaction implementation.
/// </summary>
- internal sealed class TransactionImpl
+ internal sealed class TransactionImpl : IDisposable
{
/** Metadatas. */
private object[] _metas;
@@ -400,7 +401,8 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// </summary>
private InvalidOperationException GetClosedException()
{
- return new InvalidOperationException(string.Format("Transaction {0} is closed, state is {1}", Id, State));
+ return new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
+ "Transaction {0} is closed, state is {1}", Id, State));
}
/// <summary>