Skip to content

Commit e7b87f3

Browse files
CopilotYoussef1313
andauthored
Obsolete CancelledTestNodeStateProperty (#6828)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Youssef1313 <[email protected]>
1 parent 5c6ea3b commit e7b87f3

File tree

13 files changed

+27
-0
lines changed

13 files changed

+27
-0
lines changed

src/Adapter/MSTest.Engine/Engine/TestExecutionContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public void ReportException(Exception exception, CancellationToken? timeoutCance
5555
// We want to consider user timeouts as failures if they didn't use our cancellation token
5656
OperationCanceledException canceledException
5757
when canceledException.CancellationToken == _originalCancellationToken || canceledException.CancellationToken == CancellationToken
58+
#pragma warning disable CS0618 // Type or member is obsolete
5859
=> new CancelledTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception)),
60+
#pragma warning restore CS0618 // Type or member is obsolete
5961
OperationCanceledException canceledException when canceledException.CancellationToken == timeoutCancellationToken
6062
=> new TimeoutTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception)),
6163
AssertFailedException => new FailedTestNodeStateProperty(ExceptionFlattener.FlattenOrUnwrap(exception), exception.Message),

src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsReporter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella
130130
case ErrorTestNodeStateProperty error:
131131
await WriteExceptionAsync(error.Explanation, error.Exception, cancellationToken).ConfigureAwait(false);
132132
break;
133+
#pragma warning disable CS0618 // Type or member is obsolete
133134
case CancelledTestNodeStateProperty cancelled:
135+
#pragma warning restore CS0618 // Type or member is obsolete
134136
await WriteExceptionAsync(cancelled.Explanation, cancelled.Exception, cancellationToken).ConfigureAwait(false);
135137
break;
136138
case TimeoutTestNodeStateProperty timeout:

src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpActivityIndicator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella
172172

173173
_testsCurrentExecutionState.TryAdd(nodeChangedMessage.TestNode.Uid, (nodeChangedMessage.TestNode.DisplayName, typeof(InProgressTestNodeStateProperty), _clock.UtcNow));
174174
}
175+
#pragma warning disable CS0618 // Type or member is obsolete
175176
else if (state is PassedTestNodeStateProperty or ErrorTestNodeStateProperty or CancelledTestNodeStateProperty
177+
#pragma warning restore CS0618 // Type or member is obsolete
176178
or FailedTestNodeStateProperty or TimeoutTestNodeStateProperty or SkippedTestNodeStateProperty
177179
&& _testsCurrentExecutionState.TryRemove(nodeChangedMessage.TestNode.Uid, out (string Name, Type Type, DateTimeOffset StartTime) record)
178180
&& _traceLevelEnabled)

src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildConsumer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ await HandleFailuresAsync(
125125
cancellationToken).ConfigureAwait(false);
126126
break;
127127

128+
#pragma warning disable CS0618 // Type or member is obsolete
128129
case CancelledTestNodeStateProperty canceledState:
130+
#pragma warning restore CS0618 // Type or member is obsolete
129131
await HandleFailuresAsync(
130132
testNodeStateChanged.TestNode.DisplayName,
131133
isCanceled: true,

src/Platform/Microsoft.Testing.Platform/Messages/TestNodeProperties.Categories.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ internal static class TestNodePropertiesCategories
1919
typeof(FailedTestNodeStateProperty),
2020
typeof(ErrorTestNodeStateProperty),
2121
typeof(TimeoutTestNodeStateProperty),
22+
#pragma warning disable CS0618 // Type or member is obsolete
2223
typeof(CancelledTestNodeStateProperty),
24+
#pragma warning restore CS0618 // Type or member is obsolete
2325
];
2426

2527
public static Type[] WellKnownTestNodeTestRunOutcomeFailedProperties { get; } =
2628
[
2729
typeof(FailedTestNodeStateProperty),
2830
typeof(ErrorTestNodeStateProperty),
2931
typeof(TimeoutTestNodeStateProperty),
32+
#pragma warning disable CS0618 // Type or member is obsolete
3033
typeof(CancelledTestNodeStateProperty),
34+
#pragma warning restore CS0618 // Type or member is obsolete
3135
];
3236
}

src/Platform/Microsoft.Testing.Platform/Messages/TestNodeProperties.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ public override int GetHashCode()
437437
/// <summary>
438438
/// Property that represents an eventual cancellation of a test node.
439439
/// </summary>
440+
[Obsolete("CancelledTestNodeStateProperty is obsolete. Test frameworks should throw OperationCanceledException using the cancellation token passed by Microsoft.Testing.Platform instead of using this state.")]
440441
public sealed class CancelledTestNodeStateProperty : TestNodeStateProperty, IEquatable<CancelledTestNodeStateProperty>
441442
{
442443
/// <summary>

src/Platform/Microsoft.Testing.Platform/OutputDevice/BrowserOutputDevice.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo
356356
OnFailedTest(testNodeStateChanged, timeoutState, timeoutState.Exception, duration);
357357
break;
358358

359+
#pragma warning disable CS0618 // Type or member is obsolete
359360
case CancelledTestNodeStateProperty cancelledState:
361+
#pragma warning restore CS0618 // Type or member is obsolete
360362
OnFailedTest(testNodeStateChanged, cancelledState, cancelledState.Exception, duration);
361363
break;
362364

src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ public Task ConsumeAsync(IDataProducer dataProducer, IData value, CancellationTo
460460
standardError);
461461
break;
462462

463+
#pragma warning disable CS0618 // Type or member is obsolete
463464
case CancelledTestNodeStateProperty cancelledState:
465+
#pragma warning restore CS0618 // Type or member is obsolete
464466
_terminalTestReporter.TestCompleted(
465467
testNodeStateChanged.TestNode.Uid.Value,
466468
testNodeStateChanged.TestNode.DisplayName,

src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ public async Task ConsumeAsync(IDataProducer dataProducer, IData value, Cancella
241241
exceptions = FlattenToExceptionMessages(reason, timeoutTestNodeStateProperty.Exception);
242242
break;
243243

244+
#pragma warning disable CS0618 // Type or member is obsolete
244245
case CancelledTestNodeStateProperty cancelledTestNodeStateProperty:
246+
#pragma warning restore CS0618 // Type or member is obsolete
245247
state = TestStates.Cancelled;
246248
duration = testNodeUpdateMessage.TestNode.Properties.SingleOrDefault<TimingProperty>()?.GlobalTiming.Duration.Ticks;
247249
reason = nodeState.Explanation;

src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Json.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public Json(Dictionary<Type, JsonSerializer>? serializers = null, Dictionary<Typ
248248
break;
249249
}
250250

251+
#pragma warning disable CS0618 // Type or member is obsolete
251252
case CancelledTestNodeStateProperty canceledTestNodeStateProperty:
253+
#pragma warning restore CS0618 // Type or member is obsolete
252254
{
253255
properties.Add(("execution-state", "canceled"));
254256
Exception? exception = canceledTestNodeStateProperty.Exception;

0 commit comments

Comments
 (0)