Describe the bug
I have a record which includes some explicit properties that override automatic properties.
public record Size(double Width, double Height)
{
public double Width { get; } = FilterNegative(Width);
public double Height { get; } = FilterNegative(Height);
private static double FilterNegative(double value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
{
ArgumentOutOfRangeException.ThrowIfNegative(value, paramName);
return value;
}
}
I am using this type in two ways in my unit tests:
- Explicit creation in code:
[TestMethod]
public void TestMethod()
{
var foo = new Size(1, 2);
}
- Directly as dynamic data:
public static IEnumerable<object[]> TestData()
{
yield return new object[] { new Size(1, 2) };
}
Version used
- MSTest version 4.4.1
- Microsoft.NET.Test.Sdk version 18.10.0
- Visual Studio 2026 version 18.10.1
Steps To Reproduce
- When run from the command line
dotnet test ..., all tests pass. Explicit properties Width and Height are properly initialized.
- When run from Visual Studio (Test Explorer window, Run All Tests):
- Records created in the test method are properly initialized.
- Records created in the dynamic data have their explicit fields at the default value, zero.
At some point in the past, this was not the case. Under MSTest version 3.10.0, .Net 9, and a corresponding version of Visual Studio, running the tests from Visual Studio properly initialized the explicit properties, all the time.
Describe the bug
I have a record which includes some explicit properties that override automatic properties.
I am using this type in two ways in my unit tests:
Version used
Steps To Reproduce
dotnet test ..., all tests pass. Explicit propertiesWidthandHeightare properly initialized.At some point in the past, this was not the case. Under MSTest version 3.10.0, .Net 9, and a corresponding version of Visual Studio, running the tests from Visual Studio properly initialized the explicit properties, all the time.