Apply readonly modifier when possible (#8531)

This commit is contained in:
James Terwilliger 2023-07-07 07:57:28 -07:00 коммит произвёл GitHub
Родитель e32d9b92f5
Коммит 10493a0c83
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
151 изменённых файлов: 256 добавлений и 254 удалений

Просмотреть файл

@ -16,7 +16,7 @@ namespace Orleans.Clustering.DynamoDB
internal class DynamoDBGatewayListProvider : IGatewayListProvider
{
private DynamoDBStorage storage;
private string clusterId;
private readonly string clusterId;
private readonly string INSTANCE_STATUS_ACTIVE = ((int)SiloStatus.Active).ToString();
private readonly ILogger logger;
private readonly DynamoDBGatewayOptions options;

Просмотреть файл

@ -25,7 +25,7 @@ namespace OrleansAWSUtils.Storage
private const string AccessKeyPropertyName = "AccessKey";
private const string SecretKeyPropertyName = "SecretKey";
private const string ServicePropertyName = "Service";
private ILogger Logger;
private readonly ILogger Logger;
private string accessKey;
private string secretKey;
private string service;

Просмотреть файл

@ -20,8 +20,8 @@ namespace OrleansAWSUtils.Streams
private readonly ClusterOptions clusterOptions;
private readonly Serializer<SQSBatchContainer> serializer;
private readonly ILoggerFactory loggerFactory;
private HashRingBasedStreamQueueMapper streamQueueMapper;
private IQueueAdapterCache adapterCache;
private readonly HashRingBasedStreamQueueMapper streamQueueMapper;
private readonly IQueueAdapterCache adapterCache;
/// <summary>
/// Application level failure handler override.

Просмотреть файл

@ -30,12 +30,12 @@ namespace Orleans.Transactions.DynamoDB
/// </summary>
internal class DynamoDBStorage
{
private string accessKey;
private string token;
private string profileName;
private readonly string accessKey;
private readonly string token;
private readonly string profileName;
/// <summary> Secret key for this dynamoDB table </summary>
protected string secretKey;
private string service;
private readonly string service;
public const int DefaultReadCapacityUnits = 10;
public const int DefaultWriteCapacityUnits = 5;
private readonly ProvisionedThroughput provisionedThroughput;
@ -47,7 +47,7 @@ namespace Orleans.Transactions.DynamoDB
TableStatus.CREATING, TableStatus.UPDATING, TableStatus.ACTIVE
});
private AmazonDynamoDBClient ddbClient;
private ILogger Logger;
private readonly ILogger Logger;
/// <summary>
/// Create a DynamoDBStorage instance

Просмотреть файл

@ -10,9 +10,9 @@ namespace Orleans.Runtime.MembershipService
{
public class AdoNetClusteringTable : IMembershipTable
{
private string clusterId;
private readonly string clusterId;
private readonly IServiceProvider serviceProvider;
private ILogger logger;
private readonly ILogger logger;
private RelationalOrleansQueries orleansQueries;
private readonly AdoNetClusteringSiloOptions clusteringTableOptions;

Просмотреть файл

@ -13,7 +13,7 @@ namespace Orleans.Runtime.Membership
public class AdoNetGatewayListProvider : IGatewayListProvider
{
private readonly ILogger logger;
private string clusterId;
private readonly string clusterId;
private readonly AdoNetClusteringClientOptions options;
private RelationalOrleansQueries orleansQueries;
private readonly IServiceProvider serviceProvider;

Просмотреть файл

@ -20,11 +20,11 @@ namespace Orleans.Storage
/// </summary>
public class AzureBlobGrainStorage : IGrainStorage, ILifecycleParticipant<ISiloLifecycle>
{
private ILogger logger;
private readonly ILogger logger;
private readonly string name;
private readonly IBlobContainerFactory blobContainerFactory;
private readonly AzureBlobStorageOptions options;
private IGrainStorageSerializer grainStorageSerializer;
private readonly IGrainStorageSerializer grainStorageSerializer;
/// <summary> Default constructor </summary>
public AzureBlobGrainStorage(

Просмотреть файл

@ -43,7 +43,7 @@ namespace Orleans.Storage
private const string BINARY_DATA_PROPERTY_NAME = "Data";
private const string STRING_DATA_PROPERTY_NAME = "StringData";
private string name;
private readonly string name;
/// <summary> Default constructor </summary>
public AzureTableGrainStorage(

Просмотреть файл

@ -16,7 +16,7 @@ namespace Orleans.LeaseProviders
public class AzureBlobLeaseProvider : ILeaseProvider
{
private BlobContainerClient container;
private AzureBlobLeaseProviderOptions options;
private readonly AzureBlobLeaseProviderOptions options;
private BlobServiceClient blobClient;
public AzureBlobLeaseProvider(IOptions<AzureBlobLeaseProviderOptions> options)
: this(options.Value)

Просмотреть файл

@ -103,8 +103,8 @@ namespace Orleans.Streaming.EventHubs.Testing
private readonly EventDataGeneratorStreamOptions options;
private readonly IntCounter sequenceNumberCounter = new IntCounter();
private readonly ILogger logger;
private Func<StreamId, IStreamDataGenerator<EventData>> generatorFactory;
private List<IStreamDataGenerator<EventData>> generators;
private readonly Func<StreamId, IStreamDataGenerator<EventData>> generatorFactory;
private readonly List<IStreamDataGenerator<EventData>> generators;
/// <summary>
/// Constructor

Просмотреть файл

@ -12,7 +12,7 @@ namespace Orleans.Streaming.EventHubs.Testing
/// </summary>
public class EventHubPartitionGeneratorReceiver : IEventHubReceiver
{
private IDataGenerator<EventData> generator;
private readonly IDataGenerator<EventData> generator;
/// <summary>
/// Constructor
/// </summary>

Просмотреть файл

@ -13,7 +13,7 @@ namespace Orleans.Streaming.EventHubs
public class AggregatedCachePressureMonitor : List<ICachePressureMonitor>, ICachePressureMonitor
{
private bool isUnderPressure;
private ILogger logger;
private readonly ILogger logger;
/// <summary>
/// Cache monitor which is used to report cache related metrics
/// </summary>

Просмотреть файл

@ -23,7 +23,7 @@ namespace Orleans.Streaming.EventHubs
private double cachePressureContributionCount;
private DateTime nextCheckedTime;
private bool isUnderPressure;
private double flowControlThreshold;
private readonly double flowControlThreshold;
/// <summary>
/// Constructor

Просмотреть файл

@ -50,7 +50,7 @@ namespace Orleans.Streaming.EventHubs
private IEventHubReceiver receiver;
private Func<EventHubPartitionSettings, string, ILogger, IEventHubReceiver> eventHubReceiverFactory;
private readonly Func<EventHubPartitionSettings, string, ILogger, IEventHubReceiver> eventHubReceiverFactory;
private IStreamQueueCheckpointer<string> checkpointer;
private AggregatedQueueFlowController flowController;

Просмотреть файл

@ -192,7 +192,7 @@ namespace Orleans.Configuration
public class StreamCheckpointerConfigurationValidator : IConfigurationValidator
{
private readonly IServiceProvider services;
private string name;
private readonly string name;
public StreamCheckpointerConfigurationValidator(IServiceProvider services, string name)
{
this.services = services;

Просмотреть файл

@ -15,7 +15,7 @@ namespace Orleans.BroadcastChannel
{
private readonly ConcurrentDictionary<InternalChannelId, ICallback> _handlers = new();
private readonly IOnBroadcastChannelSubscribed _subscriptionObserver;
private AsyncLock _lock = new AsyncLock();
private readonly AsyncLock _lock = new AsyncLock();
private interface ICallback
{

Просмотреть файл

@ -18,7 +18,7 @@ namespace Orleans.Runtime.Membership
public class ConsulBasedMembershipTable : IMembershipTable
{
private static readonly TableVersion NotFoundTableVersion = new TableVersion(0, "0");
private ILogger _logger;
private readonly ILogger _logger;
private readonly IConsulClient _consulClient;
private readonly ConsulClusteringOptions clusteringSiloTableOptions;
private readonly string clusterId;

Просмотреть файл

@ -14,8 +14,8 @@ namespace Orleans.Runtime.Membership
public class ConsulGatewayListProvider : IGatewayListProvider
{
private IConsulClient consulClient;
private string clusterId;
private ILogger logger;
private readonly string clusterId;
private readonly ILogger logger;
private readonly ConsulClusteringOptions options;
private readonly TimeSpan maxStaleness;
private readonly string kvRootFolder;

Просмотреть файл

@ -36,7 +36,7 @@ namespace Orleans.Runtime.Membership
/// </remarks>
public class ZooKeeperBasedMembershipTable : IMembershipTable
{
private ILogger logger;
private readonly ILogger logger;
private const int ZOOKEEPER_CONNECTION_TIMEOUT = 2000;

Просмотреть файл

@ -256,13 +256,13 @@ namespace Orleans.Runtime
/// The grain reference functionality which is shared by all grain references of a given type.
/// </summary>
[NonSerialized]
private GrainReferenceShared _shared;
private readonly GrainReferenceShared _shared;
/// <summary>
/// The underlying grain id key.
/// </summary>
[NonSerialized]
private IdSpan _key;
private readonly IdSpan _key;
/// <summary>
/// Gets the grain reference functionality which is shared by all grain references of a given type.

Просмотреть файл

@ -110,7 +110,7 @@ namespace Orleans
/// </summary>
public class AsyncSerialExecutor
{
private AsyncSerialExecutor<bool> executor = new AsyncSerialExecutor<bool>();
private readonly AsyncSerialExecutor<bool> executor = new AsyncSerialExecutor<bool>();
/// <summary>
/// Submits the next function for execution. It will execute after all previously submitted functions have finished, without interleaving their executions.

Просмотреть файл

@ -44,7 +44,7 @@ namespace Orleans.Configuration
/// </summary>
public class ClusterOptionsValidator : IConfigurationValidator
{
private ClusterOptions options;
private readonly ClusterOptions options;
/// <summary>
/// Initializes a new instance of the <see cref="ClusterOptionsValidator"/> class.

Просмотреть файл

@ -16,9 +16,9 @@ namespace Orleans
/// </summary>
public class SerializerConfigurationValidator : IConfigurationValidator
{
private ICodecProvider _codecProvider;
private TypeManifestOptions _options;
private bool _enabled;
private readonly ICodecProvider _codecProvider;
private readonly TypeManifestOptions _options;
private readonly bool _enabled;
/// <summary>
/// Initializes a new instance of the <see cref="SerializerConfigurationValidator"/> class.

Просмотреть файл

@ -242,7 +242,7 @@ namespace Orleans.EventSourcing.Common
/// <summary>
/// Background worker which asynchronously sends operations to the leader
/// </summary>
private BatchWorker worker;
private readonly BatchWorker worker;

Просмотреть файл

@ -31,7 +31,7 @@ namespace Orleans.EventSourcing.CustomStorage
this.primaryCluster = primaryCluster;
}
private string primaryCluster;
private readonly string primaryCluster;
private TLogView cached;
private int version;
@ -280,7 +280,7 @@ namespace Orleans.EventSourcing.CustomStorage
}
}
private SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
private readonly SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
/// <inheritdoc/>
protected override void OnNotificationReceived(INotificationMessage payload)

Просмотреть файл

@ -35,8 +35,8 @@ namespace Orleans.EventSourcing.LogStorage
private const int maxEntriesInNotifications = 200;
IGrainStorage globalGrainStorage;
string grainTypeName;
readonly IGrainStorage globalGrainStorage;
readonly string grainTypeName;
// the object containing the entire log, as retrieved from / sent to storage
LogStateWithMetaDataAndETag<TLogEntry> GlobalLog;
@ -300,7 +300,7 @@ namespace Orleans.EventSourcing.LogStorage
return base.Merge(earlierMessage, laterMessage); // keep only the version number
}
private SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
private readonly SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
/// <inheritdoc/>
protected override void OnNotificationReceived(INotificationMessage payload)

Просмотреть файл

@ -35,8 +35,8 @@ namespace Orleans.EventSourcing.StateStorage
private const int maxEntriesInNotifications = 200;
IGrainStorage globalGrainStorage;
string grainTypeName; // stores the confirmed state including metadata
readonly IGrainStorage globalGrainStorage;
readonly string grainTypeName; // stores the confirmed state including metadata
GrainStateWithMetaDataAndETag<TLogView> GlobalStateCache;
/// <inheritdoc/>
@ -270,7 +270,7 @@ namespace Orleans.EventSourcing.StateStorage
return base.Merge(earlierMessage, laterMessage); // keep only the version number
}
private SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
private readonly SortedList<long, UpdateNotificationMessage> notifications = new SortedList<long,UpdateNotificationMessage>();
/// <inheritdoc/>
protected override void OnNotificationReceived(INotificationMessage payload)

Просмотреть файл

@ -44,8 +44,8 @@ namespace Orleans.Storage
[DebuggerDisplay("MemoryStore:{Name},WithLatency:{latency}")]
public class MemoryGrainStorageWithLatency :IGrainStorage
{
private MemoryGrainStorage baseGranStorage;
private MemoryStorageWithLatencyOptions options;
private readonly MemoryGrainStorage baseGranStorage;
private readonly MemoryStorageWithLatencyOptions options;
/// <summary> Default constructor. </summary>
public MemoryGrainStorageWithLatency(
string name,

Просмотреть файл

@ -2,7 +2,7 @@ namespace Orleans.Runtime
{
internal class GrainContextAccessor : IGrainContextAccessor
{
private HostedClient _hostedClient;
private readonly HostedClient _hostedClient;
public GrainContextAccessor(HostedClient hostedClient)
{

Просмотреть файл

@ -24,7 +24,7 @@ namespace Orleans.Runtime
private DateTime nextTicket;
private static readonly List<ICollectibleGrainContext> nothing = new(0);
private readonly ILogger logger;
private IAsyncTimer _collectionTimer;
private readonly IAsyncTimer _collectionTimer;
private Task _collectionLoopTask;
private int collectionNumber;
private int _activationCount;

Просмотреть файл

@ -28,7 +28,7 @@ namespace Orleans.Runtime
private readonly GrainDirectoryResolver grainDirectoryResolver;
private readonly ILocalGrainDirectory directory;
private readonly ActivationDirectory activations;
private IServiceProvider serviceProvider;
private readonly IServiceProvider serviceProvider;
private readonly ILogger logger;
private readonly string localSiloName;
private readonly IOptions<GrainCollectionOptions> collectionOptions;

Просмотреть файл

@ -6,7 +6,7 @@ namespace Orleans.Configuration
{
internal class GrainCollectionOptionsValidator : IConfigurationValidator
{
private IOptions<GrainCollectionOptions> options;
private readonly IOptions<GrainCollectionOptions> options;
public GrainCollectionOptionsValidator(IOptions<GrainCollectionOptions> options)
{

Просмотреть файл

@ -38,7 +38,7 @@ namespace Orleans.Runtime
private Catalog catalog;
private MessageCenter messageCenter;
private List<IIncomingGrainCallFilter> grainCallFilters;
private DeepCopier _deepCopier;
private readonly DeepCopier _deepCopier;
private readonly InterfaceToImplementationMappingCache interfaceToImplementationMapping;
private HostedClient hostedClient;

Просмотреть файл

@ -27,7 +27,7 @@ namespace Orleans.Runtime.MembershipService
private readonly object _lockObj = new object();
private readonly IAsyncTimer _pingTimer;
private ValueStopwatch _elapsedSinceLastSuccessfulResponse;
private Func<SiloHealthMonitor, ProbeResult, Task> _onProbeResult;
private readonly Func<SiloHealthMonitor, ProbeResult, Task> _onProbeResult;
private Task _runTask;
/// <summary>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Orleans.Runtime
private readonly string typeName;
private GrainServiceStatus status;
private ILogger Logger;
private readonly ILogger Logger;
/// <summary>Gets the token for signaling cancellation upon stopping of grain service</summary>
protected CancellationTokenSource StoppedCancellationTokenSource { get; }

Просмотреть файл

@ -17,7 +17,7 @@ namespace Orleans.Runtime
private int totalNumTicks;
private readonly ILogger logger;
private volatile Task currentlyExecutingTickTask;
private object currentlyExecutingTickTaskLock = new();
private readonly object currentlyExecutingTickTaskLock = new();
private readonly IGrainContext grainContext;
public string Name { get; }

Просмотреть файл

@ -89,7 +89,7 @@ namespace Orleans.Serialization
[RegisterCopier]
public sealed class FSharpOptionCopier<T> : IDeepCopier<FSharpOption<T>>
{
private IDeepCopier<T> _valueCopier;
private readonly IDeepCopier<T> _valueCopier;
/// <summary>
/// Initializes a new instance of the <see cref="FSharpOptionCopier{T}"/> class.
@ -189,7 +189,7 @@ namespace Orleans.Serialization
[RegisterCopier]
public sealed class FSharpValueOptionCopier<T> : IDeepCopier<FSharpValueOption<T>>
{
private IDeepCopier<T> _valueCopier;
private readonly IDeepCopier<T> _valueCopier;
/// <summary>
/// Initializes a new instance of the <see cref="FSharpValueOptionCopier{T}"/> class.

Просмотреть файл

@ -19,8 +19,8 @@ namespace Orleans.Providers.GCP.Streams.PubSub
private readonly ClusterOptions clusterOptions;
private readonly ILoggerFactory loggerFactory;
private readonly Func<TDataAdapter> _adaptorFactory;
private HashRingBasedStreamQueueMapper _streamQueueMapper;
private IQueueAdapterCache _adapterCache;
private readonly HashRingBasedStreamQueueMapper _streamQueueMapper;
private readonly IQueueAdapterCache _adapterCache;
/// <summary>
/// Application level failure handler override.

Просмотреть файл

@ -24,8 +24,8 @@ namespace Orleans.Providers.GCP.Streams.PubSub
private Topic _topic;
private PublisherClient _publisher;
private SubscriberClient _subscriber;
private TimeSpan? _deadline;
private ServiceEndpoint _customEndpoint;
private readonly TimeSpan? _deadline;
private readonly ServiceEndpoint _customEndpoint;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
private readonly ILogger _logger;

Просмотреть файл

@ -34,8 +34,8 @@ namespace Orleans.Providers.Streams.Common
/// </summary>
public class ObjectPoolMonitorBridge : IObjectPoolMonitor
{
private IBlockPoolMonitor blockPoolMonitor;
private int blockSizeInBytes;
private readonly IBlockPoolMonitor blockPoolMonitor;
private readonly int blockSizeInBytes;
/// <summary>
/// Initializes a new instance of the <see cref="ObjectPoolMonitorBridge"/> class.

Просмотреть файл

@ -9,9 +9,9 @@ namespace Orleans.Streams
/// <typeparam name="T">The type of object produced by the observable.</typeparam>
internal class GenericAsyncObserver<T> : IAsyncObserver<T>
{
private Func<T, StreamSequenceToken, Task> onNextAsync;
private Func<Exception, Task> onErrorAsync;
private Func<Task> onCompletedAsync;
private readonly Func<T, StreamSequenceToken, Task> onNextAsync;
private readonly Func<Exception, Task> onErrorAsync;
private readonly Func<Task> onCompletedAsync;
public GenericAsyncObserver(Func<T, StreamSequenceToken, Task> onNextAsync, Func<Exception, Task> onErrorAsync, Func<Task> onCompletedAsync)
{

Просмотреть файл

@ -31,7 +31,7 @@ namespace Orleans.Streams
private readonly ILoggerFactory loggerFactory;
private int latestRingNotificationSequenceNumber;
private int latestCommandNumber;
private IQueueAdapter queueAdapter;
private readonly IQueueAdapter queueAdapter;
private readonly IQueueAdapterCache queueAdapterCache;
private IStreamQueueBalancer queueBalancer;
private readonly IStreamFilter streamFilter;

Просмотреть файл

@ -9,9 +9,9 @@ namespace Orleans.Providers
{
internal class ClientStreamingProviderRuntime : IStreamProviderRuntime, ILifecycleParticipant<IClusterClientLifecycle>
{
private IStreamPubSub grainBasedPubSub;
private IStreamPubSub implicitPubSub;
private IStreamPubSub combinedGrainBasedAndImplicitPubSub;
private readonly IStreamPubSub grainBasedPubSub;
private readonly IStreamPubSub implicitPubSub;
private readonly IStreamPubSub combinedGrainBasedAndImplicitPubSub;
private StreamDirectory streamDirectory;
private readonly IInternalGrainFactory grainFactory;
private readonly ImplicitStreamSubscriberTable implicitSubscriberTable;

Просмотреть файл

@ -14,8 +14,8 @@ namespace Orleans.Hosting
/// </summary>
public class PersistentStreamStorageConfigurationValidator : IConfigurationValidator
{
private IServiceProvider services;
private string streamProviderName;
private readonly IServiceProvider services;
private readonly string streamProviderName;
/// <summary>
/// Initializes a new instance of the <see cref="PersistentStreamStorageConfigurationValidator"/> class.

Просмотреть файл

@ -137,7 +137,7 @@ namespace Orleans.TestingHost.Logging
public class FileLogger : ILogger
{
private readonly FileLoggingOutput output;
private string category;
private readonly string category;
/// <summary>
/// Initializes a new instance of the <see cref="FileLogger"/> class.

Просмотреть файл

@ -8,7 +8,7 @@ namespace Orleans.TestingHost.Logging
/// </summary>
public class FileLoggerProvider : ILoggerProvider
{
private FileLoggingOutput output;
private readonly FileLoggingOutput output;
/// <summary>
/// Initializes a new instance of the <see cref="FileLoggerProvider"/> class.

Просмотреть файл

@ -31,8 +31,8 @@ namespace Orleans.TestingHost
public class FaultInjectionGrainStorage : IGrainStorage, ILifecycleParticipant<ISiloLifecycle>
{
private readonly IGrainStorage realStorageProvider;
private IGrainFactory grainFactory;
private ILogger logger;
private readonly IGrainFactory grainFactory;
private readonly ILogger logger;
private readonly FaultInjectionGrainStorageOptions options;
/// <summary>

Просмотреть файл

@ -11,12 +11,12 @@ namespace Orleans.TestingHost.UnixSocketTransport;
internal class UnixSocketConnectionListener : IConnectionListener
{
private UnixDomainSocketEndPoint _unixEndpoint;
private EndPoint _endpoint;
private UnixSocketConnectionOptions _socketConnectionOptions;
private SocketsTrace _trace;
private SocketSchedulers _schedulers;
private MemoryPool<byte> _memoryPool;
private readonly UnixDomainSocketEndPoint _unixEndpoint;
private readonly EndPoint _endpoint;
private readonly UnixSocketConnectionOptions _socketConnectionOptions;
private readonly SocketsTrace _trace;
private readonly SocketSchedulers _schedulers;
private readonly MemoryPool<byte> _memoryPool;
private Socket _listenSocket;
public UnixSocketConnectionListener(UnixDomainSocketEndPoint unixEndpoint, EndPoint endpoint, UnixSocketConnectionOptions socketConnectionOptions, SocketsTrace trace, SocketSchedulers schedulers)

Просмотреть файл

@ -23,7 +23,7 @@ namespace Orleans.Transactions.TestKit.Consistency
private readonly HashSet<string> aborted;
private readonly Dictionary<string, string> indoubt;
private bool timeoutsOccurred;
private bool tolerateUnknownExceptions;
private readonly bool tolerateUnknownExceptions;
private readonly IGrainFactory grainFactory;
private readonly Dictionary<string, HashSet<string>> orderEdges = new Dictionary<string, HashSet<string>>();

Просмотреть файл

@ -11,7 +11,7 @@ namespace Orleans.Transactions.TestKit
internal class FaultInjectionTransactionManager<TState> : ITransactionManager
where TState : class, new()
{
private TransactionManager<TState> tm;
private readonly TransactionManager<TState> tm;
private readonly IGrainRuntime grainRuntime;
private readonly IGrainContext context;
private readonly FaultInjectionControl faultInjectionControl;

Просмотреть файл

@ -63,7 +63,7 @@ namespace Orleans.Transactions.TestKit
private readonly TransactionalState<TState> txState;
private readonly ILogger logger;
public FaultInjectionControl FaultInjectionControl { get; set; }
private IControlledTransactionFaultInjector faultInjector;
private readonly IControlledTransactionFaultInjector faultInjector;
public string CurrentTransactionId => this.txState.CurrentTransactionId;
public FaultInjectionTransactionalState(TransactionalState<TState> txState, IControlledTransactionFaultInjector faultInjector, IGrainRuntime grainRuntime, ILogger<FaultInjectionTransactionalState<TState>> logger)
{

Просмотреть файл

@ -30,7 +30,7 @@ namespace Orleans.Transactions.TestKit
public class FaultInjectionTransactionalStateFactory : IFaultInjectionTransactionalStateFactory
{
private IGrainContextAccessor contextAccessor;
private readonly IGrainContextAccessor contextAccessor;
public FaultInjectionTransactionalStateFactory(IGrainContextAccessor contextAccessor)
{
this.contextAccessor = contextAccessor;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Orleans.Transactions.TestKit
public bool InjectAfterStore { get; set; }
private int injectionBeforeStoreCounter = 0;
private int injectionAfterStoreCounter = 0;
private ILogger logger;
private readonly ILogger logger;
public SimpleAzureStorageExceptionInjector(ILogger<SimpleAzureStorageExceptionInjector> logger)
{
this.logger = logger;

Просмотреть файл

@ -17,7 +17,7 @@ namespace Orleans.Transactions.TestKit
// - can produce errors for fault senarios.
public class RemoteCommitService : IRemoteCommitService
{
ILogger logger;
readonly ILogger logger;
public RemoteCommitService(ILogger<RemoteCommitService> logger)
{

Просмотреть файл

@ -49,7 +49,7 @@ namespace Orleans.Transactions.TestKit
response.PendingStates.Should().BeEmpty();
}
private static List<PendingTransactionState<TState>> emptyPendingStates = new List<PendingTransactionState<TState>>();
private static readonly List<PendingTransactionState<TState>> emptyPendingStates = new List<PendingTransactionState<TState>>();
public virtual async Task StoreWithoutChanges()
{

Просмотреть файл

@ -15,8 +15,8 @@ namespace Orleans.Transactions.State
{
private readonly TransactionalStateOptions options;
private readonly TransactionQueue<TState> queue;
private BatchWorker lockWorker;
private BatchWorker storageWorker;
private readonly BatchWorker lockWorker;
private readonly BatchWorker storageWorker;
private readonly ILogger logger;
private readonly IActivationLifetime activationLifetime;

Просмотреть файл

@ -34,14 +34,14 @@ namespace Orleans.Transactions
// watermarks for commit, prepare, abort
private long confirmUpTo;
private long cancelAbove;
private long cancelAboveStart;
private readonly long cancelAboveStart;
// prepare records
private SortedDictionary<long, PendingTransactionState<TState>> prepares;
private readonly SortedDictionary<long, PendingTransactionState<TState>> prepares;
// follow-up actions, to be executed after storing this batch
private List<Action> followUpActions;
private List<Func<Task<bool>>> storeConditions;
private readonly List<Action> followUpActions;
private readonly List<Func<Task<bool>>> storeConditions;
// counters for each type of event
private int total = 0;

Просмотреть файл

@ -32,7 +32,7 @@ namespace Orleans.Transactions.State
private int failCounter;
// collection tasks
private Dictionary<DateTime, PreparedMessages> unprocessedPreparedMessages;
private readonly Dictionary<DateTime, PreparedMessages> unprocessedPreparedMessages;
private class PreparedMessages
{
public PreparedMessages(TransactionalStatus status)

Просмотреть файл

@ -9,7 +9,7 @@ namespace Orleans.Transactions
{
public class TransactionalStateFactory : ITransactionalStateFactory
{
private IGrainContextAccessor contextAccessor;
private readonly IGrainContextAccessor contextAccessor;
public TransactionalStateFactory(IGrainContextAccessor contextAccessor)
{
this.contextAccessor = contextAccessor;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Orleans.Transactions.TOC
internal class TocTransactionQueue<TService> : TransactionQueue<TransactionCommitter<TService>.OperationState>
where TService : class
{
private TService service;
private readonly TService service;
public TocTransactionQueue(
TService service,

Просмотреть файл

@ -7,7 +7,7 @@ namespace Orleans.Transactions
{
public class TransactionCommitterFactory : ITransactionCommitterFactory
{
private IGrainContextAccessor contextAccessor;
private readonly IGrainContextAccessor contextAccessor;
public TransactionCommitterFactory(IGrainContextAccessor contextAccessor)
{

Просмотреть файл

@ -13,9 +13,9 @@ namespace Benchmarks.GrainStorage
public class GrainStorageBenchmark : IDisposable
{
private TestCluster host;
private int concurrent;
private int payloadSize;
private TimeSpan duration;
private readonly int concurrent;
private readonly int payloadSize;
private readonly TimeSpan duration;
public GrainStorageBenchmark(int concurrent, int payloadSize, TimeSpan duration)
{

Просмотреть файл

@ -107,7 +107,7 @@ namespace Benchmarks.MapReduce
_host?.Dispose();
}
private string _text = @"Historically, the world of data and the world of objects" +
private readonly string _text = @"Historically, the world of data and the world of objects" +
@" have not been well integrated. Programmers work in C# or Visual Basic" +
@" and also in SQL or XQuery. On the one side are concepts such as classes," +
@" objects, fields, inheritance, and .NET Framework APIs. On the other side" +

Просмотреть файл

@ -18,9 +18,9 @@ namespace Benchmarks.Transactions
public class TransactionBenchmark : IDisposable
{
private TestCluster host;
private int runs;
private int transactionsPerRun;
private int concurrent;
private readonly int runs;
private readonly int transactionsPerRun;
private readonly int concurrent;
public TransactionBenchmark(int runs, int transactionsPerRun, int concurrent)
{

Просмотреть файл

@ -13,12 +13,12 @@ namespace DefaultCluster.Tests
public class ClientAddressableTests : HostedTestClusterEnsureDefaultStarted
{
private object anchor;
private IRuntimeClient runtimeClient;
private readonly IRuntimeClient runtimeClient;
private class MyPseudoGrain : IClientAddressableTestClientObject
{
private int counter = 0;
private List<int> numbers = new List<int>();
private readonly List<int> numbers = new List<int>();
public Task<string> OnHappyPath(string message)
{

Просмотреть файл

@ -12,7 +12,7 @@ namespace DefaultCluster.Tests.ActivationsLifeCycleTests
{
public class GrainActivateDeactivateTests : HostedTestClusterEnsureDefaultStarted, IDisposable
{
private IActivateDeactivateWatcherGrain watcher;
private readonly IActivateDeactivateWatcherGrain watcher;
public GrainActivateDeactivateTests(DefaultClusterFixture fixture) : base(fixture)
{

Просмотреть файл

@ -23,7 +23,7 @@ namespace DefaultCluster.Tests.General
public class Fixture : IAsyncLifetime
{
private TestClusterPortAllocator portAllocator;
private readonly TestClusterPortAllocator portAllocator;
public IHost Host { get; private set; }
public Fixture()

Просмотреть файл

@ -14,7 +14,7 @@ namespace DefaultCluster.Tests.General
IMultifacetReader reader;
//int eventCounter;
const int EXPECTED_NUMBER_OF_EVENTS = 4;
private TimeSpan timeout = TimeSpan.FromSeconds(5);
private readonly TimeSpan timeout = TimeSpan.FromSeconds(5);
public MultifacetGrainTest(DefaultClusterFixture fixture) : base(fixture)
{

Просмотреть файл

@ -11,7 +11,7 @@ namespace DistributedTests.Grains
[ImplicitStreamSubscription(StreamingConstants.StreamingNamespace)]
public class ImplicitSubscriberGrain : Grain, IImplicitSubscriberGrain, IStreamSubscriptionObserver, IAsyncObserver<object>
{
private ILogger _logger;
private readonly ILogger _logger;
private int _requestCounter;
private int _errorCounter;

Просмотреть файл

@ -16,8 +16,8 @@ namespace AWSUtils.Tests.StorageTests
public class DynamoDBStorageStressTests : IClassFixture<DynamoDBStorageTestsFixture>
{
private readonly ITestOutputHelper output;
private string PartitionKey;
private UnitTestDynamoDBStorage manager;
private readonly string PartitionKey;
private readonly UnitTestDynamoDBStorage manager;
public DynamoDBStorageStressTests(DynamoDBStorageTestsFixture fixture, ITestOutputHelper output)
{

Просмотреть файл

@ -10,8 +10,8 @@ namespace AWSUtils.Tests.StorageTests.AWSUtils
[TestCategory("Storage"), TestCategory("AWS"), TestCategory("DynamoDb")]
public class DynamoDBStorageTests : IClassFixture<DynamoDBStorageTestsFixture>
{
private string PartitionKey;
private UnitTestDynamoDBStorage manager;
private readonly string PartitionKey;
private readonly UnitTestDynamoDBStorage manager;
public DynamoDBStorageTests(DynamoDBStorageTestsFixture fixture)
{

Просмотреть файл

@ -21,7 +21,7 @@ namespace AWSUtils.Tests.Streaming
{
private const string SQSStreamProviderName = "SQSProvider";
private const string StreamNamespace = "SQSSubscriptionMultiplicityTestsNamespace";
private string StorageConnectionString = AWSTestConstants.SqsConnectionString;
private readonly string StorageConnectionString = AWSTestConstants.SqsConnectionString;
private readonly ITestOutputHelper output;
private ClientStreamTestRunner runner;

Просмотреть файл

@ -19,7 +19,7 @@ namespace AWSUtils.Tests.Streaming
{
private const string SQSStreamProviderName = "SQSProvider";
private const string StreamNamespace = "SQSSubscriptionMultiplicityTestsNamespace";
private string StreamConnectionString = AWSTestConstants.SqsConnectionString;
private readonly string StreamConnectionString = AWSTestConstants.SqsConnectionString;
private SubscriptionMultiplicityTestRunner runner;
protected override void ConfigureTestCluster(TestClusterBuilder builder)

Просмотреть файл

@ -24,14 +24,14 @@ namespace ServiceBus.Tests.EvictionStrategyTests
[TestCategory("EventHub"), TestCategory("Streaming")]
public class EHPurgeLogicTests
{
private CachePressureInjectionMonitor cachePressureInjectionMonitor;
private PurgeDecisionInjectionPredicate purgePredicate;
private Serializer serializer;
private readonly CachePressureInjectionMonitor cachePressureInjectionMonitor;
private readonly PurgeDecisionInjectionPredicate purgePredicate;
private readonly Serializer serializer;
private EventHubAdapterReceiver receiver1;
private EventHubAdapterReceiver receiver2;
private ObjectPool<FixedSizeBuffer> bufferPool;
private TimeSpan timeOut = TimeSpan.FromSeconds(30);
private EventHubPartitionSettings ehSettings;
private readonly ObjectPool<FixedSizeBuffer> bufferPool;
private readonly TimeSpan timeOut = TimeSpan.FromSeconds(30);
private readonly EventHubPartitionSettings ehSettings;
private NoOpHostEnvironmentStatistics _hostEnvironmentStatistics;
private ConcurrentBag<EventHubQueueCacheForTesting> cacheList;
private List<EHEvictionStrategyForTesting> evictionStrategyList;

Просмотреть файл

@ -30,8 +30,8 @@ namespace ServiceBus.Tests.EvictionStrategyTests
public class MockEventHubCacheAdaptor : EventHubDataAdapter
{
private long sequenceNumberCounter = 0;
private int eventIndex = 1;
private string eventHubOffset = "OffSet";
private readonly int eventIndex = 1;
private readonly string eventHubOffset = "OffSet";
public MockEventHubCacheAdaptor(Orleans.Serialization.Serializer serializer) : base(serializer)
{ }

Просмотреть файл

@ -95,7 +95,7 @@ namespace ServiceBus.Tests.TestStreamProviders
private class CacheFactoryForMonitorTesting : EventHubQueueCacheFactory
{
private CachePressureInjectionMonitor cachePressureInjectionMonitor;
private readonly CachePressureInjectionMonitor cachePressureInjectionMonitor;
public CacheFactoryForMonitorTesting(
CachePressureInjectionMonitor cachePressureInjectionMonitor,
EventHubStreamCachePressureOptions cacheOptions,

Просмотреть файл

@ -56,7 +56,7 @@ namespace Tester.Redis.Persistence
protected override void CheckPreconditionsOrThrow() => TestUtils.CheckForRedis();
}
private Fixture fixture;
private readonly Fixture fixture;
public RedisPersistenceGrainTests(ITestOutputHelper output, Fixture fixture) : base(output, fixture)
{
@ -84,8 +84,8 @@ namespace Tester.Redis.Persistence
// Redis specific tests
private GrainState state;
private IDatabase database;
private readonly GrainState state;
private readonly IDatabase database;
[SkippableFact]
public async Task Redis_InitializeWithNoStateTest()

Просмотреть файл

@ -62,7 +62,7 @@ namespace Tester.AdoNet.Persistence
}
}
private Fixture fixture;
private readonly Fixture fixture;
public PersistenceGrainTests_MySql(ITestOutputHelper output, Fixture fixture) : base(output, fixture)
{

Просмотреть файл

@ -62,7 +62,7 @@ namespace Tester.AdoNet.Persistence
}
}
private Fixture fixture;
private readonly Fixture fixture;
public PersistenceGrainTests_Postgres(ITestOutputHelper output, Fixture fixture) : base(output, fixture)
{

Просмотреть файл

@ -61,7 +61,7 @@ namespace Tester.AdoNet.Persistence
}
}
private Fixture fixture;
private readonly Fixture fixture;
public PersistenceGrainTests_SqlServer(ITestOutputHelper output, Fixture fixture) : base(output, fixture)
{

Просмотреть файл

@ -24,7 +24,7 @@ namespace Tester.AdoNet.Reminders
public class ReminderTests_AdoNet_SqlServer : ReminderTests_Base, IClassFixture<ReminderTests_AdoNet_SqlServer.Fixture>
{
private const string TestDatabaseName = "OrleansTest_SqlServer_Reminders";
private static string AdoInvariant = AdoNetInvariants.InvariantNameSqlServer;
private static readonly string AdoInvariant = AdoNetInvariants.InvariantNameSqlServer;
private const string ConnectionStringKey = "ReminderConnectionString";
public class Fixture : BaseTestClusterFixture

Просмотреть файл

@ -16,8 +16,8 @@ namespace Tester.AzureUtils
public class AzureTableDataManagerStressTests : AzureStorageBasicTests
{
private readonly ITestOutputHelper output;
private string PartitionKey;
private UnitTestAzureTableDataManager manager;
private readonly string PartitionKey;
private readonly UnitTestAzureTableDataManager manager;
public AzureTableDataManagerStressTests(ITestOutputHelper output)
{

Просмотреть файл

@ -12,8 +12,8 @@ namespace Tester.AzureUtils
[TestCategory("AzureStorage"), TestCategory("Storage")]
public class AzureTableDataManagerTests : AzureStorageBasicTests
{
private string PartitionKey;
private UnitTestAzureTableDataManager manager;
private readonly string PartitionKey;
private readonly UnitTestAzureTableDataManager manager;
private UnitTestAzureTableData GenerateNewData()
{

Просмотреть файл

@ -35,7 +35,7 @@ namespace Tester.AzureUtils.Persistence
protected readonly ILogger logger;
private const int LoopIterations_Grain = 1000;
private const int BatchSize = 100;
private GrainPersistenceTestsRunner basicPersistenceTestsRunner;
private readonly GrainPersistenceTestsRunner basicPersistenceTestsRunner;
private const int MaxReadTime = 200;
private const int MaxWriteTime = 2000;
public class SiloBuilderConfigurator : ISiloConfigurator

Просмотреть файл

@ -33,7 +33,7 @@ namespace Tester.AzureUtils
}
}
private string clusterId;
private readonly string clusterId;
private int generation;
private SiloAddress siloAddress;
private SiloInstanceTableEntry myEntry;

Просмотреть файл

@ -31,7 +31,7 @@ namespace Tester.AzureUtils.Streaming
private const int NumMessagesPerBatch = 20;
public static readonly string AZURE_QUEUE_STREAM_PROVIDER_NAME = "AQAdapterTests";
private readonly ILoggerFactory loggerFactory;
private static List<string> azureQueueNames = AzureQueueUtilities.GenerateQueueNames($"AzureQueueAdapterTests-{Guid.NewGuid()}", 8);
private static readonly List<string> azureQueueNames = AzureQueueUtilities.GenerateQueueNames($"AzureQueueAdapterTests-{Guid.NewGuid()}", 8);
public AzureQueueAdapterTests(ITestOutputHelper output, TestEnvironmentFixture fixture)
{

Просмотреть файл

@ -16,7 +16,7 @@ namespace BenchmarkGrains.Transaction
public class TransactionGrain : Grain, ITransactionGrain
{
private ITransactionalState<Info> info;
private readonly ITransactionalState<Info> info;
public TransactionGrain(
[TransactionalState("Info")] ITransactionalState<Info> info)

Просмотреть файл

@ -8,7 +8,7 @@ namespace Orleans.UnitTest.GrainInterfaces
public class MyTypeWithAnInternalTypeField
{
[Id(0)]
private MyInternalDependency _dependency;
private readonly MyInternalDependency _dependency;
public MyTypeWithAnInternalTypeField()
{

Просмотреть файл

@ -8,7 +8,7 @@ namespace UnitTests.Grains
{
internal class ActivateDeactivateWatcherGrain : IActivateDeactivateWatcherGrain
{
private ILogger logger;
private readonly ILogger logger;
private readonly List<string> activationCalls = new List<string>();
private readonly List<string> deactivationCalls = new List<string>();

Просмотреть файл

@ -28,7 +28,7 @@ namespace UnitTests.Grains
[StorageProvider(ProviderName = "MemoryStore")]
public class ChainedGrain : Grain<ChainedGrainState>, IChainedGrain
{
private ILogger logger;
private readonly ILogger logger;
public ChainedGrain(ILoggerFactory loggerFactory)
{

Просмотреть файл

@ -12,7 +12,7 @@ namespace UnitTests.Grains
{
public class ConcurrentGrain : Grain, IConcurrentGrain
{
private ILogger logger;
private readonly ILogger logger;
private List<IConcurrentGrain> children;
private int index;
private int callNumber;
@ -115,7 +115,7 @@ namespace UnitTests.Grains
[Reentrant]
public class ConcurrentReentrantGrain : Grain, IConcurrentReentrantGrain
{
private ILogger logger;
private readonly ILogger logger;
private int index;
private TaskCompletionSource<int> resolver;

Просмотреть файл

@ -12,7 +12,7 @@ namespace UnitTests.Grains
public class ConsumerEventCountingGrain : Grain, IConsumerEventCountingGrain
{
private int _numConsumedItems;
private ILogger _logger;
private readonly ILogger _logger;
private IAsyncObservable<int> _consumer;
private StreamSubscriptionHandle<int> _subscriptionHandle;
internal const string StreamNamespace = "HaloStreamingNamespace";

Просмотреть файл

@ -16,7 +16,7 @@ namespace UnitTests.Grains
private int eventsConsumedCount;
private int errorsCount;
private int eventsFailedCount;
private ILogger logger;
private readonly ILogger logger;
private StreamSubscriptionHandle<int> consumerHandle;
private Stopwatch failPeriodTimer;
private TimeSpan failPeriod;

Просмотреть файл

@ -19,7 +19,7 @@ namespace TestGrains
{
public const string StreamNamespace = "Generated";
private ILogger logger;
private readonly ILogger logger;
private IAsyncStream<GeneratedEvent> stream;
private int accumulated;

Просмотреть файл

@ -11,7 +11,7 @@ namespace TestGrains
{
class GeneratedEventReporterGrain : Grain, IGeneratedEventReporterGrain
{
private ILogger logger;
private readonly ILogger logger;
private Dictionary<Tuple<string, string>, Dictionary<Guid, int>> reports;

Просмотреть файл

@ -21,7 +21,7 @@ namespace TestGrains
public const string StreamNamespace = "NonTransientError_RecoverableStream";
// grain instance state
private ILogger logger;
private readonly ILogger logger;
private IAsyncStream<GeneratedEvent> stream;
private class FaultsState

Просмотреть файл

@ -21,7 +21,7 @@ namespace TestGrains
public const string StorageProviderName = "AzureStorage";
// grain instance state
private ILogger logger;
private readonly ILogger logger;
private IAsyncStream<GeneratedEvent> stream;
public ImplicitSubscription_RecoverableStream_CollectorGrain(ILoggerFactory loggerFactory)

Просмотреть файл

@ -73,7 +73,7 @@ namespace TestGrains
private FaultsState Faults { get { return myFaults ?? (myFaults = FaultInjectionTracker.GetOrAdd(this.GetPrimaryKey(), key => new FaultsState())); } }
// grain instance state
private ILogger logger;
private readonly ILogger logger;
private IAsyncStream<GeneratedEvent> stream;
public ImplicitSubscription_TransientError_RecoverableStream_CollectorGrain(ILoggerFactory loggerFactory)

Просмотреть файл

@ -7,7 +7,7 @@ namespace UnitTests.Grains
{
internal class KeyExtensionTestGrain : Grain, IKeyExtensionTestGrain
{
private Guid uniqueId = Guid.NewGuid();
private readonly Guid uniqueId = Guid.NewGuid();
public Task<IKeyExtensionTestGrain> GetGrainReference()
{

Просмотреть файл

@ -11,7 +11,7 @@ namespace UnitTests.Grains
internal class LivenessTestGrain : Grain, ILivenessTestGrain
{
private string label;
private ILogger logger;
private readonly ILogger logger;
private Guid uniqueId;
public LivenessTestGrain(ILoggerFactory loggerFactory)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше