From 90a7b1f3e7bf784293014982e35d30c27378db93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:11:36 +0000 Subject: [PATCH 1/6] Initial plan From 821796a0a637a9486e136e0d573d3a5834579ab2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:17:54 +0000 Subject: [PATCH 2/6] Add NULL detection to IsExactInstanceOfType error message and update tests Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- Directory.Build.props.bak | 106 ++++++++++++++++++ Directory.Build.targets.bak | 63 +++++++++++ .../Assert.IsExactInstanceOfType.cs | 4 + .../AssertTests.IsExactInstanceOfTypeTests.cs | 8 +- 4 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 Directory.Build.props.bak create mode 100644 Directory.Build.targets.bak diff --git a/Directory.Build.props.bak b/Directory.Build.props.bak new file mode 100644 index 0000000000..c52560a235 --- /dev/null +++ b/Directory.Build.props.bak @@ -0,0 +1,106 @@ + + + + + + + true + + + + false + + + + + + preview + enable + true + enable + + true + + + + + + uap10.0.16299 + net9.0-windows10.0.17763.0 + net8.0-windows10.0.18362.0 + + net8.0;net9.0 + + + + + + false + + true + embedded + + 0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7 + + + $(NoWarn);TPEXP + + $(NoWarn);IDE0370 + + + + + alpha + + + 2.0.0 + + + + + $(CopyrightMicrosoft) + MIT + + + + + Microsoft + + + + + + Microsoft.Testing.Platform + + + + + true + + true + true + true + + + + + + + + + + + + + + + + + + + + diff --git a/Directory.Build.targets.bak b/Directory.Build.targets.bak new file mode 100644 index 0000000000..fabf8f1dd8 --- /dev/null +++ b/Directory.Build.targets.bak @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + $(CommonPackageTags) + PACKAGE.md + + + + + + + + + + + + + + <_TemplateProperties>Version=$(Version) + <_TemplatePropertiesCacheFile>$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateVersionSourceFile.cache + + + + + + + + + + + + + + + + + + + <_TemplateCsproj Include="$(MSBuildProjectDirectory)/BuildInfo.cs.template" Destination="$(IntermediateOutputPath)BuildInfo.cs" /> + + + + + + + + + diff --git a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs index 144f17cdbe..6828abfecf 100644 --- a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs +++ b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs @@ -341,6 +341,10 @@ private static void ThrowAssertIsExactInstanceOfTypeFailed(object? value, Type? expectedType.ToString(), value.GetType().ToString()); } + else if (value is null) + { + finalMessage = $"{userMessage} 'value' was NULL."; + } ThrowAssertFailed("Assert.IsExactInstanceOfType", finalMessage); } diff --git a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs index af72c579fa..9f24933607 100644 --- a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs @@ -12,7 +12,7 @@ public void ExactInstanceOfTypeShouldFailWhenValueIsNull() { Action action = () => Assert.IsExactInstanceOfType(null, typeof(AssertTests)); action.Should().Throw() - .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'."); + .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. 'value' was NULL."); } public void ExactInstanceOfTypeShouldFailWhenTypeIsNull() @@ -56,7 +56,7 @@ public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenValueIsNull() { Action action = () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), "User-provided message"); action.Should().Throw() - .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message"); + .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message 'value' was NULL."); } public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenTypeIsNull() @@ -82,7 +82,7 @@ public async Task ExactInstanceOfType_WithInterpolatedString_ShouldFailWhenValue DateTime dateTime = DateTime.Now; Func action = async () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), $"User-provided message. {o}, {o,35}, {await GetHelloStringAsync()}, {new DummyIFormattable()}, {dateTime:tt}, {dateTime,5:tt}"); (await action.Should().ThrowAsync()) - .WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)}"); + .WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)} 'value' was NULL."); o.WasToStringCalled.Should().BeTrue(); } @@ -141,7 +141,7 @@ public void IsExactInstanceOfTypeUsingGenericType_WhenValueIsNull_Fails() { Action action = () => Assert.IsExactInstanceOfType(null); action.Should().Throw() - .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'."); + .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. 'value' was NULL."); } public void IsExactInstanceOfTypeUsingGenericType_WhenTypeMismatch_Fails() From 076ac244a4052600396fdf1680cc6d50294a1a3f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:18:04 +0000 Subject: [PATCH 3/6] Remove accidentally committed backup files Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- Directory.Build.props.bak | 106 ------------------------------------ Directory.Build.targets.bak | 63 --------------------- 2 files changed, 169 deletions(-) delete mode 100644 Directory.Build.props.bak delete mode 100644 Directory.Build.targets.bak diff --git a/Directory.Build.props.bak b/Directory.Build.props.bak deleted file mode 100644 index c52560a235..0000000000 --- a/Directory.Build.props.bak +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - true - - - - false - - - - - - preview - enable - true - enable - - true - - - - - - uap10.0.16299 - net9.0-windows10.0.17763.0 - net8.0-windows10.0.18362.0 - - net8.0;net9.0 - - - - - - false - - true - embedded - - 0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7 - - - $(NoWarn);TPEXP - - $(NoWarn);IDE0370 - - - - - alpha - - - 2.0.0 - - - - - $(CopyrightMicrosoft) - MIT - - - - - Microsoft - - - - - - Microsoft.Testing.Platform - - - - - true - - true - true - true - - - - - - - - - - - - - - - - - - - - diff --git a/Directory.Build.targets.bak b/Directory.Build.targets.bak deleted file mode 100644 index fabf8f1dd8..0000000000 --- a/Directory.Build.targets.bak +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - $(CommonPackageTags) - PACKAGE.md - - - - - - - - - - - - - - <_TemplateProperties>Version=$(Version) - <_TemplatePropertiesCacheFile>$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateVersionSourceFile.cache - - - - - - - - - - - - - - - - - - - <_TemplateCsproj Include="$(MSBuildProjectDirectory)/BuildInfo.cs.template" Destination="$(IntermediateOutputPath)BuildInfo.cs" /> - - - - - - - - - From 93c6664c351a02692cc3a2d11a18b823d38a62e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:21:20 +0000 Subject: [PATCH 4/6] Add proper punctuation before NULL message when userMessage doesn't end with punctuation Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../Assertions/Assert.IsExactInstanceOfType.cs | 11 ++++++++++- .../AssertTests.IsExactInstanceOfTypeTests.cs | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs index 6828abfecf..0eba8476da 100644 --- a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs +++ b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs @@ -343,7 +343,16 @@ private static void ThrowAssertIsExactInstanceOfTypeFailed(object? value, Type? } else if (value is null) { - finalMessage = $"{userMessage} 'value' was NULL."; + // Ensure proper punctuation before adding the NULL message + string trimmedMessage = userMessage.TrimEnd(); + if (!trimmedMessage.EndsWith('.') && !trimmedMessage.EndsWith('!') && !trimmedMessage.EndsWith('?')) + { + finalMessage = $"{userMessage}. 'value' was NULL."; + } + else + { + finalMessage = $"{userMessage} 'value' was NULL."; + } } ThrowAssertFailed("Assert.IsExactInstanceOfType", finalMessage); diff --git a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs index 9f24933607..c33356a318 100644 --- a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.IsExactInstanceOfTypeTests.cs @@ -56,7 +56,7 @@ public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenValueIsNull() { Action action = () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), "User-provided message"); action.Should().Throw() - .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message 'value' was NULL."); + .WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. 'value' was NULL."); } public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenTypeIsNull() @@ -82,7 +82,7 @@ public async Task ExactInstanceOfType_WithInterpolatedString_ShouldFailWhenValue DateTime dateTime = DateTime.Now; Func action = async () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), $"User-provided message. {o}, {o,35}, {await GetHelloStringAsync()}, {new DummyIFormattable()}, {dateTime:tt}, {dateTime,5:tt}"); (await action.Should().ThrowAsync()) - .WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)} 'value' was NULL."); + .WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)}. 'value' was NULL."); o.WasToStringCalled.Should().BeTrue(); } From 97485968b32e47ac7d8bde605edf42adb240fda6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:21:56 +0000 Subject: [PATCH 5/6] Use trimmed message consistently when adding NULL indicator Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../TestFramework/Assertions/Assert.IsExactInstanceOfType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs index 0eba8476da..2b40fb76dc 100644 --- a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs +++ b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs @@ -347,11 +347,11 @@ private static void ThrowAssertIsExactInstanceOfTypeFailed(object? value, Type? string trimmedMessage = userMessage.TrimEnd(); if (!trimmedMessage.EndsWith('.') && !trimmedMessage.EndsWith('!') && !trimmedMessage.EndsWith('?')) { - finalMessage = $"{userMessage}. 'value' was NULL."; + finalMessage = $"{trimmedMessage}. 'value' was NULL."; } else { - finalMessage = $"{userMessage} 'value' was NULL."; + finalMessage = $"{trimmedMessage} 'value' was NULL."; } } From 8307e33fd8a6e3e7502a715bc7a4714952f17ee9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:22:26 +0000 Subject: [PATCH 6/6] Improve punctuation handling - handle empty messages and use index access Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../Assertions/Assert.IsExactInstanceOfType.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs index 2b40fb76dc..67b713c393 100644 --- a/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs +++ b/src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs @@ -345,13 +345,17 @@ private static void ThrowAssertIsExactInstanceOfTypeFailed(object? value, Type? { // Ensure proper punctuation before adding the NULL message string trimmedMessage = userMessage.TrimEnd(); - if (!trimmedMessage.EndsWith('.') && !trimmedMessage.EndsWith('!') && !trimmedMessage.EndsWith('?')) + if (trimmedMessage.Length > 0 && (trimmedMessage[^1] == '.' || trimmedMessage[^1] == '!' || trimmedMessage[^1] == '?')) + { + finalMessage = $"{trimmedMessage} 'value' was NULL."; + } + else if (trimmedMessage.Length > 0) { finalMessage = $"{trimmedMessage}. 'value' was NULL."; } else { - finalMessage = $"{trimmedMessage} 'value' was NULL."; + finalMessage = "'value' was NULL."; } }