Skip to content

Commit

Permalink
#nullable enable our log aggregators
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmalinowski committed Aug 17, 2022
1 parent d3f53e7 commit 166035a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/Workspaces/Core/Portable/Log/AbstractLogAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using Roslyn.Utilities;
Expand All @@ -17,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Internal.Log
/// <summary>
/// helper class to aggregate some numeric value log in client side
/// </summary>
internal abstract class AbstractLogAggregator<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>
internal abstract class AbstractLogAggregator<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>> where TKey : notnull
{
private readonly ConcurrentDictionary<TKey, TValue> _map = new(concurrencyLevel: 2, capacity: 2);
private readonly Func<TKey, TValue> _createCounter;
Expand All @@ -41,7 +40,7 @@ IEnumerator IEnumerable.GetEnumerator()
protected TValue GetCounter(TKey key)
=> _map.GetOrAdd(key, _createCounter);

protected bool TryGetCounter(TKey key, out TValue counter)
protected bool TryGetCounter(TKey key, [MaybeNullWhen(false)] out TValue counter)
{
if (_map.TryGetValue(key, out counter))
{
Expand Down
4 changes: 1 addition & 3 deletions src/Workspaces/Core/Portable/Log/CountLogAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Threading;

namespace Microsoft.CodeAnalysis.Internal.Log
{
internal class CountLogAggregator<TKey> : AbstractLogAggregator<TKey, CountLogAggregator<TKey>.Counter>
internal class CountLogAggregator<TKey> : AbstractLogAggregator<TKey, CountLogAggregator<TKey>.Counter> where TKey : notnull
{
protected override Counter CreateCounter()
=> new();
Expand Down
2 changes: 1 addition & 1 deletion src/Workspaces/Core/Portable/Log/HistogramLogAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Internal.Log
/// <summary>
/// Defines a log aggregator to create a histogram
/// </summary>
internal sealed class HistogramLogAggregator<TKey> : AbstractLogAggregator<TKey, HistogramLogAggregator<TKey>.HistogramCounter>
internal sealed class HistogramLogAggregator<TKey> : AbstractLogAggregator<TKey, HistogramLogAggregator<TKey>.HistogramCounter> where TKey : notnull
{
private readonly int _bucketSize;
private readonly int _maxBucketValue;
Expand Down
4 changes: 1 addition & 3 deletions src/Workspaces/Core/Portable/Log/StatisticLogAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;

namespace Microsoft.CodeAnalysis.Internal.Log
{
internal sealed class StatisticLogAggregator<TKey> : AbstractLogAggregator<TKey, StatisticLogAggregator<TKey>.StatisticCounter>
internal sealed class StatisticLogAggregator<TKey> : AbstractLogAggregator<TKey, StatisticLogAggregator<TKey>.StatisticCounter> where TKey : notnull
{
protected override StatisticCounter CreateCounter()
=> new();
Expand Down

0 comments on commit 166035a

Please sign in to comment.