I wrote a unit test and used the new C# record to store some data I needed for testing. The unit test run fine, but when I set a break point and moved the mouse over the record variable name, the debugging session ended and I got a strange looking error message.
To report the problem to Microsoft, I wrote a simple unit test, which demonstrates the problem, but doesn't make much sense otherwise:
#nullable enable
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CSharpRecordTest {
record Twin(string Name) {
public Twin? OtherTwin { get; set; }
}
[TestClass]
public class UnitTest1 {
[TestMethod]
public void TestMethod1() {
var twinA = new Twin("A");
var twinB = new Twin("B");
twinA.OtherTwin = twinB;
twinB.OtherTwin = twinA;
Assert.AreEqual(twinA, twinA.OtherTwin.OtherTwin);
}
}
}
The test runs fine, but when setting a break point at Assert.AreEqual( and moving the mouse over twinA, the debugging session stops and this error message gets shown:
