Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ When making change to resource files, you MUST:

## Public API guidelines

- Treat adding an overload as a potential source-breaking change, even when it is binary-compatible. Existing calls can become ambiguous when an argument converts to multiple parameter types, especially across `Span<T>`, `ReadOnlySpan<T>`, arrays, generic interfaces such as `IEnumerable<T>`, and overloads with optional parameters.
- Before adding or changing overloads, enumerate representative existing call shapes and compare all applicable implicit conversions and generic type-inference paths.
- For `Assert` overload changes, update the manually maintained implicit consumer call shapes in [`AssertSourceCompatibilityTests.cs`](../test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AssertSourceCompatibilityTests.cs). The test compiles them against the packed `MSTest.TestFramework` using C# 12 and automatically requires every public `Assert` method family to have at least one representative scenario.
- Add equivalent package-consuming compilation coverage for overload changes in other public API types, using the oldest relevant default C# language version and target framework. Repository projects use `LangVersion=preview`, so an ordinary in-repo unit test does not detect overload-resolution regressions that only affect older compilers.
- During review, do not treat successful compilation under the repository's language version as sufficient evidence of source compatibility.
- Public API for MSTest and Microsoft.Testing.Platform MUST NOT use `init` accessors.
- Exception: Existing APIs in Microsoft.Testing.Platform, because changing them right now would be a breaking change. However, we MUST NOT introduce **new** APIs using `init` accessors.
- IMPORTANT: Make sure to apply this rule strictly both during PR review and when working on code changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ internal sealed record AzureDevOpsTestCaseResult(
[property: JsonPropertyName("startedDate")] DateTimeOffset? StartedDate,
[property: JsonPropertyName("completedDate")] DateTimeOffset? CompletedDate)
{
/// <summary>
/// Gets the terminal state of the test result.
/// </summary>
/// <remarks>
/// Azure DevOps does not infer this from <see cref="Outcome"/>. Omitting it leaves the result in
/// <c>Pending</c> even after the containing run is completed.
/// </remarks>
[JsonPropertyName("state")]
public string State { get; } = AzureDevOpsLivePublishingConstants.CompletedTestRunState;

/// <summary>
/// Gets the id Azure DevOps assigned to this result, set only when updating an already published result.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
Microsoft.Testing.Extensions.AzureDevOpsReport.AzureDevOpsTestCaseResult.State.get -> string!
Microsoft.Testing.Extensions.AzureDevOpsReport.AzureDevOpsTestResultsClient.AzureDevOpsTestResultsClient(Microsoft.Testing.Platform.Helpers.ITask! task, Microsoft.Testing.Platform.Helpers.IClock! clock, Microsoft.Testing.Platform.Logging.ILoggerFactory! loggerFactory) -> void
Microsoft.Testing.Extensions.AzureDevOpsReport.AzureDevOpsTestResultsClient.AzureDevOpsTestResultsClient(System.Net.Http.HttpClient! httpClient, Microsoft.Testing.Platform.Helpers.ITask! task, Microsoft.Testing.Platform.Helpers.IClock! clock, Microsoft.Testing.Platform.Logging.ILogger? logger) -> void
20 changes: 20 additions & 0 deletions src/Polyfills/OverloadResolutionPriorityAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// <auto-generated />

#pragma warning disable

#if !NET9_0_OR_GREATER

using Microsoft.CodeAnalysis;

namespace System.Runtime.CompilerServices;

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
[Embedded]
internal sealed class OverloadResolutionPriorityAttribute(int priority) : Attribute
{
public int Priority { get; } = priority;
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,48 @@ private static void ReportAssertAreAllDistinctFailed<T>(IEnumerable<T> collectio

#region AreAllDistinct span/memory

/// <summary>
/// Tests whether all elements in the specified array are distinct and throws an exception if any two elements are equal.
/// </summary>
/// <typeparam name="T">The type of the array elements.</typeparam>
/// <param name="collection">The array whose elements must all be distinct.</param>
/// <param name="message">The message to include in the exception when two equal elements are found.</param>
/// <param name="collectionExpression">The syntactic expression of collection as given by the compiler via caller argument expression.</param>
/// <exception cref="AssertFailedException">Thrown if any two elements in <paramref name="collection"/> are equal.</exception>
public static void AreAllDistinct<T>([NotNull] T[]? collection, string? message = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
=> AreAllDistinct((IEnumerable<T>?)collection, message, collectionExpression);

/// <summary>
/// Tests whether all elements in the specified array are distinct using the specified equality comparer
/// and throws an exception if any two elements are equal.
/// </summary>
/// <typeparam name="T">The type of the array elements.</typeparam>
/// <param name="collection">The array whose elements must all be distinct.</param>
/// <param name="comparer">The equality comparer to use when comparing elements.</param>
/// <param name="message">The message to include in the exception when two equal elements are found.</param>
/// <param name="collectionExpression">The syntactic expression of collection as given by the compiler via caller argument expression.</param>
/// <exception cref="AssertFailedException">Thrown if any two elements in <paramref name="collection"/> are equal.</exception>
public static void AreAllDistinct<T>([NotNull] T[]? collection, [NotNull] IEqualityComparer<T>? comparer, string? message = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
=> AreAllDistinct((IEnumerable<T>?)collection, comparer, message, collectionExpression);

/// <summary>
/// Tests whether all elements in the specified collection are distinct using the specified equality comparer
/// and throws an exception if any two elements are equal.
/// </summary>
/// <typeparam name="T">The type of the collection elements.</typeparam>
/// <typeparam name="TCollection">The concrete type of the collection.</typeparam>
/// <param name="collection">The collection whose elements must all be distinct.</param>
/// <param name="comparer">The equality comparer to use when comparing elements.</param>
/// <param name="message">The message to include in the exception when two equal elements are found.</param>
/// <param name="collectionExpression">
/// The syntactic expression of collection as given by the compiler via caller argument expression.
/// Users shouldn't pass a value for this parameter.
/// </param>
/// <exception cref="AssertFailedException">Thrown if any two elements in <paramref name="collection"/> are equal.</exception>
public static void AreAllDistinct<T, TCollection>([NotNull] TCollection? collection, [NotNull] IEqualityComparer<T>? comparer, string? message = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
where TCollection : IEnumerable<T>
=> AreAllDistinct((IEnumerable<T>?)collection, comparer, message, collectionExpression);

/// <summary>
/// Tests whether all items in the specified span are distinct (no two elements are equal).
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/TestFramework/TestFramework/Assertions/Assert.AreAllNotNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ private static void ReportAssertAreAllNotNullFailed<T>(IEnumerable<T> collection

#region AreAllNotNull span/memory

/// <summary>
/// Tests whether all items in the specified array are non-null.
/// </summary>
/// <typeparam name="T">The type of the array items.</typeparam>
/// <param name="collection">The array in which to search for null elements.</param>
/// <param name="message">The message to include in the exception when the assertion fails.</param>
/// <param name="collectionExpression">
/// The syntactic expression of collection as given by the compiler via caller argument expression.
/// Users shouldn't pass a value for this parameter.
/// </param>
public static void AreAllNotNull<T>([NotNull] T[]? collection, string? message = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
=> AreAllNotNull((IEnumerable<T>?)collection, message, collectionExpression);

/// <summary>
/// Tests whether all items in the specified span are non-null.
/// </summary>
Expand Down
Loading