Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address all IDE0032. Use auto-implemented property. #8614

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class AdoNetGatewayListProvider : IGatewayListProvider
private readonly AdoNetClusteringClientOptions _options;
private RelationalOrleansQueries _orleansQueries;
private readonly IServiceProvider _serviceProvider;
private readonly TimeSpan _maxStaleness;

public AdoNetGatewayListProvider(
ILogger<AdoNetGatewayListProvider> logger,
Expand All @@ -29,13 +28,10 @@ public AdoNetGatewayListProvider(
this._serviceProvider = serviceProvider;
this._options = options.Value;
this._clusterId = clusterOptions.Value.ClusterId;
this._maxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
this.MaxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
}

public TimeSpan MaxStaleness
{
get { return this._maxStaleness; }
}
public TimeSpan MaxStaleness { get; }

public bool IsUpdatable
{
Expand Down
18 changes: 3 additions & 15 deletions src/AdoNet/Shared/Storage/RelationalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ namespace Orleans.Tests.SqlUtils
[DebuggerDisplay("InvariantName = {InvariantName}, ConnectionString = {ConnectionString}")]
internal class RelationalStorage : IRelationalStorage
{
/// <summary>
/// The connection string to use.
/// </summary>
private readonly string _connectionString;

/// <summary>
/// The invariant name of the connector for this database.
/// </summary>
Expand Down Expand Up @@ -67,14 +62,7 @@ public string InvariantName
/// <summary>
/// The connection string used to connect to the database.
/// </summary>
public string ConnectionString
{
get
{
return _connectionString;
}
}

public string ConnectionString { get; }

/// <summary>
/// Creates an instance of a database of type <see cref="IRelationalStorage"/>.
Expand Down Expand Up @@ -203,7 +191,7 @@ public async Task<int> ExecuteAsync(string query, Action<IDbCommand> parameterPr
/// <param name="connectionString">The connection string this database should use for database operations.</param>
private RelationalStorage(string invariantName, string connectionString)
{
this._connectionString = connectionString;
this.ConnectionString = connectionString;
this._invariantName = invariantName;
_supportsCommandCancellation = DbConstantsStore.SupportsCommandCancellation(InvariantName);
_isSynchronousAdoNetImplementation = DbConstantsStore.IsSynchronousAdoNetImplementation(InvariantName);
Expand Down Expand Up @@ -259,7 +247,7 @@ private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteAsync<TResult>(
CommandBehavior commandBehavior,
CancellationToken cancellationToken)
{
using (var connection = DbConnectionFactory.CreateConnection(_invariantName, _connectionString))
using (var connection = DbConnectionFactory.CreateConnection(_invariantName, ConnectionString))
{
await connection.OpenAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
using (var command = connection.CreateCommand())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ public interface IIntCounter

internal class IntCounter : IIntCounter
{
private int counter = 0;
public int Value { get { return this.counter; } }
public int Value { get; private set; } = 0;
public void Increment()
{
counter++;
Value++;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public class EventHubAdapterFactory : IQueueAdapterFactory, IQueueAdapter, IQueu
private readonly EventHubReceiverOptions receiverOptions;
private readonly StreamStatisticOptions statisticOptions;
private readonly StreamCacheEvictionOptions cacheEvictionOptions;
private HashRingBasedPartitionedStreamQueueMapper streamQueueMapper;
private string[] partitionIds;
private ConcurrentDictionary<QueueId, EventHubAdapterReceiver> receivers;
private EventHubProducerClient client;

/// <summary>
Expand Down Expand Up @@ -99,8 +97,8 @@ public class EventHubAdapterFactory : IQueueAdapterFactory, IQueueAdapter, IQueu
/// Factory to create a IEventHubReceiver
/// </summary>
protected Func<EventHubPartitionSettings, string, ILogger, IEventHubReceiver> EventHubReceiverFactory;
internal ConcurrentDictionary<QueueId, EventHubAdapterReceiver> EventHubReceivers => receivers;
internal HashRingBasedPartitionedStreamQueueMapper EventHubQueueMapper => streamQueueMapper;
internal ConcurrentDictionary<QueueId, EventHubAdapterReceiver> EventHubReceivers { get; private set; }
internal HashRingBasedPartitionedStreamQueueMapper EventHubQueueMapper { get; private set; }

public EventHubAdapterFactory(
string name,
Expand Down Expand Up @@ -128,7 +126,7 @@ public EventHubAdapterFactory(

public virtual void Init()
{
this.receivers = new ConcurrentDictionary<QueueId, EventHubAdapterReceiver>();
this.EventHubReceivers = new ConcurrentDictionary<QueueId, EventHubAdapterReceiver>();

InitEventHubClient();

Expand Down Expand Up @@ -167,10 +165,10 @@ private void InitCheckpointerFactory()
/// <returns></returns>
public async Task<IQueueAdapter> CreateAdapter()
{
if (this.streamQueueMapper == null)
if (this.EventHubQueueMapper == null)
{
this.partitionIds = await GetPartitionIdsAsync();
this.streamQueueMapper = this.QueueMapperFactory(this.partitionIds);
this.EventHubQueueMapper = this.QueueMapperFactory(this.partitionIds);
}
return this;
}
Expand All @@ -191,7 +189,7 @@ public IQueueAdapterCache GetQueueAdapterCache()
public IStreamQueueMapper GetStreamQueueMapper()
{
//TODO: CreateAdapter must be called first. Figure out how to safely enforce this
return this.streamQueueMapper;
return this.EventHubQueueMapper;
}

/// <summary>
Expand All @@ -201,7 +199,7 @@ public IStreamQueueMapper GetStreamQueueMapper()
/// <returns></returns>
public Task<IStreamFailureHandler> GetDeliveryFailureHandler(QueueId queueId)
{
return this.StreamFailureHandlerFactory(this.streamQueueMapper.QueueToPartition(queueId));
return this.StreamFailureHandlerFactory(this.EventHubQueueMapper.QueueToPartition(queueId));
}

/// <summary>
Expand Down Expand Up @@ -242,7 +240,7 @@ public IQueueCache CreateQueueCache(QueueId queueId)

private EventHubAdapterReceiver GetOrCreateReceiver(QueueId queueId)
{
return this.receivers.GetOrAdd(queueId, (q, instance) => instance.MakeReceiver(q), this);
return this.EventHubReceivers.GetOrAdd(queueId, (q, instance) => instance.MakeReceiver(q), this);
}

protected virtual void InitEventHubClient()
Expand Down Expand Up @@ -270,7 +268,7 @@ private EventHubAdapterReceiver MakeReceiver(QueueId queueId)
var config = new EventHubPartitionSettings
{
Hub = ehOptions,
Partition = this.streamQueueMapper.QueueToPartition(queueId),
Partition = this.EventHubQueueMapper.QueueToPartition(queueId),
ReceiverOptions = this.receiverOptions
};

Expand Down
8 changes: 2 additions & 6 deletions src/Orleans.Clustering.Consul/ConsulGatewayListProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class ConsulGatewayListProvider : IGatewayListProvider
private readonly string clusterId;
private readonly ILogger logger;
private readonly ConsulClusteringOptions options;
private readonly TimeSpan maxStaleness;
private readonly string kvRootFolder;

public ConsulGatewayListProvider(
Expand All @@ -27,15 +26,12 @@ public ConsulGatewayListProvider(
{
this.logger = logger;
this.clusterId = clusterOptions.Value.ClusterId;
this.maxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
this.MaxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
this.options = options.Value;
this.kvRootFolder = options.Value.KvRootFolder;
}

public TimeSpan MaxStaleness
{
get { return this.maxStaleness; }
}
public TimeSpan MaxStaleness { get; }

public bool IsUpdatable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class ZooKeeperGatewayListProvider : IGatewayListProvider
/// The deployment connection string. for eg. "192.168.1.1,192.168.1.2/ClusterId"
/// </summary>
private readonly string _deploymentConnectionString;
private readonly TimeSpan _maxStaleness;

public ZooKeeperGatewayListProvider(
ILogger<ZooKeeperGatewayListProvider> logger,
Expand All @@ -33,7 +32,7 @@ public ZooKeeperGatewayListProvider(
_watcher = new ZooKeeperWatcher(logger);
_deploymentPath = "/" + clusterOptions.Value.ClusterId;
_deploymentConnectionString = options.Value.ConnectionString + _deploymentPath;
_maxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
MaxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
}

/// <summary>
Expand All @@ -60,7 +59,7 @@ public async Task<IList<Uri>> GetGateways()
/// <summary>
/// Specifies how often this IGatewayListProvider is refreshed, to have a bound on max staleness of its returned information.
/// </summary>
public TimeSpan MaxStaleness => _maxStaleness;
public TimeSpan MaxStaleness { get; }

/// <summary>
/// Specifies whether this IGatewayListProvider ever refreshes its returned information, or always returns the same gw list.
Expand Down
18 changes: 8 additions & 10 deletions src/Orleans.CodeGenerator/Model/MetadataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ internal class MetadataModel
/// </summary>
internal sealed class CompoundTypeAliasTree
{
private Dictionary<object, CompoundTypeAliasTree> _children;

/// <summary>
/// Initializes a new instance of the <see cref="CompoundTypeAliasTree"/> class.
Expand All @@ -55,7 +54,7 @@ private CompoundTypeAliasTree(CompoundTypeAliasComponent key, TypeSyntax value)
/// </summary>
public static CompoundTypeAliasTree Create() => new(default, default);

public Dictionary<object, CompoundTypeAliasTree> Children => _children;
public Dictionary<object, CompoundTypeAliasTree> Children { get; private set; }

internal CompoundTypeAliasTree GetChildOrDefault(object key)
{
Expand All @@ -65,7 +64,7 @@ internal CompoundTypeAliasTree GetChildOrDefault(object key)

internal bool TryGetChild(object key, out CompoundTypeAliasTree result)
{
if (_children is { } children)
if (Children is { } children)
{
return children.TryGetValue(key, out result);
}
Expand Down Expand Up @@ -127,9 +126,9 @@ public void Add(ReadOnlySpan<CompoundTypeAliasComponent> keys, TypeSyntax value)
private CompoundTypeAliasTree AddInternal(CompoundTypeAliasComponent key) => AddInternal(key, default);
private CompoundTypeAliasTree AddInternal(CompoundTypeAliasComponent key, TypeSyntax value)
{
_children ??= new();
Children ??= new();

if (_children.TryGetValue(key, out var existing))
if (Children.TryGetValue(key, out var existing))
{
if (value is not null && existing.Value is not null)
{
Expand All @@ -141,7 +140,7 @@ private CompoundTypeAliasTree AddInternal(CompoundTypeAliasComponent key, TypeSy
}
else
{
return _children[key] = new CompoundTypeAliasTree(key, value);
return Children[key] = new CompoundTypeAliasTree(key, value);
}
}
}
Expand Down Expand Up @@ -184,21 +183,20 @@ private CompoundTypeAliasTree AddInternal(CompoundTypeAliasComponent key, TypeSy

internal readonly struct Either<T, U> where T : class where U : class
{
private readonly bool _isLeft;
private readonly object _value;
public Either(T value)
{
_value = value;
_isLeft = true;
IsLeft = true;
}

public Either(U value)
{
_value = value;
_isLeft = false;
IsLeft = false;
}

public bool IsLeft => _isLeft;
public bool IsLeft { get; }
public bool IsRight => !IsLeft;
public T LeftValue => (T)_value;
public U RightValue => (U)_value;
Expand Down
8 changes: 3 additions & 5 deletions src/Orleans.CodeGenerator/Model/MethodDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ namespace Orleans.CodeGenerator
{
internal class MethodDescription
{
private readonly InvokableInterfaceDescription _iface;

public MethodDescription(InvokableInterfaceDescription containingType, IMethodSymbol method, string methodId, bool hasCollision)
{
_iface = containingType;
ContainingInterface = containingType;
Method = method;
MethodId = methodId;
HasCollision = hasCollision;
Expand All @@ -21,7 +19,7 @@ public MethodDescription(InvokableInterfaceDescription containingType, IMethodSy
AllTypeParameters = new List<(string Name, ITypeParameterSymbol Parameter)>();
MethodTypeParameters = new List<(string Name, ITypeParameterSymbol Parameter)>();

foreach (var tp in _iface.InterfaceType.GetAllTypeParameters())
foreach (var tp in ContainingInterface.InterfaceType.GetAllTypeParameters())
{
var tpName = GetTypeParameterName(names, tp);
AllTypeParameters.Add((tpName, tp));
Expand Down Expand Up @@ -149,7 +147,7 @@ bool TryGetNamedArgument(ImmutableArray<KeyValuePair<string, TypedConstant>> arg

public IMethodSymbol Method { get; }

public InvokableInterfaceDescription ContainingInterface => _iface;
public InvokableInterfaceDescription ContainingInterface { get; }

public bool HasCollision { get; }

Expand Down
Loading
Loading