Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 4 additions & 5 deletions src/Common/DiagnosticEditProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ internal enum EditType
/// <returns>The current object as an immutable dictionary.</returns>
public ImmutableDictionary<string, string?> ToImmutableDictionary()
{
return new Dictionary<string, string?>(StringComparer.Ordinal)
{
{ EditTypeKey, TypeOfEdit.ToString() },
{ EditPositionKey, EditPosition.ToString(CultureInfo.InvariantCulture) },
}.ToImmutableDictionary();
var builder = ImmutableDictionary.CreateBuilder<string, string?>(StringComparer.Ordinal);
builder.Add(EditTypeKey, TypeOfEdit.ToString());
builder.Add(EditPositionKey, EditPosition.ToString(CultureInfo.InvariantCulture));
return builder.ToImmutable();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Immutable;

Check failure on line 1 in tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs#L1

Provide an 'AssemblyVersion' attribute for assembly 'srcassembly.dll'.
using System.Globalization;

namespace Moq.Analyzers.Benchmarks;
Comment thread
rjmurillo marked this conversation as resolved.
Outdated

[InProcess]
[MemoryDiagnoser]
public class DiagnosticEditPropertiesBenchmarks
{
[Benchmark(Baseline = true)]
public ImmutableDictionary<string, string?> UsingBuilder()
{
var builder = ImmutableDictionary.CreateBuilder<string, string?>(StringComparer.Ordinal);

Check failure on line 13 in tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use explicit type instead of 'var' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0008)

Check failure on line 13 in tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use explicit type instead of 'var' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0008)

Check failure on line 13 in tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04-arm)

Use explicit type instead of 'var' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0008)

Check failure on line 13 in tests/Moq.Analyzers.Benchmarks/DiagnosticEditPropertiesBenchmarks.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04-arm)

Use explicit type instead of 'var' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0008)
Comment thread
rjmurillo marked this conversation as resolved.
Outdated
builder.Add("Type", "Insert");
builder.Add("Position", 1.ToString(CultureInfo.InvariantCulture));
Comment thread
rjmurillo marked this conversation as resolved.
Outdated
return builder.ToImmutable();
}
Comment thread
rjmurillo marked this conversation as resolved.
Outdated

[Benchmark]
public ImmutableDictionary<string, string?> UsingDictionary()
{
return new Dictionary<string, string?>(StringComparer.Ordinal)
{
{ "Type", "Insert" },
{ "Position", 1.ToString(CultureInfo.InvariantCulture) },
}.ToImmutableDictionary();
}
}
Loading