Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed job name bug
  • Loading branch information
MattFromRVA committed Jan 2, 2024
commit 69390e935b1dd3daa3fa4f4936d8be23c9a4bcfb
6 changes: 6 additions & 0 deletions src/BenchmarkDotNet/Characteristics/CharacteristicObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ protected CharacteristicObject UnfreezeCopyCore()
var newRoot = (CharacteristicObject)Activator.CreateInstance(GetType());
newRoot.ApplyCore(this);

// Preserve the IdCharacteristic of the original object
if (this.HasValue(IdCharacteristic))
{
newRoot.SetValue(IdCharacteristic, this.GetValue(IdCharacteristic));
}

return newRoot;
}
#endregion
Expand Down
14 changes: 14 additions & 0 deletions tests/BenchmarkDotNet.Tests/Configs/JobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,20 @@ public static void WithNuGet()
Assert.Equal(expected, j.Infrastructure.NuGetReferences); // ensure that the list's equality operator returns true when the contents are the same
}

[Fact]
public static void UnfreezeCopy_PreservesIdCharacteristic()
{
// Arrange
var original = new Job();
original.SetValue(Job.IdCharacteristic, "TestID");

// Act
var copy = original.UnfreezeCopy();

// Assert
Assert.Equal("TestID", copy.GetValue(Job.IdCharacteristic));
}

private static bool IsSubclassOfobModeOfItself(Type type)
{
Type jobModeOfT;
Expand Down