Skip to content

Commit

Permalink
chore: fix ActivityBaggageLogScopeWrapper implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
NatMarchand committed Nov 1, 2024
1 parent 7af5298 commit 06e0bf2
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ IEnumerator IEnumerable.GetEnumerator()
}
}

private sealed class ActivityBaggageLogScopeWrapper : IEnumerable<KeyValuePair<string, string?>>, IEnumerable<KeyValuePair<string, object?>>
private sealed class ActivityBaggageLogScopeWrapper : IEnumerable<KeyValuePair<string, object?>>
{
private readonly IEnumerable<KeyValuePair<string, string?>> _items;

Expand All @@ -247,20 +247,10 @@ public ActivityBaggageLogScopeWrapper(IEnumerable<KeyValuePair<string, string?>>
_items = items;
}

public IEnumerator<KeyValuePair<string, string?>> GetEnumerator()
{
return _items.GetEnumerator();
}

IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
return _items.Select(x => KeyValuePair.Create<string, object?>(x.Key, x.Value)).GetEnumerator();
}
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator() =>
new BaggageEnumerator(_items.GetEnumerator());

IEnumerator IEnumerable.GetEnumerator()
{
return _items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => new BaggageEnumerator(_items.GetEnumerator());

public override string ToString()
{
Expand Down Expand Up @@ -290,6 +280,27 @@ public override string ToString()
return result;
}
}

private struct BaggageEnumerator : IEnumerator<KeyValuePair<string, object?>>

Check failure on line 284 in src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs#L284

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs(284,28): error IDE0250: (NETCORE_ENGINEERING_TELEMETRY=Build) Struct can be made 'readonly' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0250)
{
private readonly IEnumerator<KeyValuePair<string, string?>> _enumerator;

public BaggageEnumerator(IEnumerator<KeyValuePair<string, string?>> enumerator)
{
_enumerator = enumerator;
}

public KeyValuePair<string, object?> Current =>

Check failure on line 293 in src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs#L293

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs(293,62): error IDE0251: (NETCORE_ENGINEERING_TELEMETRY=Build) Member can be made 'readonly' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0251)
new KeyValuePair<string, object?>(_enumerator.Current.Key, _enumerator.Current.Value);

object? IEnumerator.Current => Current;

public void Dispose() => _enumerator.Dispose();

Check failure on line 298 in src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs#L298

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs(298,29): error IDE0251: (NETCORE_ENGINEERING_TELEMETRY=Build) Member can be made 'readonly' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0251)

public bool MoveNext() => _enumerator.MoveNext();

Check failure on line 300 in src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs#L300

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs(300,29): error IDE0251: (NETCORE_ENGINEERING_TELEMETRY=Build) Member can be made 'readonly' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0251)

public void Reset() => _enumerator.Reset();

Check failure on line 302 in src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs#L302

src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs(302,29): error IDE0251: (NETCORE_ENGINEERING_TELEMETRY=Build) Member can be made 'readonly' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0251)
}
}
}

Expand Down

0 comments on commit 06e0bf2

Please sign in to comment.