diff --git a/Directory.Build.targets b/Directory.Build.targets
index 193a0cd7065bd9..b0e8a59779f3f5 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -31,6 +31,23 @@
+
+
+ false
+ <_RuntimeIdentifierUsesAppHost Condition="'$(SelfContained)' == 'true'">false
+
+
+
+
+
$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)
$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'native', '$(NetCoreAppCurrentBuildSettings)'))
diff --git a/NuGet.config b/NuGet.config
index 8d2d351914d014..25b710059ddbdb 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -12,6 +12,7 @@
one as a template. The following line is a marker to insert the test restore sources.
-->
+
diff --git a/docs/workflow/testing/libraries/filtering-tests.md b/docs/workflow/testing/libraries/filtering-tests.md
index 35bf2cb2717920..a54cee32a64e5b 100644
--- a/docs/workflow/testing/libraries/filtering-tests.md
+++ b/docs/workflow/testing/libraries/filtering-tests.md
@@ -338,6 +338,12 @@ A common usage in the libraries tests is the following:
This is put on test classes to indicate that none of the tests in that class (which as usual run serially with respect to each other) may run concurrently with tests in another class. This is used for tests that use a lot of disk space or memory, or dominate all the cores, such that they are likely to disrupt any tests that run concurrently.
+## xunit v3 Migration
+
+For xunit v3–specific patterns (empty `[MemberData]`, `ConditionalTheory`
+migration, non-serializable test data), see the
+[xunit v3 Migration Notes](xunit3-migration.md).
+
## FactAttribute and `Skip`
Another way to disable the test entirely is to use the `Skip` named argument that is used on the `FactAttribute`.
diff --git a/docs/workflow/testing/libraries/xunit3-migration.md b/docs/workflow/testing/libraries/xunit3-migration.md
new file mode 100644
index 00000000000000..f5f65f295b1368
--- /dev/null
+++ b/docs/workflow/testing/libraries/xunit3-migration.md
@@ -0,0 +1,175 @@
+# xunit v3 Migration Notes
+
+This document covers common issues and patterns encountered when migrating
+tests from xunit v2 to xunit v3.
+
+## Empty `[MemberData]` at Runtime
+
+In xunit v3, a `[Theory]` whose `[MemberData]` source returns **zero rows**
+is a hard failure ("No data found"), not a silent no-op. When running through
+the test harness this surfaces as:
+
+```
+[FATAL ERROR] System.InvalidOperationException
+ Cannot find test case metadata for ID
+```
+
+This commonly happens when:
+
+- A `[MemberData]` source filters its output based on platform support
+ (e.g., `Where(x => SomeAlgorithm.IsSupported)`) and all items are
+ filtered out on the current platform.
+- A `[MemberData]` source **throws during enumeration** (e.g., because an
+ object in the test data does not support `GetHashCode()`). The
+ `ModifiedType` returned by `GetModifiedFieldType()` is a known example —
+ it throws `NotSupportedException` from `GetHashCode()`.
+
+### Diagnosing
+
+Run the test assembly directly with `-list full` to map the failing ID to a
+test method name:
+
+```bash
+# Use the testhost dotnet, not the system one
+artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec \
+ artifacts/bin//Debug/net11.0-unix/.dll \
+ -list full 2>&1 | grep
+```
+
+Then inspect the `[MemberData]` source for conditional logic or types that
+cannot be serialized/hashed by xunit v3.
+
+### Fixing Empty Data
+
+Switch to an unconditional data source and move the platform check into the
+test body:
+
+```cs
+// BROKEN: MemberData can return zero rows
+public static IEnumerable
-
-
-
-
-
-
-
-
+
+
+ false
+ <_RuntimeIdentifierUsesAppHost Condition="'$(SelfContained)' == 'true'">false
+ false
+
+
+ false
+ <_RuntimeIdentifierUsesAppHost>false
+ false
+
+ $(NoWarn);CS8625
+
+ $(DefineConstants);XUNIT_AOT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+
+
+
diff --git a/src/coreclr/tools/ILVerification.Tests/ILVerification.Tests.csproj b/src/coreclr/tools/ILVerification.Tests/ILVerification.Tests.csproj
index 09923f87e7238b..24a17c6e9d50ef 100644
--- a/src/coreclr/tools/ILVerification.Tests/ILVerification.Tests.csproj
+++ b/src/coreclr/tools/ILVerification.Tests/ILVerification.Tests.csproj
@@ -3,6 +3,8 @@
true
$(NetCoreAppToolCurrent)
false
+ XUnitV3
+ Exe
diff --git a/src/coreclr/tools/ILVerification.Tests/TestDataLoader.cs b/src/coreclr/tools/ILVerification.Tests/TestDataLoader.cs
index bcd0f240b0c584..f85d399ef606e7 100644
--- a/src/coreclr/tools/ILVerification.Tests/TestDataLoader.cs
+++ b/src/coreclr/tools/ILVerification.Tests/TestDataLoader.cs
@@ -13,8 +13,7 @@
using Internal.TypeSystem.Ecma;
using System.Text.Json;
using Xunit;
-using Xunit.Abstractions;
-
+using Xunit.Sdk;
namespace ILVerification.Tests
{
///
diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj
index f8d85c1da3e025..8cbeba09dfc1e1 100644
--- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj
+++ b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj
@@ -9,6 +9,7 @@
$(RuntimeBinDir)/ilc-published/netstandard
Debug;Release;Checked
AnyCPU
+ false
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/ILCompiler.Compiler.Tests.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/ILCompiler.Compiler.Tests.csproj
index 69e9d87637f92d..27077adbcf4b43 100644
--- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/ILCompiler.Compiler.Tests.csproj
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/ILCompiler.Compiler.Tests.csproj
@@ -5,7 +5,7 @@
Debug;Release;Checked
true
- -notrait category=failing
+ --filter-not-trait category=failing
$(NoWarn);NU1701
true
- -notrait category=failing
+ --filter-not-trait category=failing
$(NoWarn);NU1701
-
false
AnyCPU;x64
AnyCPU
true
-
+
READYTORUN;$(DefineConstants)
+ XUnitV3
+ Exe
-
+
diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs
index 2909c2e553c8c3..e773e6c1bcfb6a 100644
--- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs
+++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs
@@ -12,8 +12,6 @@
using Internal.TypeSystem.Ecma;
using Xunit;
-using Xunit.Abstractions;
-
namespace TypeSystemTests
{
public class SignatureTests
diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs
index 298982f37e00b8..e9ab893ad1242f 100644
--- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs
+++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs
@@ -8,16 +8,18 @@
using Internal.TypeSystem.Ecma;
using Xunit;
-using Xunit.Abstractions;
-
namespace TypeSystemTests
{
public class Entrypoint
{
class Logger : ITestOutputHelper
{
- void ITestOutputHelper.WriteLine(string message) => Console.WriteLine(message);
- void ITestOutputHelper.WriteLine(string format, params object[] args) => Console.WriteLine(format, args);
+ private readonly System.Text.StringBuilder _output = new();
+ string ITestOutputHelper.Output => _output.ToString();
+ void ITestOutputHelper.Write(string message) { Console.Write(message); _output.Append(message); }
+ void ITestOutputHelper.Write(string format, params object[] args) { string msg = string.Format(format, args); Console.Write(msg); _output.Append(msg); }
+ void ITestOutputHelper.WriteLine(string message) { Console.WriteLine(message); _output.AppendLine(message); }
+ void ITestOutputHelper.WriteLine(string format, params object[] args) { string msg = string.Format(format, args); Console.WriteLine(msg); _output.AppendLine(msg); }
}
public static void NotQuiteMain()
diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs
index b6ddb314c70dfc..b78660280c398d 100644
--- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs
+++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs
@@ -11,9 +11,6 @@
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;
using Xunit;
-using Xunit.Abstractions;
-
-
namespace TypeSystemTests
{
public class VirtualFunctionOverrideTests
diff --git a/src/installer/tests/Directory.Build.targets b/src/installer/tests/Directory.Build.targets
index e4218ebb7b53f4..a0e57f66aac71d 100644
--- a/src/installer/tests/Directory.Build.targets
+++ b/src/installer/tests/Directory.Build.targets
@@ -93,8 +93,8 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
diff --git a/src/installer/tests/helixpublish.proj b/src/installer/tests/helixpublish.proj
index 7ad19673f90ad7..9be8d466f12f50 100644
--- a/src/installer/tests/helixpublish.proj
+++ b/src/installer/tests/helixpublish.proj
@@ -48,14 +48,13 @@
- <_TestExePath>$([System.IO.Path]::GetFileNameWithoutExtension($(_TargetPath)))$(ExeSuffix)
+ <_TestDllPath>$([System.IO.Path]::GetFileName($(_TargetPath)))
- $(_TestExePath) $(TestRunnerAdditionalArguments) --report-trx --results-directory .
- ./$(_TestExePath) $(TestRunnerAdditionalArguments) --report-trx --results-directory .
- chmod +x $(_TestExePath)
+ dotnet exec $(_TestDllPath) $(TestRunnerAdditionalArguments) --report-trx --results-directory .
+ dotnet exec $(_TestDllPath) $(TestRunnerAdditionalArguments) --report-trx --results-directory .
$(_PayloadDirectory)
diff --git a/src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsa.cs b/src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsa.cs
index 8145cdcdcd6e4a..37c8bb21a8abed 100644
--- a/src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsa.cs
+++ b/src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsa.cs
@@ -673,6 +673,7 @@ public static CompositeMLDsa ImportSubjectPublicKeyInfo(ReadOnlySpan sourc
static void SubjectPublicKeyReader(ReadOnlySpan key, in ValueAlgorithmIdentifierAsn identifier, out CompositeMLDsa dsa)
{
CompositeMLDsaAlgorithm algorithm = GetAlgorithmIdentifier(in identifier);
+ ThrowIfNotSupported(algorithm);
if (!algorithm.IsValidPublicKeySize(key.Length))
{
@@ -866,6 +867,7 @@ static void PrivateKeyReader(
out CompositeMLDsa dsa)
{
CompositeMLDsaAlgorithm algorithm = GetAlgorithmIdentifier(in algorithmIdentifier);
+ ThrowIfNotSupported(algorithm);
if (!algorithm.IsValidPrivateKeySize(privateKeyContents.Length))
{
diff --git a/src/libraries/Common/tests/AotXunitExtensions/AotXunitExtensions.csproj b/src/libraries/Common/tests/AotXunitExtensions/AotXunitExtensions.csproj
new file mode 100644
index 00000000000000..522432cc88b8ec
--- /dev/null
+++ b/src/libraries/Common/tests/AotXunitExtensions/AotXunitExtensions.csproj
@@ -0,0 +1,21 @@
+
+
+
+ $(NetCoreAppMinimum)
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libraries/Common/tests/AotXunitExtensions/AttributeStubs.cs b/src/libraries/Common/tests/AotXunitExtensions/AttributeStubs.cs
new file mode 100644
index 00000000000000..6ecdf01035a790
--- /dev/null
+++ b/src/libraries/Common/tests/AotXunitExtensions/AttributeStubs.cs
@@ -0,0 +1,449 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Compile-time shim definitions for Microsoft.DotNet.XUnitV3Extensions types.
+//
+// When NativeAOT test projects use the xunit v4 AOT packages, the
+// Microsoft.DotNet.XUnitV3Extensions package cannot be referenced because
+// FactAttribute and TheoryAttribute are sealed in the AOT packages.
+//
+// These stubs let test source compile without the Extensions package.
+// Attributes that inherit from FactAttribute/TheoryAttribute in the real
+// package are plain [Attribute] stubs here — methods decorated with them
+// will NOT be discovered as tests by the AOT source generator (which only
+// recognizes [Fact] and [Theory]). This is the expected trade-off:
+// only plain [Fact]/[Theory] tests run in NativeAOT mode.
+//
+// ActiveIssueAttribute extends BeforeAfterTestAttribute so that tests
+// decorated with [Fact]/[Theory] + [ActiveIssue] are skipped at runtime
+// when their conditions match, rather than running and failing.
+//
+// ConditionalClassAttribute is intentionally NOT stubbed — see comment in the
+// Xunit namespace below. Use Assert.SkipUnless in constructors instead.
+
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using Xunit.Sdk;
+using Xunit.v3;
+
+namespace Xunit
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
+ public sealed class ConditionalFactAttribute : Attribute
+ {
+ public ConditionalFactAttribute(Type conditionType, params string[] conditionMemberNames) { }
+ public ConditionalFactAttribute(params Type[] conditions) { }
+ public string? DisplayName { get; set; }
+ public string? Skip { get; set; }
+ public int Timeout { get; set; }
+ }
+
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
+ public sealed class ConditionalTheoryAttribute : Attribute
+ {
+ public ConditionalTheoryAttribute(Type conditionType, params string[] conditionMemberNames) { }
+ public ConditionalTheoryAttribute(params Type[] conditions) { }
+ public string? DisplayName { get; set; }
+ public string? Skip { get; set; }
+ public bool SkipTestWithoutData { get; set; }
+ public int Timeout { get; set; }
+ }
+
+ // ConditionalClassAttribute is intentionally NOT stubbed here. The real
+ // implementation in Microsoft.DotNet.XUnitV3Extensions works via traits in
+ // non-AOT builds. For NativeAOT builds, classes should use Assert.SkipUnless
+ // in the constructor instead — this works in both AOT and non-AOT modes.
+ // Removing the stub ensures any new usage produces a compile error, forcing
+ // an explicit fix rather than silently running tests that should be skipped.
+
+ ///
+ /// Marks a test as having a known active issue. In NativeAOT builds, this
+ /// attribute extends so that tests
+ /// decorated with [Fact]/[Theory] plus [ActiveIssue]
+ /// are skipped at runtime when the specified conditions match.
+ ///
+ ///
+ /// The xUnit v3 AOT source generator always instantiates BeforeAfterTestAttribute
+ /// subclasses via their parameterless constructor (new T()), discarding
+ /// all constructor arguments from metadata. To work around this, the
+ /// method reads the original attribute metadata from the
+ /// test method, class, and assembly using and
+ /// evaluates the skip conditions from the actual constructor arguments.
+ ///
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+ public sealed class ActiveIssueAttribute : BeforeAfterTestAttribute
+ {
+ // The parameterless constructor is required by the xUnit v3 AOT source generator,
+ // which emits `new ActiveIssueAttribute()` in generated code. It is never used
+ // directly by test authors (the real package has no parameterless constructor).
+ // The remaining constructors match the real ActiveIssueAttribute API so test
+ // source code compiles against this stub.
+
+ public ActiveIssueAttribute() { }
+ public ActiveIssueAttribute(string issue) { }
+ public ActiveIssueAttribute(string issue, TestPlatforms platforms) { }
+ public ActiveIssueAttribute(string issue, TargetFrameworkMonikers frameworks) { }
+ public ActiveIssueAttribute(string issue, TestRuntimes runtimes) { }
+ public ActiveIssueAttribute(string issue, TestPlatforms platforms, TestRuntimes runtimes) { }
+ public ActiveIssueAttribute(string issue, TestPlatforms platforms, TargetFrameworkMonikers frameworks, TestRuntimes runtimes) { }
+ public ActiveIssueAttribute(string issue, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)] Type conditionType, params string[] conditionMemberNames) { }
+
+ public override void Before(ICodeGenTest test)
+ {
+ // Read the real ActiveIssueAttribute metadata from the test method, class,
+ // and assembly (since the source generator discards constructor arguments).
+ foreach (var parsed in GetActiveIssueMetadata(test))
+ {
+ if (ShouldSkip(parsed))
+ {
+ throw SkipException.ForSkip($"Active issue: {parsed.Issue}");
+ }
+ }
+ }
+
+ private static IEnumerable GetActiveIssueMetadata(ICodeGenTest test)
+ {
+ var testMethod = test.TestCase.TestMethod;
+ var testClass = testMethod.TestClass;
+
+ // Method-level attributes
+ MethodInfo? methodInfo = ResolveMethod(testMethod, testClass);
+ if (methodInfo is not null)
+ {
+ foreach (var data in ReadActiveIssueData(CustomAttributeData.GetCustomAttributes(methodInfo)))
+ yield return data;
+ }
+
+ // Class-level attributes (check declaring type if different from test class)
+ Type classType = testClass.Class;
+ foreach (var data in ReadActiveIssueData(CustomAttributeData.GetCustomAttributes(classType)))
+ yield return data;
+
+ // If the method is declared on a base type, also check that type
+ if (methodInfo?.DeclaringType is not null && methodInfo.DeclaringType != classType)
+ {
+ foreach (var data in ReadActiveIssueData(CustomAttributeData.GetCustomAttributes(methodInfo.DeclaringType)))
+ yield return data;
+ }
+
+ // Assembly-level attributes
+ foreach (var data in ReadActiveIssueData(CustomAttributeData.GetCustomAttributes(classType.Assembly)))
+ yield return data;
+ }
+
+ private static MethodInfo? ResolveMethod(Xunit.Sdk.ITestMethodMetadata testMethod, Xunit.v3.ICoreTestClass testClass)
+ {
+ string methodName = testMethod.MethodName;
+ Type classType = testClass.Class;
+
+ // If the method is declared on a different type (base class), resolve from there
+ if (testMethod is Xunit.v3.ICodeGenTestMethod codeGenMethod
+ && codeGenMethod.DeclaredTypeIndex is string declaredTypeIndex)
+ {
+ // DeclaredTypeIndex uses "global::Namespace.Type" format; strip the prefix
+ string typeName = declaredTypeIndex.StartsWith("global::", StringComparison.Ordinal)
+ ? declaredTypeIndex.Substring("global::".Length)
+ : declaredTypeIndex;
+ Type? declaredType = classType.Assembly.GetType(typeName)
+ ?? Type.GetType(typeName);
+ if (declaredType is not null)
+ classType = declaredType;
+ }
+
+ // Use GetMethods to handle overloads gracefully - pick the first match
+ try
+ {
+ return classType.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
+ }
+ catch
+ {
+ // If reflection fails (trimmed metadata, ambiguous match, etc.), fail open
+ return null;
+ }
+ }
+
+ private static IEnumerable ReadActiveIssueData(IList attributes)
+ {
+ foreach (var attr in attributes)
+ {
+ if (attr.AttributeType != typeof(ActiveIssueAttribute))
+ continue;
+
+ var args = attr.ConstructorArguments;
+ if (args.Count == 0)
+ continue;
+
+ string issue = args[0].Value as string ?? string.Empty;
+
+ if (args.Count == 1)
+ {
+ // ActiveIssueAttribute(string issue)
+ yield return new ActiveIssueData(issue, TestPlatforms.Any, TargetFrameworkMonikers.Any,
+ TestRuntimes.CoreCLR | TestRuntimes.Mono, null, []);
+ }
+ else if (args.Count >= 2 && args[1].ArgumentType == typeof(Type))
+ {
+ // ActiveIssueAttribute(string issue, Type conditionType, params string[] conditionMemberNames)
+ Type? conditionType = args[1].Value as Type;
+ string[] memberNames = args.Count > 2
+ ? args.Skip(2).SelectMany(a =>
+ a.ArgumentType.IsArray
+ ? ((System.Collections.ObjectModel.ReadOnlyCollection)a.Value!).Select(e => (string)e.Value!)
+ : [(string)a.Value!]).ToArray()
+ : [];
+ yield return new ActiveIssueData(issue, TestPlatforms.Any, TargetFrameworkMonikers.Any,
+ TestRuntimes.CoreCLR | TestRuntimes.Mono, conditionType, memberNames);
+ }
+ else
+ {
+ // Enum-based overloads: determine which enums are present by argument types
+ var platforms = TestPlatforms.Any;
+ var frameworks = TargetFrameworkMonikers.Any;
+ var runtimes = TestRuntimes.CoreCLR | TestRuntimes.Mono;
+
+ for (int i = 1; i < args.Count; i++)
+ {
+ if (args[i].ArgumentType == typeof(TestPlatforms))
+ platforms = (TestPlatforms)(int)args[i].Value!;
+ else if (args[i].ArgumentType == typeof(TargetFrameworkMonikers))
+ frameworks = (TargetFrameworkMonikers)(int)args[i].Value!;
+ else if (args[i].ArgumentType == typeof(TestRuntimes))
+ runtimes = (TestRuntimes)(int)args[i].Value!;
+ }
+
+ yield return new ActiveIssueData(issue, platforms, frameworks, runtimes, null, []);
+ }
+ }
+ }
+
+ private static bool ShouldSkip(ActiveIssueData data)
+ {
+ if (data.ConditionType is not null)
+ {
+ return EvaluateTypeConditions(data.ConditionType, data.ConditionMemberNames);
+ }
+
+ return MatchesPlatform(data.Platforms)
+ && MatchesFramework(data.Frameworks)
+ && MatchesRuntime(data.Runtimes);
+ }
+
+ private static bool EvaluateTypeConditions(
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)] Type conditionType,
+ string[] memberNames)
+ {
+ foreach (string memberName in memberNames)
+ {
+ if (!EvaluateMember(conditionType, memberName))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static bool EvaluateMember(
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)] Type type,
+ string memberName)
+ {
+ PropertyInfo? property = type.GetProperty(memberName, BindingFlags.Public | BindingFlags.Static);
+ if (property?.PropertyType == typeof(bool))
+ {
+ return (bool)property.GetValue(null)!;
+ }
+
+ MethodInfo? method = type.GetMethod(memberName, BindingFlags.Public | BindingFlags.Static, Type.EmptyTypes);
+ if (method?.ReturnType == typeof(bool))
+ {
+ return (bool)method.Invoke(null, null)!;
+ }
+
+ return false;
+ }
+
+ private static bool MatchesPlatform(TestPlatforms platforms)
+ {
+ if (platforms == TestPlatforms.Any)
+ return true;
+
+ if (platforms.HasFlag(TestPlatforms.Windows) && OperatingSystem.IsWindows())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.Linux) && OperatingSystem.IsLinux())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.OSX) && OperatingSystem.IsMacOS())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")))
+ return true;
+ if (platforms.HasFlag(TestPlatforms.iOS) && OperatingSystem.IsIOS())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.tvOS) && OperatingSystem.IsTvOS())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.MacCatalyst) && OperatingSystem.IsMacCatalyst())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.Browser) && OperatingSystem.IsBrowser())
+ return true;
+ if (platforms.HasFlag(TestPlatforms.Android) && OperatingSystem.IsAndroid())
+ return true;
+
+ return false;
+ }
+
+ private static bool MatchesFramework(TargetFrameworkMonikers frameworks)
+ {
+ // NativeAOT is always .NET Core
+ return frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp);
+ }
+
+ private static bool MatchesRuntime(TestRuntimes runtimes)
+ {
+ // NativeAOT is CoreCLR-based
+ return runtimes.HasFlag(TestRuntimes.CoreCLR);
+ }
+
+ private readonly record struct ActiveIssueData(
+ string Issue,
+ TestPlatforms Platforms,
+ TargetFrameworkMonikers Frameworks,
+ TestRuntimes Runtimes,
+ [property: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)]
+ Type? ConditionType,
+ string[] ConditionMemberNames);
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
+ public sealed class OuterLoopAttribute : Attribute
+ {
+ public OuterLoopAttribute() { }
+ public OuterLoopAttribute(string? reason) { }
+ public OuterLoopAttribute(string? reason, TestPlatforms platforms) { }
+ public OuterLoopAttribute(string? reason, TargetFrameworkMonikers frameworks) { }
+ public OuterLoopAttribute(string? reason, Type conditionType, params string[] conditionMemberNames) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
+ public sealed class PlatformSpecificAttribute : Attribute
+ {
+ public PlatformSpecificAttribute(TestPlatforms platforms) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+ public sealed class SkipOnPlatformAttribute : Attribute
+ {
+ public SkipOnPlatformAttribute(TestPlatforms platforms, string? reason = null) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+ public sealed class SkipOnMonoAttribute : Attribute
+ {
+ public SkipOnMonoAttribute(string reason) { }
+ public SkipOnMonoAttribute(string reason, TestPlatforms platforms) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+ public sealed class SkipOnCoreClrAttribute : Attribute
+ {
+ public SkipOnCoreClrAttribute(string reason) { }
+ public SkipOnCoreClrAttribute(string reason, RuntimeTestModes modes) { }
+ public SkipOnCoreClrAttribute(string reason, RuntimeConfiguration configuration) { }
+ public SkipOnCoreClrAttribute(string reason, RuntimeTestModes modes, RuntimeConfiguration configuration) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+ public sealed class SkipOnTargetFrameworkAttribute : Attribute
+ {
+ public SkipOnTargetFrameworkAttribute(TargetFrameworkMonikers frameworks, string? reason = null) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
+ public sealed class SkipOnCIAttribute : Attribute
+ {
+ public SkipOnCIAttribute(string? reason = null) { }
+ }
+
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
+ public sealed class WindowsFullFrameworkOnlyFactAttribute : Attribute
+ {
+ public string? Skip { get; set; }
+ }
+
+ [Flags]
+ public enum TestPlatforms
+ {
+ Windows = 1,
+ Linux = 2,
+ OSX = 4,
+ FreeBSD = 8,
+ NetBSD = 16,
+ iOS = 32,
+ tvOS = 64,
+ MacCatalyst = 128,
+ Browser = 256,
+ Wasi = 512,
+ Android = 1024,
+ LinuxBionic = 2048,
+ Unix = Linux | OSX | FreeBSD | NetBSD | iOS | tvOS | MacCatalyst | Android | LinuxBionic,
+ AnyUnix = Unix | Browser | Wasi,
+ Any = ~0,
+ }
+
+ [Flags]
+ public enum TargetFrameworkMonikers
+ {
+ Netcoreapp = 1,
+ NetFramework = 2,
+ Any = ~0,
+ }
+
+ [Flags]
+ public enum TestRuntimes
+ {
+ CoreCLR = 1,
+ Mono = 2,
+ }
+
+ [Flags]
+ public enum RuntimeTestModes
+ {
+ RegularRun = 1,
+ JitStress = 2,
+ JitStressRegs = 4,
+ JitMinOpts = 8,
+ }
+
+ [Flags]
+ public enum RuntimeConfiguration
+ {
+ Release = 1,
+ Checked = 2,
+ Debug = 4,
+ Any = ~0,
+ }
+
+ public static class XunitConstants
+ {
+ public const string Category = "category";
+ public const string IgnoreForCI = "IgnoreForCI";
+ public const string OuterLoop = "OuterLoop";
+ public const string Failing = "failing";
+ }
+
+ public static class CoreClrConfigurationDetection
+ {
+ public static bool IsStressTest => false;
+ }
+}
+
+namespace Microsoft.DotNet.XUnitExtensions
+{
+ public class SkipTestException : Exception
+ {
+ public SkipTestException(string reason) : base(reason) { }
+ }
+}
diff --git a/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs b/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs
index 86991cbd9bc4db..bf9dd04792d4d8 100644
--- a/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs
+++ b/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs
@@ -1,197 +1,126 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#nullable disable
-
using System;
using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Reflection;
-using System.Runtime.Loader;
+using System.Text;
+using System.Threading;
using System.Threading.Tasks;
-using System.Xml.Linq;
-using Xunit;
-using Xunit.Abstractions;
+using Xunit.Internal;
+using Xunit.Runner.Common;
+using Xunit.Runner.InProc.SystemConsole;
using Xunit.Sdk;
// @TODO medium-to-longer term, we should try to get rid of the special-unicorn-single-file runner in favor of making the real runner work for single file.
// https://github.com/dotnet/runtime/issues/70432
-public class SingleFileTestRunner : XunitTestFramework
+public static class SingleFileTestRunner
{
- private SingleFileTestRunner(IMessageSink messageSink)
- : base(messageSink) { }
-
- public static int Main(string[] args)
+ public static async Task Main(string[] args)
{
- var asm = typeof(SingleFileTestRunner).Assembly;
- Console.WriteLine("Running assembly:" + asm.FullName);
+ Console.OutputEncoding = Encoding.UTF8;
+
+ var testAssembly = typeof(SingleFileTestRunner).Assembly;
+ Console.WriteLine("Running assembly:" + testAssembly.FullName);
// The current RemoteExecutor implementation is not compatible with the SingleFileTestRunner.
Environment.SetEnvironmentVariable("DOTNET_REMOTEEXECUTOR_SUPPORTED", "0");
- // To detect ReadyToRun testing mode, we set a constant in
- // eng/testing/tests.singlefile.targets, which we use in the following
- // preprocessor directive. In the case that it is defined, we set an
- // environment variable that we consume later to implement
- // PlatformDetection.IsReadyToRunCompiled. This last value is used for the
- // [ActiveIssue] annotations designed to exclude tests from running.
-
#if TEST_READY_TO_RUN_COMPILED
- Environment.SetEnvironmentVariable("TEST_READY_TO_RUN_MODE" ,"1");
+ Environment.SetEnvironmentVariable("TEST_READY_TO_RUN_MODE", "1");
#endif
- var diagnosticSink = new ConsoleDiagnosticMessageSink();
- var testsFinished = new TaskCompletionSource();
- var testSink = new TestMessageSink();
-
-#pragma warning disable CS0618 // Delegating*Sink types are marked obsolete
- var summarySink = new DelegatingExecutionSummarySink(testSink,
- () => false,
- (completed, summary) => Console.WriteLine($"Tests run: {summary.Total}, Errors: {summary.Errors}, Failures: {summary.Failed}, Skipped: {summary.Skipped}. Time: {TimeSpan.FromSeconds((double)summary.Time).TotalSeconds}s"));
- var resultsXmlAssembly = new XElement("assembly");
- var resultsSink = new DelegatingXmlCreationSink(summarySink, resultsXmlAssembly);
-#pragma warning restore CS0618
-
- testSink.Execution.TestSkippedEvent += args => { Console.WriteLine($"[SKIP] {args.Message.Test.DisplayName}"); };
- testSink.Execution.TestFailedEvent += args => { Console.WriteLine($"[FAIL] {args.Message.Test.DisplayName}{Environment.NewLine}{Xunit.ExceptionUtility.CombineMessages(args.Message)}{Environment.NewLine}{Xunit.ExceptionUtility.CombineStackTraces(args.Message)}"); };
-
- testSink.Execution.TestAssemblyFinishedEvent += args =>
- {
- Console.WriteLine($"Finished {args.Message.TestAssembly.Assembly}{Environment.NewLine}");
- testsFinished.SetResult();
- };
-
- var assemblyConfig = new TestAssemblyConfiguration()
- {
- // Turn off pre-enumeration of theories, since there is no theory selection UI in this runner
- PreEnumerateTheories = false,
- };
-
- var xunitTestFx = new SingleFileTestRunner(diagnosticSink);
- var asmInfo = Reflector.Wrap(asm);
- var asmName = asm.GetName();
+ // In NativeAOT, Assembly.Location returns empty string. Fall back
+ // to the native executable path so xunit can resolve the assembly.
+ var processPath = testAssembly.Location;
+#if NET
+ if (string.IsNullOrEmpty(processPath))
+ processPath = Environment.ProcessPath ?? "unknown";
+#endif
- var discoverySink = new TestDiscoverySink();
- var discoverer = xunitTestFx.CreateDiscoverer(asmInfo);
- discoverer.Find(false, discoverySink, TestFrameworkOptions.ForDiscovery(assemblyConfig));
- discoverySink.Finished.WaitOne();
+ string? xmlResultFileName = null;
+ var excludedTraits = new Dictionary>();
- string xmlResultFileName = null;
- XunitFilters filters = new XunitFilters();
- // Quick hack wo much validation to get args that are passed (notrait, xml)
- Dictionary> noTraits = new Dictionary>();
for (int i = 0; i < args.Length; i++)
{
- if (args[i].Equals("-notrait", StringComparison.OrdinalIgnoreCase))
+ if ((args[i].Equals("-trait-", StringComparison.OrdinalIgnoreCase) ||
+ args[i].Equals("-notrait", StringComparison.OrdinalIgnoreCase)) && i + 1 < args.Length)
{
- var traitKeyValue = args[i + 1].Split("=", StringSplitOptions.TrimEntries);
-
- if (!noTraits.TryGetValue(traitKeyValue[0], out List values))
+ var parts = args[++i].Split('=', 2);
+ if (parts.Length == 2)
{
- noTraits.Add(traitKeyValue[0], values = new List());
+ if (!excludedTraits.TryGetValue(parts[0], out var values))
+ excludedTraits[parts[0]] = values = new HashSet();
+ values.Add(parts[1]);
}
-
- values.Add(traitKeyValue[1]);
- i++;
}
-
- if (args[i].Equals("-xml", StringComparison.OrdinalIgnoreCase))
+ else if (args[i].Equals("-xml", StringComparison.OrdinalIgnoreCase) && i + 1 < args.Length)
{
- xmlResultFileName = args[i + 1].Trim();
- i++;
+ xmlResultFileName = args[++i];
}
+ }
- if (args[i].Equals("-class", StringComparison.OrdinalIgnoreCase))
- {
- filters.IncludedClasses.Add(args[i + 1].Trim());
- i++;
- }
+ var project = new XunitProject();
+ var targetFramework = testAssembly.GetTargetFramework();
+ var projectAssembly = new XunitProjectAssembly(
+ project, processPath, new AssemblyMetadata(3, targetFramework))
+ {
+ Assembly = testAssembly
+ };
+ projectAssembly.Configuration.PreEnumerateTheories = false;
- if (args[i].Equals("-noclass", StringComparison.OrdinalIgnoreCase) ||
- args[i].Equals("-class-", StringComparison.OrdinalIgnoreCase))
- {
- filters.ExcludedClasses.Add(args[i + 1].Trim());
- i++;
- }
+ foreach (var (key, values) in excludedTraits)
+ foreach (var value in values)
+ projectAssembly.Configuration.Filters.AddExcludedTraitFilter(key, value);
- if (args[i].Equals("-method", StringComparison.OrdinalIgnoreCase))
- {
- filters.IncludedMethods.Add(args[i + 1].Trim());
- i++;
- }
+ if (xmlResultFileName is not null)
+ project.Configuration.Output.Add("xml", xmlResultFileName);
- if (args[i].Equals("-nomethod", StringComparison.OrdinalIgnoreCase) ||
- args[i].Equals("-method-", StringComparison.OrdinalIgnoreCase))
- {
- filters.ExcludedMethods.Add(args[i + 1].Trim());
- i++;
- }
+ project.Add(projectAssembly);
+ project.RunnerReporter = new DefaultRunnerReporter();
- if (args[i].Equals("-namespace", StringComparison.OrdinalIgnoreCase))
- {
- filters.IncludedNamespaces.Add(args[i + 1].Trim());
- i++;
- }
+ var cts = new CancellationTokenSource();
+ Console.CancelKeyPress += (_, e) => { e.Cancel = true; cts.Cancel(); };
- if (args[i].Equals("-nonamespace", StringComparison.OrdinalIgnoreCase) ||
- args[i].Equals("-namespace-", StringComparison.OrdinalIgnoreCase))
- {
- filters.ExcludedNamespaces.Add(args[i + 1].Trim());
- i++;
- }
+ var consoleHelper = new ConsoleHelper(Console.In, Console.Out);
+ var logger = new ConsoleRunnerLogger(useColors: true, useAnsiColor: false, consoleHelper, waitForAcknowledgment: false);
- if (args[i].Equals("-parallel", StringComparison.OrdinalIgnoreCase))
- {
- string parallelismArg = args[i + 1].Trim().ToLower();
- var (parallelizeAssemblies, parallelizeTestCollections) = parallelismArg switch
- {
- "all" => (true, true),
- "assemblies" => (true, false),
- "collections" => (false, true),
- "none" => (false, false),
- _ => throw new ArgumentException($"Unknown parallelism option '{parallelismArg}'.")
- };
-
- assemblyConfig.ParallelizeAssembly = parallelizeAssemblies;
- assemblyConfig.ParallelizeTestCollections = parallelizeTestCollections;
- i++;
- }
- }
+ var pipelineStartup = await ProjectAssemblyRunner.InvokePipelineStartup(testAssembly, null);
- foreach (KeyValuePair> kvp in noTraits)
- {
- filters.ExcludedTraits.Add(kvp.Key, kvp.Value);
- }
+ var reporter = project.RunnerReporter;
+ var reporterMessageHandler = await reporter.CreateMessageHandler(logger, null);
- var filteredTestCases = discoverySink.TestCases.Where(filters.Filter).ToList();
- var executor = xunitTestFx.CreateExecutor(asmName);
- executor.RunTests(filteredTestCases, resultsSink, TestFrameworkOptions.ForExecution(assemblyConfig));
+ int failCount;
+ try
+ {
+ consoleHelper.WriteLine(ProjectAssemblyRunner.Banner);
- resultsSink.Finished.WaitOne();
+ var projectRunner = new ProjectAssemblyRunner(
+ testAssembly, AutomatedMode.Off,
+ NullSourceInformationProvider.Instance, cts);
- // Helix need to see results file in the drive to detect if the test has failed or not
- if(xmlResultFileName != null)
+ failCount = await projectRunner.Run(
+ projectAssembly, reporterMessageHandler, null, logger, pipelineStartup);
+ }
+ catch (Exception ex)
{
- resultsXmlAssembly.Save(xmlResultFileName);
+ // ProjectAssemblyRunner.Run has an internal catch-all that logs the
+ // primary failure, then unconditionally sends TestExecutionSummaries.
+ // When the summaries are empty (because the failure prevented the
+ // summary from being recorded), the reporter's WriteDefaultSummary
+ // crashes on Max() over the empty collection. ConsoleRunner handles
+ // this with an outer catch; we need the same protection so the real
+ // error (already logged above) isn't masked by the secondary crash.
+ consoleHelper.WriteLine("error: {0}", ex.Message);
+ failCount = 1;
}
-
- var failed = resultsSink.ExecutionSummary.Failed > 0 || resultsSink.ExecutionSummary.Errors > 0;
- return failed ? 1 : 0;
- }
-}
-
-// This is about running on desktop FX, which we don't do
-#pragma warning disable xUnit3000
-internal class ConsoleDiagnosticMessageSink : IMessageSink
-{
- public bool OnMessage(IMessageSinkMessage message)
- {
- if (message is IDiagnosticMessage diagnosticMessage)
+ finally
{
- return true;
+ if (pipelineStartup is not null)
+ await pipelineStartup.StopAsync();
+ await reporterMessageHandler.DisposeAsync();
}
- return false;
+
+ return failCount > 0 ? 1 : 0;
}
}
-#pragma warning restore xUnit3000
diff --git a/src/libraries/Common/tests/StaticTestGenerator/Program.cs b/src/libraries/Common/tests/StaticTestGenerator/Program.cs
index 049129edb8d269..b6407acdd6f178 100644
--- a/src/libraries/Common/tests/StaticTestGenerator/Program.cs
+++ b/src/libraries/Common/tests/StaticTestGenerator/Program.cs
@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Xunit;
-using Xunit.Abstractions;
using Xunit.Sdk;
namespace StaticTestGenerator
@@ -1017,11 +1016,11 @@ private sealed class TestCase
/// Default options to use when constructing xunit options if no additional options are provided.
private static readonly string[] s_defaultXunitOptions = new string[]
{
- "-notrait", "category=nonnetcoreapptests",
- "-notrait", "category=nonwindowstests",
- "-notrait", "category=IgnoreForCI",
- "-notrait", "category=failing",
- "-notrait", "category=OuterLoop"
+ "-trait-", "category=nonnetcoreapptests",
+ "-trait-", "category=nonwindowstests",
+ "-trait-", "category=IgnoreForCI",
+ "-trait-", "category=failing",
+ "-trait-", "category=OuterLoop"
};
/// The code to write out to the output file before all of the test cases.
@@ -1029,8 +1028,6 @@ private sealed class TestCase
@"using System;
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
-using Xunit.Abstractions;
-
public static class Test
{
private static bool s_verbose;
@@ -1078,7 +1075,7 @@ private static void Execute(string name, Action action)
action();
s_succeeded++;
}
- catch (SkipTestException) { }
+ catch (SkipException) { }
catch (Exception e)
{
s_failed++;
@@ -1097,7 +1094,7 @@ private static void Execute(string name, Func action)
action().GetAwaiter().GetResult();
s_succeeded++;
}
- catch (SkipTestException) { }
+ catch (SkipException) { }
catch (Exception e)
{
s_failed++;
@@ -1115,6 +1112,18 @@ private static T Cast(object obj) =>
private sealed class DefaultTestOutputHelper : ITestOutputHelper
{
+ public string Output => throw new NotSupportedException();
+
+ public void Write(string message)
+ {
+ if (s_verbose) Console.Write(""TestOutputHelper: "" + message);
+ }
+
+ public void Write(string format, params object[] args)
+ {
+ if (s_verbose) Console.Write(""TestOutputHelper: "" + string.Format(format, args));
+ }
+
public void WriteLine(string message)
{
if (s_verbose) Console.WriteLine(""TestOutputHelper: "" + message);
@@ -1139,7 +1148,6 @@ private static string GetCsprojTemplate(string targetFramework) =>
#HelperAssemblyLocation#xunit.core.dll
#HelperAssemblyLocation#xunit.assert.dll
- #HelperAssemblyLocation#xunit.abstractions.dll
#HelperAssemblyLocation#Microsoft.DotNet.XUnitExtensions.dll
#HelperAssemblyLocation#TestUtilities.dll
#TestAssemblyLocation#
diff --git a/src/libraries/Common/tests/StreamConformanceTests/StreamConformanceTests.csproj b/src/libraries/Common/tests/StreamConformanceTests/StreamConformanceTests.csproj
index eebde98cad90e7..d49e1fec058424 100644
--- a/src/libraries/Common/tests/StreamConformanceTests/StreamConformanceTests.csproj
+++ b/src/libraries/Common/tests/StreamConformanceTests/StreamConformanceTests.csproj
@@ -14,10 +14,13 @@
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/libraries/Common/tests/System/Collections/ICollection.Generic.Tests.cs b/src/libraries/Common/tests/System/Collections/ICollection.Generic.Tests.cs
index a94a9308b99ab4..17be32cd58f4ad 100644
--- a/src/libraries/Common/tests/System/Collections/ICollection.Generic.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/ICollection.Generic.Tests.cs
@@ -114,7 +114,7 @@ protected override IEnumerable GetModifyEnumerables(ModifyOper
#region IsReadOnly
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_IsReadOnly_Validity(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -126,7 +126,7 @@ public void ICollection_Generic_IsReadOnly_Validity(int count)
#region Count
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Count_Validity(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -138,7 +138,7 @@ public void ICollection_Generic_Count_Validity(int count)
#region Add
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void ICollection_Generic_Add_DefaultValue(int count)
{
if (DefaultValueAllowed && !IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -150,7 +150,7 @@ public virtual void ICollection_Generic_Add_DefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_InvalidValueToMiddleOfCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -167,7 +167,7 @@ public void ICollection_Generic_Add_InvalidValueToMiddleOfCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_InvalidValueToBeginningOfCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -184,7 +184,7 @@ public void ICollection_Generic_Add_InvalidValueToBeginningOfCollection(int coun
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_InvalidValueToEndOfCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -199,7 +199,7 @@ public void ICollection_Generic_Add_InvalidValueToEndOfCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_DuplicateValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DuplicateValuesAllowed)
@@ -213,7 +213,7 @@ public void ICollection_Generic_Add_DuplicateValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_AfterCallingClear(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -226,7 +226,7 @@ public void ICollection_Generic_Add_AfterCallingClear(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_AfterRemovingAnyValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -251,7 +251,7 @@ public void ICollection_Generic_Add_AfterRemovingAnyValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_AfterRemovingAllItems(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -266,7 +266,7 @@ public void ICollection_Generic_Add_AfterRemovingAllItems(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_ToReadOnlyCollection(int count)
{
if (IsReadOnly || AddRemoveClear_ThrowsNotSupported)
@@ -278,7 +278,7 @@ public void ICollection_Generic_Add_ToReadOnlyCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_AfterRemoving(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -299,7 +299,7 @@ public void ICollection_Generic_Add_AfterRemoving(int count)
#region Clear
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Clear(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -316,7 +316,7 @@ public void ICollection_Generic_Clear(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Clear_Repeatedly(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -381,7 +381,7 @@ WeakReference PopulateAndRemove(ICollection collection, bool useRemov
#region Contains
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_ValidValueOnCollectionNotContainingThatValue(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -393,7 +393,7 @@ public void ICollection_Generic_Contains_ValidValueOnCollectionNotContainingThat
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_ValidValueOnCollectionContainingThatValue(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -402,7 +402,7 @@ public void ICollection_Generic_Contains_ValidValueOnCollectionContainingThatVal
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_DefaultValueOnCollectionNotContainingDefaultValue(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -413,7 +413,7 @@ public void ICollection_Generic_Contains_DefaultValueOnCollectionNotContainingDe
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void ICollection_Generic_Contains_DefaultValueOnCollectionContainingDefaultValue(int count)
{
if (DefaultValueAllowed && !IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -425,7 +425,7 @@ public virtual void ICollection_Generic_Contains_DefaultValueOnCollectionContain
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_ValidValueThatExistsTwiceInTheCollection(int count)
{
if (DuplicateValuesAllowed && !IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -439,7 +439,7 @@ public void ICollection_Generic_Contains_ValidValueThatExistsTwiceInTheCollectio
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_InvalidValue_ThrowsArgumentException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -449,7 +449,7 @@ public void ICollection_Generic_Contains_InvalidValue_ThrowsArgumentException(in
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void ICollection_Generic_Contains_DefaultValueWhenNotAllowed(int count)
{
if (!DefaultValueAllowed && !IsReadOnly)
@@ -467,7 +467,7 @@ public virtual void ICollection_Generic_Contains_DefaultValueWhenNotAllowed(int
#region CopyTo
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_NullArray_ThrowsArgumentNullException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -475,7 +475,7 @@ public void ICollection_Generic_CopyTo_NullArray_ThrowsArgumentNullException(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_NegativeIndex_ThrowsArgumentOutOfRangeException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -485,7 +485,7 @@ public void ICollection_Generic_CopyTo_NegativeIndex_ThrowsArgumentOutOfRangeExc
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_IndexEqualToArrayCount_ThrowsArgumentException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -497,7 +497,7 @@ public void ICollection_Generic_CopyTo_IndexEqualToArrayCount_ThrowsArgumentExce
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_IndexLargerThanArrayCount_ThrowsAnyArgumentException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -506,7 +506,7 @@ public void ICollection_Generic_CopyTo_IndexLargerThanArrayCount_ThrowsAnyArgume
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_NotEnoughSpaceInOffsettedArray_ThrowsArgumentException(int count)
{
if (count > 0) // Want the T array to have at least 1 element
@@ -518,7 +518,7 @@ public void ICollection_Generic_CopyTo_NotEnoughSpaceInOffsettedArray_ThrowsArgu
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_ExactlyEnoughSpaceInArray(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -528,7 +528,7 @@ public void ICollection_Generic_CopyTo_ExactlyEnoughSpaceInArray(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_CopyTo_ArrayIsLargerThanCollection(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -542,7 +542,7 @@ public void ICollection_Generic_CopyTo_ArrayIsLargerThanCollection(int count)
#region Remove
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_OnReadOnlyCollection_ThrowsNotSupportedException(int count)
{
if (IsReadOnly || AddRemoveClear_ThrowsNotSupported)
@@ -553,7 +553,7 @@ public void ICollection_Generic_Remove_OnReadOnlyCollection_ThrowsNotSupportedEx
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_DefaultValueNotContainedInCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DefaultValueAllowed && !Enumerable.Contains(InvalidValues, default(T)))
@@ -572,7 +572,7 @@ public void ICollection_Generic_Remove_DefaultValueNotContainedInCollection(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_NonDefaultValueNotContainedInCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -588,7 +588,7 @@ public void ICollection_Generic_Remove_NonDefaultValueNotContainedInCollection(i
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void ICollection_Generic_Remove_DefaultValueContainedInCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DefaultValueAllowed && !Enumerable.Contains(InvalidValues, default(T)))
@@ -607,7 +607,7 @@ public virtual void ICollection_Generic_Remove_DefaultValueContainedInCollection
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_NonDefaultValueContainedInCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -626,7 +626,7 @@ public void ICollection_Generic_Remove_NonDefaultValueContainedInCollection(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_ValueThatExistsTwiceInCollection(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DuplicateValuesAllowed)
@@ -644,7 +644,7 @@ public void ICollection_Generic_Remove_ValueThatExistsTwiceInCollection(int coun
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_EveryValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -659,7 +659,7 @@ public void ICollection_Generic_Remove_EveryValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_InvalidValue_ThrowsArgumentException(int count)
{
ICollection collection = GenericICollectionFactory(count);
@@ -671,7 +671,7 @@ public void ICollection_Generic_Remove_InvalidValue_ThrowsArgumentException(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_DefaultValueWhenNotAllowed(int count)
{
if (!DefaultValueAllowed && !IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
diff --git a/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.cs b/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.cs
index df92ab206f6686..402be858dc4e0b 100644
--- a/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.cs
@@ -257,7 +257,7 @@ protected override IEnumerable GetModifyEnumerables(ModifyOper
#region Item Getter
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemGet_DefaultKey(int count)
{
if (!IsReadOnly)
@@ -277,7 +277,7 @@ public void IDictionary_Generic_ItemGet_DefaultKey(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemGet_MissingNonDefaultKey_ThrowsKeyNotFoundException(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -286,7 +286,7 @@ public void IDictionary_Generic_ItemGet_MissingNonDefaultKey_ThrowsKeyNotFoundEx
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemGet_MissingDefaultKey_ThrowsKeyNotFoundException(int count)
{
if (DefaultValueAllowed && !IsReadOnly)
@@ -300,7 +300,7 @@ public void IDictionary_Generic_ItemGet_MissingDefaultKey_ThrowsKeyNotFoundExcep
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemGet_PresentKeyReturnsCorrectValue(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -315,7 +315,7 @@ public void IDictionary_Generic_ItemGet_PresentKeyReturnsCorrectValue(int count)
#region Item Setter
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemSet_DefaultKey(int count)
{
if (!IsReadOnly)
@@ -335,7 +335,7 @@ public void IDictionary_Generic_ItemSet_DefaultKey(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemSet_OnReadOnlyDictionary_ThrowsNotSupportedException(int count)
{
if (IsReadOnly)
@@ -347,7 +347,7 @@ public void IDictionary_Generic_ItemSet_OnReadOnlyDictionary_ThrowsNotSupportedE
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemSet_AddsNewValueWhenNotPresent(int count)
{
if (!IsReadOnly)
@@ -360,7 +360,7 @@ public void IDictionary_Generic_ItemSet_AddsNewValueWhenNotPresent(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ItemSet_ReplacesExistingValueWhenPresent(int count)
{
if (!IsReadOnly)
@@ -380,7 +380,7 @@ public void IDictionary_Generic_ItemSet_ReplacesExistingValueWhenPresent(int cou
#region Keys
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Keys_ContainsAllCorrectKeys(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -389,7 +389,7 @@ public void IDictionary_Generic_Keys_ContainsAllCorrectKeys(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Keys_ModifyingTheDictionaryUpdatesTheCollection(int count)
{
if (!IsReadOnly)
@@ -412,7 +412,7 @@ public void IDictionary_Generic_Keys_ModifyingTheDictionaryUpdatesTheCollection(
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Keys_Enumeration_ParentDictionaryModifiedInvalidates(int count)
{
if (!IsReadOnly)
@@ -438,7 +438,7 @@ public void IDictionary_Generic_Keys_Enumeration_ParentDictionaryModifiedInvalid
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Keys_IsReadOnly(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -450,7 +450,7 @@ public void IDictionary_Generic_Keys_IsReadOnly(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Keys_Enumeration_Reset(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -467,7 +467,7 @@ public void IDictionary_Generic_Keys_Enumeration_Reset(int count)
#region Values
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_ContainsAllCorrectValues(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -476,7 +476,7 @@ public void IDictionary_Generic_Values_ContainsAllCorrectValues(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_IncludeDuplicatesMultipleTimes(int count)
{
if (!IsReadOnly)
@@ -495,7 +495,7 @@ public void IDictionary_Generic_Values_IncludeDuplicatesMultipleTimes(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_ModifyingTheDictionaryUpdatesTheCollection(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -519,7 +519,7 @@ public void IDictionary_Generic_Values_ModifyingTheDictionaryUpdatesTheCollectio
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_Enumeration_ParentDictionaryModifiedInvalidates(int count)
{
if (!IsReadOnly)
@@ -545,7 +545,7 @@ public void IDictionary_Generic_Values_Enumeration_ParentDictionaryModifiedInval
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_IsReadOnly(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -557,7 +557,7 @@ public void IDictionary_Generic_Values_IsReadOnly(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Values_Enumeration_Reset(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -574,7 +574,7 @@ public void IDictionary_Generic_Values_Enumeration_Reset(int count)
#region Add(TKey, TValue)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_OnReadOnlyDictionary_ThrowsNotSupportedException(int count)
{
if (IsReadOnly)
@@ -585,7 +585,7 @@ public void IDictionary_Generic_Add_OnReadOnlyDictionary_ThrowsNotSupportedExcep
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_DefaultKey_DefaultValue(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -604,7 +604,7 @@ public void IDictionary_Generic_Add_DefaultKey_DefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_DefaultKey_NonDefaultValue(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -623,7 +623,7 @@ public void IDictionary_Generic_Add_DefaultKey_NonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_NonDefaultKey_DefaultValue(int count)
{
if (!IsReadOnly)
@@ -638,7 +638,7 @@ public void IDictionary_Generic_Add_NonDefaultKey_DefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_NonDefaultKey_NonDefaultValue(int count)
{
if (!IsReadOnly)
@@ -653,7 +653,7 @@ public void IDictionary_Generic_Add_NonDefaultKey_NonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_DuplicateValue(int count)
{
if (!IsReadOnly)
@@ -670,7 +670,7 @@ public void IDictionary_Generic_Add_DuplicateValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_DuplicateKey(int count)
{
if (!IsReadOnly)
@@ -683,7 +683,7 @@ public void IDictionary_Generic_Add_DuplicateKey(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_Add_DistinctValuesWithHashCollisions(int count)
{
if (!IsReadOnly)
@@ -702,7 +702,7 @@ public void IDictionary_Generic_Add_DistinctValuesWithHashCollisions(int count)
#region ContainsKey
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ContainsKey_ValidKeyNotContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -714,7 +714,7 @@ public void IDictionary_Generic_ContainsKey_ValidKeyNotContainedInDictionary(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ContainsKey_ValidKeyContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -727,7 +727,7 @@ public void IDictionary_Generic_ContainsKey_ValidKeyContainedInDictionary(int co
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ContainsKey_DefaultKeyNotContainedInDictionary(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -750,7 +750,7 @@ public void IDictionary_Generic_ContainsKey_DefaultKeyNotContainedInDictionary(i
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_ContainsKey_DefaultKeyContainedInDictionary(int count)
{
if (DefaultValueAllowed && !IsReadOnly)
@@ -768,7 +768,7 @@ public void IDictionary_Generic_ContainsKey_DefaultKeyContainedInDictionary(int
#region Remove(TKey)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_OnReadOnlyDictionary_ThrowsNotSupportedException(int count)
{
if (IsReadOnly)
@@ -779,7 +779,7 @@ public void IDictionary_Generic_RemoveKey_OnReadOnlyDictionary_ThrowsNotSupporte
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_EveryKey(int count)
{
if (!IsReadOnly)
@@ -794,7 +794,7 @@ public void IDictionary_Generic_RemoveKey_EveryKey(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_ValidKeyNotContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -807,7 +807,7 @@ public void IDictionary_Generic_RemoveKey_ValidKeyNotContainedInDictionary(int c
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -821,7 +821,7 @@ public void IDictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int coun
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -842,7 +842,7 @@ public void IDictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_RemoveKey_DefaultKeyContainedInDictionary(int count)
{
if (DefaultValueAllowed && !IsReadOnly)
@@ -903,7 +903,7 @@ KeyValuePair, WeakReference> PopulateAndRemove(IDi
#region TryGetValue
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_TryGetValue_ValidKeyNotContainedInDictionary(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -914,7 +914,7 @@ public void IDictionary_Generic_TryGetValue_ValidKeyNotContainedInDictionary(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_TryGetValue_ValidKeyContainedInDictionary(int count)
{
if (!IsReadOnly)
@@ -930,7 +930,7 @@ public void IDictionary_Generic_TryGetValue_ValidKeyContainedInDictionary(int co
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_TryGetValue_DefaultKeyNotContainedInDictionary(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -952,7 +952,7 @@ public void IDictionary_Generic_TryGetValue_DefaultKeyNotContainedInDictionary(i
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IDictionary_Generic_TryGetValue_DefaultKeyContainedInDictionary(int count)
{
if (DefaultValueAllowed && !IsReadOnly)
@@ -972,7 +972,7 @@ public void IDictionary_Generic_TryGetValue_DefaultKeyContainedInDictionary(int
#region ICollection>
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_ValidPresentKeyWithDefaultValue(int count)
{
if (!IsReadOnly)
@@ -985,7 +985,7 @@ public void ICollection_Generic_Contains_ValidPresentKeyWithDefaultValue(int cou
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Remove_ValidPresentKeyWithDifferentValue(int count)
{
if (!IsReadOnly)
@@ -1002,7 +1002,7 @@ public void ICollection_Generic_Remove_ValidPresentKeyWithDifferentValue(int cou
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Contains_ValidPresentKeyWithDifferentValue(int count)
{
if (!IsReadOnly)
@@ -1023,7 +1023,7 @@ public void ICollection_Generic_Contains_ValidPresentKeyWithDifferentValue(int c
#region ICollection
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_NonGeneric_CopyTo(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -1036,7 +1036,7 @@ public void ICollection_NonGeneric_CopyTo(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public override void ICollection_Generic_Contains_DefaultValueWhenNotAllowed(int count)
{
ICollection> collection = GenericIDictionaryFactory(count);
diff --git a/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.netcoreapp.cs b/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.netcoreapp.cs
index a5973aa400f8b2..4cd0a6899cce6b 100644
--- a/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.netcoreapp.cs
+++ b/src/libraries/Common/tests/System/Collections/IDictionary.Generic.Tests.netcoreapp.cs
@@ -13,7 +13,7 @@ namespace System.Collections.Tests
public abstract partial class IDictionary_Generic_Tests : ICollection_Generic_Tests>
{
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void KeyValuePair_Deconstruct(int size)
{
IDictionary dictionary = GenericIDictionaryFactory(size);
diff --git a/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Serialization.Tests.cs b/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Serialization.Tests.cs
index 1222bbf717e454..266c4819273660 100644
--- a/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Serialization.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Serialization.Tests.cs
@@ -10,7 +10,7 @@ namespace System.Collections.Tests
public abstract partial class IEnumerable_Generic_Tests : TestBase
{
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android)]
public void IGenericSharedAPI_SerializeDeserialize(int count)
{
diff --git a/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Tests.cs b/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Tests.cs
index a71f72e6cc6fa9..ab50b64e8bd644 100644
--- a/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/IEnumerable.Generic.Tests.cs
@@ -341,7 +341,7 @@ public void IEnumerable_NonGeneric_GetEnumerator_EmptyCollection_UsesSingleton()
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_GetEnumerator_NoExceptionsWhileGetting(int count)
{
IEnumerable enumerable = GenericIEnumerableFactory(count);
@@ -349,7 +349,7 @@ public void IEnumerable_Generic_GetEnumerator_NoExceptionsWhileGetting(int count
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_GetEnumerator_ReturnsUniqueEnumerator(int count)
{
//Tests that the enumerators returned by GetEnumerator operate independently of one another
@@ -367,7 +367,7 @@ public void IEnumerable_Generic_GetEnumerator_ReturnsUniqueEnumerator(int count)
#region Enumerator.MoveNext
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_FromStartToFinish(int count)
{
int iterations = 0;
@@ -385,7 +385,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_FromStartToFinish(int count)
/// specify neither of these as being strictly correct, we leave the method virtual.
///
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void Enumerator_MoveNext_AfterDisposal(int count)
{
IEnumerator enumerator = GenericIEnumerableFactory(count).GetEnumerator();
@@ -396,7 +396,7 @@ public virtual void Enumerator_MoveNext_AfterDisposal(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_AfterEndOfCollection(int count)
{
using (IEnumerator enumerator = GenericIEnumerableFactory(count).GetEnumerator())
@@ -409,7 +409,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_AfterEndOfCollection(int cou
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -433,7 +433,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_Th
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -453,7 +453,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_Su
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -479,7 +479,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_Th
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -498,7 +498,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_Su
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -523,7 +523,7 @@ public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_Thr
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -599,7 +599,7 @@ public void IEnumerable_Generic_Enumerator_Current()
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_ReturnsSameValueOnRepeatedCalls(int count)
{
using (IEnumerator enumerator = GenericIEnumerableFactory(count).GetEnumerator())
@@ -615,7 +615,7 @@ public void IEnumerable_Generic_Enumerator_Current_ReturnsSameValueOnRepeatedCal
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_ReturnsSameObjectsOnDifferentEnumerators(int count)
{
// Ensures that the elements returned from enumeration are exactly the same collection of
@@ -633,7 +633,7 @@ public void IEnumerable_Generic_Enumerator_Current_ReturnsSameObjectsOnDifferent
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_BeforeFirstMoveNext_UndefinedBehavior(int count)
{
T current;
@@ -648,7 +648,7 @@ public void IEnumerable_Generic_Enumerator_Current_BeforeFirstMoveNext_Undefined
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_AfterEndOfEnumerable_UndefinedBehavior(int count)
{
T current;
@@ -664,7 +664,7 @@ public void IEnumerable_Generic_Enumerator_Current_AfterEndOfEnumerable_Undefine
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_ModifiedDuringEnumeration_UndefinedBehavior(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -685,7 +685,7 @@ public void IEnumerable_Generic_Enumerator_Current_ModifiedDuringEnumeration_Und
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Current_ModifiedDuringEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -707,7 +707,7 @@ public void IEnumerable_Generic_Enumerator_Current_ModifiedDuringEnumeration_Suc
#region Enumerator.Reset
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_BeforeIteration_Support(int count)
{
using (IEnumerator enumerator = GenericIEnumerableFactory(count).GetEnumerator())
@@ -720,7 +720,7 @@ public void IEnumerable_Generic_Enumerator_Reset_BeforeIteration_Support(int cou
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -744,7 +744,7 @@ public void IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_Throw
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -761,7 +761,7 @@ public void IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_Succe
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -787,7 +787,7 @@ public void IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_Throw
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
@@ -806,7 +806,7 @@ public void IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_Succe
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorThrows), ModifyEnumerable =>
@@ -831,7 +831,7 @@ public void IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_Throws
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_Succeeds(int count)
{
Assert.All(GetModifyEnumerables(ModifyEnumeratorAllowed), ModifyEnumerable =>
diff --git a/src/libraries/Common/tests/System/Collections/IGenericSharedAPI.Tests.cs b/src/libraries/Common/tests/System/Collections/IGenericSharedAPI.Tests.cs
index 22e81af5d62986..1fccb2cee1b256 100644
--- a/src/libraries/Common/tests/System/Collections/IGenericSharedAPI.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/IGenericSharedAPI.Tests.cs
@@ -110,7 +110,7 @@ protected override IEnumerable GetModifyEnumerables(ModifyOper
#region Count
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Count_Validity(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -122,7 +122,7 @@ public void IGenericSharedAPI_Count_Validity(int count)
#region Add
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_DefaultValue(int count)
{
if (DefaultValueAllowed && !IsReadOnly)
@@ -134,7 +134,7 @@ public void IGenericSharedAPI_Add_DefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_InvalidValueToMiddleOfCollection(int count)
{
if (!IsReadOnly)
@@ -151,7 +151,7 @@ public void IGenericSharedAPI_Add_InvalidValueToMiddleOfCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_InvalidValueToBeginningOfCollection(int count)
{
if (!IsReadOnly)
@@ -168,7 +168,7 @@ public void IGenericSharedAPI_Add_InvalidValueToBeginningOfCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_InvalidValueToEndOfCollection(int count)
{
if (!IsReadOnly)
@@ -183,7 +183,7 @@ public void IGenericSharedAPI_Add_InvalidValueToEndOfCollection(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_DuplicateValue(int count)
{
if (!IsReadOnly)
@@ -200,7 +200,7 @@ public void IGenericSharedAPI_Add_DuplicateValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_AfterCallingClear(int count)
{
if (!IsReadOnly)
@@ -213,7 +213,7 @@ public void IGenericSharedAPI_Add_AfterCallingClear(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_AfterRemovingAnyValue(int count)
{
if (!IsReadOnly)
@@ -236,7 +236,7 @@ public void IGenericSharedAPI_Add_AfterRemovingAnyValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Add_AfterRemovingAllItems(int count)
{
if (!IsReadOnly)
@@ -255,7 +255,7 @@ public void IGenericSharedAPI_Add_AfterRemovingAllItems(int count)
#region Clear
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Clear(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -316,7 +316,7 @@ WeakReference PopulateAndRemove(IEnumerable collection, bool useRemov
#region Contains
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_BasicFunctionality(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -338,7 +338,7 @@ public void IGenericSharedAPI_Contains_BasicFunctionality(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_ValidValueOnCollectionNotContainingThatValue(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -350,7 +350,7 @@ public void IGenericSharedAPI_Contains_ValidValueOnCollectionNotContainingThatVa
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_IGenericSharedAPI_Contains_ValidValueOnCollectionContainingThatValue(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -359,7 +359,7 @@ public void IGenericSharedAPI_IGenericSharedAPI_Contains_ValidValueOnCollectionC
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_DefaultValueOnCollectionNotContainingDefaultValue(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -368,7 +368,7 @@ public void IGenericSharedAPI_Contains_DefaultValueOnCollectionNotContainingDefa
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_DefaultValueOnCollectionContainingDefaultValue(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -380,7 +380,7 @@ public void IGenericSharedAPI_Contains_DefaultValueOnCollectionContainingDefault
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_ValidValueThatExistsTwiceInTheCollection(int count)
{
if (DuplicateValuesAllowed && !IsReadOnly)
@@ -394,7 +394,7 @@ public void IGenericSharedAPI_Contains_ValidValueThatExistsTwiceInTheCollection(
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_Contains_InvalidValue_ThrowsArgumentException(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -404,7 +404,7 @@ public void IGenericSharedAPI_Contains_InvalidValue_ThrowsArgumentException(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public virtual void IGenericSharedAPI_Contains_DefaultValueWhenNotAllowed(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -422,7 +422,7 @@ public virtual void IGenericSharedAPI_Contains_DefaultValueWhenNotAllowed(int co
#region CopyTo
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_NullArray_ThrowsArgumentNullException(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -430,7 +430,7 @@ public void IGenericSharedAPI_CopyTo_NullArray_ThrowsArgumentNullException(int c
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_NegativeIndex_ThrowsArgumentOutOfRangeException(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -440,7 +440,7 @@ public void IGenericSharedAPI_CopyTo_NegativeIndex_ThrowsArgumentOutOfRangeExcep
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_IndexEqualToArrayCount_ThrowsArgumentException(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -452,7 +452,7 @@ public void IGenericSharedAPI_CopyTo_IndexEqualToArrayCount_ThrowsArgumentExcept
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_IndexLargerThanArrayCount_ThrowsAnyArgumentException(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -461,7 +461,7 @@ public void IGenericSharedAPI_CopyTo_IndexLargerThanArrayCount_ThrowsAnyArgument
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_NotEnoughSpaceInOffsettedArray_ThrowsArgumentException(int count)
{
if (count > 0) // Want the T array to have at least 1 element
@@ -473,7 +473,7 @@ public void IGenericSharedAPI_CopyTo_NotEnoughSpaceInOffsettedArray_ThrowsArgume
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_ExactlyEnoughSpaceInArray(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
@@ -483,7 +483,7 @@ public void IGenericSharedAPI_CopyTo_ExactlyEnoughSpaceInArray(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IGenericSharedAPI_CopyTo_ArrayIsLargerThanCollection(int count)
{
IEnumerable collection = GenericIEnumerableFactory(count);
diff --git a/src/libraries/Common/tests/System/Collections/IList.Generic.Tests.cs b/src/libraries/Common/tests/System/Collections/IList.Generic.Tests.cs
index 811ac67950ac0c..dc0c2203939507 100644
--- a/src/libraries/Common/tests/System/Collections/IList.Generic.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/IList.Generic.Tests.cs
@@ -99,7 +99,7 @@ protected override IEnumerable GetModifyEnumerables(ModifyOper
#region Item Getter
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemGet_NegativeIndex_ThrowsException(int count)
{
IList list = GenericIListFactory(count);
@@ -115,7 +115,7 @@ public void IList_Generic_ItemGet_NegativeIndex_ThrowsException(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemGet_IndexGreaterThanListCount_ThrowsException(int count)
{
IList list = GenericIListFactory(count);
@@ -131,7 +131,7 @@ public void IList_Generic_ItemGet_IndexGreaterThanListCount_ThrowsException(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemGet_ValidGetWithinListBounds(int count)
{
IList list = GenericIListFactory(count);
@@ -152,7 +152,7 @@ public void IList_Generic_ItemGet_ValidGetWithinListBounds(int count)
#region Item Setter
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_NegativeIndex_ThrowsException(int count)
{
if (!IsReadOnly)
@@ -166,7 +166,7 @@ public void IList_Generic_ItemSet_NegativeIndex_ThrowsException(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_IndexGreaterThanListCount_ThrowsException(int count)
{
if (!IsReadOnly)
@@ -180,7 +180,7 @@ public void IList_Generic_ItemSet_IndexGreaterThanListCount_ThrowsException(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_OnReadOnlyList(int count)
{
if (IsReadOnly && count > 0)
@@ -193,7 +193,7 @@ public void IList_Generic_ItemSet_OnReadOnlyList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_FirstItemToNonDefaultValue(int count)
{
if (count > 0 && !IsReadOnly)
@@ -206,7 +206,7 @@ public void IList_Generic_ItemSet_FirstItemToNonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_FirstItemToDefaultValue(int count)
{
if (count > 0 && !IsReadOnly)
@@ -226,7 +226,7 @@ public void IList_Generic_ItemSet_FirstItemToDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_LastItemToNonDefaultValue(int count)
{
if (count > 0 && !IsReadOnly)
@@ -240,7 +240,7 @@ public void IList_Generic_ItemSet_LastItemToNonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_LastItemToDefaultValue(int count)
{
if (count > 0 && !IsReadOnly && DefaultValueAllowed)
@@ -261,7 +261,7 @@ public void IList_Generic_ItemSet_LastItemToDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_DuplicateValues(int count)
{
if (count >= 2 && !IsReadOnly && DuplicateValuesAllowed)
@@ -276,7 +276,7 @@ public void IList_Generic_ItemSet_DuplicateValues(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_ItemSet_InvalidValue(int count)
{
if (count > 0&& !IsReadOnly)
@@ -294,7 +294,7 @@ public void IList_Generic_ItemSet_InvalidValue(int count)
#region IndexOf
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_DefaultValueNotContainedInList(int count)
{
if (DefaultValueAllowed)
@@ -317,7 +317,7 @@ public void IList_Generic_IndexOf_DefaultValueNotContainedInList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_DefaultValueContainedInList(int count)
{
if (count > 0 && DefaultValueAllowed)
@@ -335,7 +335,7 @@ public void IList_Generic_IndexOf_DefaultValueContainedInList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_ValidValueNotContainedInList(int count)
{
IList list = GenericIListFactory(count);
@@ -347,7 +347,7 @@ public void IList_Generic_IndexOf_ValidValueNotContainedInList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_ValueInCollectionMultipleTimes(int count)
{
if (count > 0 && !IsReadOnly && DuplicateValuesAllowed)
@@ -362,7 +362,7 @@ public void IList_Generic_IndexOf_ValueInCollectionMultipleTimes(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_EachValueNoDuplicates(int count)
{
// Assumes no duplicate elements contained in the list returned by GenericIListFactory
@@ -374,7 +374,7 @@ public void IList_Generic_IndexOf_EachValueNoDuplicates(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_InvalidValue(int count)
{
if (!IsReadOnly)
@@ -388,7 +388,7 @@ public void IList_Generic_IndexOf_InvalidValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_IndexOf_ReturnsFirstMatchingValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DuplicateValuesAllowed)
@@ -409,7 +409,7 @@ public void IList_Generic_IndexOf_ReturnsFirstMatchingValue(int count)
#region Insert
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_NegativeIndex_ThrowsArgumentOutOfRangeException(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -423,7 +423,7 @@ public void IList_Generic_Insert_NegativeIndex_ThrowsArgumentOutOfRangeException
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_IndexGreaterThanListCount_Appends(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -437,7 +437,7 @@ public void IList_Generic_Insert_IndexGreaterThanListCount_Appends(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_ToReadOnlyList(int count)
{
if (IsReadOnly || AddRemoveClear_ThrowsNotSupported)
@@ -449,7 +449,7 @@ public void IList_Generic_Insert_ToReadOnlyList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_FirstItemToNonDefaultValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -463,7 +463,7 @@ public void IList_Generic_Insert_FirstItemToNonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_FirstItemToDefaultValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DefaultValueAllowed)
@@ -477,7 +477,7 @@ public void IList_Generic_Insert_FirstItemToDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_LastItemToNonDefaultValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -492,7 +492,7 @@ public void IList_Generic_Insert_LastItemToNonDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_LastItemToDefaultValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DefaultValueAllowed)
@@ -507,7 +507,7 @@ public void IList_Generic_Insert_LastItemToDefaultValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_DuplicateValues(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported && DuplicateValuesAllowed)
@@ -530,7 +530,7 @@ public void IList_Generic_Insert_DuplicateValues(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_Insert_InvalidValue(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -548,7 +548,7 @@ public void IList_Generic_Insert_InvalidValue(int count)
#region RemoveAt
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_RemoveAt_NegativeIndex_ThrowsArgumentOutOfRangeException(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -562,7 +562,7 @@ public void IList_Generic_RemoveAt_NegativeIndex_ThrowsArgumentOutOfRangeExcepti
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_RemoveAt_IndexGreaterThanListCount_ThrowsArgumentOutOfRangeException(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -576,7 +576,7 @@ public void IList_Generic_RemoveAt_IndexGreaterThanListCount_ThrowsArgumentOutOf
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_RemoveAt_OnReadOnlyList(int count)
{
if (IsReadOnly || AddRemoveClear_ThrowsNotSupported)
@@ -588,7 +588,7 @@ public void IList_Generic_RemoveAt_OnReadOnlyList(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_RemoveAt_AllValidIndices(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -604,7 +604,7 @@ public void IList_Generic_RemoveAt_AllValidIndices(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_RemoveAt_ZeroMultipleTimes(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
@@ -624,7 +624,7 @@ public void IList_Generic_RemoveAt_ZeroMultipleTimes(int count)
// Test Enumerator.Current at end after new elements was added
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IList_Generic_CurrentAtEnd_AfterAdd(int count)
{
if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
diff --git a/src/libraries/Common/tests/System/Collections/ISet.Generic.Tests.cs b/src/libraries/Common/tests/System/Collections/ISet.Generic.Tests.cs
index 303001e8bd1443..7f185f05497ed4 100644
--- a/src/libraries/Common/tests/System/Collections/ISet.Generic.Tests.cs
+++ b/src/libraries/Common/tests/System/Collections/ISet.Generic.Tests.cs
@@ -71,7 +71,7 @@ protected override void AddToCollection(ICollection collection, int numberOfI
#region ICollection_Generic
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_ReturnValue(int count)
{
if (!IsReadOnly)
@@ -90,7 +90,7 @@ public void ICollection_Generic_Add_ReturnValue(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ICollection_Generic_Add_DuplicateValue_DoesNothing(int count)
{
if (!IsReadOnly)
@@ -298,7 +298,7 @@ private void Validate_UnionWith(ISet set, IEnumerable enumerable)
#region Set Function tests
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_NullEnumerableArgument(int count)
{
ISet set = GenericISetFactory(count);
@@ -325,11 +325,8 @@ public void ISet_Generic_NullEnumerableArgument(int count)
}
}
- public static IEnumerable SetTestData() =>
- new[] { EnumerableType.HashSet, EnumerableType.List }.SelectMany(GetEnumerableTestData);
-
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_ExceptWith(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
if (!IsReadOnly)
@@ -341,7 +338,7 @@ public void ISet_Generic_ExceptWith(EnumerableType enumerableType, int setLength
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_IntersectWith(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
if (!IsReadOnly)
@@ -353,7 +350,7 @@ public void ISet_Generic_IntersectWith(EnumerableType enumerableType, int setLen
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_IsProperSubsetOf(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -362,7 +359,7 @@ public void ISet_Generic_IsProperSubsetOf(EnumerableType enumerableType, int set
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_IsProperSupersetOf(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -371,7 +368,7 @@ public void ISet_Generic_IsProperSupersetOf(EnumerableType enumerableType, int s
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_IsSubsetOf(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -380,7 +377,7 @@ public void ISet_Generic_IsSubsetOf(EnumerableType enumerableType, int setLength
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_IsSupersetOf(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -389,7 +386,7 @@ public void ISet_Generic_IsSupersetOf(EnumerableType enumerableType, int setLeng
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_Overlaps(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -398,7 +395,7 @@ public void ISet_Generic_Overlaps(EnumerableType enumerableType, int setLength,
}
[Theory]
- [MemberData(nameof(SetTestData))]
+ [MemberData(nameof(SetTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_SetEquals(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
ISet set = GenericISetFactory(setLength);
@@ -407,7 +404,7 @@ public void ISet_Generic_SetEquals(EnumerableType enumerableType, int setLength,
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_SymmetricExceptWith(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
if (!IsReadOnly)
@@ -419,7 +416,7 @@ public void ISet_Generic_SymmetricExceptWith(EnumerableType enumerableType, int
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_UnionWith(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
if (!IsReadOnly)
@@ -435,7 +432,7 @@ public void ISet_Generic_UnionWith(EnumerableType enumerableType, int setLength,
#region Set Function tests on itself
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_ExceptWith_Itself(int setLength)
{
if (!IsReadOnly)
@@ -446,7 +443,7 @@ public void ISet_Generic_ExceptWith_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework throws InvalidOperationException")]
public void ISet_Generic_IntersectWith_Itself(int setLength)
{
@@ -458,7 +455,7 @@ public void ISet_Generic_IntersectWith_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_IsProperSubsetOf_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -466,7 +463,7 @@ public void ISet_Generic_IsProperSubsetOf_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_IsProperSupersetOf_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -474,7 +471,7 @@ public void ISet_Generic_IsProperSupersetOf_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_IsSubsetOf_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -482,7 +479,7 @@ public void ISet_Generic_IsSubsetOf_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_IsSupersetOf_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -490,7 +487,7 @@ public void ISet_Generic_IsSupersetOf_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_Overlaps_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -498,7 +495,7 @@ public void ISet_Generic_Overlaps_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_SetEquals_Itself(int setLength)
{
ISet set = GenericISetFactory(setLength);
@@ -506,7 +503,7 @@ public void ISet_Generic_SetEquals_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_SymmetricExceptWith_Itself(int setLength)
{
if (!IsReadOnly)
@@ -517,7 +514,7 @@ public void ISet_Generic_SymmetricExceptWith_Itself(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ISet_Generic_UnionWith_Itself(int setLength)
{
if (!IsReadOnly)
@@ -638,7 +635,7 @@ public void ISet_Generic_UnionWith_LargeSet()
#region Other misc ISet test Scenarios
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void ISet_Generic_SymmetricExceptWith_AfterRemovingElements(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
if (!IsReadOnly)
diff --git a/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs b/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs
index f90b2d34628d1b..8fdb15fb3d0525 100644
--- a/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs
+++ b/src/libraries/Common/tests/System/Collections/TestBase.Generic.cs
@@ -33,57 +33,6 @@ public abstract class TestBase : TestBase
/// or test collections. Default if not overridden is the default comparator.
protected virtual IComparer GetIComparer() => Comparer.Default;
- ///
- /// MemberData to be passed to tests that take an IEnumerable{T}. This method returns every permutation of
- /// EnumerableType to test on (e.g. HashSet, Queue), and size of set to test with (e.g. 0, 1, etc.).
- ///
- public static IEnumerable EnumerableTestData() =>
- ((IEnumerable)Enum.GetValues(typeof(EnumerableType))).SelectMany(GetEnumerableTestData);
-
- ///
- /// MemberData to be passed to tests that take an IEnumerable{T}. This method returns results for various
- /// sizes of sets to test with (e.g. 0, 1, etc.) but only for List.
- ///
- public static IEnumerable ListTestData() =>
- GetEnumerableTestData(EnumerableType.List);
-
- protected static IEnumerable GetEnumerableTestData(EnumerableType enumerableType)
- {
- foreach (object[] collectionSizeArray in ValidCollectionSizes())
- {
- int count = (int)collectionSizeArray[0];
- yield return new object[] { enumerableType, count, 0, 0, 0 }; // Empty Enumerable
- yield return new object[] { enumerableType, count, count + 1, 0, 0 }; // Enumerable that is 1 larger
-
- if (count >= 1)
- {
- yield return new object[] { enumerableType, count, count, 0, 0 }; // Enumerable of the same size
- yield return new object[] { enumerableType, count, count - 1, 0, 0 }; // Enumerable that is 1 smaller
- yield return new object[] { enumerableType, count, count, 1, 0 }; // Enumerable of the same size with 1 matching element
- yield return new object[] { enumerableType, count, count + 1, 1, 0 }; // Enumerable that is 1 longer with 1 matching element
- yield return new object[] { enumerableType, count, count, count, 0 }; // Enumerable with all elements matching
- yield return new object[] { enumerableType, count, count + 1, count, 0 }; // Enumerable with all elements matching plus one extra
- }
-
- if (count >= 2)
- {
- yield return new object[] { enumerableType, count, count - 1, 1, 0 }; // Enumerable that is 1 smaller with 1 matching element
- yield return new object[] { enumerableType, count, count + 2, 2, 0 }; // Enumerable that is 2 longer with 2 matching element
- yield return new object[] { enumerableType, count, count - 1, count - 1, 0 }; // Enumerable with all elements matching minus one
- yield return new object[] { enumerableType, count, count, 2, 0 }; // Enumerable of the same size with 2 matching element
- if ((enumerableType == EnumerableType.List || enumerableType == EnumerableType.Queue))
- yield return new object[] { enumerableType, count, count, 0, 1 }; // Enumerable with 1 element duplicated
- }
-
- if (count >= 3)
- {
- if ((enumerableType == EnumerableType.List || enumerableType == EnumerableType.Queue))
- yield return new object[] { enumerableType, count, count, 0, 1 }; // Enumerable with all elements duplicated
- yield return new object[] { enumerableType, count, count - 1, 2, 0 }; // Enumerable that is 1 smaller with 2 matching elements
- }
- }
- }
-
///
/// Helper function to create an enumerable fulfilling the given specific parameters. The function will
/// create an enumerable of the desired type using the Default constructor for that type and then add values
diff --git a/src/libraries/Common/tests/System/Collections/TestBase.NonGeneric.cs b/src/libraries/Common/tests/System/Collections/TestBase.NonGeneric.cs
index 71df62f7d5c69e..3848d0742c49f0 100644
--- a/src/libraries/Common/tests/System/Collections/TestBase.NonGeneric.cs
+++ b/src/libraries/Common/tests/System/Collections/TestBase.NonGeneric.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
+using System.Linq;
namespace System.Collections.Tests
{
@@ -25,6 +26,60 @@ public static IEnumerable ValidPositiveCollectionSizes()
yield return new object[] { 75 };
}
+ ///
+ /// MemberData to be passed to tests that take an IEnumerable{T}. This method returns every permutation of
+ /// EnumerableType to test on (e.g. HashSet, Queue), and size of set to test with (e.g. 0, 1, etc.).
+ ///
+ public static IEnumerable EnumerableTestData() =>
+ ((IEnumerable)Enum.GetValues(typeof(EnumerableType))).SelectMany(GetEnumerableTestData);
+
+ ///
+ /// MemberData to be passed to tests that take an IEnumerable{T}. This method returns results for various
+ /// sizes of sets to test with (e.g. 0, 1, etc.) but only for List.
+ ///
+ public static IEnumerable ListTestData() =>
+ GetEnumerableTestData(EnumerableType.List);
+
+ public static IEnumerable SetTestData() =>
+ new[] { EnumerableType.HashSet, EnumerableType.List }.SelectMany(GetEnumerableTestData);
+
+ protected static IEnumerable GetEnumerableTestData(EnumerableType enumerableType)
+ {
+ foreach (object[] collectionSizeArray in ValidCollectionSizes())
+ {
+ int count = (int)collectionSizeArray[0];
+ yield return new object[] { enumerableType, count, 0, 0, 0 }; // Empty Enumerable
+ yield return new object[] { enumerableType, count, count + 1, 0, 0 }; // Enumerable that is 1 larger
+
+ if (count >= 1)
+ {
+ yield return new object[] { enumerableType, count, count, 0, 0 }; // Enumerable of the same size
+ yield return new object[] { enumerableType, count, count - 1, 0, 0 }; // Enumerable that is 1 smaller
+ yield return new object[] { enumerableType, count, count, 1, 0 }; // Enumerable of the same size with 1 matching element
+ yield return new object[] { enumerableType, count, count + 1, 1, 0 }; // Enumerable that is 1 longer with 1 matching element
+ yield return new object[] { enumerableType, count, count, count, 0 }; // Enumerable with all elements matching
+ yield return new object[] { enumerableType, count, count + 1, count, 0 }; // Enumerable with all elements matching plus one extra
+ }
+
+ if (count >= 2)
+ {
+ yield return new object[] { enumerableType, count, count - 1, 1, 0 }; // Enumerable that is 1 smaller with 1 matching element
+ yield return new object[] { enumerableType, count, count + 2, 2, 0 }; // Enumerable that is 2 longer with 2 matching element
+ yield return new object[] { enumerableType, count, count - 1, count - 1, 0 }; // Enumerable with all elements matching minus one
+ yield return new object[] { enumerableType, count, count, 2, 0 }; // Enumerable of the same size with 2 matching element
+ if ((enumerableType == EnumerableType.List || enumerableType == EnumerableType.Queue))
+ yield return new object[] { enumerableType, count, count, 0, 1 }; // Enumerable with 1 element duplicated
+ }
+
+ if (count >= 3)
+ {
+ if ((enumerableType == EnumerableType.List || enumerableType == EnumerableType.Queue))
+ yield return new object[] { enumerableType, count, count, 0, 1 }; // Enumerable with all elements duplicated
+ yield return new object[] { enumerableType, count, count - 1, 2, 0 }; // Enumerable that is 1 smaller with 2 matching elements
+ }
+ }
+ }
+
public enum EnumerableType
{
HashSet,
diff --git a/src/libraries/Common/tests/System/Net/Http/DefaultCredentialsTest.cs b/src/libraries/Common/tests/System/Net/Http/DefaultCredentialsTest.cs
index 75ac5f2562af8b..9b1d89a03f4c3f 100644
--- a/src/libraries/Common/tests/System/Net/Http/DefaultCredentialsTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/DefaultCredentialsTest.cs
@@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClient.SelectedSitesTest.cs b/src/libraries/Common/tests/System/Net/Http/HttpClient.SelectedSitesTest.cs
index d23c48e002969d..cfacbda663fa21 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClient.SelectedSitesTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClient.SelectedSitesTest.cs
@@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientEKUTest.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientEKUTest.cs
index 85b8439bd241a9..a637b673bc0114 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientEKUTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientEKUTest.cs
@@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs
index ec0e0395c6a80f..68b876b7ac9b62 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs
@@ -7,7 +7,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -33,19 +33,24 @@ public void SingletonReturnsTrue()
}
#endif
- [Theory]
- [InlineData(SslProtocols.Tls12, false)] // try various protocols to ensure we correctly set versions even when accepting all certs
- [InlineData(SslProtocols.Tls12, true)]
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
- [InlineData(SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false)]
- [InlineData(SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true)]
+ public static TheoryData SetDelegate_ConnectionSucceedsData => new()
+ {
+ { SslProtocols.Tls12, false },
+ { SslProtocols.Tls12, true },
+ { SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false },
+ { SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true },
#if !NETFRAMEWORK
- [InlineData(SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false)]
- [InlineData(SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true)]
+ { SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false },
+ { SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true },
#endif
+ { SslProtocols.None, false },
+ { SslProtocols.None, true },
+ };
#pragma warning restore SYSLIB0039
- [InlineData(SslProtocols.None, false)]
- [InlineData(SslProtocols.None, true)]
+
+ [Theory]
+ [MemberData(nameof(SetDelegate_ConnectionSucceedsData))]
public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol, bool requestOnlyThisProtocol)
{
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Asynchrony.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Asynchrony.cs
index 258081310bf277..b56c071fe0aa03 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Asynchrony.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Asynchrony.cs
@@ -9,7 +9,6 @@
using System.Threading.Tasks;
using System.Threading.Tests;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs
index 7e3b1b0fbb1c7a..dea9ed0729f953 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs
@@ -12,7 +12,7 @@
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -559,10 +559,7 @@ public async Task Proxy_DomainJoinedProxyServerUsesKerberos_Success(Uri server)
// We skip the test unless it is running on a Windows client machine. That is because only Windows
// automatically registers an SPN for HTTP/ of the machine. This will enable Kerberos to properly
// work with the loopback proxy server.
- if (!PlatformDetection.IsWindows || !PlatformDetection.IsNotWindowsNanoServer)
- {
- throw new SkipTestException("Test can only run on domain joined Windows client machine");
- }
+ Assert.SkipUnless(PlatformDetection.IsWindows && PlatformDetection.IsNotWindowsNanoServer, "Test can only run on domain joined Windows client machine");
var options = new LoopbackProxyServer.Options { AuthenticationSchemes = AuthenticationSchemes.Negotiate };
using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create(options))
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs
index c45d954d92b97d..438a320311df8f 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs
@@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs
index de521cd577a144..d960d0de8e23b3 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs
@@ -13,7 +13,7 @@
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs
index 5169535a2afbe7..54c19b72e9bcc7 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs
@@ -11,7 +11,7 @@
using Microsoft.DotNet.RemoteExecutor;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+using Xunit.Sdk;
namespace System.Net.Http.Functional.Tests
{
@@ -77,12 +77,13 @@ private HttpClient CreateHttpClientWithCert(X509Certificate2 cert)
return CreateHttpClient(handler);
}
- [ConditionalTheory]
+ [Theory]
[InlineData(1, true)]
[InlineData(2, true)]
[InlineData(3, false)]
public async Task Manual_CertificateOnlySentWhenValid_Success(int certIndex, bool serverExpectsClientCertificate)
{
+
var options = new LoopbackServer.Options { UseSsl = true };
X509Certificate2 GetClientCertificate(int certIndex) => certIndex switch
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs
index 27e2c8f0ebd060..ff3e7cc7fe99ca 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs
@@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Decompression.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Decompression.cs
index 02724599c120ee..5757bb4adc8584 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Decompression.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Decompression.cs
@@ -10,7 +10,6 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
@@ -331,7 +330,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
break;
}
}
-
+
Assert.True(acceptEncodingValid, "Accept-Encoding missing or invalid");
using (HttpResponseMessage response = await clientTask)
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.DefaultProxyCredentials.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.DefaultProxyCredentials.cs
index 0924f2357ac4d7..081efa33313ae1 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.DefaultProxyCredentials.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.DefaultProxyCredentials.cs
@@ -9,7 +9,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxConnectionsPerServer.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxConnectionsPerServer.cs
index 5cf44f8689e111..2bd15e80706b60 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxConnectionsPerServer.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxConnectionsPerServer.cs
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs
index 0d9b82b491d38d..9c0c697c8301f3 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs
@@ -13,7 +13,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs
index 82b67f978bcc3d..5de56f4335e9eb 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs
@@ -12,7 +12,7 @@
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs
index 49b2a61a1fd110..02bcbc6a16fe98 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs
@@ -10,7 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -20,7 +20,6 @@ namespace System.Net.Http.Functional.Tests
using HttpClientHandler = System.Net.Http.WinHttpClientHandler;
#endif
- [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))]
public sealed class HttpClientHandler_RemoteServerTest : HttpClientHandlerTestBase
{
private const string ExpectedContent = "Test content";
@@ -57,6 +56,7 @@ private static IEnumerable GetMethods(params string[] methods)
public HttpClientHandler_RemoteServerTest(ITestOutputHelper output) : base(output)
{
+ Assert.SkipUnless(PlatformDetection.IsBrowserDomSupportedOrNotBrowser, "ConditionalClass: PlatformDetection.IsBrowserDomSupportedOrNotBrowser");
}
[OuterLoop("Uses external servers")]
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs
index 8bd55e52abe05d..42eec5a47d375e 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs
@@ -14,7 +14,7 @@
using Microsoft.DotNet.RemoteExecutor;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs
index 1bbe73dd0a3a04..f479cbbcbbc72f 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs
@@ -11,7 +11,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -34,24 +34,29 @@ public void DefaultProtocols_MatchesExpected()
}
}
- [Theory]
- [InlineData(SslProtocols.None)]
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
- [InlineData(SslProtocols.Tls)]
- [InlineData(SslProtocols.Tls11)]
- [InlineData(SslProtocols.Tls12)]
- [InlineData(SslProtocols.Tls | SslProtocols.Tls11)]
- [InlineData(SslProtocols.Tls11 | SslProtocols.Tls12)]
- [InlineData(SslProtocols.Tls | SslProtocols.Tls12)]
- [InlineData(SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12)]
+ public static TheoryData SetGetProtocols_RoundtripsData => new()
+ {
+ SslProtocols.None,
+ SslProtocols.Tls,
+ SslProtocols.Tls11,
+ SslProtocols.Tls12,
+ SslProtocols.Tls | SslProtocols.Tls11,
+ SslProtocols.Tls11 | SslProtocols.Tls12,
+ SslProtocols.Tls | SslProtocols.Tls12,
+ SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
#if !NETFRAMEWORK
- [InlineData(SslProtocols.Tls13)]
- [InlineData(SslProtocols.Tls11 | SslProtocols.Tls13)]
- [InlineData(SslProtocols.Tls12 | SslProtocols.Tls13)]
- [InlineData(SslProtocols.Tls | SslProtocols.Tls13)]
- [InlineData(SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13)]
+ SslProtocols.Tls13,
+ SslProtocols.Tls11 | SslProtocols.Tls13,
+ SslProtocols.Tls12 | SslProtocols.Tls13,
+ SslProtocols.Tls | SslProtocols.Tls13,
+ SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13,
#endif
+ };
#pragma warning restore SYSLIB0039
+
+ [Theory]
+ [MemberData(nameof(SetGetProtocols_RoundtripsData))]
public void SetGetProtocols_Roundtrips(SslProtocols protocols)
{
using (HttpClientHandler handler = CreateHttpClientHandler())
@@ -260,17 +265,22 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
}
}
- [Theory]
#pragma warning disable 0618 // SSL2/3 are deprecated
- [InlineData(SslProtocols.Ssl2, SslProtocols.Tls12)]
- [InlineData(SslProtocols.Ssl3, SslProtocols.Tls12)]
-#pragma warning restore 0618
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
- [InlineData(SslProtocols.Tls11, SslProtocols.Tls)]
- [InlineData(SslProtocols.Tls11 | SslProtocols.Tls12, SslProtocols.Tls)] // Skip this on WinHttpHandler.
- [InlineData(SslProtocols.Tls12, SslProtocols.Tls11)]
- [InlineData(SslProtocols.Tls, SslProtocols.Tls12)]
+ public static TheoryData SslMismatchData => new()
+ {
+ { SslProtocols.Ssl2, SslProtocols.Tls12 },
+ { SslProtocols.Ssl3, SslProtocols.Tls12 },
+ { SslProtocols.Tls11, SslProtocols.Tls },
+ { SslProtocols.Tls11 | SslProtocols.Tls12, SslProtocols.Tls }, // Skip this on WinHttpHandler.
+ { SslProtocols.Tls12, SslProtocols.Tls11 },
+ { SslProtocols.Tls, SslProtocols.Tls12 },
+ };
#pragma warning restore SYSLIB0039
+#pragma warning restore 0618
+
+ [Theory]
+ [MemberData(nameof(SslMismatchData))]
public async Task GetAsync_AllowedClientSslVersionDiffersFromServer_ThrowsException(
SslProtocols allowedClientProtocols, SslProtocols acceptedServerProtocols)
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs
index 322474fb38fef7..68dfc5bf6a2edf 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs
@@ -16,7 +16,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -155,7 +155,7 @@ public void Properties_AddItemToDictionary_ItemPresent()
}
}
- [ConditionalFact]
+ [Fact]
[SkipOnPlatform(TestPlatforms.Browser, "ServerCertificateCustomValidationCallback not supported on Browser")]
public async Task GetAsync_IPv6LinkLocalAddressUri_Success()
{
@@ -173,10 +173,7 @@ public async Task GetAsync_IPv6LinkLocalAddressUri_Success()
using HttpClient client = CreateHttpClient(handler);
var options = new GenericLoopbackOptions { Address = Configuration.Sockets.LinkLocalAddress };
- if (options.Address == null)
- {
- throw new SkipTestException("Unable to find valid IPv6 LL address.");
- }
+ Assert.SkipWhen(options.Address == null, "Unable to find valid IPv6 LL address.");
await LoopbackServerFactory.CreateServerAsync(async (server, url) =>
{
@@ -187,7 +184,7 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
}, options: options);
}
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(GetAsync_IPBasedUri_Success_MemberData))]
public async Task GetAsync_IPBasedUri_Success(IPAddress address)
{
@@ -266,7 +263,7 @@ from useSsl in BoolValues
where PlatformDetection.IsNotBrowser || !useSsl
select new object[] { address, useSsl };
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(SecureAndNonSecure_IPBasedUri_MemberData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/86317", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJS))]
public async Task GetAsync_SecureAndNonSecureIPBasedUri_CorrectlyFormatted(IPAddress address, bool useSsl)
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTestBase.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTestBase.cs
index f2874862d08226..197ec7e30583f6 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTestBase.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTestBase.cs
@@ -8,7 +8,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-using Xunit.Abstractions;
+using Xunit;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/HttpProtocolTests.cs b/src/libraries/Common/tests/System/Net/Http/HttpProtocolTests.cs
index 0d3f460d586dd5..93e5f5107259d3 100644
--- a/src/libraries/Common/tests/System/Net/Http/HttpProtocolTests.cs
+++ b/src/libraries/Common/tests/System/Net/Http/HttpProtocolTests.cs
@@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
@@ -170,7 +169,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
await TestHelper.WhenAllCompletedOrAnyFailed(getResponseTask, serverTask);
using (HttpResponseMessage response = await getResponseTask)
- {
+ {
if (IsWinHttpHandler)
{
Assert.Equal(0, response.Version.Major);
@@ -398,7 +397,7 @@ public async Task GetAsync_Chunked_VaryingSizeChunks_ReceivedCorrectly(int maxCh
{
return;
}
-
+
var rand = new Random(42);
byte[] expectedData = new byte[100_000];
rand.NextBytes(expectedData);
diff --git a/src/libraries/Common/tests/System/Net/Http/IdnaProtocolTests.cs b/src/libraries/Common/tests/System/Net/Http/IdnaProtocolTests.cs
index 28324ecad91048..0b44a50ed8e120 100644
--- a/src/libraries/Common/tests/System/Net/Http/IdnaProtocolTests.cs
+++ b/src/libraries/Common/tests/System/Net/Http/IdnaProtocolTests.cs
@@ -5,7 +5,6 @@
using System.Net.Test.Common;
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs
index 6f465ff0e998c5..4316fe81a679ed 100644
--- a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs
@@ -7,7 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
diff --git a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs
index 3390ae5c5fa4db..50be93ff9aa13e 100644
--- a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs
+++ b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs
@@ -9,7 +9,7 @@
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
+
namespace System.Net.Http.Functional.Tests
{
@@ -647,7 +647,7 @@ await StartTransferTypeAndErrorServer(transferType, transferError, async uri =>
HttpIOException exception = await Assert.ThrowsAsync(() => ReadAsStreamHelper(uri));
Assert.Equal(HttpRequestError.ResponseEnded, exception.HttpRequestError);
}
-
+
});
}
diff --git a/src/libraries/Common/tests/System/Net/Security/Kerberos/KerberosExecutor.cs b/src/libraries/Common/tests/System/Net/Security/Kerberos/KerberosExecutor.cs
index 00f1f1d471db90..12dc210d90c9c1 100644
--- a/src/libraries/Common/tests/System/Net/Security/Kerberos/KerberosExecutor.cs
+++ b/src/libraries/Common/tests/System/Net/Security/Kerberos/KerberosExecutor.cs
@@ -11,7 +11,7 @@
using Kerberos.NET.Crypto;
using Kerberos.NET.Server;
using Kerberos.NET.Logging;
-using Xunit.Abstractions;
+using Xunit;
namespace System.Net.Security.Kerberos;
@@ -102,7 +102,7 @@ public void AddService(string name, string password = DefaultAdminPassword)
_principalService.Add(name, principal);
_servicePrincipals.Add(principal);
}
-
+
public void AddUser(string name, string password = DefaultUserPassword)
{
var principal = new FakeKerberosPrincipal(PrincipalType.User, name, _realm, Encoding.Unicode.GetBytes(password));
diff --git a/src/libraries/Common/tests/System/Net/TestLogging.cs b/src/libraries/Common/tests/System/Net/TestLogging.cs
index b13a169d50b9b5..d8e392b9f34b40 100644
--- a/src/libraries/Common/tests/System/Net/TestLogging.cs
+++ b/src/libraries/Common/tests/System/Net/TestLogging.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using Xunit.Abstractions;
+using Xunit;
namespace System.Net.Test.Common
{
@@ -13,11 +13,23 @@ private TestLogging()
{
}
+ public string Output => throw new NotSupportedException();
+
public static TestLogging GetInstance()
{
return s_instance;
}
+ public void Write(string message)
+ {
+ EventSourceTestLogging.Log.TestMessage(message);
+ }
+
+ public void Write(string format, params object[] args)
+ {
+ EventSourceTestLogging.Log.TestMessage(string.Format(format, args));
+ }
+
public void WriteLine(string message)
{
EventSourceTestLogging.Log.TestMessage(message);
diff --git a/src/libraries/Common/tests/System/Net/VerboseTestLogging.cs b/src/libraries/Common/tests/System/Net/VerboseTestLogging.cs
index 45d184724d6479..d7f4d7089ada37 100644
--- a/src/libraries/Common/tests/System/Net/VerboseTestLogging.cs
+++ b/src/libraries/Common/tests/System/Net/VerboseTestLogging.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
-using Xunit.Abstractions;
+using Xunit;
namespace System.Net.Test.Common
{
@@ -14,11 +14,26 @@ private VerboseTestLogging()
{
}
+ public string Output => throw new NotSupportedException();
+
public static VerboseTestLogging GetInstance()
{
return s_instance;
}
+ public void Write(string message)
+ {
+ EventSourceTestLogging.Log.TestVerboseMessage(message);
+ Debug.Write(message);
+ }
+
+ public void Write(string message, params object[] args)
+ {
+ string formattedMessage = string.Format(message, args);
+ EventSourceTestLogging.Log.TestVerboseMessage(formattedMessage);
+ Debug.Write(formattedMessage);
+ }
+
public void WriteLine(string message)
{
EventSourceTestLogging.Log.TestVerboseMessage(message);
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AesGcmTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AesGcmTests.cs
index 8cf9eb6f078a7b..8d72626b7f951e 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AesGcmTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AesGcmTests.cs
@@ -8,14 +8,18 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(AesGcm), nameof(AesGcm.IsSupported))]
public class AesGcmTests : CommonAEADTests
{
+ public AesGcmTests()
+ {
+ Assert.SkipUnless(AesGcm.IsSupported, "ConditionalClass: AesGcm.IsSupported");
+ }
+
private const int CryptoKitSupportedTagSizeInBytes = 16;
[Theory]
[MemberData(nameof(EncryptTamperAADDecryptTestInputs))]
- public static void EncryptTamperAADDecrypt(int dataLength, int additionalDataLength)
+ public void EncryptTamperAADDecrypt(int dataLength, int additionalDataLength)
{
byte[] additionalData = new byte[additionalDataLength];
FillRandom(additionalData);
@@ -47,7 +51,7 @@ public static void EncryptTamperAADDecrypt(int dataLength, int additionalDataLen
[InlineData(17)]
[InlineData(29)]
[InlineData(33)]
- public static void InvalidKeyLength(int keyLength)
+ public void InvalidKeyLength(int keyLength)
{
byte[] key = new byte[keyLength];
#if NET
@@ -62,7 +66,7 @@ public static void InvalidKeyLength(int keyLength)
[Theory]
[MemberData(nameof(GetInvalidNonceSizes))]
- public static void InvalidNonceSize(int nonceSize)
+ public void InvalidNonceSize(int nonceSize)
{
int dataLength = 30;
byte[] plaintext = Enumerable.Range(1, dataLength).Select((x) => (byte)x).ToArray();
@@ -81,7 +85,7 @@ public static void InvalidNonceSize(int nonceSize)
[Theory]
[MemberData(nameof(GetValidNonceSizes))]
- public static void ValidNonceSize(int nonceSize)
+ public void ValidNonceSize(int nonceSize)
{
const int dataLength = 35;
byte[] plaintext = Enumerable.Range(1, dataLength).Select((x) => (byte)x).ToArray();
@@ -105,7 +109,7 @@ public static void ValidNonceSize(int nonceSize)
#if NET
[Theory]
[MemberData(nameof(GetInvalidTagSizes))]
- public static void InvalidTagSizeForUnspecifiedRequiredTag(int tagSize)
+ public void InvalidTagSizeForUnspecifiedRequiredTag(int tagSize)
{
int dataLength = 30;
byte[] plaintext = Enumerable.Range(1, dataLength).Select((x) => (byte)x).ToArray();
@@ -128,7 +132,7 @@ public static void InvalidTagSizeForUnspecifiedRequiredTag(int tagSize)
[Theory]
[MemberData(nameof(GetInvalidTagSizes))]
- public static void InvalidTagSizeForRequiredTag(int tagSize)
+ public void InvalidTagSizeForRequiredTag(int tagSize)
{
byte[] key = new byte[32];
Assert.Throws("tagSizeInBytes", () => new AesGcm(key, tagSize));
@@ -137,7 +141,7 @@ public static void InvalidTagSizeForRequiredTag(int tagSize)
[Theory]
[MemberData(nameof(GetValidTagSizes))]
- public static void ValidTagSize(int tagSize)
+ public void ValidTagSize(int tagSize)
{
const int dataLength = 35;
byte[] plaintext = Enumerable.Range(1, dataLength).Select((x) => (byte)x).ToArray();
@@ -163,7 +167,7 @@ public static void ValidTagSize(int tagSize)
[InlineData(13)]
[InlineData(14)]
[InlineData(15)]
- public static void TagSizeDoesNotMatchConstructorRequirement(int wrongTagSize)
+ public void TagSizeDoesNotMatchConstructorRequirement(int wrongTagSize)
{
byte[] key = new byte[16];
byte[] nonce = new byte[12];
@@ -190,7 +194,7 @@ public static void TagSizeDoesNotMatchConstructorRequirement(int wrongTagSize)
}
[Fact]
- public static void TwoEncryptionsAndDecryptionsUsingOneInstance()
+ public void TwoEncryptionsAndDecryptionsUsingOneInstance()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] originalData1 = Enumerable.Range(1, 15).Select((x) => (byte)x).ToArray();
@@ -240,7 +244,7 @@ public static void TwoEncryptionsAndDecryptionsUsingOneInstance()
[Theory]
[MemberData(nameof(PlaintextAndCiphertextSizeDifferTestInputs))]
- public static void PlaintextAndCiphertextSizeDiffer(int ptLen, int ctLen)
+ public void PlaintextAndCiphertextSizeDiffer(int ptLen, int ctLen)
{
byte[] key = new byte[16];
byte[] nonce = new byte[12];
@@ -256,7 +260,7 @@ public static void PlaintextAndCiphertextSizeDiffer(int ptLen, int ctLen)
}
[Fact]
- public static void NullKey()
+ public void NullKey()
{
#if NET
#pragma warning disable SYSLIB0053
@@ -267,7 +271,7 @@ public static void NullKey()
}
[Fact]
- public static void EncryptDecryptNullNonce()
+ public void EncryptDecryptNullNonce()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] plaintext = new byte[0];
@@ -282,7 +286,7 @@ public static void EncryptDecryptNullNonce()
}
[Fact]
- public static void EncryptDecryptNullPlaintext()
+ public void EncryptDecryptNullPlaintext()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] nonce = new byte[12];
@@ -297,7 +301,7 @@ public static void EncryptDecryptNullPlaintext()
}
[Fact]
- public static void EncryptDecryptNullCiphertext()
+ public void EncryptDecryptNullCiphertext()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] nonce = new byte[12];
@@ -312,7 +316,7 @@ public static void EncryptDecryptNullCiphertext()
}
[Fact]
- public static void EncryptDecryptNullTag()
+ public void EncryptDecryptNullTag()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] nonce = new byte[12];
@@ -327,7 +331,7 @@ public static void EncryptDecryptNullTag()
}
[Fact]
- public static void InplaceEncryptDecrypt()
+ public void InplaceEncryptDecrypt()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] nonce = new byte[12];
@@ -347,7 +351,7 @@ public static void InplaceEncryptDecrypt()
}
[Fact]
- public static void InplaceEncryptTamperTagDecrypt()
+ public void InplaceEncryptTamperTagDecrypt()
{
byte[] key = "d5a194ed90cfe08abecd4691997ceb2c".HexToByteArray();
byte[] nonce = new byte[12];
@@ -372,7 +376,7 @@ public static void InplaceEncryptTamperTagDecrypt()
#if NET
[Theory]
[MemberData(nameof(GetNistGcmTestCases))]
- public static void AesGcmNistTestsUnspecifiedTagSize(AEADTest testCase)
+ public void AesGcmNistTestsUnspecifiedTagSize(AEADTest testCase)
{
#pragma warning disable SYSLIB0053
using (var aesGcm = new AesGcm(testCase.Key))
@@ -409,7 +413,7 @@ public static void AesGcmNistTestsUnspecifiedTagSize(AEADTest testCase)
[Theory]
[MemberData(nameof(GetNistGcmTestCases))]
- public static void AesGcmNistTestsSpecifiedTagSize(AEADTest testCase)
+ public void AesGcmNistTestsSpecifiedTagSize(AEADTest testCase)
{
if ((PlatformDetection.IsOSX || PlatformDetection.UsesMobileAppleCrypto) && testCase.Tag.Length != CryptoKitSupportedTagSizeInBytes)
{
@@ -435,7 +439,7 @@ public static void AesGcmNistTestsSpecifiedTagSize(AEADTest testCase)
[Theory]
[MemberData(nameof(GetNistGcmTestCases))]
- public static void AesGcmNistTestsTamperTag(AEADTest testCase)
+ public void AesGcmNistTestsTamperTag(AEADTest testCase)
{
if ((PlatformDetection.IsOSX || PlatformDetection.UsesMobileAppleCrypto) && testCase.Tag.Length != CryptoKitSupportedTagSizeInBytes)
{
@@ -462,7 +466,7 @@ public static void AesGcmNistTestsTamperTag(AEADTest testCase)
[Theory]
[MemberData(nameof(GetNistGcmTestCasesWithNonEmptyPT))]
- public static void AesGcmNistTestsTamperCiphertext(AEADTest testCase)
+ public void AesGcmNistTestsTamperCiphertext(AEADTest testCase)
{
if ((PlatformDetection.IsOSX || PlatformDetection.UsesMobileAppleCrypto) && testCase.Tag.Length != CryptoKitSupportedTagSizeInBytes)
{
@@ -489,7 +493,7 @@ public static void AesGcmNistTestsTamperCiphertext(AEADTest testCase)
}
[Fact]
- public static void UseAfterDispose()
+ public void UseAfterDispose()
{
byte[] key = new byte[16];
byte[] nonce = new byte[12];
@@ -993,7 +997,7 @@ public class AesGcmIsSupportedTests
public static bool RuntimeSaysIsNotSupported => !AesGcm.IsSupported;
[ConditionalFact(typeof(AesGcmIsSupportedTests), nameof(RuntimeSaysIsNotSupported))]
- public static void CtorThrowsPNSEIfNotSupported()
+ public void CtorThrowsPNSEIfNotSupported()
{
byte[] key;
#if NET
@@ -1019,7 +1023,7 @@ public static void CtorThrowsPNSEIfNotSupported()
}
[Fact]
- public static void CheckIsSupported()
+ public void CheckIsSupported()
{
bool expectedIsSupported = !PlatformDetection.IsBrowser;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesContractTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesContractTests.cs
index 8121a006ed8eb4..980fa469ba56b0 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesContractTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesContractTests.cs
@@ -162,7 +162,7 @@ public static void ValidCFBFeedbackSizes(int feedbackSize)
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(64, false)] // smaller than default BlockSize
[InlineData(129, false)] // larger than default BlockSize
// Skip on .NET Framework because change is not ported https://github.com/dotnet/runtime/issues/21236
@@ -172,8 +172,7 @@ public static void InvalidIVSizes(int invalidIvSize, bool skipOnNetfx)
if (skipOnNetfx && PlatformDetection.IsNetFramework)
return;
- if (PlatformDetection.IstvOS && invalidIvSize == 536870928)
- throw new SkipTestException($"https://github.com/dotnet/runtime/issues/76728 This test case flakily crashes tvOS arm64");
+ Assert.SkipWhen(PlatformDetection.IstvOS && invalidIvSize == 536870928, $"https://github.com/dotnet/runtime/issues/76728 This test case flakily crashes tvOS arm64");
using (Aes aes = AesFactory.Create())
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaFactoryTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaFactoryTests.cs
index 97118669d7de84..3322cd4e988cca 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaFactoryTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaFactoryTests.cs
@@ -73,7 +73,7 @@ public static void ImportBadPrivateKey_ShortTradKey(CompositeMLDsaAlgorithm algo
[Theory]
[SkipOnPlatform(TestPlatforms.Android, "Not supported on Android")]
- [MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
+ [MemberData(nameof(CompositeMLDsaTestData.AllIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public static void ImportBadPrivateKey_TrailingData(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
byte[] key = vector.SecretKey;
@@ -374,7 +374,7 @@ public static void ImportBadPublicKey_ShortTradKey(CompositeMLDsaAlgorithm algor
[Theory]
[SkipOnPlatform(TestPlatforms.Android, "Not supported on Android")]
- [MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
+ [MemberData(nameof(CompositeMLDsaTestData.AllIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public static void ImportBadPublicKey_TrailingData(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
byte[] key = vector.PublicKey;
@@ -385,9 +385,13 @@ public static void ImportBadPublicKey_TrailingData(CompositeMLDsaTestData.Compos
[Theory]
[SkipOnPlatform(TestPlatforms.Android, "Not supported on Android")]
- [MemberData(nameof(CompositeMLDsaTestData.SupportedECDsaAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
+ [MemberData(nameof(CompositeMLDsaTestData.AllIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public static void ImportBadPublicKey_ECDsa_Uncompressed(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
+ Assert.SkipUnless(
+ CompositeMLDsa.IsAlgorithmSupported(vector.Algorithm) && CompositeMLDsaTestHelpers.IsECDsa(vector.Algorithm),
+ "Algorithm is not supported or is not ECDsa.");
+
byte[] key = vector.PublicKey.AsSpan().ToArray();
int formatIndex = CompositeMLDsaTestHelpers.MLDsaAlgorithms[vector.Algorithm].PublicKeySizeInBytes;
@@ -654,7 +658,7 @@ static void AssertThrows(string encryptedPem)
}
[Theory]
- [MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
+ [MemberData(nameof(CompositeMLDsaTestData.AllAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public static void AlgorithmMatches_GenerateKey(CompositeMLDsaAlgorithm algorithm)
{
AssertThrowIfNotSupported(
@@ -668,7 +672,7 @@ public static void AlgorithmMatches_GenerateKey(CompositeMLDsaAlgorithm algorith
[Theory]
[SkipOnPlatform(TestPlatforms.Android, "Not supported on Android")]
- [MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
+ [MemberData(nameof(CompositeMLDsaTestData.AllIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public static void AlgorithmMatches_Import(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
CompositeMLDsaTestHelpers.AssertImportPublicKey(
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaImplementationTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaImplementationTests.cs
index 2d7c9c7bba839e..c39413fc8535a2 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaImplementationTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaImplementationTests.cs
@@ -6,19 +6,23 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
public sealed class CompositeMLDsaImplementationTests : CompositeMLDsaTestsBase
{
- [Theory]
+ public CompositeMLDsaImplementationTests()
+ {
+ Assert.SkipUnless(CompositeMLDsa.IsSupported, "ConditionalClass: CompositeMLDsa.IsSupported");
+ }
+
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
- public static void CompositeMLDsaIsOnlyPublicAncestor_GenerateKey(CompositeMLDsaAlgorithm algorithm)
+ public void CompositeMLDsaIsOnlyPublicAncestor_GenerateKey(CompositeMLDsaAlgorithm algorithm)
{
AssertCompositeMLDsaIsOnlyPublicAncestor(() => CompositeMLDsa.GenerateKey(algorithm));
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
- public static void CompositeMLDsaIsOnlyPublicAncestor_Import(CompositeMLDsaTestData.CompositeMLDsaTestVector info)
+ public void CompositeMLDsaIsOnlyPublicAncestor_Import(CompositeMLDsaTestData.CompositeMLDsaTestVector info)
{
CompositeMLDsaTestHelpers.AssertImportPublicKey(
AssertCompositeMLDsaIsOnlyPublicAncestor, info.Algorithm, info.PublicKey);
@@ -41,7 +45,7 @@ private static void AssertCompositeMLDsaIsOnlyPublicAncestor(Func source);
protected abstract CompositeMLDsa ImportPublicKey(CompositeMLDsaAlgorithm algorithm, ReadOnlySpan source);
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyWithPublicKey(CompositeMLDsaAlgorithm algorithm)
{
@@ -39,7 +43,7 @@ public void GenerateSignVerifyWithPublicKey(CompositeMLDsaAlgorithm algorithm)
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyWithPrivateKey(CompositeMLDsaAlgorithm algorithm)
{
@@ -64,7 +68,7 @@ public void GenerateSignVerifyWithPrivateKey(CompositeMLDsaAlgorithm algorithm)
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyNoContext(CompositeMLDsaAlgorithm algorithm)
{
@@ -78,7 +82,7 @@ public void GenerateSignVerifyNoContext(CompositeMLDsaAlgorithm algorithm)
ExerciseSuccessfulVerify(dsa, data, signature, Array.Empty());
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyWithContext(CompositeMLDsaAlgorithm algorithm)
{
@@ -94,7 +98,7 @@ public void GenerateSignVerifyWithContext(CompositeMLDsaAlgorithm algorithm)
ExerciseSuccessfulVerify(dsa, data, signature, context);
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyEmptyMessageNoContext(CompositeMLDsaAlgorithm algorithm)
{
@@ -107,7 +111,7 @@ public void GenerateSignVerifyEmptyMessageNoContext(CompositeMLDsaAlgorithm algo
ExerciseSuccessfulVerify(dsa, [], signature, []);
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void GenerateSignVerifyEmptyMessageWithContext(CompositeMLDsaAlgorithm algorithm)
{
@@ -126,7 +130,7 @@ from vector in CompositeMLDsaTestData.SupportedAlgorithmIetfVectors
from useContext in new[] { false, true }
select new object[] { vector, useContext };
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(SupportedIetfVectorsWithContextFlagTestData))]
public void ImportExportVerify(CompositeMLDsaTestData.CompositeMLDsaTestVector vector, bool useContext)
{
@@ -159,7 +163,7 @@ public void ImportExportVerify(CompositeMLDsaTestData.CompositeMLDsaTestVector v
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(SupportedIetfVectorsWithContextFlagTestData))]
public void ImportSignVerify(CompositeMLDsaTestData.CompositeMLDsaTestVector vector, bool useContext)
{
@@ -184,7 +188,7 @@ public void ImportSignVerify(CompositeMLDsaTestData.CompositeMLDsaTestVector vec
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void ImportPublicKey_Export(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -197,7 +201,7 @@ public void ImportPublicKey_Export(CompositeMLDsaTestData.CompositeMLDsaTestVect
export => Assert.Throws(() => export(dsa)));
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void ImportPrivateKey_Export(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -210,7 +214,7 @@ public void ImportPrivateKey_Export(CompositeMLDsaTestData.CompositeMLDsaTestVec
export => CompositeMLDsaTestHelpers.AssertPrivateKeyEquals(vector.Algorithm, vector.SecretKey, export(dsa)));
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void Generate_Export_Import_PublicKey(CompositeMLDsaAlgorithm algorithm)
{
@@ -234,7 +238,7 @@ public void Generate_Export_Import_PublicKey(CompositeMLDsaAlgorithm algorithm)
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void Generate_Export_Import_PrivateKey(CompositeMLDsaAlgorithm algorithm)
{
@@ -260,7 +264,7 @@ public void Generate_Export_Import_PrivateKey(CompositeMLDsaAlgorithm algorithm)
}
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void SignData_PublicKeyOnlyThrows(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -272,7 +276,7 @@ public void SignData_PublicKeyOnlyThrows(CompositeMLDsaTestData.CompositeMLDsaTe
Assert.DoesNotContain("unknown", ce.Message, StringComparison.OrdinalIgnoreCase);
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void TryExportPrivateKey_BufferTooSmall(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -282,7 +286,7 @@ public void TryExportPrivateKey_BufferTooSmall(CompositeMLDsaTestData.CompositeM
Assert.Equal(0, bytesWritten);
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void TryExportPublicKey_BufferTooSmall(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -292,7 +296,7 @@ public void TryExportPublicKey_BufferTooSmall(CompositeMLDsaTestData.CompositeML
Assert.Equal(0, bytesWritten);
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void ImportPrivateKey_TrailingData(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
@@ -301,7 +305,7 @@ public void ImportPrivateKey_TrailingData(CompositeMLDsaTestData.CompositeMLDsaT
Assert.Throws(() => ImportPrivateKey(vector.Algorithm, secretKeyWithTrailingData));
}
- [Theory]
+ [ConditionalTheory(typeof(CompositeMLDsa), nameof(CompositeMLDsa.IsSupported))]
[MemberData(nameof(CompositeMLDsaTestData.SupportedAlgorithmIetfVectorsTestData), MemberType = typeof(CompositeMLDsaTestData))]
public void ImportPublicKey_TrailingData(CompositeMLDsaTestData.CompositeMLDsaTestVector vector)
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAImportExport.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAImportExport.cs
index 9ce2a37b5388a2..ac9b91148d737a 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAImportExport.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAImportExport.cs
@@ -6,11 +6,15 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public partial class DSAImportExport
{
+ public DSAImportExport()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
[Fact]
- public static void ExportAutoKey()
+ public void ExportAutoKey()
{
DSAParameters privateParams;
DSAParameters publicParams;
@@ -39,7 +43,7 @@ public static void ExportAutoKey()
}
[Fact]
- public static void Import_512()
+ public void Import_512()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -50,7 +54,7 @@ public static void Import_512()
}
[Fact]
- public static void Import_576()
+ public void Import_576()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -61,7 +65,7 @@ public static void Import_576()
}
[Fact]
- public static void Import_1024()
+ public void Import_1024()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -72,7 +76,7 @@ public static void Import_1024()
}
[ConditionalFact(typeof(DSAFactory), nameof(DSAFactory.SupportsFips186_3))]
- public static void Import_2048()
+ public void Import_2048()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -83,7 +87,7 @@ public static void Import_2048()
}
[Fact]
- public static void MultiExport()
+ public void MultiExport()
{
DSAParameters imported = DSATestData.GetDSA1024Params();
@@ -113,7 +117,7 @@ public static void MultiExport()
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void ImportRoundTrip(bool includePrivate)
+ public void ImportRoundTrip(bool includePrivate)
{
DSAParameters imported = DSATestData.GetDSA1024Params();
@@ -133,7 +137,7 @@ public static void ImportRoundTrip(bool includePrivate)
[Theory]
[InlineData(false)]
[InlineData(true)]
- public static void ExportAfterDispose(bool importKey)
+ public void ExportAfterDispose(bool importKey)
{
DSA key = importKey ? DSAFactory.Create(DSATestData.GetDSA1024Params()) : DSAFactory.Create(1024);
byte[] hash = new byte[20];
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyFileTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyFileTests.cs
index 8b0a730fd78481..eca046a98f6d44 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyFileTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyFileTests.cs
@@ -10,19 +10,23 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
- public static class DSAKeyFileTests
+ public class DSAKeyFileTests
{
+ public DSAKeyFileTests()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
public static bool SupportsFips186_3 => DSAFactory.SupportsFips186_3;
[Fact]
- public static void UseAfterDispose_NewKey()
+ public void UseAfterDispose_NewKey()
{
UseAfterDispose(false);
}
[Fact]
- public static void UseAfterDispose_ImportedKey()
+ public void UseAfterDispose_ImportedKey()
{
UseAfterDispose(true);
}
@@ -75,7 +79,7 @@ private static void UseAfterDispose(bool importKey)
}
[Fact]
- public static void ReadWriteDsa512Pkcs8()
+ public void ReadWriteDsa512Pkcs8()
{
ReadWriteBase64Pkcs8(
@"
@@ -88,7 +92,7 @@ public static void ReadWriteDsa512Pkcs8()
}
[ConditionalFact(typeof(DSAKeyFileTests), nameof(SupportsFips186_3))]
- public static void ReadWriteDsa2048DeficientXPkcs8()
+ public void ReadWriteDsa2048DeficientXPkcs8()
{
ReadWriteBase64Pkcs8(
@"
@@ -109,7 +113,7 @@ public static void ReadWriteDsa2048DeficientXPkcs8()
}
[ConditionalFact(typeof(RC2Factory), nameof(RC2Factory.IsSupported))]
- public static void ReadWriteDsa512EncryptedPkcs8()
+ public void ReadWriteDsa512EncryptedPkcs8()
{
// pbeWithSHA1And40BitRC2-CBC (PKCS12-PBE)
ReadBase64EncryptedPkcs8(
@@ -129,7 +133,7 @@ public static void ReadWriteDsa512EncryptedPkcs8()
}
[ConditionalFact(typeof(RC2Factory), nameof(RC2Factory.IsSupported))]
- public static void ReadWriteDsa576EncryptedPkcs8()
+ public void ReadWriteDsa576EncryptedPkcs8()
{
// pbeWithSHA1And128BitRC2-CBC (PKCS12-PBE)
ReadBase64EncryptedPkcs8(
@@ -149,7 +153,7 @@ public static void ReadWriteDsa576EncryptedPkcs8()
}
[Fact]
- public static void ReadWriteDsa1024EncryptedPkcs8()
+ public void ReadWriteDsa1024EncryptedPkcs8()
{
// pbeWithSHA1AndDES-CBC (PBES1)
ReadBase64EncryptedPkcs8(
@@ -171,7 +175,7 @@ public static void ReadWriteDsa1024EncryptedPkcs8()
}
[Fact]
- public static void ReadWriteDsa1024EncryptedPkcs8_PasswordBytes()
+ public void ReadWriteDsa1024EncryptedPkcs8_PasswordBytes()
{
// pbeWithSHA1AndDES-CBC (PBES1)
ReadBase64EncryptedPkcs8(
@@ -193,7 +197,7 @@ public static void ReadWriteDsa1024EncryptedPkcs8_PasswordBytes()
}
[ConditionalFact(typeof(DSAKeyFileTests), nameof(SupportsFips186_3))]
- public static void ReadWriteDsa2048EncryptedPkcs8()
+ public void ReadWriteDsa2048EncryptedPkcs8()
{
ReadBase64EncryptedPkcs8(
@"
@@ -220,7 +224,7 @@ public static void ReadWriteDsa2048EncryptedPkcs8()
}
[ConditionalFact(typeof(DSAKeyFileTests), nameof(SupportsFips186_3))]
- public static void ReadWriteDsa2048DeficientXEncryptedPkcs8()
+ public void ReadWriteDsa2048DeficientXEncryptedPkcs8()
{
ReadBase64EncryptedPkcs8(
@"
@@ -247,7 +251,7 @@ public static void ReadWriteDsa2048DeficientXEncryptedPkcs8()
}
[Fact]
- public static void ReadWriteDsa576SubjectPublicKeyInfo()
+ public void ReadWriteDsa576SubjectPublicKeyInfo()
{
ReadWriteBase64SubjectPublicKeyInfo(
@"
@@ -261,7 +265,7 @@ public static void ReadWriteDsa576SubjectPublicKeyInfo()
}
[Fact]
- public static void ReadWriteDsa1024SubjectPublicKeyInfo()
+ public void ReadWriteDsa1024SubjectPublicKeyInfo()
{
ReadWriteBase64SubjectPublicKeyInfo(
@"
@@ -279,7 +283,7 @@ public static void ReadWriteDsa1024SubjectPublicKeyInfo()
}
[ConditionalFact(typeof(DSAKeyFileTests), nameof(SupportsFips186_3))]
- public static void ReadWriteDsa2048SubjectPublicKeyInfo()
+ public void ReadWriteDsa2048SubjectPublicKeyInfo()
{
ReadWriteBase64SubjectPublicKeyInfo(
@"
@@ -305,7 +309,7 @@ public static void ReadWriteDsa2048SubjectPublicKeyInfo()
}
[Fact]
- public static void ImportNonsensePublicParameters()
+ public void ImportNonsensePublicParameters()
{
AsnWriter writer = new AsnWriter(AsnEncodingRules.DER);
@@ -374,7 +378,7 @@ static void ImportSPKI(
}
[Fact]
- public static void ImportNonsensePrivateParameters()
+ public void ImportNonsensePrivateParameters()
{
AsnWriter writer = new AsnWriter(AsnEncodingRules.DER);
@@ -448,7 +452,7 @@ static void ImportPkcs8(
}
[Fact]
- public static void NoFuzzySubjectPublicKeyInfo()
+ public void NoFuzzySubjectPublicKeyInfo()
{
using (DSA key = DSAFactory.Create())
{
@@ -479,7 +483,7 @@ public static void NoFuzzySubjectPublicKeyInfo()
}
[Fact]
- public static void NoFuzzyPkcs8()
+ public void NoFuzzyPkcs8()
{
using (DSA key = DSAFactory.Create())
{
@@ -510,7 +514,7 @@ public static void NoFuzzyPkcs8()
}
[Fact]
- public static void NoFuzzyEncryptedPkcs8()
+ public void NoFuzzyEncryptedPkcs8()
{
using (DSA key = DSAFactory.Create())
{
@@ -535,7 +539,7 @@ public static void NoFuzzyEncryptedPkcs8()
}
[Fact]
- public static void NoPrivKeyFromPublicOnly()
+ public void NoPrivKeyFromPublicOnly()
{
using (DSA key = DSAFactory.Create())
{
@@ -564,7 +568,7 @@ public static void NoPrivKeyFromPublicOnly()
}
[Fact]
- public static void BadPbeParameters()
+ public void BadPbeParameters()
{
using (DSA key = DSAFactory.Create())
{
@@ -688,7 +692,7 @@ public static void BadPbeParameters()
}
[Fact]
- public static void DecryptPkcs12WithBytes()
+ public void DecryptPkcs12WithBytes()
{
using (DSA key = DSAFactory.Create())
{
@@ -711,7 +715,7 @@ public static void DecryptPkcs12WithBytes()
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/62547", TestPlatforms.Android)]
- public static void DecryptPkcs12PbeTooManyIterations()
+ public void DecryptPkcs12PbeTooManyIterations()
{
// pbeWithSHAAnd3-KeyTripleDES-CBC with 600,001 iterations
byte[] high3DesIterationKey = Convert.FromBase64String(@"
@@ -732,7 +736,7 @@ public static void DecryptPkcs12PbeTooManyIterations()
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/62547", TestPlatforms.Android)]
- public static void ReadWriteDsa1024EncryptedPkcs8_Pbes2HighIterations()
+ public void ReadWriteDsa1024EncryptedPkcs8_Pbes2HighIterations()
{
// pkcs5PBES2 hmacWithSHA256 aes128-CBC with 600,001 iterations
ReadBase64EncryptedPkcs8(@"
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyGeneration.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyGeneration.cs
index 6a14b9183efed7..a290aed2467b87 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyGeneration.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyGeneration.cs
@@ -6,13 +6,17 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public partial class DSAKeyGeneration
{
+ public DSAKeyGeneration()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
public static bool HasSecondMinSize { get; } = GetHasSecondMinSize();
[Fact]
- public static void VerifyDefaultKeySize_Fips186_2()
+ public void VerifyDefaultKeySize_Fips186_2()
{
if (!DSAFactory.SupportsFips186_3)
{
@@ -24,19 +28,19 @@ public static void VerifyDefaultKeySize_Fips186_2()
}
[Fact]
- public static void GenerateMinKey()
+ public void GenerateMinKey()
{
GenerateKey(dsa => GetMin(dsa.LegalKeySizes));
}
[ConditionalFact(typeof(DSAKeyGeneration), nameof(HasSecondMinSize))]
- public static void GenerateSecondMinKey()
+ public void GenerateSecondMinKey()
{
GenerateKey(dsa => GetSecondMin(dsa.LegalKeySizes));
}
[Fact]
- public static void GenerateKey_1024()
+ public void GenerateKey_1024()
{
GenerateKey(1024);
}
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyPemTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyPemTests.cs
index 86ae8ed1595efc..f74f978c835431 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyPemTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAKeyPemTests.cs
@@ -7,15 +7,19 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
- public static class DSAKeyPemTests
+ public class DSAKeyPemTests
{
+ public DSAKeyPemTests()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
private const string AmbiguousExceptionMarker = "multiple keys";
private const string EncryptedExceptionMarker = "encrypted key";
private const string NoPemExceptionMarker = "No supported key";
[Fact]
- public static void ImportFromPem_NoPem()
+ public void ImportFromPem_NoPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -26,7 +30,7 @@ public static void ImportFromPem_NoPem()
}
[Fact]
- public static void ImportFromPem_Pkcs8UnEncrypted_Simple()
+ public void ImportFromPem_Pkcs8UnEncrypted_Simple()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -46,7 +50,7 @@ public static void ImportFromPem_Pkcs8UnEncrypted_Simple()
}
[Fact]
- public static void ImportFromPem_Pkcs8UnEncrypted_IgnoresUnrelatedAlgorithm()
+ public void ImportFromPem_Pkcs8UnEncrypted_IgnoresUnrelatedAlgorithm()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -71,7 +75,7 @@ public static void ImportFromPem_Pkcs8UnEncrypted_IgnoresUnrelatedAlgorithm()
}
[Fact]
- public static void ImportFromPem_Pkcs8_UnrelatedPrecedingPem()
+ public void ImportFromPem_Pkcs8_UnrelatedPrecedingPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -94,7 +98,7 @@ public static void ImportFromPem_Pkcs8_UnrelatedPrecedingPem()
}
[Fact]
- public static void ImportFromPem_Pkcs8_PrecedingMalformedPem()
+ public void ImportFromPem_Pkcs8_PrecedingMalformedPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -117,7 +121,7 @@ public static void ImportFromPem_Pkcs8_PrecedingMalformedPem()
}
[Fact]
- public static void ImportFromPem_SubjectPublicKeyInfo_Simple()
+ public void ImportFromPem_SubjectPublicKeyInfo_Simple()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -133,12 +137,12 @@ public static void ImportFromPem_SubjectPublicKeyInfo_Simple()
dsa.ImportFromPem(pem);
DSAParameters dsaParameters = dsa.ExportParameters(false);
- DSAImportExport.AssertKeyEquals(DSATestData.Dsa512Parameters.ToPublic(), dsaParameters);
+ DSAImportExport.AssertKeyEquals(ToPublic(DSATestData.Dsa512Parameters), dsaParameters);
}
}
[Fact]
- public static void ImportFromPem_Pkcs8_AmbiguousKey_Pkcs8()
+ public void ImportFromPem_Pkcs8_AmbiguousKey_Pkcs8()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -163,7 +167,7 @@ public static void ImportFromPem_Pkcs8_AmbiguousKey_Pkcs8()
}
[Fact]
- public static void ImportFromPem_Pkcs8_AmbiguousKey_Spki()
+ public void ImportFromPem_Pkcs8_AmbiguousKey_Spki()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -189,7 +193,7 @@ public static void ImportFromPem_Pkcs8_AmbiguousKey_Spki()
}
[Fact]
- public static void ImportFromPem_Pkcs8_AmbiguousKey_EncryptedPkcs8()
+ public void ImportFromPem_Pkcs8_AmbiguousKey_EncryptedPkcs8()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -216,7 +220,7 @@ public static void ImportFromPem_Pkcs8_AmbiguousKey_EncryptedPkcs8()
}
[Fact]
- public static void ImportFromPem_EncryptedPrivateKeyFails()
+ public void ImportFromPem_EncryptedPrivateKeyFails()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -236,7 +240,7 @@ public static void ImportFromPem_EncryptedPrivateKeyFails()
}
[Fact]
- public static void ImportFromPem_SpkiAlgorithmMismatch_Throws()
+ public void ImportFromPem_SpkiAlgorithmMismatch_Throws()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -251,7 +255,7 @@ public static void ImportFromPem_SpkiAlgorithmMismatch_Throws()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_Encrypted_Char_Simple()
+ public void ImportFromEncryptedPem_Pkcs8_Encrypted_Char_Simple()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -273,7 +277,7 @@ public static void ImportFromEncryptedPem_Pkcs8_Encrypted_Char_Simple()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_Encrypted_Byte_Simple()
+ public void ImportFromEncryptedPem_Pkcs8_Encrypted_Byte_Simple()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -296,7 +300,7 @@ public static void ImportFromEncryptedPem_Pkcs8_Encrypted_Byte_Simple()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_Encrypted_AmbiguousPem()
+ public void ImportFromEncryptedPem_Pkcs8_Encrypted_AmbiguousPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -326,7 +330,7 @@ public static void ImportFromEncryptedPem_Pkcs8_Encrypted_AmbiguousPem()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_Byte_NoPem()
+ public void ImportFromEncryptedPem_Pkcs8_Byte_NoPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -338,7 +342,7 @@ public static void ImportFromEncryptedPem_Pkcs8_Byte_NoPem()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_Char_NoPem()
+ public void ImportFromEncryptedPem_Pkcs8_Char_NoPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -350,7 +354,7 @@ public static void ImportFromEncryptedPem_Pkcs8_Char_NoPem()
}
[Fact]
- public static void ImportFromEncryptedPem_Pkcs8_NoEncryptedPem()
+ public void ImportFromEncryptedPem_Pkcs8_NoEncryptedPem()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -368,7 +372,7 @@ public static void ImportFromEncryptedPem_Pkcs8_NoEncryptedPem()
}
}
- private static DSAParameters ToPublic(this DSAParameters dsaParams)
+ private static DSAParameters ToPublic(DSAParameters dsaParams)
{
dsaParams.X = null;
return dsaParams;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignVerify.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignVerify.cs
index 658fc5cdfc9a04..af9671a8d9417e 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignVerify.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignVerify.cs
@@ -7,9 +7,13 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public sealed class DSASignVerify_Array : DSASignVerify
{
+ public DSASignVerify_Array()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
public override byte[] SignData(DSA dsa, byte[] data, HashAlgorithmName hashAlgorithm) =>
dsa.SignData(data, hashAlgorithm);
public override bool VerifyData(DSA dsa, byte[] data, byte[] signature, HashAlgorithmName hashAlgorithm) =>
@@ -53,10 +57,17 @@ public void InvalidStreamArrayArguments_Throws()
}
}
}
-
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public sealed class DSASignVerify_Stream : DSASignVerify
{
+
+ public DSASignVerify_Stream()
+
+ {
+
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+
+ }
+
public override byte[] SignData(DSA dsa, byte[] data, HashAlgorithmName hashAlgorithm) =>
dsa.SignData(new MemoryStream(data), hashAlgorithm);
public override bool VerifyData(DSA dsa, byte[] data, byte[] signature, HashAlgorithmName hashAlgorithm) =>
@@ -76,9 +87,13 @@ public void InvalidArrayArguments_Throws()
}
#if NET
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public sealed class DSASignVerify_Span : DSASignVerify
{
+ public DSASignVerify_Span()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
public override byte[] SignData(DSA dsa, byte[] data, HashAlgorithmName hashAlgorithm) =>
TryWithOutputArray(dest => dsa.TrySignData(data, dest, hashAlgorithm, out int bytesWritten) ? (true, bytesWritten) : (false, 0));
@@ -109,9 +124,13 @@ private static byte[] TryWithOutputArray(Func func)
}
}
#endif
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public abstract partial class DSASignVerify
{
+ public DSASignVerify()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
public abstract byte[] SignData(DSA dsa, byte[] data, HashAlgorithmName hashAlgorithm);
public abstract bool VerifyData(DSA dsa, byte[] data, byte[] signature, HashAlgorithmName hashAlgorithm);
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatTests.cs
index 28ce3e7a0a60c0..eb4ed7ee5706ce 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatTests.cs
@@ -9,9 +9,13 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public abstract class DSASignatureFormatTests : DsaFamilySignatureFormatTests
{
+ public DSASignatureFormatTests()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
protected override bool SupportsSha2 => DSAFactory.SupportsFips186_3;
protected override string HashParameterName => "rgbHash";
protected override string SignatureParameterName => "rgbSignature";
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatter.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatter.cs
index 9b19f42d34a9c5..d8cc0e14c144ee 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatter.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSASignatureFormatter.cs
@@ -7,11 +7,15 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
public partial class DSASignatureFormatterTests : AsymmetricSignatureFormatterTests
{
+ public DSASignatureFormatterTests()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
[Fact]
- public static void VerifySignature_SHA1()
+ public void VerifySignature_SHA1()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -29,7 +33,7 @@ public static void VerifySignature_SHA1()
}
[Fact]
- public static void InvalidHashAlgorithm()
+ public void InvalidHashAlgorithm()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -51,7 +55,7 @@ public static void InvalidHashAlgorithm()
}
[Fact]
- public static void VerifyKnownSignature()
+ public void VerifyKnownSignature()
{
using (DSA dsa = DSAFactory.Create())
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAXml.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAXml.cs
index 4c6ea3050803f0..fca1031c212689 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAXml.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DSA/DSAXml.cs
@@ -8,11 +8,15 @@
namespace System.Security.Cryptography.Dsa.Tests
{
- [ConditionalClass(typeof(PlatformSupport), nameof(PlatformSupport.IsDSASupported))]
- public static class DSAXml
+ public class DSAXml
{
+ public DSAXml()
+ {
+ Assert.SkipUnless(PlatformSupport.IsDSASupported, "ConditionalClass: PlatformSupport.IsDSASupported");
+ }
+
[Fact]
- public static void TestRead512Parameters_Public()
+ public void TestRead512Parameters_Public()
{
DSAParameters expectedParameters = DSATestData.Dsa512Parameters;
expectedParameters.X = null;
@@ -30,7 +34,7 @@ public static void TestRead512Parameters_Public()
}
[Fact]
- public static void TestRead512Parameters_Private()
+ public void TestRead512Parameters_Private()
{
TestReadXml(
// Bonus trait of this XML, it shows that the order doesn't matter in the elements,
@@ -48,7 +52,7 @@ public static void TestRead512Parameters_Private()
}
[Fact]
- public static void TestRead576Parameters_Public()
+ public void TestRead576Parameters_Public()
{
DSAParameters expectedParameters = DSATestData.Dsa576Parameters;
expectedParameters.X = null;
@@ -78,7 +82,7 @@ public static void TestRead576Parameters_Public()
}
[Fact]
- public static void TestRead576Parameters_Private()
+ public void TestRead576Parameters_Private()
{
TestReadXml(
// Bonus trait of this XML: it shows the root element name is not considered.
@@ -108,7 +112,7 @@ public static void TestRead576Parameters_Private()
}
[Fact]
- public static void TestRead1024Parameters_Public()
+ public void TestRead1024Parameters_Public()
{
DSAParameters expectedParameters = DSATestData.GetDSA1024Params();
expectedParameters.X = null;
@@ -143,7 +147,7 @@ public static void TestRead1024Parameters_Public()
}
[Fact]
- public static void TestRead1024Parameters_Private()
+ public void TestRead1024Parameters_Private()
{
TestReadXml(
// Bonus trait of this XML: very odd whitespace
@@ -184,7 +188,7 @@ S 9 R / j 6 9 C v C
}
[ConditionalFact(typeof(DSAFactory), nameof(DSAFactory.SupportsFips186_3))]
- public static void TestRead2048Parameters_Public()
+ public void TestRead2048Parameters_Public()
{
DSAParameters expectedParameters = DSATestData.Dsa2048DeficientXParameters;
expectedParameters.X = null;
@@ -224,7 +228,7 @@ public static void TestRead2048Parameters_Public()
}
[ConditionalFact(typeof(DSAFactory), nameof(DSAFactory.SupportsFips186_3))]
- public static void TestRead2048Parameters_Private_CryptoBinary()
+ public void TestRead2048Parameters_Private_CryptoBinary()
{
TestReadXml(
// Bonus trait of this XML: The X parameter is encoded as a CryptoBinary,
@@ -262,7 +266,7 @@ public static void TestRead2048Parameters_Private_CryptoBinary()
}
[ConditionalFact(typeof(DSAFactory), nameof(DSAFactory.SupportsFips186_3))]
- public static void TestRead2048Parameters_Private_Base64Binary()
+ public void TestRead2048Parameters_Private_Base64Binary()
{
TestReadXml(
// Bonus trait of this XML: The X parameter is encoded as a Base64Binary,
@@ -302,7 +306,7 @@ public static void TestRead2048Parameters_Private_Base64Binary()
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void TestWrite512Parameters(bool includePrivateParameters)
+ public void TestWrite512Parameters(bool includePrivateParameters)
{
TestWriteXml(
DSATestData.Dsa512Parameters,
@@ -326,7 +330,7 @@ public static void TestWrite512Parameters(bool includePrivateParameters)
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void TestWrite576Parameters(bool includePrivateParameters)
+ public void TestWrite576Parameters(bool includePrivateParameters)
{
TestWriteXml(
DSATestData.Dsa576Parameters,
@@ -350,7 +354,7 @@ public static void TestWrite576Parameters(bool includePrivateParameters)
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void TestWrite1024Parameters(bool includePrivateParameters)
+ public void TestWrite1024Parameters(bool includePrivateParameters)
{
TestWriteXml(
DSATestData.GetDSA1024Params(),
@@ -377,7 +381,7 @@ public static void TestWrite1024Parameters(bool includePrivateParameters)
[ConditionalTheory(typeof(DSAFactory), nameof(DSAFactory.SupportsFips186_3))]
[InlineData(true)]
[InlineData(false)]
- public static void TestWriteDeficientXParameters(bool includePrivateParameters)
+ public void TestWriteDeficientXParameters(bool includePrivateParameters)
{
TestWriteXml(
DSATestData.Dsa2048DeficientXParameters,
@@ -417,7 +421,7 @@ public static void TestWriteDeficientXParameters(bool includePrivateParameters)
[Fact]
[OuterLoop("DSA key generation is very slow")]
- public static void FromToXml()
+ public void FromToXml()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -445,7 +449,7 @@ public static void FromToXml()
}
[Fact]
- public static void FromNullXml()
+ public void FromNullXml()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -456,7 +460,7 @@ public static void FromNullXml()
}
[Fact]
- public static void FromInvalidXml()
+ public void FromInvalidXml()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -474,7 +478,7 @@ public static void FromInvalidXml()
}
[Fact]
- public static void FromNonsenseXml()
+ public void FromNonsenseXml()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -506,7 +510,7 @@ public static void FromNonsenseXml()
}
[Fact]
- public static void FromXml_MissingP()
+ public void FromXml_MissingP()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -525,7 +529,7 @@ public static void FromXml_MissingP()
}
[Fact]
- public static void FromXml_MissingQ()
+ public void FromXml_MissingQ()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -544,7 +548,7 @@ public static void FromXml_MissingQ()
}
[Fact]
- public static void FromXml_MissingG()
+ public void FromXml_MissingG()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -563,7 +567,7 @@ public static void FromXml_MissingG()
}
[Fact]
- public static void FromXml_MissingY()
+ public void FromXml_MissingY()
{
using (DSA dsa = DSAFactory.Create())
{
@@ -582,7 +586,7 @@ public static void FromXml_MissingY()
}
[Fact]
- public static void FromXmlWithSeedAndCounterAndJ()
+ public void FromXmlWithSeedAndCounterAndJ()
{
// This key comes from FIPS-186-2, Appendix 5, Example of the DSA.
// The version in DSATestData does not have the seed or counter supplied.
@@ -616,7 +620,7 @@ public static void FromXmlWithSeedAndCounterAndJ()
}
[Fact]
- public static void FromXmlWrongJ_OK()
+ public void FromXmlWrongJ_OK()
{
// No one really reads the J value on import, but xmldsig defined it,
// so we read it.
@@ -653,7 +657,7 @@ public static void FromXmlWrongJ_OK()
}
[Fact]
- public static void FromXmlInvalidJ_Fails()
+ public void FromXmlInvalidJ_Fails()
{
// No one really reads the J value on import, but xmldsig defined it,
// so we read it and pass it to ImportParameters.
@@ -689,7 +693,7 @@ public static void FromXmlInvalidJ_Fails()
}
[Fact]
- public static void FromXmlWrongCounter_SometimesOK()
+ public void FromXmlWrongCounter_SometimesOK()
{
// DSACryptoServiceProvider doesn't check this error state, DSACng does.
//
@@ -741,7 +745,7 @@ public static void FromXmlWrongCounter_SometimesOK()
}
[Fact]
- public static void FromXml_CounterOverflow_Succeeds()
+ public void FromXml_CounterOverflow_Succeeds()
{
// The counter value should be 105 (0x69).
// This payload says 0x01_00000069 (4294967401).
@@ -779,7 +783,7 @@ public static void FromXml_CounterOverflow_Succeeds()
}
[Fact]
- public static void FromXmlSeedWithoutCounter()
+ public void FromXmlSeedWithoutCounter()
{
// This key comes from FIPS-186-2, Appendix 5, Example of the DSA.
// The version in DSATestData does not have the seed or counter supplied.
@@ -810,7 +814,7 @@ public static void FromXmlSeedWithoutCounter()
}
[Fact]
- public static void FromXmlCounterWithoutSeed()
+ public void FromXmlCounterWithoutSeed()
{
// This key comes from FIPS-186-2, Appendix 5, Example of the DSA.
// The version in DSATestData does not have the seed or counter supplied.
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.cs
index da6b507994cd2b..2ff99df4bbe5c6 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.cs
@@ -9,6 +9,7 @@
using System.Text;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
+using Xunit.Sdk;
namespace System.Security.Cryptography.EcDsa.Tests
{
@@ -167,10 +168,10 @@ protected byte[] SignData(ECDsa ecdsa, byte[] data, HashAlgorithmName hashAlgori
protected abstract byte[] SignData(ECDsa ecdsa, byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
protected virtual byte[] SignHash(ECDsa ecdsa, byte[] hash, int offset, int count) =>
- throw new SkipTestException("SignHash not implemented.");
+ throw SkipException.ForSkip("SignHash not implemented.");
protected virtual bool VerifyHash(ECDsa ecdsa, byte[] hash, int offset, int count, byte[] signature) =>
- throw new SkipTestException("VerifyHash not implemented.");
+ throw SkipException.ForSkip("VerifyHash not implemented.");
public static IEnumerable RealImplementations() =>
new[] {
@@ -235,7 +236,7 @@ protected virtual void UseAfterDispose(ECDsa ecdsa, byte[] data, byte[] sig)
() => VerifyData(ecdsa, data, sig, HashAlgorithmName.SHA256));
}
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(RealImplementations))]
public void SignHash_Roundtrip(ECDsa ecdsa)
{
@@ -245,7 +246,7 @@ public void SignHash_Roundtrip(ECDsa ecdsa)
Assert.True(VerifyHash(ecdsa, hash, 0, hash.Length, signature), nameof(VerifyHash));
}
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(RealImplementations))]
public void SignHash_TamperedSignature(ECDsa ecdsa)
{
@@ -257,7 +258,7 @@ public void SignHash_TamperedSignature(ECDsa ecdsa)
Assert.False(VerifyHash(ecdsa, hash, 0, hash.Length, signature), nameof(VerifyHash));
}
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(RealImplementations))]
public void SignHash_DifferentHashes(ECDsa ecdsa)
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.netcoreapp.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.netcoreapp.cs
index 6c53a870aae00e..4a8e715cdc15ae 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.netcoreapp.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.netcoreapp.cs
@@ -187,7 +187,7 @@ public void KeySizeProp()
}
}
- [Theory, MemberData(nameof(TestNewCurves))]
+ [ConditionalTheory(typeof(ECDsaTests), nameof(ECExplicitCurvesSupported)), MemberData(nameof(TestNewCurves))]
public void TestRegenKeyExplicit(CurveDef curveDef)
{
ECParameters param, param2;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaCngTests.Windows.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaCngTests.Windows.cs
index 6265ab1cbb8d13..8150f2b4fd1ec2 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaCngTests.Windows.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaCngTests.Windows.cs
@@ -7,10 +7,14 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLDsa), nameof(MLDsa.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MLDsaCngTests_AllowPlaintextExport : MLDsaTestsBase
{
+ public MLDsaCngTests_AllowPlaintextExport()
+ {
+ Assert.SkipUnless(MLDsa.IsSupported, "ConditionalClass: MLDsa.IsSupported");
+ }
+
protected override MLDsa GenerateKey(MLDsaAlgorithm algorithm) =>
MLDsaTestHelpers.GenerateKey(algorithm, CngExportPolicies.AllowExport | CngExportPolicies.AllowPlaintextExport);
@@ -26,11 +30,18 @@ protected override MLDsa ImportPublicKey(MLDsaAlgorithm algorithm, ReadOnlySpan<
protected override void AssertExportPkcs8FromPublicKey(Action export) =>
MLDsaTestHelpers.AssertThrowsCryptographicExceptionWithHResult(export);
}
-
- [ConditionalClass(typeof(MLDsa), nameof(MLDsa.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MLDsaCngTests_AllowExport : MLDsaTestsBase
{
+
+ public MLDsaCngTests_AllowExport()
+
+ {
+
+ Assert.SkipUnless(MLDsa.IsSupported, "ConditionalClass: MLDsa.IsSupported");
+
+ }
+
protected override MLDsa GenerateKey(MLDsaAlgorithm algorithm) =>
MLDsaTestHelpers.GenerateKey(algorithm, CngExportPolicies.AllowExport);
@@ -46,11 +57,18 @@ protected override MLDsa ImportPublicKey(MLDsaAlgorithm algorithm, ReadOnlySpan<
protected override void AssertExportPkcs8FromPublicKey(Action export) =>
MLDsaTestHelpers.AssertThrowsCryptographicExceptionWithHResult(export);
}
-
- [ConditionalClass(typeof(MLDsa), nameof(MLDsa.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MLDsaCngTests
{
+
+ public MLDsaCngTests()
+
+ {
+
+ Assert.SkipUnless(MLDsa.IsSupported, "ConditionalClass: MLDsa.IsSupported");
+
+ }
+
[Theory]
[MemberData(nameof(MLDsaTestsData.IetfMLDsaAlgorithms), MemberType = typeof(MLDsaTestsData))]
public void ImportPrivateKey_NoExportFlag(MLDsaKeyInfo info)
@@ -236,7 +254,7 @@ public void MLDsaCng_DuplicateHandle(string? name)
}
[Fact]
- public static void MLDsaCng_GetKey()
+ public void MLDsaCng_GetKey()
{
CngProperty parameterSet = MLDsaTestHelpers.GetCngProperty(MLDsaAlgorithm.MLDsa65);
CngKeyCreationParameters creationParams = new();
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaImplementationTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaImplementationTests.cs
index 425834743c014c..81edf8eb932e80 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaImplementationTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaImplementationTests.cs
@@ -127,7 +127,7 @@ public static void ImportEncrypted_NullPassword()
}
[Fact]
- public static void UseAfterDispose()
+ public void UseAfterDispose()
{
MLDsa mldsa = MLDsa.GenerateKey(MLDsaAlgorithm.MLDsa44);
mldsa.Dispose();
@@ -178,7 +178,7 @@ public static void ImportSpki_BerEncoding()
}
[Fact]
- public static void ImportPkcs8_BerEncoding()
+ public void ImportPkcs8_BerEncoding()
{
// Seed is DER encoded, so create a BER encoding from it by making it use indefinite length encoding.
byte[] seedPkcs8 = MLDsaTestsData.IetfMLDsa44.Pkcs8PrivateKey_Seed;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs
index 848ce919fe025c..548ecc8d5ebd74 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs
@@ -8,9 +8,13 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLDsa), nameof(MLDsa.IsSupported))]
public abstract class MLDsaTestsBase
{
+ public MLDsaTestsBase()
+ {
+ Assert.SkipUnless(MLDsa.IsSupported, "ConditionalClass: MLDsa.IsSupported");
+ }
+
protected abstract MLDsa GenerateKey(MLDsaAlgorithm algorithm);
protected abstract MLDsa ImportPrivateSeed(MLDsaAlgorithm algorithm, ReadOnlySpan seed);
protected abstract MLDsa ImportPrivateKey(MLDsaAlgorithm algorithm, ReadOnlySpan source);
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherOneShotTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherOneShotTests.cs
index 7e22c1a02e998f..342b7ab0f172c6 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherOneShotTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherOneShotTests.cs
@@ -10,9 +10,13 @@
namespace System.Security.Cryptography.Encryption.RC2.Tests
{
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
- [ConditionalClass(typeof(RC2Factory), nameof(RC2Factory.IsSupported))]
public class RC2CipherOneShotTests : SymmetricOneShotBase
{
+ public RC2CipherOneShotTests()
+ {
+ Assert.SkipUnless(RC2Factory.IsSupported, "ConditionalClass: RC2Factory.IsSupported");
+ }
+
protected override byte[] Key => new byte[]
{
0x83, 0x2F, 0x81, 0x1B, 0x61, 0x02, 0xCC, 0x8F,
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherTests.cs
index a1e2409c360919..3bf4fb64da4d4d 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RC2/RC2CipherTests.cs
@@ -11,9 +11,13 @@ namespace System.Security.Cryptography.Encryption.RC2.Tests
using RC2 = System.Security.Cryptography.RC2;
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
- [ConditionalClass(typeof(RC2Factory), nameof(RC2Factory.IsSupported))]
- public static partial class RC2CipherTests
+ public partial class RC2CipherTests
{
+ public RC2CipherTests()
+ {
+ Assert.SkipUnless(RC2Factory.IsSupported, "ConditionalClass: RC2Factory.IsSupported");
+ }
+
// These are the expected output of many decryptions. Changing these values requires re-generating test input.
private static readonly string s_multiBlockString = new ASCIIEncoding().GetBytes(
"This is a sentence that is longer than a block, it ensures that multi-block functions work.").ByteArrayToHex();
@@ -142,7 +146,7 @@ public static IEnumerable RC2TestData
}
[Theory, MemberData(nameof(RC2TestData))]
- public static void RC2RoundTrip(CipherMode cipherMode, PaddingMode paddingMode, string key, string iv, string textHex, string expectedDecrypted, string expectedEncrypted)
+ public void RC2RoundTrip(CipherMode cipherMode, PaddingMode paddingMode, string key, string iv, string textHex, string expectedDecrypted, string expectedEncrypted)
{
byte[] expectedDecryptedBytes = expectedDecrypted == null ? textHex.HexToByteArray() : expectedDecrypted.HexToByteArray();
byte[] expectedEncryptedBytes = expectedEncrypted.HexToByteArray();
@@ -188,7 +192,7 @@ public static void RC2RoundTrip(CipherMode cipherMode, PaddingMode paddingMode,
[Theory]
[InlineData(CipherMode.CBC, 0)]
[InlineData(CipherMode.ECB, 0)]
- public static void EncryptorReuse_LeadsToSameResults(CipherMode cipherMode, int feedbackSize)
+ public void EncryptorReuse_LeadsToSameResults(CipherMode cipherMode, int feedbackSize)
{
// AppleCCCryptor does not allow calling Reset on CFB cipher.
// this test validates that the behavior is taken into consideration.
@@ -216,7 +220,7 @@ public static void EncryptorReuse_LeadsToSameResults(CipherMode cipherMode, int
[Theory]
[InlineData(CipherMode.CBC, 0)]
[InlineData(CipherMode.ECB, 0)]
- public static void DecryptorReuse_LeadsToSameResults(CipherMode cipherMode, int feedbackSize)
+ public void DecryptorReuse_LeadsToSameResults(CipherMode cipherMode, int feedbackSize)
{
// AppleCCCryptor does not allow calling Reset on CFB cipher.
// this test validates that the behavior is taken into consideration.
@@ -247,7 +251,7 @@ public static void DecryptorReuse_LeadsToSameResults(CipherMode cipherMode, int
}
[Fact]
- public static void RC2ReuseEncryptorDecryptor()
+ public void RC2ReuseEncryptorDecryptor()
{
using (RC2 alg = RC2Factory.Create())
{
@@ -288,7 +292,7 @@ public static void RC2ReuseEncryptorDecryptor()
}
[Fact]
- public static void RC2ExplicitEncryptorDecryptor_WithIV()
+ public void RC2ExplicitEncryptorDecryptor_WithIV()
{
using (RC2 alg = RC2Factory.Create())
{
@@ -307,7 +311,7 @@ public static void RC2ExplicitEncryptorDecryptor_WithIV()
}
[Fact]
- public static void RC2ExplicitEncryptorDecryptor_NoIV()
+ public void RC2ExplicitEncryptorDecryptor_NoIV()
{
using (RC2 alg = RC2Factory.Create())
{
@@ -328,7 +332,7 @@ public static void RC2ExplicitEncryptorDecryptor_NoIV()
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void EncryptWithLargeOutputBuffer(bool blockAlignedOutput)
+ public void EncryptWithLargeOutputBuffer(bool blockAlignedOutput)
{
using (RC2 alg = RC2Factory.Create())
using (ICryptoTransform xform = alg.CreateEncryptor())
@@ -357,7 +361,7 @@ public static void EncryptWithLargeOutputBuffer(bool blockAlignedOutput)
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
- public static void TransformWithTooShortOutputBuffer(bool encrypt, bool blockAlignedOutput)
+ public void TransformWithTooShortOutputBuffer(bool encrypt, bool blockAlignedOutput)
{
using (RC2 alg = RC2Factory.Create())
using (ICryptoTransform xform = encrypt ? alg.CreateEncryptor() : alg.CreateDecryptor())
@@ -378,7 +382,7 @@ public static void TransformWithTooShortOutputBuffer(bool encrypt, bool blockAli
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void MultipleBlockDecryptTransform(bool blockAlignedOutput)
+ public void MultipleBlockDecryptTransform(bool blockAlignedOutput)
{
const string ExpectedOutput = "This is a test";
@@ -404,7 +408,7 @@ public static void MultipleBlockDecryptTransform(bool blockAlignedOutput)
}
[Fact]
- public static void SetKey_Sanity()
+ public void SetKey_Sanity()
{
using (RC2 one = RC2Factory.Create())
using (RC2 two = RC2Factory.Create())
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs
index c4e33527cdc277..3e788cb4a3b6e2 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs
@@ -1433,15 +1433,12 @@ public void PssSignature_WrongLength()
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(true)]
[InlineData(false)]
public void SignHash_NullSignature_Fails(bool usePss)
{
- if (!SupportsPss)
- {
- throw new SkipTestException("Platform does not support PSS");
- }
+ Assert.SkipUnless(SupportsPss, "Platform does not support PSS");
RSASignaturePadding padding = usePss ? RSASignaturePadding.Pss : RSASignaturePadding.Pkcs1;
@@ -1464,15 +1461,12 @@ public void SignHash_NullSignature_Fails(bool usePss)
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(true)]
[InlineData(false)]
public void SignData_NullSignature_Fails(bool usePss)
{
- if (!SupportsPss)
- {
- throw new SkipTestException("Platform does not support PSS");
- }
+ Assert.SkipUnless(SupportsPss, "Platform does not support PSS");
RSASignaturePadding padding = usePss ? RSASignaturePadding.Pss : RSASignaturePadding.Pkcs1;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
index 8a20ca3b1be8de..860fb894744106 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
@@ -10,19 +10,23 @@
namespace System.Security.Cryptography.SLHDsa.Tests
{
- [ConditionalClass(typeof(SlhDsa), nameof(SlhDsa.IsSupported))]
public sealed class SlhDsaImplementationTests : SlhDsaTests
{
+ public SlhDsaImplementationTests()
+ {
+ Assert.SkipUnless(SlhDsa.IsSupported, "ConditionalClass: SlhDsa.IsSupported");
+ }
+
[Theory]
[MemberData(nameof(SlhDsaTestData.AlgorithmsData), MemberType = typeof(SlhDsaTestData))]
- public static void SlhDsaIsOnlyPublicAncestor_GenerateKey(SlhDsaAlgorithm algorithm)
+ public void SlhDsaIsOnlyPublicAncestor_GenerateKey(SlhDsaAlgorithm algorithm)
{
AssertSlhDsaIsOnlyPublicAncestor(() => SlhDsa.GenerateKey(algorithm));
}
[Theory]
[MemberData(nameof(SlhDsaTestData.GeneratedKeyInfosData), MemberType = typeof(SlhDsaTestData))]
- public static void SlhDsaIsOnlyPublicAncestor_Import(SlhDsaTestData.SlhDsaGeneratedKeyInfo info)
+ public void SlhDsaIsOnlyPublicAncestor_Import(SlhDsaTestData.SlhDsaGeneratedKeyInfo info)
{
// Tests ImportPublicKey, ImportSPKI, ImportPem (with PUBLIC KEY)
SlhDsaTestHelpers.AssertImportPublicKey(
@@ -308,7 +312,7 @@ public void RoundTrip_Import_Export_Pkcs8PublicKeyPem(SlhDsaTestData.SlhDsaGener
#region IETF samples
[Fact]
- public static void ImportPkcs8PrivateKeyIetf()
+ public void ImportPkcs8PrivateKeyIetf()
{
using SlhDsa slhDsa = SlhDsa.ImportPkcs8PrivateKey(SlhDsaTestData.IetfSlhDsaSha2_128sPrivateKeyPkcs8);
Assert.Equal(SlhDsaAlgorithm.SlhDsaSha2_128s, slhDsa.Algorithm);
@@ -318,7 +322,7 @@ public static void ImportPkcs8PrivateKeyIetf()
}
[Fact]
- public static void ImportPkcs8PublicKeyIetf()
+ public void ImportPkcs8PublicKeyIetf()
{
using SlhDsa slhDsa = SlhDsa.ImportSubjectPublicKeyInfo(SlhDsaTestData.IetfSlhDsaSha2_128sPublicKeyPkcs8);
Assert.Equal(SlhDsaAlgorithm.SlhDsaSha2_128s, slhDsa.Algorithm);
@@ -328,7 +332,7 @@ public static void ImportPkcs8PublicKeyIetf()
}
[Fact]
- public static void ImportPemPrivateKeyIetf()
+ public void ImportPemPrivateKeyIetf()
{
string pem = PemEncoding.WriteString("PRIVATE KEY", SlhDsaTestData.IetfSlhDsaSha2_128sPrivateKeyPkcs8);
using SlhDsa slhDsa = SlhDsa.ImportFromPem(pem);
@@ -339,7 +343,7 @@ public static void ImportPemPrivateKeyIetf()
}
[Fact]
- public static void ImportPemPublicKeyIetf()
+ public void ImportPemPublicKeyIetf()
{
string pem = PemEncoding.WriteString("PUBLIC KEY", SlhDsaTestData.IetfSlhDsaSha2_128sPublicKeyPkcs8);
using SlhDsa slhDsa = SlhDsa.ImportFromPem(pem);
@@ -397,7 +401,7 @@ public void NistKeyGenerationTest(SlhDsaTestData.SlhDsaKeyGenTestVector vector)
#endregion NIST test vectors
[Fact]
- public static void ImportPkcs8_BerEncoding()
+ public void ImportPkcs8_BerEncoding()
{
// Private key is DER encoded, so create a BER encoding from it by making it use indefinite length encoding.
byte[] privateKeyPkcs8 = SlhDsaTestData.IetfSlhDsaSha2_128sPrivateKeyPkcs8;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/Symmetric/SymmetricOneShotBase.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/Symmetric/SymmetricOneShotBase.cs
index d30a8bb7c22557..9bbac9c6bd31c3 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/Symmetric/SymmetricOneShotBase.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/Symmetric/SymmetricOneShotBase.cs
@@ -419,15 +419,12 @@ public void DerivedTypesDefineTest()
Assert.Empty(missingMethods);
}
- [ConditionalFact]
+ [Fact]
public void DecryptOneShot_Cfb8_ToleratesExtraPadding()
{
using (SymmetricAlgorithm alg = CreateAlgorithm())
{
- if (alg is RC2)
- {
- throw new SkipTestException("RC2 does not support CFB.");
- }
+ Assert.SkipWhen(alg is RC2, "RC2 does not support CFB.");
alg.Key = Key;
@@ -498,7 +495,7 @@ public void DecryptOneShot_Ecb_InvalidPadding_DoesNotContainPlaintext(PaddingMod
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(PaddingMode.PKCS7, 0)]
[InlineData(PaddingMode.ANSIX923, 0)]
[InlineData(PaddingMode.ISO10126, 0)]
@@ -509,10 +506,7 @@ public void DecryptOneShot_Cfb_InvalidPadding_DoesNotContainPlaintext(PaddingMod
{
using (SymmetricAlgorithm alg = CreateAlgorithm())
{
- if (alg is RC2)
- {
- throw new SkipTestException("RC2 does not support CFB.");
- }
+ Assert.SkipWhen(alg is RC2, "RC2 does not support CFB.");
alg.Key = Key;
int size = ciphertextSize > 0 ? ciphertextSize : alg.BlockSize / 8;
@@ -553,7 +547,7 @@ public void DecryptOneShot_Cbc_TooShortDoesNotContainPlaintext(PaddingMode paddi
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(PaddingMode.PKCS7)]
[InlineData(PaddingMode.ANSIX923)]
[InlineData(PaddingMode.ISO10126)]
@@ -561,10 +555,7 @@ public void DecryptOneShot_Cfb8_TooShortDoesNotContainPlaintext(PaddingMode padd
{
using (SymmetricAlgorithm alg = CreateAlgorithm())
{
- if (alg is RC2)
- {
- throw new SkipTestException("RC2 does not support CFB.");
- }
+ Assert.SkipWhen(alg is RC2, "RC2 does not support CFB.");
alg.Key = Key;
int size = 2048;
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemCngTests.Windows.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemCngTests.Windows.cs
index ceb27987f3a11b..d38df8e0a30366 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemCngTests.Windows.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemCngTests.Windows.cs
@@ -10,29 +10,40 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MLKemCngPlaintextExportableTests : MLKemCngTests
{
+ public MLKemCngPlaintextExportableTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
protected override CngExportPolicies ExportPolicies => CngExportPolicies.AllowExport | CngExportPolicies.AllowPlaintextExport;
}
// ML-KEM as of Windows build 27881 does not have PKCS#8 exports, so we cannot implement encrypted exports.
[ActiveIssue("https://github.com/dotnet/runtime/issues/116304")]
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MLKemCngExportableTests : MLKemCngTests
{
+ public MLKemCngExportableTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
protected override CngExportPolicies ExportPolicies => CngExportPolicies.AllowExport;
}
-
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
- public static class MLKemCngNonExportableTests
+ public class MLKemCngNonExportableTests
{
+ public MLKemCngNonExportableTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void MLKemCng_NonExportable_ExportPrivateSeedThrows(MLKemAlgorithm algorithm)
+ public void MLKemCng_NonExportable_ExportPrivateSeedThrows(MLKemAlgorithm algorithm)
{
using CngKey key = MLKemCngTests.GenerateCngKey(algorithm, CngExportPolicies.None);
using MLKemCng kem = new MLKemCng(key);
@@ -41,7 +52,7 @@ public static void MLKemCng_NonExportable_ExportPrivateSeedThrows(MLKemAlgorithm
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void MLKemCng_NonExportable_ExportDecapsulationKeyThrows(MLKemAlgorithm algorithm)
+ public void MLKemCng_NonExportable_ExportDecapsulationKeyThrows(MLKemAlgorithm algorithm)
{
using CngKey key = MLKemCngTests.GenerateCngKey(algorithm, CngExportPolicies.None);
using MLKemCng kem = new MLKemCng(key);
@@ -49,7 +60,7 @@ public static void MLKemCng_NonExportable_ExportDecapsulationKeyThrows(MLKemAlgo
}
[Fact]
- public static void MLKemCng_NonExportable_ExportEncapsulationKeyAlwaysWorks()
+ public void MLKemCng_NonExportable_ExportEncapsulationKeyAlwaysWorks()
{
using CngKey key = MLKemCngTests.ImportPrivateSeed(
MLKemAlgorithm.MLKem512,
@@ -61,19 +72,22 @@ public static void MLKemCng_NonExportable_ExportEncapsulationKeyAlwaysWorks()
AssertExtensions.SequenceEqual(MLKemTestData.MLKem512EncapsulationKey, exportedKey);
}
}
-
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
[PlatformSpecific(TestPlatforms.Windows)]
- public static class MLKemCngContractTests
+ public class MLKemCngContractTests
{
+ public MLKemCngContractTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
[Fact]
- public static void MLKemCng_Ctor_ArgValidation()
+ public void MLKemCng_Ctor_ArgValidation()
{
AssertExtensions.Throws("key", static () => new MLKemCng(null));
}
[Fact]
- public static void MLKemCng_Ctor_KeyWrongAlgorithm()
+ public void MLKemCng_Ctor_KeyWrongAlgorithm()
{
using CngKey rsaKey = CngKey.Create(CngAlgorithm.Rsa, keyName: null);
AssertExtensions.Throws("key", () => new MLKemCng(rsaKey));
@@ -81,7 +95,7 @@ public static void MLKemCng_Ctor_KeyWrongAlgorithm()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void MLKemCng_GetKey(MLKemAlgorithm algorithm)
+ public void MLKemCng_GetKey(MLKemAlgorithm algorithm)
{
using CngKey key = MLKemCngTests.GenerateCngKey(
algorithm,
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemImplementationTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemImplementationTests.cs
index 9b031d61700c73..b0b04b0a4eb6fa 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemImplementationTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemImplementationTests.cs
@@ -7,9 +7,13 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
public class MLKemImplementationTests : MLKemBaseTests
{
+ public MLKemImplementationTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
public override MLKem GenerateKey(MLKemAlgorithm algorithm)
{
return MLKem.GenerateKey(algorithm);
@@ -31,12 +35,9 @@ public override MLKem ImportEncapsulationKey(MLKemAlgorithm algorithm, ReadOnlyS
}
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
- public static void IsSupported_InitializesCrypto()
+ public void IsSupported_InitializesCrypto()
{
- if (!MLKem.IsSupported)
- {
- throw new SkipTestException("Algorithm is not supported on current platform.");
- }
+ Assert.SkipUnless(MLKem.IsSupported, "Algorithm is not supported on current platform.");
// This ensures that ML-KEM is the first cryptographic algorithm touched in the process, which kicks off
// the initialization of the crypto layer on some platforms. Running in a remote executor ensures no other
@@ -48,7 +49,7 @@ public static void IsSupported_InitializesCrypto()
}
[Fact]
- public static void IsSupported_AgreesWithPlatform()
+ public void IsSupported_AgreesWithPlatform()
{
Assert.Equal(PlatformSupportsMLKem(), MLKem.IsSupported);
}
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemKeyTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemKeyTests.cs
index 418e4a587f64e2..c0abdb670e35e4 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemKeyTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemKeyTests.cs
@@ -10,12 +10,16 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
- public static class MLKemKeyTests
+ public class MLKemKeyTests
{
+ public MLKemKeyTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void Generate_Roundtrip(MLKemAlgorithm algorithm)
+ public void Generate_Roundtrip(MLKemAlgorithm algorithm)
{
using MLKem kem = MLKem.GenerateKey(algorithm);
Assert.Equal(algorithm, kem.Algorithm);
@@ -36,7 +40,7 @@ public static void Generate_Roundtrip(MLKemAlgorithm algorithm)
}
[Fact]
- public static void Generate_NistVectors_Span()
+ public void Generate_NistVectors_Span()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
@@ -55,7 +59,7 @@ public static void Generate_NistVectors_Span()
}
[Fact]
- public static void Generate_NistVectors_Array()
+ public void Generate_NistVectors_Array()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
@@ -72,7 +76,7 @@ public static void Generate_NistVectors_Array()
}
[Fact]
- public static void ImportEncapsulationKey_Array_Roundtrip()
+ public void ImportEncapsulationKey_Array_Roundtrip()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
@@ -86,7 +90,7 @@ public static void ImportEncapsulationKey_Array_Roundtrip()
}
[Fact]
- public static void ImportEncapsulationKey_Span_Roundtrip()
+ public void ImportEncapsulationKey_Span_Roundtrip()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
@@ -101,7 +105,7 @@ public static void ImportEncapsulationKey_Span_Roundtrip()
}
[Fact]
- public static void ImportDecapsulationKey_Span_Roundtrip()
+ public void ImportDecapsulationKey_Span_Roundtrip()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
@@ -121,7 +125,7 @@ public static void ImportDecapsulationKey_Span_Roundtrip()
}
[Fact]
- public static void ImportDecapsulationKey_Array_Roundtrip()
+ public void ImportDecapsulationKey_Array_Roundtrip()
{
foreach (MLKemGenerateTestVector vector in MLKemGenerateTestVectors)
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemNotSupportedTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemNotSupportedTests.cs
index 8f9610cdf049b3..b8e2a87cab2adf 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemNotSupportedTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemNotSupportedTests.cs
@@ -6,21 +6,25 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLKemNotSupportedTests), nameof(MLKemNotSupportedTests.IsNotSupported))]
- public static class MLKemNotSupportedTests
+ public class MLKemNotSupportedTests
{
+ public MLKemNotSupportedTests()
+ {
+ Assert.SkipUnless(MLKemNotSupportedTests.IsNotSupported, "ConditionalClass: MLKemNotSupportedTests.IsNotSupported");
+ }
+
public static bool IsNotSupported => !MLKem.IsSupported;
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void Generate_NotSupported(MLKemAlgorithm algorithm)
+ public void Generate_NotSupported(MLKemAlgorithm algorithm)
{
Assert.Throws(() => MLKem.GenerateKey(algorithm));
}
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPrivateSeed_NotSupported(MLKemAlgorithm algorithm)
+ public void ImportPrivateSeed_NotSupported(MLKemAlgorithm algorithm)
{
Assert.Throws(() =>
MLKem.ImportPrivateSeed(algorithm, new byte[algorithm.PrivateSeedSizeInBytes]));
@@ -30,7 +34,7 @@ public static void ImportPrivateSeed_NotSupported(MLKemAlgorithm algorithm)
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_NotSupported()
+ public void ImportSubjectPublicKeyInfo_NotSupported()
{
Assert.Throws(() =>
MLKem.ImportSubjectPublicKeyInfo(MLKemTestData.IetfMlKem512Spki));
@@ -41,7 +45,7 @@ public static void ImportSubjectPublicKeyInfo_NotSupported()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportEncapsulationKey_NotSupported(MLKemAlgorithm algorithm)
+ public void ImportEncapsulationKey_NotSupported(MLKemAlgorithm algorithm)
{
Assert.Throws(() => MLKem.ImportEncapsulationKey(
algorithm,
@@ -54,7 +58,7 @@ public static void ImportEncapsulationKey_NotSupported(MLKemAlgorithm algorithm)
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportDecapsulationKey_NotSupported(MLKemAlgorithm algorithm)
+ public void ImportDecapsulationKey_NotSupported(MLKemAlgorithm algorithm)
{
Assert.Throws(() => MLKem.ImportDecapsulationKey(
algorithm,
@@ -66,7 +70,7 @@ public static void ImportDecapsulationKey_NotSupported(MLKemAlgorithm algorithm)
}
[Fact]
- public static void ImportPkcs8PrivateKey_NotSupported()
+ public void ImportPkcs8PrivateKey_NotSupported()
{
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(
MLKemTestData.IetfMlKem512PrivateKeySeed));
@@ -76,7 +80,7 @@ public static void ImportPkcs8PrivateKey_NotSupported()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_NotSupported()
+ public void ImportEncryptedPkcs8PrivateKey_NotSupported()
{
Assert.Throws(() => MLKem.ImportEncryptedPkcs8PrivateKey(
MLKemTestData.EncryptedPrivateKeyPassword, MLKemTestData.IetfMlKem512EncryptedPrivateKeySeed));
@@ -89,7 +93,7 @@ public static void ImportEncryptedPkcs8PrivateKey_NotSupported()
}
[Fact]
- public static void ImportFromPem_NotSupported()
+ public void ImportFromPem_NotSupported()
{
string pem = """
-----BEGIN THING-----
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs
index d88209dff2705b..2259ce61bd6924 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs
@@ -11,19 +11,23 @@
namespace System.Security.Cryptography.Tests
{
- [ConditionalClass(typeof(MLKem), nameof(MLKem.IsSupported))]
- public static class MLKemTests
+ public class MLKemTests
{
+ public MLKemTests()
+ {
+ Assert.SkipUnless(MLKem.IsSupported, "ConditionalClass: MLKem.IsSupported");
+ }
+
private static readonly byte[] s_asnNull = new byte[] { 0x05, 0x00 };
[Fact]
- public static void Generate_NullAlgorithm()
+ public void Generate_NullAlgorithm()
{
AssertExtensions.Throws("algorithm", static () => MLKem.GenerateKey(null));
}
[Fact]
- public static void ImportPrivateSeed_NullAlgorithm()
+ public void ImportPrivateSeed_NullAlgorithm()
{
AssertExtensions.Throws("algorithm", static () =>
MLKem.ImportPrivateSeed(null, new byte[MLKemAlgorithm.MLKem512.PrivateSeedSizeInBytes]));
@@ -33,7 +37,7 @@ public static void ImportPrivateSeed_NullAlgorithm()
}
[Fact]
- public static void ImportPrivateSeed_NullSource()
+ public void ImportPrivateSeed_NullSource()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportPrivateSeed(MLKemAlgorithm.MLKem512, null));
@@ -41,7 +45,7 @@ public static void ImportPrivateSeed_NullSource()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPrivateSeed_WrongSize_Array(MLKemAlgorithm algorithm)
+ public void ImportPrivateSeed_WrongSize_Array(MLKemAlgorithm algorithm)
{
AssertExtensions.Throws("source", () =>
MLKem.ImportPrivateSeed(algorithm, new byte[algorithm.PrivateSeedSizeInBytes + 1]));
@@ -55,7 +59,7 @@ public static void ImportPrivateSeed_WrongSize_Array(MLKemAlgorithm algorithm)
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPrivateSeed_WrongSize_Span(MLKemAlgorithm algorithm)
+ public void ImportPrivateSeed_WrongSize_Span(MLKemAlgorithm algorithm)
{
byte[] seed = new byte[algorithm.PrivateSeedSizeInBytes + 1];
@@ -70,14 +74,14 @@ public static void ImportPrivateSeed_WrongSize_Span(MLKemAlgorithm algorithm)
}
[Fact]
- public static void ImportDecapsulationKey_NullAlgorithm()
+ public void ImportDecapsulationKey_NullAlgorithm()
{
AssertExtensions.Throws("algorithm", static () =>
MLKem.ImportDecapsulationKey(null, new byte[MLKemAlgorithm.MLKem512.DecapsulationKeySizeInBytes]));
}
[Fact]
- public static void ImportDecapsulationKey_NullSource()
+ public void ImportDecapsulationKey_NullSource()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportDecapsulationKey(MLKemAlgorithm.MLKem512, null));
@@ -85,7 +89,7 @@ public static void ImportDecapsulationKey_NullSource()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportDecapsulationKey_WrongSize_Array(MLKemAlgorithm algorithm)
+ public void ImportDecapsulationKey_WrongSize_Array(MLKemAlgorithm algorithm)
{
AssertExtensions.Throws("source", () =>
MLKem.ImportDecapsulationKey(algorithm, new byte[algorithm.DecapsulationKeySizeInBytes + 1]));
@@ -99,7 +103,7 @@ public static void ImportDecapsulationKey_WrongSize_Array(MLKemAlgorithm algorit
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportDecapsulationKey_WrongSize_Span(MLKemAlgorithm algorithm)
+ public void ImportDecapsulationKey_WrongSize_Span(MLKemAlgorithm algorithm)
{
byte[] destination = new byte[algorithm.DecapsulationKeySizeInBytes + 1];
@@ -114,14 +118,14 @@ public static void ImportDecapsulationKey_WrongSize_Span(MLKemAlgorithm algorith
}
[Fact]
- public static void ImportEncapsulationKey_NullAlgorithm()
+ public void ImportEncapsulationKey_NullAlgorithm()
{
AssertExtensions.Throws("algorithm", static () =>
MLKem.ImportEncapsulationKey(null, new byte[MLKemAlgorithm.MLKem512.EncapsulationKeySizeInBytes]));
}
[Fact]
- public static void ImportEncapsulationKey_NullSource()
+ public void ImportEncapsulationKey_NullSource()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportEncapsulationKey(MLKemAlgorithm.MLKem512, null));
@@ -129,7 +133,7 @@ public static void ImportEncapsulationKey_NullSource()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportEncapsulationKey_WrongSize_Array(MLKemAlgorithm algorithm)
+ public void ImportEncapsulationKey_WrongSize_Array(MLKemAlgorithm algorithm)
{
AssertExtensions.Throws("source", () =>
MLKem.ImportEncapsulationKey(algorithm, new byte[algorithm.EncapsulationKeySizeInBytes + 1]));
@@ -143,7 +147,7 @@ public static void ImportEncapsulationKey_WrongSize_Array(MLKemAlgorithm algorit
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportEncapsulationKey_WrongSize_Span(MLKemAlgorithm algorithm)
+ public void ImportEncapsulationKey_WrongSize_Span(MLKemAlgorithm algorithm)
{
byte[] destination = new byte[algorithm.EncapsulationKeySizeInBytes + 1];
@@ -158,14 +162,14 @@ public static void ImportEncapsulationKey_WrongSize_Span(MLKemAlgorithm algorith
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_NullSource()
+ public void ImportSubjectPublicKeyInfo_NullSource()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportSubjectPublicKeyInfo((byte[])null));
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_WrongAlgorithm()
+ public void ImportSubjectPublicKeyInfo_WrongAlgorithm()
{
byte[] ecP256Spki = Convert.FromBase64String(@"
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuiPJ2IV089LVrXZGDo9Mc542UZZE
@@ -174,14 +178,14 @@ public static void ImportSubjectPublicKeyInfo_WrongAlgorithm()
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_NotAsn()
+ public void ImportSubjectPublicKeyInfo_NotAsn()
{
Assert.Throws(() => MLKem.ImportSubjectPublicKeyInfo("potatoes"u8));
Assert.Throws(() => MLKem.ImportSubjectPublicKeyInfo("potatoes"u8.ToArray()));
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_WrongParameters()
+ public void ImportSubjectPublicKeyInfo_WrongParameters()
{
byte[] mlKem512BadParameters = (
"30820342301B0609608648016503040401040E62616420706172616D65746572" +
@@ -215,14 +219,14 @@ public static void ImportSubjectPublicKeyInfo_WrongParameters()
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_WrongSize()
+ public void ImportSubjectPublicKeyInfo_WrongSize()
{
byte[] mlKem512BadEncapKey = "3014300B060960864801650304040103050000264512".HexToByteArray();
Assert.Throws(() => MLKem.ImportSubjectPublicKeyInfo(mlKem512BadEncapKey));
}
[Fact]
- public static void ImportSubjectPublicKeyInfo_TrailingData()
+ public void ImportSubjectPublicKeyInfo_TrailingData()
{
byte[] spki = new byte[MLKemTestData.IetfMlKem512Spki.Length + 1];
MLKemTestData.IetfMlKem512Spki.AsSpan().CopyTo(spki);
@@ -231,14 +235,14 @@ public static void ImportSubjectPublicKeyInfo_TrailingData()
}
[Fact]
- public static void ImportPkcs8PrivateKey_NullSource()
+ public void ImportPkcs8PrivateKey_NullSource()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportPkcs8PrivateKey((byte[])null));
}
[Fact]
- public static void ImportPkcs8PrivateKey_WrongAlgorithm()
+ public void ImportPkcs8PrivateKey_WrongAlgorithm()
{
byte[] ecP256Key = Convert.FromBase64String(@"
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgZg/vYKeaTgco6dGx
@@ -252,7 +256,7 @@ public static void ImportPkcs8PrivateKey_WrongAlgorithm()
[Theory]
[InlineData(true)]
[InlineData(false)]
- public static void ImportPkcs8PrivateKey_BogusAsnChoice(bool useSpanImport)
+ public void ImportPkcs8PrivateKey_BogusAsnChoice(bool useSpanImport)
{
// SEQUENCE {
// INTEGER 0
@@ -274,7 +278,7 @@ public static void ImportPkcs8PrivateKey_BogusAsnChoice(bool useSpanImport)
}
[Fact]
- public static void ImportPkcs8PrivateKey_Seed_Array()
+ public void ImportPkcs8PrivateKey_Seed_Array()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -285,7 +289,7 @@ public static void ImportPkcs8PrivateKey_Seed_Array()
}
[Fact]
- public static void ImportPkcs8PrivateKey_Seed_Span()
+ public void ImportPkcs8PrivateKey_Seed_Span()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -297,17 +301,17 @@ public static void ImportPkcs8PrivateKey_Seed_Span()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_Seed_BadLength(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_Seed_BadLength(MLKemAlgorithm algorithm)
{
- byte[] encoded = Pkcs8Encode(algorithm.GetOid(), seed: new byte[algorithm.PrivateSeedSizeInBytes - 1]);
+ byte[] encoded = Pkcs8Encode(GetOid(algorithm), seed: new byte[algorithm.PrivateSeedSizeInBytes - 1]);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(encoded));
- encoded = Pkcs8Encode(algorithm.GetOid(), seed: new byte[algorithm.PrivateSeedSizeInBytes + 1]);
+ encoded = Pkcs8Encode(GetOid(algorithm), seed: new byte[algorithm.PrivateSeedSizeInBytes + 1]);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(encoded));
}
[Fact]
- public static void ImportPkcs8PrivateKey_Seed_TrailingData()
+ public void ImportPkcs8PrivateKey_Seed_TrailingData()
{
foreach ((_, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -321,10 +325,10 @@ public static void ImportPkcs8PrivateKey_Seed_TrailingData()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_Seed_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_Seed_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
{
byte[] encoded = Pkcs8Encode(
- algorithm.GetOid(),
+ GetOid(algorithm),
seed: MLKemTestData.IncrementalSeed.ToArray(),
algorithmParameters: s_asnNull);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(encoded.AsSpan()));
@@ -332,7 +336,7 @@ public static void ImportPkcs8PrivateKey_Seed_BadAlgorithmIdentifier(MLKemAlgori
}
[Fact]
- public static void ImportPkcs8PrivateKey_ExpandedKey_Array()
+ public void ImportPkcs8PrivateKey_ExpandedKey_Array()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyExpandedKeyTestData)
{
@@ -344,7 +348,7 @@ public static void ImportPkcs8PrivateKey_ExpandedKey_Array()
}
[Fact]
- public static void ImportPkcs8PrivateKey_ExpandedKey_Span()
+ public void ImportPkcs8PrivateKey_ExpandedKey_Span()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyExpandedKeyTestData)
{
@@ -356,7 +360,7 @@ public static void ImportPkcs8PrivateKey_ExpandedKey_Span()
}
[Fact]
- public static void ImportPkcs8PrivateKey_ExpandedKey_WrongAlgorithm()
+ public void ImportPkcs8PrivateKey_ExpandedKey_WrongAlgorithm()
{
byte[] pkcs8 = Pkcs8Encode(
MLKemTestData.MlKem768Oid,
@@ -368,10 +372,10 @@ public static void ImportPkcs8PrivateKey_ExpandedKey_WrongAlgorithm()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_ExpandedKey_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_ExpandedKey_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
{
byte[] pkcs8 = Pkcs8Encode(
- algorithm.GetOid(),
+ GetOid(algorithm),
expandedKey: MLKemTestData.IetfMlKem512PrivateKeyDecapsulationKey,
algorithmParameters: s_asnNull);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(pkcs8.AsSpan()));
@@ -379,7 +383,7 @@ public static void ImportPkcs8PrivateKey_ExpandedKey_BadAlgorithmIdentifier(MLKe
}
[Fact]
- public static void ImportPkcs8PrivateKey_ExpandedKey_TrailingData()
+ public void ImportPkcs8PrivateKey_ExpandedKey_TrailingData()
{
foreach ((_, byte[] pkcs8, _) in Pkcs8PrivateKeyExpandedKeyTestData)
{
@@ -392,7 +396,7 @@ public static void ImportPkcs8PrivateKey_ExpandedKey_TrailingData()
}
[Fact]
- public static void ImportPkcs8PrivateKey_Both_Array()
+ public void ImportPkcs8PrivateKey_Both_Array()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyBothTestData)
{
@@ -406,7 +410,7 @@ public static void ImportPkcs8PrivateKey_Both_Array()
}
[Fact]
- public static void ImportPkcs8PrivateKey_Both_Span()
+ public void ImportPkcs8PrivateKey_Both_Span()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyBothTestData)
{
@@ -421,34 +425,34 @@ public static void ImportPkcs8PrivateKey_Both_Span()
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_Both_Array_MismatchedKeys(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_Both_Array_MismatchedKeys(MLKemAlgorithm algorithm)
{
using MLKem kem1 = MLKem.GenerateKey(algorithm);
using MLKem kem2 = MLKem.GenerateKey(algorithm);
byte[] seed = kem1.ExportPrivateSeed();
byte[] decapKey = kem2.ExportDecapsulationKey();
- byte[] encoded = Pkcs8Encode(algorithm.GetOid(), seed: seed, expandedKey: decapKey);
+ byte[] encoded = Pkcs8Encode(GetOid(algorithm), seed: seed, expandedKey: decapKey);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(encoded));
}
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_Both_Span_MismatchedKeys(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_Both_Span_MismatchedKeys(MLKemAlgorithm algorithm)
{
using MLKem kem1 = MLKem.GenerateKey(algorithm);
using MLKem kem2 = MLKem.GenerateKey(algorithm);
byte[] seed = kem1.ExportPrivateSeed();
byte[] decapKey = kem2.ExportDecapsulationKey();
- byte[] encoded = Pkcs8Encode(algorithm.GetOid(), seed: seed, expandedKey: decapKey);
+ byte[] encoded = Pkcs8Encode(GetOid(algorithm), seed: seed, expandedKey: decapKey);
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey(encoded.AsSpan()));
}
[Theory]
[MemberData(nameof(MLKemTestData.MLKemAlgorithms), MemberType = typeof(MLKemTestData))]
- public static void ImportPkcs8PrivateKey_Both_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
+ public void ImportPkcs8PrivateKey_Both_BadAlgorithmIdentifier(MLKemAlgorithm algorithm)
{
byte[] pkcs8 = Pkcs8Encode(
- algorithm.GetOid(),
+ GetOid(algorithm),
expandedKey: MLKemTestData.IetfMlKem512PrivateKeyDecapsulationKey,
seed: MLKemTestData.IncrementalSeed.ToArray(),
algorithmParameters: s_asnNull);
@@ -457,7 +461,7 @@ public static void ImportPkcs8PrivateKey_Both_BadAlgorithmIdentifier(MLKemAlgori
}
[Fact]
- public static void ImportPkcs8PrivateKey_Both_TrailingData()
+ public void ImportPkcs8PrivateKey_Both_TrailingData()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyBothTestData)
{
@@ -470,14 +474,14 @@ public static void ImportPkcs8PrivateKey_Both_TrailingData()
}
[Fact]
- public static void ImportPkcs8PrivateKey_NotAsn()
+ public void ImportPkcs8PrivateKey_NotAsn()
{
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey("potatoes"u8));
Assert.Throws(() => MLKem.ImportPkcs8PrivateKey("potatoes"u8.ToArray()));
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_WrongAlgorithm()
+ public void ImportEncryptedPkcs8PrivateKey_WrongAlgorithm()
{
byte[] ecP256Key = Convert.FromBase64String(@"
MIHrMFYGCSqGSIb3DQEFDTBJMDEGCSqGSIb3DQEFDDAkBBCr0ipJGBOnThng8uXT
@@ -497,7 +501,7 @@ public static void ImportEncryptedPkcs8PrivateKey_WrongAlgorithm()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_TrailingData()
+ public void ImportEncryptedPkcs8PrivateKey_TrailingData()
{
foreach ((_, byte[] pkcs8) in Pkcs8EncryptedPrivateKeySeedTestData)
{
@@ -516,7 +520,7 @@ public static void ImportEncryptedPkcs8PrivateKey_TrailingData()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_NotAsn()
+ public void ImportEncryptedPkcs8PrivateKey_NotAsn()
{
Assert.Throws(() =>
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", "potatoes"u8.ToArray()));
@@ -529,7 +533,7 @@ public static void ImportEncryptedPkcs8PrivateKey_NotAsn()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_DoesNotProcessUnencryptedData()
+ public void ImportEncryptedPkcs8PrivateKey_DoesNotProcessUnencryptedData()
{
foreach ((_, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -545,7 +549,7 @@ public static void ImportEncryptedPkcs8PrivateKey_DoesNotProcessUnencryptedData(
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Seed_CharPassword()
+ public void ImportEncryptedPkcs8PrivateKey_Seed_CharPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8EncryptedPrivateKeySeedTestData)
{
@@ -557,7 +561,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Seed_CharPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Seed_StringPassword()
+ public void ImportEncryptedPkcs8PrivateKey_Seed_StringPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8EncryptedPrivateKeySeedTestData)
{
@@ -568,7 +572,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Seed_StringPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Seed_BytePassword()
+ public void ImportEncryptedPkcs8PrivateKey_Seed_BytePassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8EncryptedPrivateKeySeedTestData)
{
@@ -579,7 +583,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Seed_BytePassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_CharPassword()
+ public void ImportEncryptedPkcs8PrivateKey_ExpandedKey_CharPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyExpandedKeyTestData)
{
@@ -591,7 +595,7 @@ public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_CharPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_StringPassword()
+ public void ImportEncryptedPkcs8PrivateKey_ExpandedKey_StringPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyExpandedKeyTestData)
{
@@ -603,7 +607,7 @@ public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_StringPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_BytePassword()
+ public void ImportEncryptedPkcs8PrivateKey_ExpandedKey_BytePassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyExpandedKeyTestData)
{
@@ -615,7 +619,7 @@ public static void ImportEncryptedPkcs8PrivateKey_ExpandedKey_BytePassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Both_CharPassword()
+ public void ImportEncryptedPkcs8PrivateKey_Both_CharPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyBothTestData)
{
@@ -629,7 +633,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Both_CharPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Both_StringPassword()
+ public void ImportEncryptedPkcs8PrivateKey_Both_StringPassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyBothTestData)
{
@@ -643,7 +647,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Both_StringPassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_Both_BytePassword()
+ public void ImportEncryptedPkcs8PrivateKey_Both_BytePassword()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyBothTestData)
{
@@ -657,7 +661,7 @@ public static void ImportEncryptedPkcs8PrivateKey_Both_BytePassword()
}
[Fact]
- public static void ImportEncryptedPkcs8PrivateKey_NullArgs()
+ public void ImportEncryptedPkcs8PrivateKey_NullArgs()
{
AssertExtensions.Throws("source", static () =>
MLKem.ImportEncryptedPkcs8PrivateKey(MLKemTestData.EncryptedPrivateKeyPassword, (byte[])null));
@@ -667,13 +671,13 @@ public static void ImportEncryptedPkcs8PrivateKey_NullArgs()
}
[Fact]
- public static void ImportFromPem_NullSource()
+ public void ImportFromPem_NullSource()
{
AssertExtensions.Throws("source", static () => MLKem.ImportFromPem((string)null));
}
[Fact]
- public static void ImportFromPem_PublicKey_Roundtrip()
+ public void ImportFromPem_PublicKey_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] spki) in SubjectPublicKeyInfoTestData)
{
@@ -688,7 +692,7 @@ public static void ImportFromPem_PublicKey_Roundtrip()
}
[Fact]
- public static void ImportFromPem_PublicKey_IgnoresNotUnderstoodPems()
+ public void ImportFromPem_PublicKey_IgnoresNotUnderstoodPems()
{
foreach ((MLKemAlgorithm algorithm, byte[] spki) in SubjectPublicKeyInfoTestData)
{
@@ -709,7 +713,7 @@ public static void ImportFromPem_PublicKey_IgnoresNotUnderstoodPems()
}
[Fact]
- public static void ImportFromPem_PrivateKey_Seed_Roundtrip()
+ public void ImportFromPem_PrivateKey_Seed_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -724,7 +728,7 @@ public static void ImportFromPem_PrivateKey_Seed_Roundtrip()
}
[Fact]
- public static void ImportFromPem_PrivateKey_ExpandedKey_Roundtrip()
+ public void ImportFromPem_PrivateKey_ExpandedKey_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyExpandedKeyTestData)
{
@@ -739,7 +743,7 @@ public static void ImportFromPem_PrivateKey_ExpandedKey_Roundtrip()
}
[Fact]
- public static void ImportFromPem_PrivateKey_Both_Roundtrip()
+ public void ImportFromPem_PrivateKey_Both_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8PrivateKeyBothTestData)
{
@@ -754,7 +758,7 @@ public static void ImportFromPem_PrivateKey_Both_Roundtrip()
}
[Fact]
- public static void ImportFromPem_AmbiguousImportWithPublicKey_Throws()
+ public void ImportFromPem_AmbiguousImportWithPublicKey_Throws()
{
string pem = $"""
{WritePem("PUBLIC KEY", MLKemTestData.IetfMlKem512Spki)}
@@ -768,7 +772,7 @@ public static void ImportFromPem_AmbiguousImportWithPublicKey_Throws()
}
[Fact]
- public static void ImportFromPem_AmbiguousImportWithPrivateKey_Throws()
+ public void ImportFromPem_AmbiguousImportWithPrivateKey_Throws()
{
string pem = $"""
{WritePem("PUBLIC KEY", MLKemTestData.IetfMlKem512Spki)}
@@ -782,7 +786,7 @@ public static void ImportFromPem_AmbiguousImportWithPrivateKey_Throws()
}
[Fact]
- public static void ImportFromPem_AmbiguousImportWithEncryptedPrivateKey_Throws()
+ public void ImportFromPem_AmbiguousImportWithEncryptedPrivateKey_Throws()
{
string pem = $"""
{WritePem("PUBLIC KEY", MLKemTestData.IetfMlKem512Spki)}
@@ -796,7 +800,7 @@ public static void ImportFromPem_AmbiguousImportWithEncryptedPrivateKey_Throws()
}
[Fact]
- public static void ImportFromPem_EncryptedPrivateKey_Throws()
+ public void ImportFromPem_EncryptedPrivateKey_Throws()
{
string pem = WritePem("ENCRYPTED PRIVATE KEY", MLKemTestData.IetfMlKem512EncryptedPrivateKeySeed);
AssertImportFromPem(importer =>
@@ -806,7 +810,7 @@ public static void ImportFromPem_EncryptedPrivateKey_Throws()
}
[Fact]
- public static void ImportFromPem_NoUnderstoodPem_Throws()
+ public void ImportFromPem_NoUnderstoodPem_Throws()
{
string pem = """
-----BEGIN UNKNOWN-----
@@ -821,7 +825,7 @@ public static void ImportFromPem_NoUnderstoodPem_Throws()
}
[Fact]
- public static void ImportFromPem_PrivateKey_IgnoresNotUnderstoodPems()
+ public void ImportFromPem_PrivateKey_IgnoresNotUnderstoodPems()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8PrivateKeySeedTestData)
{
@@ -842,7 +846,7 @@ public static void ImportFromPem_PrivateKey_IgnoresNotUnderstoodPems()
}
[Fact]
- public static void ImportFromEncryptedPem_NullSource()
+ public void ImportFromEncryptedPem_NullSource()
{
AssertExtensions.Throws("source",
static () => MLKem.ImportFromEncryptedPem((string)null, "PLACEHOLDER"));
@@ -852,7 +856,7 @@ public static void ImportFromEncryptedPem_NullSource()
}
[Fact]
- public static void ImportFromEncryptedPem_NullPassword()
+ public void ImportFromEncryptedPem_NullPassword()
{
AssertExtensions.Throws("password",
static () => MLKem.ImportFromEncryptedPem("the pem", (string)null));
@@ -862,7 +866,7 @@ public static void ImportFromEncryptedPem_NullPassword()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_Seed_Roundtrip()
+ public void ImportFromEncryptedPem_PrivateKey_Seed_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8) in Pkcs8EncryptedPrivateKeySeedTestData)
{
@@ -877,7 +881,7 @@ public static void ImportFromEncryptedPem_PrivateKey_Seed_Roundtrip()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_ExpandedKey_Roundtrip()
+ public void ImportFromEncryptedPem_PrivateKey_ExpandedKey_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyExpandedKeyTestData)
{
@@ -892,7 +896,7 @@ public static void ImportFromEncryptedPem_PrivateKey_ExpandedKey_Roundtrip()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_Both_Roundtrip()
+ public void ImportFromEncryptedPem_PrivateKey_Both_Roundtrip()
{
foreach ((MLKemAlgorithm algorithm, byte[] pkcs8, byte[] decapKey) in Pkcs8EncryptedPrivateKeyBothTestData)
{
@@ -907,7 +911,7 @@ public static void ImportFromEncryptedPem_PrivateKey_Both_Roundtrip()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_Ambiguous_Throws()
+ public void ImportFromEncryptedPem_PrivateKey_Ambiguous_Throws()
{
string pem = $"""
{WritePem("ENCRYPTED PRIVATE KEY", MLKemTestData.IetfMlKem512EncryptedPrivateKeyBoth)}
@@ -921,7 +925,7 @@ public static void ImportFromEncryptedPem_PrivateKey_Ambiguous_Throws()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_DoesNotImportNonEncrypted()
+ public void ImportFromEncryptedPem_PrivateKey_DoesNotImportNonEncrypted()
{
string pem = WritePem("PRIVATE KEY", MLKemTestData.IetfMlKem512PrivateKeyBoth);
AssertImportFromEncryptedPem(importer =>
@@ -932,7 +936,7 @@ public static void ImportFromEncryptedPem_PrivateKey_DoesNotImportNonEncrypted()
}
[Fact]
- public static void ImportFromEncryptedPem_NoUnderstoodPem_Throws()
+ public void ImportFromEncryptedPem_NoUnderstoodPem_Throws()
{
string pem = """
-----BEGIN UNKNOWN-----
@@ -947,7 +951,7 @@ public static void ImportFromEncryptedPem_NoUnderstoodPem_Throws()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_IgnoresNotUnderstoodPems()
+ public void ImportFromEncryptedPem_PrivateKey_IgnoresNotUnderstoodPems()
{
string pem = $"""
-----BEGIN UNKNOWN-----
@@ -964,7 +968,7 @@ public static void ImportFromEncryptedPem_PrivateKey_IgnoresNotUnderstoodPems()
}
[Fact]
- public static void ImportFromEncryptedPem_PrivateKey_WrongPassword()
+ public void ImportFromEncryptedPem_PrivateKey_WrongPassword()
{
string pem = WritePem("ENCRYPTED PRIVATE KEY", MLKemTestData.IetfMlKem768EncryptedPrivateKeyBoth);
AssertImportFromEncryptedPem(importer =>
@@ -1189,7 +1193,7 @@ byte[] EncodePrivateKey()
return writer.Encode();
}
- private static string GetOid(this MLKemAlgorithm algorithm)
+ private static string GetOid(MLKemAlgorithm algorithm)
{
if (algorithm == MLKemAlgorithm.MLKem512)
{
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs b/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs
index 31191e4164195c..3c259bef375408 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs
@@ -5,6 +5,7 @@
using System.Globalization;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
+using Xunit.Sdk;
namespace System.Security.Cryptography.Tests
{
@@ -82,7 +83,7 @@ public static void EmptyTests(byte[] key, string label, string context, byte[] e
VerifyKbkdf(expected, key, HashAlgorithmName.SHA256, label.ToCharArray(), context.ToCharArray());
}
- [ConditionalTheory]
+ [Theory]
[InlineData(nameof(HashAlgorithmName.SHA1), 512 / 8 - 1, new byte[] { 0xc9, 0x0f, 0x9d, 0x91, 0x85, 0xe5, 0xeb, 0x9b })]
[InlineData(nameof(HashAlgorithmName.SHA1), 512 / 8, new byte[] { 0x7b, 0xdb, 0x38, 0x28, 0xc0, 0x9f, 0x49, 0x05 })]
[InlineData(nameof(HashAlgorithmName.SHA1), 512 / 8 + 1, new byte[] { 0x6c, 0x3a, 0xba, 0x28, 0x38, 0xad, 0x51, 0x2c })]
@@ -113,7 +114,7 @@ public static void Kdk_HmacBlockBoundarySizes(string hashAlgorithmName, int kdkS
(hashAlgorithmName == "SHA3-384" && !SHA3_384.IsSupported) ||
(hashAlgorithmName == "SHA3-512" && !SHA3_512.IsSupported))
{
- throw new SkipTestException($"Algorithm '{hashAlgorithmName}' is not supported on the current platform.");
+ throw SkipException.ForSkip($"Algorithm '{hashAlgorithmName}' is not supported on the current platform.");
}
#endif
diff --git a/src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/X509CertificateLoaderPkcs12Tests.WindowsAttributes.cs b/src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/X509CertificateLoaderPkcs12Tests.WindowsAttributes.cs
index 858a4dc5f7aa3e..fd25584b826991 100644
--- a/src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/X509CertificateLoaderPkcs12Tests.WindowsAttributes.cs
+++ b/src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/X509CertificateLoaderPkcs12Tests.WindowsAttributes.cs
@@ -9,17 +9,14 @@ namespace System.Security.Cryptography.X509Certificates.Tests
{
public abstract partial class X509CertificateLoaderPkcs12Tests
{
- [ConditionalTheory]
+ [Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void VerifyPreserveKeyName(bool preserveName, bool machineKey)
{
- if (machineKey && !PlatformDetection.IsPrivilegedProcess)
- {
- throw new SkipTestException("Test requires administrator privileges.");
- }
+ Assert.SkipWhen(machineKey && !PlatformDetection.IsPrivilegedProcess, "Test requires administrator privileges.");
Pkcs12LoaderLimits loaderLimits = new Pkcs12LoaderLimits
{
@@ -57,17 +54,14 @@ public void VerifyPreserveKeyName(bool preserveName, bool machineKey)
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
{
- if (machineKey && !PlatformDetection.IsPrivilegedProcess)
- {
- throw new SkipTestException("Test requires administrator privileges.");
- }
+ Assert.SkipWhen(machineKey && !PlatformDetection.IsPrivilegedProcess, "Test requires administrator privileges.");
Pkcs12LoaderLimits loaderLimits = new Pkcs12LoaderLimits
{
@@ -106,7 +100,7 @@ public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(true, true, true)]
[InlineData(true, true, false)]
[InlineData(true, false, true)]
@@ -117,10 +111,7 @@ public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
[InlineData(false, false, false)]
public void VerifyPreserveProvider(bool preserveProvider, bool preserveName, bool machineKey)
{
- if (machineKey && !PlatformDetection.IsPrivilegedProcess)
- {
- throw new SkipTestException("Test requires administrator privileges.");
- }
+ Assert.SkipWhen(machineKey && !PlatformDetection.IsPrivilegedProcess, "Test requires administrator privileges.");
// This test forces a key creation with CAPI, and verifies that
// PreserveStorageProvider keeps the key in CAPI. Additionally,
@@ -174,15 +165,12 @@ public void VerifyPreserveProvider(bool preserveProvider, bool preserveName, boo
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData(false)]
[InlineData(true)]
public void VerifyNamesWithDuplicateAttributes(bool noLimits)
{
- if (!PlatformDetection.IsPrivilegedProcess)
- {
- throw new SkipTestException("Test requires administrator privileges.");
- }
+ Assert.SkipUnless(PlatformDetection.IsPrivilegedProcess, "Test requires administrator privileges.");
// This test mainly shows that when duplicate attributes are present contents
// processed by our filter and processed directly by PFXImportCertStore come up
diff --git a/src/libraries/Common/tests/System/Xml/ModuleCore/ModuleCore.csproj b/src/libraries/Common/tests/System/Xml/ModuleCore/ModuleCore.csproj
index 292cb9050a2ddc..a409299cda0153 100644
--- a/src/libraries/Common/tests/System/Xml/ModuleCore/ModuleCore.csproj
+++ b/src/libraries/Common/tests/System/Xml/ModuleCore/ModuleCore.csproj
@@ -19,7 +19,14 @@
-
-
+
+
+
-
\ No newline at end of file
+
diff --git a/src/libraries/Common/tests/System/Xml/ModuleCore/XunitRunner.cs b/src/libraries/Common/tests/System/Xml/ModuleCore/XunitRunner.cs
index 79d210d9e13442..2dc9c31b5c2bac 100644
--- a/src/libraries/Common/tests/System/Xml/ModuleCore/XunitRunner.cs
+++ b/src/libraries/Common/tests/System/Xml/ModuleCore/XunitRunner.cs
@@ -7,13 +7,41 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
-using Xunit.Abstractions;
+using Xunit;
using Xunit.Sdk;
+using Xunit.v3;
namespace OLEDB.Test.ModuleCore
{
- public class XmlInlineDataDiscoverer : IDataDiscoverer
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+ public sealed class XmlTestsAttribute : DataAttribute
{
+ private delegate CTestModule ModuleGenerator();
+
+ private string _methodName;
+
+ public XmlTestsAttribute(string methodName)
+ {
+ _methodName = methodName;
+ }
+
+ public static Func GetGenerator(Type type, string methodName)
+ {
+ ModuleGenerator moduleGenerator = (ModuleGenerator)type.GetMethod(methodName).CreateDelegate(typeof(ModuleGenerator));
+ return new Func(moduleGenerator);
+ }
+
+ public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)
+ {
+ Func moduleGenerator = GetGenerator(testMethod.DeclaringType, _methodName);
+ var testCases = new List();
+ foreach (object[] testCase in GenerateTestCases(moduleGenerator))
+ {
+ testCases.Add(new TheoryDataRow(testCase));
+ }
+ return new ValueTask>(testCases);
+ }
+
public static IEnumerable GenerateTestCases(Func moduleGenerator)
{
CModInfo.CommandLine = "";
@@ -37,63 +65,6 @@ private static IEnumerable GenerateTestCasesForModule(CTestModule modu
}
}
- private static Type ToRuntimeType(ITypeInfo typeInfo)
- {
- var reflectionTypeInfo = typeInfo as IReflectionTypeInfo;
- if (reflectionTypeInfo != null)
- return reflectionTypeInfo.Type;
-
- Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == typeInfo.Assembly.Name);
- if (assembly != null)
- {
- return assembly.GetType(typeInfo.Name);
- }
-
- throw new Exception($"Could not find runtime type `{typeInfo.Name}`");
- }
-
- private static Type GetDeclaringType(IMethodInfo methodInfo)
- {
- var reflectionMethodInfo = methodInfo as IReflectionMethodInfo;
- if (reflectionMethodInfo != null)
- return reflectionMethodInfo.MethodInfo.DeclaringType;
-
- return ToRuntimeType(methodInfo.Type);
- }
-
- public virtual IEnumerable GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
- {
- string methodName = (string)dataAttribute.GetConstructorArguments().Single();
- Func moduleGenerator = XmlTestsAttribute.GetGenerator(GetDeclaringType(testMethod), methodName);
- return GenerateTestCases(moduleGenerator);
- }
-
- public virtual bool SupportsDiscoveryEnumeration(IAttributeInfo dataAttribute, IMethodInfo testMethod) => true;
- }
-
- [DataDiscoverer("OLEDB.Test.ModuleCore.XmlInlineDataDiscoverer", "ModuleCore")]
- [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
- public sealed class XmlTestsAttribute : DataAttribute
- {
- private delegate CTestModule ModuleGenerator();
-
- private string _methodName;
-
- public XmlTestsAttribute(string methodName)
- {
- _methodName = methodName;
- }
-
- public static Func GetGenerator(Type type, string methodName)
- {
- ModuleGenerator moduleGenerator = (ModuleGenerator)type.GetMethod(methodName).CreateDelegate(typeof(ModuleGenerator));
- return new Func(moduleGenerator);
- }
-
- public override IEnumerable GetData(MethodInfo testMethod)
- {
- Func moduleGenerator = GetGenerator(testMethod.DeclaringType, _methodName);
- return XmlInlineDataDiscoverer.GenerateTestCases(moduleGenerator);
- }
+ public override bool SupportsDiscoveryEnumeration() => true;
}
}
diff --git a/src/libraries/Common/tests/TestUtilities.Unicode/TestUtilities.Unicode.csproj b/src/libraries/Common/tests/TestUtilities.Unicode/TestUtilities.Unicode.csproj
index 7f45c508db6b13..61a1c46f60428f 100644
--- a/src/libraries/Common/tests/TestUtilities.Unicode/TestUtilities.Unicode.csproj
+++ b/src/libraries/Common/tests/TestUtilities.Unicode/TestUtilities.Unicode.csproj
@@ -46,9 +46,14 @@
emoji-data.txt
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/libraries/Common/tests/TestUtilities/RandomTestCaseOrderer.cs b/src/libraries/Common/tests/TestUtilities/RandomTestCaseOrderer.cs
index 5fa3d67e5c4fbe..a9ec6e955dad81 100644
--- a/src/libraries/Common/tests/TestUtilities/RandomTestCaseOrderer.cs
+++ b/src/libraries/Common/tests/TestUtilities/RandomTestCaseOrderer.cs
@@ -6,7 +6,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
-using Xunit.Abstractions;
+using Xunit.v3;
using Xunit.Sdk;
namespace TestUtilities;
@@ -42,6 +42,12 @@ public IEnumerable OrderTestCases(IEnumerable t
? randomizedTests
: testCases;
+ public IReadOnlyCollection OrderTestCases(IReadOnlyCollection testCases)
+ where TTestCase : notnull, ITestCase
+ => TryRandomize(testCases.ToList(), _diagnosticMessageSink, out List? randomizedTests)
+ ? randomizedTests
+ : testCases;
+
public static bool TryRandomize(List tests, IMessageSink messageSink, [NotNullWhen(true)] out List? randomizedTests)
{
randomizedTests = null;
diff --git a/src/libraries/Common/tests/TestUtilities/RandomTestCollectionOrderer.cs b/src/libraries/Common/tests/TestUtilities/RandomTestCollectionOrderer.cs
index 4d5171b8dc94f9..b1598277d52974 100644
--- a/src/libraries/Common/tests/TestUtilities/RandomTestCollectionOrderer.cs
+++ b/src/libraries/Common/tests/TestUtilities/RandomTestCollectionOrderer.cs
@@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using Xunit;
-using Xunit.Abstractions;
+using Xunit.v3;
using Xunit.Sdk;
namespace TestUtilities;
@@ -24,4 +24,10 @@ public IEnumerable OrderTestCollections(IEnumerable RandomTestCaseOrderer.TryRandomize(testCollections.ToList(), _diagnosticMessageSink, out List? randomizedTests)
? randomizedTests
: testCollections;
+
+ public IReadOnlyCollection OrderTestCollections(IReadOnlyCollection testCollections)
+ where TTestCollection : ITestCollection
+ => RandomTestCaseOrderer.TryRandomize(testCollections.ToList(), _diagnosticMessageSink, out List? randomizedTests)
+ ? randomizedTests
+ : testCollections;
}
diff --git a/src/libraries/Common/tests/TestUtilities/TestEventListener.cs b/src/libraries/Common/tests/TestUtilities/TestEventListener.cs
index bdfae390d47732..2d318b2a90b295 100644
--- a/src/libraries/Common/tests/TestUtilities/TestEventListener.cs
+++ b/src/libraries/Common/tests/TestUtilities/TestEventListener.cs
@@ -7,7 +7,8 @@
using System.Diagnostics.Tracing;
using System.IO;
using System.Text;
-using Xunit.Abstractions;
+using Xunit;
+using Xunit.Sdk;
namespace TestUtilities;
diff --git a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
index e29f6f24e3633a..7291d4f63c8af6 100644
--- a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
+++ b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
@@ -1,9 +1,11 @@
$(NetCoreAppMinimum);$(NetFrameworkCurrent)
+
true
false
+ $(DefineConstants);TEST_SINGLE_FILE
@@ -105,14 +107,18 @@
Link="Common\Interop\Android\System.Security.Cryptography.Native.Android\Interop.Ssl.ProtocolSupport.cs" />
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
@@ -122,7 +128,6 @@
-
diff --git a/src/libraries/Common/tests/Tests/RandomizedTestOrderAssemblyInfo.cs b/src/libraries/Common/tests/Tests/RandomizedTestOrderAssemblyInfo.cs
index 3b051bad65bc80..1ff25c927faf9c 100644
--- a/src/libraries/Common/tests/Tests/RandomizedTestOrderAssemblyInfo.cs
+++ b/src/libraries/Common/tests/Tests/RandomizedTestOrderAssemblyInfo.cs
@@ -3,5 +3,5 @@
using Xunit;
-[assembly: TestCaseOrderer("TestUtilities.RandomTestCaseOrderer", "TestUtilities")]
-[assembly: TestCollectionOrderer("TestUtilities.RandomTestCollectionOrderer", "TestUtilities")]
+[assembly: TestCaseOrderer(typeof(TestUtilities.RandomTestCaseOrderer))]
+[assembly: TestCollectionOrderer(typeof(TestUtilities.RandomTestCollectionOrderer))]
diff --git a/src/libraries/Common/tests/Tests/System/Collections/Generic/ArrayBuilderTests.cs b/src/libraries/Common/tests/Tests/System/Collections/Generic/ArrayBuilderTests.cs
index b82ed6509155b6..2ef3c28b3d9433 100644
--- a/src/libraries/Common/tests/Tests/System/Collections/Generic/ArrayBuilderTests.cs
+++ b/src/libraries/Common/tests/Tests/System/Collections/Generic/ArrayBuilderTests.cs
@@ -36,7 +36,8 @@ public static IEnumerable GenerateEnumerable(this IGenerator generator,
{
private static readonly TGenerator s_generator = new TGenerator();
- [Fact]
+ // Test attributes are on the concrete subclasses (not here) so the xunit
+ // AOT source generator emits code for closed types instead of the open generic.
public void ParameterlessConstructor()
{
var builder = new ArrayBuilder();
@@ -49,8 +50,6 @@ public void ParameterlessConstructor()
Assert.Same(Array.Empty(), builder.ToArray());
}
- [Theory]
- [MemberData(nameof(CapacityData))]
public void CapacityConstructor(int capacity)
{
Debug.Assert(capacity >= 0);
@@ -64,8 +63,6 @@ public void CapacityConstructor(int capacity)
Assert.Same(Array.Empty(), builder.ToArray());
}
- [Theory]
- [MemberData(nameof(CountData))]
public void Count(int count)
{
Debug.Assert(count >= 0);
@@ -83,8 +80,6 @@ public void Count(int count)
}
}
- [Theory]
- [MemberData(nameof(EnumerableData))]
public void ToArray(IEnumerable seed)
{
ArrayBuilder builder = CreateBuilderFromSequence(seed);
@@ -96,8 +91,6 @@ public void ToArray(IEnumerable seed)
Assert.Equal(seed, array);
}
- [Theory]
- [MemberData(nameof(CapacityData))]
public void UncheckedAdd(int capacity)
{
Debug.Assert(capacity >= 0);
@@ -208,8 +201,32 @@ private static int CalculateExpectedCapacity(int count)
}
}
+ // The xunit AOT source generator cannot discover test methods declared on
+ // open generic base classes. Each concrete subclass re-declares the test
+ // methods as thin stubs so the generator emits entry points for them.
+
+#pragma warning disable xUnit1024 // Test methods cannot have overloads — intentional: stubs hide base methods
public class ArrayBuilderTestsInt32 : ArrayBuilderTests
{
+ [Fact]
+ public new void ParameterlessConstructor() => base.ParameterlessConstructor();
+
+ [Theory]
+ [MemberData(nameof(CapacityData))]
+ public new void CapacityConstructor(int capacity) => base.CapacityConstructor(capacity);
+
+ [Theory]
+ [MemberData(nameof(CountData))]
+ public new void Count(int count) => base.Count(count);
+
+ [Theory]
+ [MemberData(nameof(EnumerableData))]
+ public new void ToArray(IEnumerable seed) => base.ToArray(seed);
+
+ [Theory]
+ [MemberData(nameof(CapacityData))]
+ public new void UncheckedAdd(int capacity) => base.UncheckedAdd(capacity);
+
public sealed class Generator : IGenerator
{
public int Generate(int seed) => seed;
@@ -218,9 +235,29 @@ public sealed class Generator : IGenerator
public class ArrayBuilderTestsString : ArrayBuilderTests
{
+ [Fact]
+ public new void ParameterlessConstructor() => base.ParameterlessConstructor();
+
+ [Theory]
+ [MemberData(nameof(CapacityData))]
+ public new void CapacityConstructor(int capacity) => base.CapacityConstructor(capacity);
+
+ [Theory]
+ [MemberData(nameof(CountData))]
+ public new void Count(int count) => base.Count(count);
+
+ [Theory]
+ [MemberData(nameof(EnumerableData))]
+ public new void ToArray(IEnumerable seed) => base.ToArray(seed);
+
+ [Theory]
+ [MemberData(nameof(CapacityData))]
+ public new void UncheckedAdd(int capacity) => base.UncheckedAdd(capacity);
+
public sealed class Generator : IGenerator
{
public string Generate(int seed) => seed.ToString();
}
}
+#pragma warning restore xUnit1024
}
diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs
index fa5214bb43609a..940463b6996aeb 100644
--- a/src/libraries/Common/tests/Tests/System/StringTests.cs
+++ b/src/libraries/Common/tests/Tests/System/StringTests.cs
@@ -2884,7 +2884,7 @@ public static void Format_Invalid_FormatExceptionFromFormatOrArgs(IFormatProvide
}
}
- [ConditionalTheory]
+ [Theory]
[InlineData("Hello", 'l', 0, 5, 2)]
[InlineData("Hello", 'x', 0, 5, -1)]
[InlineData("Hello", 'l', 1, 4, 2)]
@@ -2937,10 +2937,7 @@ public static void IndexOf_SingleLetter(string s, char target, int startIndex, i
// This is by design. ICU ignores the null characters (i.e. null characters have no weights for the string comparison).
// For desired behavior, use ordinal comparison instead of linguistic comparison.
// This is a known difference between NLS and ICU (https://github.com/dotnet/runtime/issues/4673).
- if (target == '\0' && PlatformDetection.IsIcuGlobalization)
- {
- throw new SkipTestException("Target \\0 is not supported in ICU");
- }
+ Assert.SkipWhen(target == '\0' && PlatformDetection.IsIcuGlobalization, "Target \\0 is not supported in ICU");
bool safeForCurrentCulture =
IsSafeForCurrentCultureComparisons(s)
diff --git a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs
index 005c736e936594..878bcf2950f2a6 100644
--- a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs
+++ b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs
@@ -66,6 +66,7 @@ public static async Task MainAsync(string[] args)
switch (option)
{
case "-notrait":
+ case "-trait-":
excludedTraits.Add(args[i + 1]);
i++;
break;
diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/ConfigBindingGenTestDriver.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/ConfigBindingGenTestDriver.cs
index b15815d72527fc..2e9627a09fa1df 100644
--- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/ConfigBindingGenTestDriver.cs
+++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/ConfigBindingGenTestDriver.cs
@@ -18,9 +18,13 @@
namespace Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests
{
- [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
public partial class ConfigurationBindingGeneratorTests : ConfigurationBinderTestsBase
{
+ public ConfigurationBindingGeneratorTests()
+ {
+ Assert.SkipUnless(PlatformDetection.HasAssemblyFiles, "ConditionalClass: PlatformDetection.HasAssemblyFiles");
+ }
+
internal sealed class ConfigBindingGenTestDriver
{
private readonly CSharpParseOptions _parseOptions;
@@ -118,7 +122,7 @@ internal enum ExpectedDiagnostics
internal static class ConfigBindingGenTestDriverExtensions
{
- public static void ValidateIncrementalResult(this ConfigBindingGenRunResult result,
+ public void ValidateIncrementalResult(this ConfigBindingGenRunResult result,
IncrementalStepRunReason inputReason,
IncrementalStepRunReason outputReason)
{
@@ -129,7 +133,7 @@ public static void ValidateIncrementalResult(this ConfigBindingGenRunResult resu
});
}
- public static void ValidateDiagnostics(this ConfigBindingGenRunResult result, ExpectedDiagnostics expectedDiags)
+ public void ValidateDiagnostics(this ConfigBindingGenRunResult result, ExpectedDiagnostics expectedDiags)
{
ImmutableArray outputDiagnostics = result.OutputCompilation.GetDiagnostics();
diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Incremental.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Incremental.cs
index bb6c5baae32272..9289760d311993 100644
--- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Incremental.cs
+++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Incremental.cs
@@ -12,9 +12,13 @@ namespace Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests
{
public partial class ConfigurationBindingGeneratorTests : ConfigurationBinderTestsBase
{
- [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
public sealed class IncrementalTests
{
+ public IncrementalTests()
+ {
+ Assert.SkipUnless(PlatformDetection.HasAssemblyFiles, "ConditionalClass: PlatformDetection.HasAssemblyFiles");
+ }
+
[Fact]
public async Task CompilingTheSameSourceResultsInEqualModels()
{
@@ -145,7 +149,7 @@ public async Task RunWithDiags_Then_EditWithDiags()
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -178,7 +182,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -211,7 +215,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -241,7 +245,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -272,7 +276,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -303,7 +307,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
@@ -334,7 +338,7 @@ public class MyClass2 { }
public class Program
{
- public static void Main()
+ public void Main()
{
ConfigurationBuilder configurationBuilder = new();
IConfigurationRoot config = configurationBuilder.Build();
diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/MsBuildTargetTest.cs b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/MsBuildTargetTest.cs
index a7838756ede7b9..bffd909a0365ef 100644
--- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/MsBuildTargetTest.cs
+++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/MsBuildTargetTest.cs
@@ -7,7 +7,6 @@
using System.Linq;
using System.Reflection;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Extensions.Configuration.UserSecrets
{
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml
new file mode 100644
index 00000000000000..ae5861f7a1899b
--- /dev/null
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ CP0002
+ M:Microsoft.Extensions.DependencyInjection.Specification.DependencyInjectionSpecificationTests.get_ServiceContainerPicksConstructorWithLongestMatchesData
+ lib/net10.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ lib/net10.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ true
+
+
+ CP0002
+ M:Microsoft.Extensions.DependencyInjection.Specification.DependencyInjectionSpecificationTests.get_ServiceContainerPicksConstructorWithLongestMatchesData
+ lib/net462/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ lib/net462/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ true
+
+
+ CP0002
+ M:Microsoft.Extensions.DependencyInjection.Specification.DependencyInjectionSpecificationTests.get_ServiceContainerPicksConstructorWithLongestMatchesData
+ lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll
+ true
+
+
\ No newline at end of file
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/DependencyInjectionSpecificationTests.cs b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/DependencyInjectionSpecificationTests.cs
index 46381662e03d02..f081766c02f8b9 100644
--- a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/DependencyInjectionSpecificationTests.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/DependencyInjectionSpecificationTests.cs
@@ -811,7 +811,7 @@ public void NonexistentServiceCanBeIEnumerableResolved()
Assert.Empty(services);
}
- public static TheoryData ServiceContainerPicksConstructorWithLongestMatchesData
+ public static TheoryData ServiceContainerPicksConstructorWithLongestMatchesData
{
get
{
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj
index b4e61ea14be2a4..9a1f15812f68ec 100644
--- a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj
@@ -15,11 +15,15 @@
Suite of xUnit.net tests to check for container compatibility with Microsoft.Extensions.DependencyInjection.
false
+ true
-
-
+
+
+
+
+
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionDescriptorExtensionsTests.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionDescriptorExtensionsTests.cs
index 60e490214998ed..6b282203fdd6f2 100644
--- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionDescriptorExtensionsTests.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionDescriptorExtensionsTests.cs
@@ -5,7 +5,6 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.DependencyInjection.Specification.Fakes;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Extensions.DependencyInjection
{
diff --git a/src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs b/src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
index 8d0dd4b403a6b7..132af8502d766d 100644
--- a/src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
+++ b/src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
@@ -9,6 +9,7 @@
using Microsoft.Extensions.FileSystemGlobbing.Abstractions;
using Microsoft.Extensions.FileSystemGlobbing.Tests.TestUtility;
using Xunit;
+using Xunit.Sdk;
namespace Microsoft.Extensions.FileSystemGlobbing.Tests
{
@@ -869,7 +870,7 @@ public void VerifyFiles_RedundantSegment_HasMatches(string file)
}
}
- [ConditionalFact]
+ [Fact]
public void VerifyFiles_ParentRedundantSegment_HasMatches()
{
string file = "sdk/9.0.100-preview.4.24207.1/.version";
@@ -882,14 +883,14 @@ public void VerifyFiles_ParentRedundantSegment_HasMatches()
}
}
- [ConditionalFact]
+ [Fact]
public void VerifyFiles_ParentRedundantSegment_CurrentDirectory_HasMatches()
{
string cwd = Environment.CurrentDirectory;
string cwdFolderName = new DirectoryInfo(cwd).Name;
if (cwd == cwdFolderName) // cwd is root, we can't do ../C:/
{
- throw new SkipTestException($"CurrentDirectory {cwd} is the root directory.");
+ throw SkipException.ForSkip($"CurrentDirectory {cwd} is the root directory.");
}
string file = "sdk/9.0.100-preview.4.24207.1/.version";
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/TestVariant.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/TestVariant.cs
index bb6a07357fbe71..6a01d177055ef4 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/TestVariant.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/TestVariant.cs
@@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using Xunit.Abstractions;
+using Xunit;
namespace Microsoft.Extensions.Hosting.IntegrationTesting
{
- public class TestVariant : IXunitSerializable
+ public class TestVariant
{
public string Tfm { get; set; }
public ApplicationType ApplicationType { get; set; }
@@ -18,21 +18,5 @@ public override string ToString()
// For debug and test explorer view
return $"TFM: {Tfm}, Type: {ApplicationType}, Arch: {Architecture}";
}
-
- public void Serialize(IXunitSerializationInfo info)
- {
- info.AddValue(nameof(Skip), Skip, typeof(string));
- info.AddValue(nameof(Tfm), Tfm, typeof(string));
- info.AddValue(nameof(ApplicationType), ApplicationType, typeof(ApplicationType));
- info.AddValue(nameof(Architecture), Architecture, typeof(RuntimeArchitecture));
- }
-
- public void Deserialize(IXunitSerializationInfo info)
- {
- Skip = info.GetValue(nameof(Skip));
- Tfm = info.GetValue(nameof(Tfm));
- ApplicationType = info.GetValue(nameof(ApplicationType));
- Architecture = info.GetValue(nameof(Architecture));
- }
}
}
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj
index f195afdccd0be6..0eaa80e06fe015 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj
+++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj
@@ -5,6 +5,7 @@
true
true
+ Exe
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs
index e55a29dd0de78b..d23e89f15a1eeb 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs
@@ -10,7 +10,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Test;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Hosting.FunctionalTests
{
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs
index d8e4c7c403658e..2c40fdc30a2cd3 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs
@@ -9,6 +9,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.DotNet.RemoteExecutor;
@@ -318,7 +319,7 @@ string SaveRandomConfig()
Assert.Equal(dynamicConfigMessage1, config["Hello"]); // Config did not reload
}
- [Fact]
+ [Fact(Skip = "true")]
public async Task CreateDefaultBuilder_ConfigJsonDoesReload()
{
var reloadFlagConfig = new Dictionary() { { "hostbuilder:reloadConfigOnChange", "true" } };
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs
index c345548c3a44c3..ae090c996d65a5 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs
@@ -1382,16 +1382,21 @@ public void ThrowExceptionForCustomImplementationOfIHostApplicationLifetime()
});
}
+ public static TheoryData BackgroundServiceExceptionLoggedData => new()
+ {
+ { BackgroundServiceExceptionBehavior.Ignore, new[] { "BackgroundService failed" } },
+ { BackgroundServiceExceptionBehavior.StopHost, new[] { "BackgroundService failed", "The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost" } },
+ };
+
///
/// Tests when a BackgroundService throws an exception asynchronously
/// (after an await), the exception gets logged correctly.
///
[Theory]
- [InlineData(BackgroundServiceExceptionBehavior.Ignore, "BackgroundService failed")]
- [InlineData(BackgroundServiceExceptionBehavior.StopHost, "BackgroundService failed", "The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost")]
+ [MemberData(nameof(BackgroundServiceExceptionLoggedData))]
public async Task BackgroundServiceAsyncExceptionGetsLogged(
BackgroundServiceExceptionBehavior testBehavior,
- params string[] expectedExceptionMessages)
+ string[] expectedExceptionMessages)
{
TestLoggerProvider logger = new TestLoggerProvider();
var backgroundDelayTaskSource = new TaskCompletionSource();
diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs
index 1dabceba194e26..03c99a0329a6b4 100644
--- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs
+++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs
@@ -11,7 +11,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Extensions.Http.Logging
{
diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs
index cb62d0cd6b5f19..2de051e6a2d555 100644
--- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs
+++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs
@@ -70,7 +70,7 @@ public void GetRedactedUriString_DisableUriRedaction_DoesNotRedactUri(string que
break;
}
- Uri[] uris = GetRedactedUriString_Data.Select(a => a[0] == null ? null : new Uri((string)a[0], UriKind.RelativeOrAbsolute)).ToArray();
+ Uri[] uris = GetRedactedUriString_Data.Select(a => a.Data.Item1 == null ? null : new Uri((string)a.Data.Item1, UriKind.RelativeOrAbsolute)).ToArray();
foreach (Uri uri in uris)
{
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/AnsiParserTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/AnsiParserTests.cs
index 215535c8efb9e4..6d919b4fe92e50 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/AnsiParserTests.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/AnsiParserTests.cs
@@ -150,35 +150,8 @@ public void Parse_RepeatedColorChange_PicksLastSet()
}
[Theory]
- // supported
- [InlineData("\e[77mInfo", "Info")]
- [InlineData("\e[77m\e[1m\e[2m\e[0mInfo\e[1m", "Info")]
- [InlineData("\e[7mInfo", "Info")]
- [InlineData("\e[40m\e[1m\e[33mwarn\e[39m\e[22m\e[49m:", "warn", ":")]
- // unsupported: skips
- [InlineData("Info\e[77m:", "Info", ":")]
- [InlineData("Info\e[7m:", "Info", ":")]
- // treats as content
- [InlineData("\e", "\e")]
- [InlineData("\e ", "\e ")]
- [InlineData("\em", "\em")]
- [InlineData("\e m", "\e m")]
- [InlineData("\exym", "\exym")]
- [InlineData("\e[", "\e[")]
- [InlineData("\e[m", "\e[m")]
- [InlineData("\e[ ", "\e[ ")]
- [InlineData("\e[ m", "\e[ m")]
- [InlineData("\e[xym", "\e[xym")]
- [InlineData("\e[7777m", "\e[7777m")]
- [InlineData("\e\e\e", "\e\e\e")]
- [InlineData("Message\e\e\e", "Message\e\e\e")]
- [InlineData("\e\eMessage\e", "\e\eMessage\e")]
- [InlineData("\e\e\eMessage", "\e\e\eMessage")]
- [InlineData("Message\e ", "Message\e ")]
- [InlineData("\emMessage", "\emMessage")]
- [InlineData("\e[77m\e m\e[40m", "\e m")]
- [InlineData("\e mMessage\exym", "\e mMessage\exym")]
- public void Parse_ValidSupportedOrUnsupportedCodesInMessage_MessageParsedSuccessfully(string messageWithUnsupportedCode, params string[] output)
+ [MemberData(nameof(ValidSupportedOrUnsupportedCodesInMessage_Data))]
+ public void Parse_ValidSupportedOrUnsupportedCodesInMessage_MessageParsedSuccessfully(string messageWithUnsupportedCode, string[] output)
{
// Arrange
var message = messageWithUnsupportedCode;
@@ -207,6 +180,38 @@ public void NullDelegate_Throws()
Assert.Throws(() => new AnsiParser(null));
}
+ public static IEnumerable ValidSupportedOrUnsupportedCodesInMessage_Data()
+ {
+ // supported
+ yield return new object[] { "\e[77mInfo", new[] { "Info" } };
+ yield return new object[] { "\e[77m\e[1m\e[2m\e[0mInfo\e[1m", new[] { "Info" } };
+ yield return new object[] { "\e[7mInfo", new[] { "Info" } };
+ yield return new object[] { "\e[40m\e[1m\e[33mwarn\e[39m\e[22m\e[49m:", new[] { "warn", ":" } };
+ // unsupported: skips
+ yield return new object[] { "Info\e[77m:", new[] { "Info", ":" } };
+ yield return new object[] { "Info\e[7m:", new[] { "Info", ":" } };
+ // treats as content
+ yield return new object[] { "\e", new[] { "\e" } };
+ yield return new object[] { "\e ", new[] { "\e " } };
+ yield return new object[] { "\em", new[] { "\em" } };
+ yield return new object[] { "\e m", new[] { "\e m" } };
+ yield return new object[] { "\exym", new[] { "\exym" } };
+ yield return new object[] { "\e[", new[] { "\e[" } };
+ yield return new object[] { "\e[m", new[] { "\e[m" } };
+ yield return new object[] { "\e[ ", new[] { "\e[ " } };
+ yield return new object[] { "\e[ m", new[] { "\e[ m" } };
+ yield return new object[] { "\e[xym", new[] { "\e[xym" } };
+ yield return new object[] { "\e[7777m", new[] { "\e[7777m" } };
+ yield return new object[] { "\e\e\e", new[] { "\e\e\e" } };
+ yield return new object[] { "Message\e\e\e", new[] { "Message\e\e\e" } };
+ yield return new object[] { "\e\eMessage\e", new[] { "\e\eMessage\e" } };
+ yield return new object[] { "\e\e\eMessage", new[] { "\e\e\eMessage" } };
+ yield return new object[] { "Message\e ", new[] { "Message\e " } };
+ yield return new object[] { "\emMessage", new[] { "\emMessage" } };
+ yield return new object[] { "\e[77m\e m\e[40m", new[] { "\e m" } };
+ yield return new object[] { "\e mMessage\exym", new[] { "\e mMessage\exym" } };
+ }
+
public static TheoryData Colors
{
get
diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/Common/FormattedLogValuesTest.cs b/src/libraries/Microsoft.Extensions.Logging/tests/Common/FormattedLogValuesTest.cs
index 4f5b3a8af4746b..077d96e537b920 100644
--- a/src/libraries/Microsoft.Extensions.Logging/tests/Common/FormattedLogValuesTest.cs
+++ b/src/libraries/Microsoft.Extensions.Logging/tests/Common/FormattedLogValuesTest.cs
@@ -29,25 +29,35 @@ public void LogValues_With_Basic_Types(string expected, string format, object[]?
}
[Theory]
- [InlineData("[null]", null, null)]
- [InlineData("[null]", null, new object[] { })]
- [InlineData("[null]", null, new object[] { null })]
- [InlineData("[null]", null, new object[] { 1 })]
- public void Log_NullFormat(string expected, string? format, object[]? args)
+ [MemberData(nameof(Log_NullFormat_Data))]
+ public void Log_NullFormat(string expected, string? format, object?[]? args)
{
var logValues = new FormattedLogValues(format, args);
Assert.Equal(expected, logValues.ToString());
}
+ public static IEnumerable Log_NullFormat_Data()
+ {
+ yield return new object?[] { "[null]", null, null };
+ yield return new object?[] { "[null]", null, new object[] { } };
+ yield return new object?[] { "[null]", null, new object?[] { null } };
+ yield return new object?[] { "[null]", null, new object[] { 1 } };
+ }
+
[Theory]
- [InlineData("(null), (null) : (null)", "{0} : {1}", new object[] { new object[] { null, null }, null })]
- [InlineData("(null)", "{0}", new object[] { null })]
- public void LogValues_WithNulls(string expected, string format, object[]? args)
+ [MemberData(nameof(LogValues_WithNulls_Data))]
+ public void LogValues_WithNulls(string expected, string format, object?[]? args)
{
var logValues = new FormattedLogValues(format, args);
Assert.Equal(expected, logValues.ToString());
}
+ public static IEnumerable LogValues_WithNulls_Data()
+ {
+ yield return new object?[] { "(null), (null) : (null)", "{0} : {1}", new object?[] { new object?[] { null, null }, null } };
+ yield return new object?[] { "(null)", "{0}", new object?[] { null } };
+ }
+
[Theory]
[InlineData("1 2015", "{Year,6:d yyyy}")]
[InlineData("1:01:2015 AM,: 01", "{Year,-10:d:MM:yyyy tt},:{second,10:ss}")]
diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerFactoryExtensions.cs b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerFactoryExtensions.cs
index 2afa57a50bc1fe..c080e5a81f80f9 100644
--- a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerFactoryExtensions.cs
+++ b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerFactoryExtensions.cs
@@ -4,7 +4,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Testing;
-using Xunit.Abstractions;
+using Xunit;
namespace Microsoft.Extensions.Logging
{
diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerProvider.cs b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerProvider.cs
index 949f044b88c477..7ca466fe43c4b2 100644
--- a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerProvider.cs
+++ b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/src/XunitLoggerProvider.cs
@@ -4,7 +4,7 @@
using System;
using System.Linq;
using System.Text;
-using Xunit.Abstractions;
+using Xunit;
namespace Microsoft.Extensions.Logging.Testing
{
diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/TestTestOutputHelper.cs b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/TestTestOutputHelper.cs
index bcd337bf1b9eb2..00b1eced1b5c6b 100644
--- a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/TestTestOutputHelper.cs
+++ b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/TestTestOutputHelper.cs
@@ -3,7 +3,7 @@
using System;
using System.Text;
-using Xunit.Abstractions;
+using Xunit;
namespace Microsoft.Extensions.Logging.Testing.Tests
{
@@ -15,6 +15,24 @@ public class TestTestOutputHelper : ITestOutputHelper
public string Output => _output.ToString();
+ public void Write(string message)
+ {
+ if (Throw)
+ {
+ throw new Exception("Boom!");
+ }
+ _output.Append(message);
+ }
+
+ public void Write(string format, params object[] args)
+ {
+ if (Throw)
+ {
+ throw new Exception("Boom!");
+ }
+ _output.Append(string.Format(format, args));
+ }
+
public void WriteLine(string message)
{
if (Throw)
diff --git a/src/libraries/Microsoft.Extensions.Options/tests/Microsoft.Extensions.Options.Tests/Microsoft.Extensions.Options.Tests.csproj b/src/libraries/Microsoft.Extensions.Options/tests/Microsoft.Extensions.Options.Tests/Microsoft.Extensions.Options.Tests.csproj
index d375c6390cb962..25b1be918ae772 100644
--- a/src/libraries/Microsoft.Extensions.Options/tests/Microsoft.Extensions.Options.Tests/Microsoft.Extensions.Options.Tests.csproj
+++ b/src/libraries/Microsoft.Extensions.Options/tests/Microsoft.Extensions.Options.Tests/Microsoft.Extensions.Options.Tests.csproj
@@ -3,6 +3,7 @@
$(NetCoreAppCurrent);$(NetFrameworkCurrent)
true
+ Microsoft.Extensions.Options.Tests
false
false
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/ErrObjectTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/ErrObjectTests.cs
index d04cfa38c504ca..9591fd833a45ec 100644
--- a/src/libraries/Microsoft.VisualBasic.Core/tests/ErrObjectTests.cs
+++ b/src/libraries/Microsoft.VisualBasic.Core/tests/ErrObjectTests.cs
@@ -13,6 +13,8 @@ public class ErrObjectTests
[Fact]
[ActiveIssue("https://github.com/mono/mono/issues/14854", typeof(PlatformDetection), nameof(PlatformDetection.IsSingleFile))]
[ActiveIssue("https://github.com/mono/mono/issues/14854", TestRuntimes.Mono)]
+ [ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
+ [ActiveIssue("https://github.com/dotnet/runtime/issues/0000")] // xunit3: LastDllError (Marshal.GetLastWin32Error) is non-zero due to P/Invoke calls in the self-hosted runner
public void Clear()
{
ProjectData.ClearProjectError();
diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs
index f844e0d0c801b7..4f603301269394 100644
--- a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs
+++ b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs
@@ -873,7 +873,6 @@ public void StrConv(string? str, Microsoft.VisualBasic.VbStrConv conversion, int
}
[Theory]
- [MemberData(nameof(StrDup_Object_TestData))]
[MemberData(nameof(StrDup_Char_TestData))]
[MemberData(nameof(StrDup_String_TestData))]
public void StrDup_Int_Object_Object(int number, object character, object expected)
@@ -916,11 +915,6 @@ public void StrDup_ArgumentException_Int_String(int number, string character)
Assert.Throws(() => Strings.StrDup(number, character));
}
- public static IEnumerable StrDup_Object_TestData()
- {
- yield break;
- }
-
public static IEnumerable StrDup_Char_TestData()
{
yield return new object[] { 3, '\0', "\0\0\0" };
diff --git a/src/libraries/Microsoft.Win32.Registry.AccessControl/tests/Microsoft.Win32.Registry.AccessControl.Tests.csproj b/src/libraries/Microsoft.Win32.Registry.AccessControl/tests/Microsoft.Win32.Registry.AccessControl.Tests.csproj
index edb1d8dc0c177a..b6045e24756295 100644
--- a/src/libraries/Microsoft.Win32.Registry.AccessControl/tests/Microsoft.Win32.Registry.AccessControl.Tests.csproj
+++ b/src/libraries/Microsoft.Win32.Registry.AccessControl/tests/Microsoft.Win32.Registry.AccessControl.Tests.csproj
@@ -1,6 +1,8 @@
$(NetCoreAppCurrent)-windows;$(NetFrameworkCurrent)
+
+ Microsoft.Win32.RegistryAccessControlTests
@@ -8,4 +10,4 @@
-
\ No newline at end of file
+
diff --git a/src/libraries/Microsoft.Win32.Registry/tests/Microsoft.Win32.Registry.Tests.csproj b/src/libraries/Microsoft.Win32.Registry/tests/Microsoft.Win32.Registry.Tests.csproj
index 817abf3dbe7d8a..702a4c8c8cd6ad 100644
--- a/src/libraries/Microsoft.Win32.Registry/tests/Microsoft.Win32.Registry.Tests.csproj
+++ b/src/libraries/Microsoft.Win32.Registry/tests/Microsoft.Win32.Registry.Tests.csproj
@@ -3,6 +3,7 @@
$(DefineConstants);REGISTRY_ASSEMBLY
$(NetCoreAppCurrent)-windows
true
+ Microsoft.Win32.RegistryTests
$(NetCoreAppCurrent)-windows;$(NetFrameworkCurrent)
true
true
+
+ Microsoft.Win32.SystemEventsTests
false
diff --git a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionCancellationTests.cs b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionCancellationTests.cs
index fb476ee5097f59..34da20cd8bf16b 100644
--- a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionCancellationTests.cs
+++ b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionCancellationTests.cs
@@ -8,11 +8,15 @@
namespace System.Collections.Concurrent.Tests
{
- [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public class BlockingCollectionCancellationTests
{
+ public BlockingCollectionCancellationTests()
+ {
+ Assert.SkipUnless(PlatformDetection.IsMultithreadingSupported, "ConditionalClass: PlatformDetection.IsMultithreadingSupported");
+ }
+
[Fact]
- public static void InternalCancellation_CompleteAdding_Negative()
+ public void InternalCancellation_CompleteAdding_Negative()
{
BlockingCollection coll1 = new BlockingCollection();
@@ -28,7 +32,7 @@ public static void InternalCancellation_CompleteAdding_Negative()
//This tests that Take/TryTake wake up correctly if CompleteAdding() is called while waiting
[Fact]
- public static void InternalCancellation_WakingUp()
+ public void InternalCancellation_WakingUp()
{
for (int test = 0; test < 2; test++)
{
@@ -62,7 +66,7 @@ public static void InternalCancellation_WakingUp()
}
[Fact]
- public static void ExternalCancel_Negative()
+ public void ExternalCancel_Negative()
{
BlockingCollection bc = new BlockingCollection(); //empty collection.
@@ -98,7 +102,7 @@ public static void ExternalCancel_Negative()
}
[Fact]
- public static void ExternalCancel_AddToAny()
+ public void ExternalCancel_AddToAny()
{
for (int test = 0; test < 3; test++)
{
@@ -131,7 +135,7 @@ public static void ExternalCancel_AddToAny()
}
[Fact]
- public static void ExternalCancel_GetConsumingEnumerable()
+ public void ExternalCancel_GetConsumingEnumerable()
{
BlockingCollection bc = new BlockingCollection();
bc.Add(1);
@@ -152,7 +156,7 @@ public static void ExternalCancel_GetConsumingEnumerable()
}
[Fact]
- public static void ExternalCancel_TakeFromAny_PreCanceled_WithAvailableItems()
+ public void ExternalCancel_TakeFromAny_PreCanceled_WithAvailableItems()
{
BlockingCollection bc1 = new BlockingCollection();
BlockingCollection bc2 = new BlockingCollection();
diff --git a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs
index 9ea9f1b8f56aae..a53eaedb53574e 100644
--- a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs
+++ b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs
@@ -13,11 +13,15 @@
namespace System.Collections.Concurrent.Tests
{
/// The class that contains the unit tests of the BlockingCollection.
- [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public class BlockingCollectionTests
{
+ public BlockingCollectionTests()
+ {
+ Assert.SkipUnless(PlatformDetection.IsMultithreadingSupported, "ConditionalClass: PlatformDetection.IsMultithreadingSupported");
+ }
+
[Fact]
- public static void TestBasicScenarios()
+ public void TestBasicScenarios()
{
BlockingCollection bc = new BlockingCollection(3);
Task[] tks = new Task[2];
@@ -55,7 +59,7 @@ public static void TestBasicScenarios()
///
///
[Fact]
- public static void TestBugFix544259()
+ public void TestBugFix544259()
{
int count = 8;
CountdownEvent cde = new CountdownEvent(count);
@@ -90,7 +94,7 @@ public static void TestBugFix544259()
// but we keep the test as a good example of how cleanup of linkedCTS must be carefully handled
// to prevent users of the source CTS mistakenly calling methods on disposed targets.
[Fact]
- public static void TestBugFix626345()
+ public void TestBugFix626345()
{
const int noOfProducers = 1;
const int noOfConsumers = 7;
@@ -154,7 +158,7 @@ public static void TestBugFix626345()
/// Making sure if TryTakeFromAny succeeds, it returns the correct index
///
[Fact]
- public static void TestBugFix914998()
+ public void TestBugFix914998()
{
var producer1 = new BlockingCollection();
var producer2 = new BlockingCollection();
@@ -172,7 +176,7 @@ public static void TestBugFix914998()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
- public static void TestDebuggerAttributes()
+ public void TestDebuggerAttributes()
{
DebuggerAttributes.ValidateDebuggerDisplayReferences(new BlockingCollection());
BlockingCollection col = new BlockingCollection { 1, 2, 3 };
@@ -183,7 +187,7 @@ public static void TestDebuggerAttributes()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
- public static void TestDebuggerAttributes_Null()
+ public void TestDebuggerAttributes_Null()
{
Type proxyType = DebuggerAttributes.GetProxyType(new BlockingCollection());
TargetInvocationException tie = Assert.Throws(() => Activator.CreateInstance(proxyType, (object)null));
@@ -197,7 +201,7 @@ public static void TestDebuggerAttributes_Null()
[Theory]
[InlineData(-1)]
[InlineData(10)]
- public static void TestConstruction(int boundedCapacity)
+ public void TestConstruction(int boundedCapacity)
{
BlockingCollection blockingQueue;
if (boundedCapacity != -1)
@@ -234,7 +238,7 @@ public static void TestConstruction(int boundedCapacity)
[Theory]
[InlineData(1, 1, -1)]
[InlineData(5, 3, 1)]
- public static void TestAddTake(int numOfAdds, int numOfTakes, int boundedCapacity)
+ public void TestAddTake(int numOfAdds, int numOfTakes, int boundedCapacity)
{
BlockingCollection blockingCollection = ConstructBlockingCollection(boundedCapacity);
AddAnyTakeAny(numOfAdds, numOfTakes, boundedCapacity, blockingCollection, null, -1);
@@ -244,7 +248,7 @@ public static void TestAddTake(int numOfAdds, int numOfTakes, int boundedCapacit
[InlineData(10, 10, 10)]
[InlineData(10, 10, 9)]
[OuterLoop]
- public static void TestAddTake_Longrunning(int numOfAdds, int numOfTakes, int boundedCapacity)
+ public void TestAddTake_Longrunning(int numOfAdds, int numOfTakes, int boundedCapacity)
{
TestAddTake(numOfAdds, numOfTakes, boundedCapacity);
}
@@ -256,7 +260,7 @@ public static void TestAddTake_Longrunning(int numOfAdds, int numOfTakes, int bo
[Theory]
[InlineData(2, 1024)]
[InlineData(8, 512)]
- public static void TestConcurrentAdd(int numOfThreads, int numOfElementsPerThread)
+ public void TestConcurrentAdd(int numOfThreads, int numOfElementsPerThread)
{
ManualResetEvent mre = new ManualResetEvent(false);
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -294,7 +298,7 @@ public static void TestConcurrentAdd(int numOfThreads, int numOfElementsPerThrea
/// Number of elements to Add/Take per thread.
[Theory]
[InlineData(8, 1024)]
- public static void TestConcurrentAddTake(int numOfThreads, int numOfElementsPerThread)
+ public void TestConcurrentAddTake(int numOfThreads, int numOfElementsPerThread)
{
//If numOfThreads is not an even number, make it even.
if ((numOfThreads % 2) != 0)
@@ -357,7 +361,7 @@ public static void TestConcurrentAddTake(int numOfThreads, int numOfElementsPerT
}
[Fact]
- public static void Test4_Dispose()
+ public void Test4_Dispose()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
blockingCollection.Dispose();
@@ -431,7 +435,7 @@ public static void Test4_Dispose()
/// same results as IConcurrentCollection.GetEnumerator().
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test5_GetEnumerator()
+ public void Test5_GetEnumerator()
{
ConcurrentStackCollection concurrentCollection = new ConcurrentStackCollection();
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -466,7 +470,7 @@ public static void Test5_GetEnumerator()
/// produces the same results as if call Take in a loop.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test6_GetConsumingEnumerable()
+ public void Test6_GetConsumingEnumerable()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
BlockingCollection blockingCollectionMirror = ConstructBlockingCollection();
@@ -511,7 +515,7 @@ public static void Test6_GetConsumingEnumerable()
/// on the enumerable returned from GetConsumingEnumerable will return false when the collection's count reaches 0.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test7_CompleteAdding()
+ public void Test7_CompleteAdding()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
blockingCollection.Add(0);
@@ -536,7 +540,7 @@ public static void Test7_CompleteAdding()
}
[Fact]
- public static void Test7_ConcurrentAdd_CompleteAdding()
+ public void Test7_ConcurrentAdd_CompleteAdding()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
Task[] threads = new Task[4];
@@ -574,7 +578,7 @@ public static void Test7_ConcurrentAdd_CompleteAdding()
/// IConcurrentCollection.ToArray().
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test8_ToArray()
+ public void Test8_ToArray()
{
ConcurrentStackCollection concurrentCollection = new ConcurrentStackCollection();
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -602,7 +606,7 @@ public static void Test8_ToArray()
[Theory]
[InlineData(0)]
[InlineData(8)]
- public static void TestCopyTo(int indexOfInsertion)
+ public void TestCopyTo(int indexOfInsertion)
{
ConcurrentStackCollection concurrentCollection = new ConcurrentStackCollection();
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -627,7 +631,7 @@ public static void TestCopyTo(int indexOfInsertion)
/// Validates BlockingCollection.Count.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test10_Count()
+ public void Test10_Count()
{
BlockingCollection blockingCollection = ConstructBlockingCollection(1);
Assert.Equal(0, blockingCollection.Count);
@@ -645,7 +649,7 @@ public static void Test10_Count()
/// Validates BlockingCollection.BoundedCapacity.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test11_BoundedCapacity()
+ public void Test11_BoundedCapacity()
{
BlockingCollection blockingCollection = ConstructBlockingCollection(1);
Assert.Equal(1, blockingCollection.BoundedCapacity);
@@ -657,7 +661,7 @@ public static void Test11_BoundedCapacity()
/// Validates BlockingCollection.IsCompleted and BlockingCollection.AddingIsCompleted.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test12_IsCompleted_AddingIsCompleted()
+ public void Test12_IsCompleted_AddingIsCompleted()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -694,7 +698,7 @@ public static void Test12_IsCompleted_AddingIsCompleted()
/// Validates BlockingCollection.IsSynchronized and BlockingCollection.SyncRoot.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test13_IsSynchronized_SyncRoot()
+ public void Test13_IsSynchronized_SyncRoot()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -717,7 +721,7 @@ public static void Test13_IsSynchronized_SyncRoot()
[Theory]
[InlineData(1, 1, 16, 0, -1)]
[InlineData(10, 10, 16, 14, 10)]
- public static void TestAddAnyTakeAny(int numOfAdds,
+ public void TestAddAnyTakeAny(int numOfAdds,
int numOfTakes,
int numOfBlockingCollections,
int indexOfBlockingCollectionUnderTest,
@@ -733,7 +737,7 @@ public static void TestAddAnyTakeAny(int numOfAdds,
[InlineData(10, 9, 16, 15, -1)]
[InlineData(10, 10, 16, 1, 9)]
[OuterLoop]
- public static void TestAddAnyTakeAny_Longrunning(int numOfAdds, int numOfTakes, int numOfBlockingCollections, int indexOfBlockingCollectionUnderTest, int boundedCapacity)
+ public void TestAddAnyTakeAny_Longrunning(int numOfAdds, int numOfTakes, int numOfBlockingCollections, int indexOfBlockingCollectionUnderTest, int boundedCapacity)
{
TestAddAnyTakeAny(numOfAdds, numOfTakes, numOfBlockingCollections, indexOfBlockingCollectionUnderTest, boundedCapacity);
}
@@ -822,7 +826,7 @@ private static void TestConcurrentAddAnyTakeAny(int numOfThreads, int numOfEleme
/// Validates the constructor of BlockingCollection.
/// True if test succeeded, false otherwise.
[Fact]
- public static void Test16_Ctor()
+ public void Test16_Ctor()
{
BlockingCollection blockingCollection = null;
@@ -844,7 +848,7 @@ public static void Test16_Ctor()
/// Verifies that the correct exceptions are thrown for invalid inputs.
/// True if test succeeds and false otherwise.
[Fact]
- public static void Test17_AddExceptions()
+ public void Test17_AddExceptions()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -863,7 +867,7 @@ public static void Test17_AddExceptions()
}
[Fact]
- public static void Test_AddTakeWithReject_DoNotCorruptCount()
+ public void Test_AddTakeWithReject_DoNotCorruptCount()
{
var secondFalse = new FalseOnSecondAddOrTake();
BlockingCollection bc = new BlockingCollection(secondFalse, 2);
@@ -894,7 +898,7 @@ public static void Test_AddTakeWithReject_DoNotCorruptCount()
/// Verifies that the correct exceptions are thrown for invalid inputs.
/// True if test succeeds and false otherwise.
[Fact]
- public static void Test18_TakeExceptions()
+ public void Test18_TakeExceptions()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
@@ -912,7 +916,7 @@ public static void Test18_TakeExceptions()
/// Verifies that the correct exceptions are thrown for invalid inputs.
/// True if test succeeds and false otherwise.
[Fact]
- public static void Test19_AddAnyExceptions()
+ public void Test19_AddAnyExceptions()
{
const int NUM_OF_COLLECTIONS = 2;
BlockingCollection[] blockingCollections = new BlockingCollection[NUM_OF_COLLECTIONS];
@@ -943,7 +947,7 @@ public static void Test19_AddAnyExceptions()
/// Verifies that the correct exceptions are thrown for invalid inputs.
/// True if test succeeds and false otherwise.
[Fact]
- public static void Test20_TakeAnyExceptions()
+ public void Test20_TakeAnyExceptions()
{
const int NUM_OF_COLLECTIONS = 2;
BlockingCollection[] blockingCollections = new BlockingCollection[NUM_OF_COLLECTIONS];
@@ -972,7 +976,7 @@ public static void Test20_TakeAnyExceptions()
/// Verifies that the correct exceptions are thrown for invalid inputs.
/// True if test succeeds and false otherwise.
[Fact]
- public static void Test21_CopyToExceptions()
+ public void Test21_CopyToExceptions()
{
BlockingCollection blockingCollection = ConstructBlockingCollection();
blockingCollection.Add(0);
@@ -996,7 +1000,7 @@ public static void Test21_CopyToExceptions()
}
[Fact]
- public static void Test_WithNullEntries()
+ public void Test_WithNullEntries()
{
BlockingCollection collection = new BlockingCollection()
{
@@ -1012,7 +1016,7 @@ public static void Test_WithNullEntries()
}
[Fact]
- public static void Test_LargeSize()
+ public void Test_LargeSize()
{
Assert.Equal(0, BlockingCollection.TryAddToAny(ConstructBlockingCollectionArray(63), 1));
Assert.Throws(() => BlockingCollection.TryAddToAny(ConstructBlockingCollectionArray(64), 1));
@@ -1021,7 +1025,7 @@ public static void Test_LargeSize()
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34360", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[PlatformSpecific(TestPlatforms.Windows)]
- public static void Test_LargeSize_STA()
+ public void Test_LargeSize_STA()
{
Thread t = new Thread(() =>
{
diff --git a/src/libraries/System.Collections.Immutable/tests/ImmutableArrayTest.cs b/src/libraries/System.Collections.Immutable/tests/ImmutableArrayTest.cs
index 6787c977ed55d4..3d883585ca0efd 100644
--- a/src/libraries/System.Collections.Immutable/tests/ImmutableArrayTest.cs
+++ b/src/libraries/System.Collections.Immutable/tests/ImmutableArrayTest.cs
@@ -11,8 +11,6 @@
using System.Text;
using System.Threading.Tasks;
using Xunit;
-using Xunit.Abstractions;
-
namespace System.Collections.Immutable.Tests
{
public partial class ImmutableArrayTest : SimpleElementImmutablesTestBase
@@ -2308,9 +2306,13 @@ public static IEnumerable IStructuralEquatableGetHashCodeData()
.Select(array => array[0])
.Cast>();
- return SharedComparers()
- .OfType()
- .Except(new IEqualityComparer[] { null })
+ var comparers = new IEqualityComparer[]
+ {
+ EqualityComparer.Default,
+ StructuralComparisons.StructuralEqualityComparer
+ };
+
+ return comparers
.SelectMany(comparer => enumerables.Select(enumerable => new object[] { enumerable, comparer }));
}
diff --git a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.IDictionary.Tests.cs b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.IDictionary.Tests.cs
index 92547c97cf1dfc..44b423a784c598 100644
--- a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.IDictionary.Tests.cs
+++ b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.IDictionary.Tests.cs
@@ -36,13 +36,10 @@ protected override object CreateTKey(int seed)
protected override object CreateTValue(int seed) => CreateTKey(seed);
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
- if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
- return;
-
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[] { count }, new int[] { 2 });
Assert.Equal(1, arr.Rank);
diff --git a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Keys.Tests.cs b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Keys.Tests.cs
index 2eea36114b941b..8cac1229d8831b 100644
--- a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Keys.Tests.cs
+++ b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Keys.Tests.cs
@@ -41,7 +41,7 @@ private string CreateT(int seed)
protected override void AddToCollection(ICollection collection, int numberOfItemsToAdd) => Debug.Assert(false);
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Values.Tests.cs b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Values.Tests.cs
index 53ae4e899f122e..559e11b51f7c92 100644
--- a/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Values.Tests.cs
+++ b/src/libraries/System.Collections.NonGeneric/tests/Hashtable/Hashtable.Values.Tests.cs
@@ -42,7 +42,7 @@ private string CreateT(int seed)
protected override void AddToCollection(ICollection collection, int numberOfItemsToAdd) => Debug.Assert(false);
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.KeysTests.cs b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.KeysTests.cs
index 110a13877fce9b..5e4971e8b0a9d5 100644
--- a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.KeysTests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.KeysTests.cs
@@ -43,7 +43,7 @@ private string CreateT(int seed)
protected override IEnumerable GetModifyEnumerables(ModifyOperation operations) => new List();
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.ValuesTests.cs b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.ValuesTests.cs
index 16f238dd120b51..404669dadaffe7 100644
--- a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.ValuesTests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionary.ValuesTests.cs
@@ -43,7 +43,7 @@ private string CreateT(int seed)
protected override IEnumerable GetModifyEnumerables(ModifyOperation operations) => new List();
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionaryTests.cs b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionaryTests.cs
index 960d3677451732..220c3771892fd3 100644
--- a/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionaryTests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/HybridDictionary/HybridDictionaryTests.cs
@@ -33,13 +33,10 @@ protected override object CreateTKey(int seed)
protected override object CreateTValue(int seed) => CreateTKey(seed);
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
- if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
- return;
-
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[] { count }, new int[] { 2 });
Assert.Equal(1, arr.Rank);
diff --git a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.IDictionary.Tests.cs b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.IDictionary.Tests.cs
index 169cc1e6988722..b4ce67bcafea7a 100644
--- a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.IDictionary.Tests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.IDictionary.Tests.cs
@@ -44,7 +44,7 @@ public override void ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_Thr
Assert.Throws(ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_ThrowType, () => collection.CopyTo(array, count + 1));
}
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Keys.Tests.cs b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Keys.Tests.cs
index 51cb28bd85ad90..e6c910af6e5710 100644
--- a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Keys.Tests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Keys.Tests.cs
@@ -85,7 +85,7 @@ public override void ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_Thr
Assert.Throws(ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_ThrowType, () => collection.CopyTo(array, count + 1));
}
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Values.Tests.cs b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Values.Tests.cs
index 0392890fc07247..65ad880ca39d8a 100644
--- a/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Values.Tests.cs
+++ b/src/libraries/System.Collections.Specialized/tests/ListDictionary/ListDictionary.Values.Tests.cs
@@ -85,7 +85,7 @@ public override void ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_Thr
Assert.Throws(ICollection_NonGeneric_CopyTo_IndexLargerThanArrayCount_ThrowType, () => collection.CopyTo(array, count + 1));
}
- [Theory]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))]
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
diff --git a/src/libraries/System.Collections/tests/CollectionTestData.cs b/src/libraries/System.Collections/tests/CollectionTestData.cs
new file mode 100644
index 00000000000000..771b8b9d31bd97
--- /dev/null
+++ b/src/libraries/System.Collections/tests/CollectionTestData.cs
@@ -0,0 +1,92 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Collections.Generic;
+
+namespace System.Collections.Tests
+{
+ ///
+ /// Non-generic static class holding MemberData providers that would otherwise
+ /// be on generic test classes. The xunit v3 AOT source generator cannot emit
+ /// valid code for MemberData on generic classes (open type parameters in non-generic context).
+ ///
+ public static class CollectionTestData
+ {
+ public static IEnumerable ValidCollectionSizes_GreaterThanOne()
+ {
+ yield return new object[] { 2 };
+ yield return new object[] { 20 };
+ }
+
+ public static IEnumerable EnsureCapacity_LargeCapacity_Throws_MemberData()
+ {
+ yield return new object[] { 5, Array.MaxLength + 1 };
+ yield return new object[] { 1, int.MaxValue };
+ }
+
+ public static IEnumerable Stack_Generic_EnsureCapacity_LargeCapacityRequested_Throws_MemberData()
+ {
+ yield return new object[] { Array.MaxLength + 1 };
+ yield return new object[] { int.MaxValue };
+ }
+
+ public static IEnumerable Queue_Generic_EnsureCapacity_LargeCapacityRequested_Throws_MemberData()
+ {
+ yield return new object[] { Array.MaxLength + 1 };
+ yield return new object[] { int.MaxValue };
+ }
+
+ public static IEnumerable UnionWith_HashSet_TestData()
+ {
+ foreach (int count in new[] { 0, 1, 75 })
+ {
+ foreach (bool destinationEmpty in new[] { true, false })
+ {
+ foreach (bool sourceSparseFilled in new[] { true, false })
+ {
+ yield return new object[] { count, destinationEmpty, sourceSparseFilled };
+ }
+ }
+ }
+ }
+
+ public static IEnumerable Dictionary_GetAlternateLookup_OperationsMatchUnderlyingDictionary_MemberData()
+ {
+ yield return new object[] { EqualityComparer.Default };
+ yield return new object[] { StringComparer.Ordinal };
+ yield return new object[] { StringComparer.OrdinalIgnoreCase };
+ yield return new object[] { StringComparer.InvariantCulture };
+ yield return new object[] { StringComparer.InvariantCultureIgnoreCase };
+ yield return new object[] { StringComparer.CurrentCulture };
+ yield return new object[] { StringComparer.CurrentCultureIgnoreCase };
+ }
+
+ public enum IndexOfMethod
+ {
+ IndexOf_T,
+ IndexOf_T_int,
+ IndexOf_T_int_int,
+ LastIndexOf_T,
+ LastIndexOf_T_int,
+ LastIndexOf_T_int_int,
+ }
+
+ public static IEnumerable IndexOfTestData()
+ {
+ foreach (object[] sizes in TestBase.ValidCollectionSizes())
+ {
+ int count = (int)sizes[0];
+ yield return new object[] { IndexOfMethod.IndexOf_T, count, true };
+ yield return new object[] { IndexOfMethod.LastIndexOf_T, count, false };
+
+ if (count > 0) // 0 is an invalid index for IndexOf when the count is 0.
+ {
+ yield return new object[] { IndexOfMethod.IndexOf_T_int, count, true };
+ yield return new object[] { IndexOfMethod.LastIndexOf_T_int, count, false };
+ yield return new object[] { IndexOfMethod.IndexOf_T_int_int, count, true };
+ yield return new object[] { IndexOfMethod.LastIndexOf_T_int_int, count, false };
+ }
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Collections/tests/Generic/Comparers/EqualityComparer.Tests.cs b/src/libraries/System.Collections/tests/Generic/Comparers/EqualityComparer.Tests.cs
index d25a7cfd7ab8b6..cc863b9233fc7a 100644
--- a/src/libraries/System.Collections/tests/Generic/Comparers/EqualityComparer.Tests.cs
+++ b/src/libraries/System.Collections/tests/Generic/Comparers/EqualityComparer.Tests.cs
@@ -16,8 +16,8 @@ public IEnumerable Items
{
get
{
- return this.Select(array => array[0])
- .Concat(this.Select(array => array[1]))
+ return this.Select(row => row.Data.Item1)
+ .Concat(this.Select(row => row.Data.Item2))
.Cast();
}
}
diff --git a/src/libraries/System.Collections/tests/Generic/Dictionary/Dictionary.Generic.Tests.cs b/src/libraries/System.Collections/tests/Generic/Dictionary/Dictionary.Generic.Tests.cs
index 2197973ca51306..4934a6d326300b 100644
--- a/src/libraries/System.Collections/tests/Generic/Dictionary/Dictionary.Generic.Tests.cs
+++ b/src/libraries/System.Collections/tests/Generic/Dictionary/Dictionary.Generic.Tests.cs
@@ -36,7 +36,7 @@ public abstract class Dictionary_Generic_Tests : IDictionary_Gener
#region Constructors
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_Constructor_IDictionary(int count)
{
IDictionary source = GenericIDictionaryFactory(count);
@@ -45,7 +45,7 @@ public void Dictionary_Generic_Constructor_IDictionary(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_Constructor_IDictionary_IEqualityComparer(int count)
{
IEqualityComparer comparer = GetKeyIEqualityComparer();
@@ -56,7 +56,7 @@ public void Dictionary_Generic_Constructor_IDictionary_IEqualityComparer(int cou
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_Constructor_IEqualityComparer(int count)
{
IEqualityComparer comparer = GetKeyIEqualityComparer();
@@ -67,7 +67,7 @@ public void Dictionary_Generic_Constructor_IEqualityComparer(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_Constructor_int(int count)
{
IDictionary dictionary = new Dictionary(count);
@@ -75,7 +75,7 @@ public void Dictionary_Generic_Constructor_int(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_Constructor_int_IEqualityComparer(int count)
{
IEqualityComparer comparer = GetKeyIEqualityComparer();
@@ -117,7 +117,7 @@ public void DictResized_CapacityChanged()
#region ContainsValue
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_ContainsValue_NotPresent(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -129,7 +129,7 @@ public void Dictionary_Generic_ContainsValue_NotPresent(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_ContainsValue_Present(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -142,7 +142,7 @@ public void Dictionary_Generic_ContainsValue_Present(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_ContainsValue_DefaultValueNotPresent(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -150,7 +150,7 @@ public void Dictionary_Generic_ContainsValue_DefaultValueNotPresent(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_ContainsValue_DefaultValuePresent(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -167,7 +167,7 @@ public void Dictionary_Generic_ContainsValue_DefaultValuePresent(int count)
#region IReadOnlyDictionary.Keys
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IReadOnlyDictionary_Generic_Keys_ContainsAllCorrectKeys(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -177,7 +177,7 @@ public void IReadOnlyDictionary_Generic_Keys_ContainsAllCorrectKeys(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void IReadOnlyDictionary_Generic_Values_ContainsAllCorrectValues(int count)
{
IDictionary dictionary = GenericIDictionaryFactory(count);
@@ -191,7 +191,7 @@ public void IReadOnlyDictionary_Generic_Values_ContainsAllCorrectValues(int coun
#region Remove(TKey)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_RemoveKey_ValidKeyNotContainedInDictionary(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -204,7 +204,7 @@ public void Dictionary_Generic_RemoveKey_ValidKeyNotContainedInDictionary(int co
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -220,7 +220,7 @@ public void Dictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int count
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int count)
{
Dictionary dictionary = (Dictionary)GenericIDictionaryFactory(count);
@@ -244,7 +244,7 @@ public void Dictionary_Generic_RemoveKey_DefaultKeyNotContainedInDictionary(int
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Dictionary_Generic_RemoveKey_DefaultKeyContainedInDictionary(int count)
{
if (DefaultValueAllowed)
@@ -313,7 +313,7 @@ public void Dictionary_Generic_Remove_RemoveLastEnumerationFinishes()
#region EnsureCapacity
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void EnsureCapacity_Generic_RequestingLargerCapacity_DoesInvalidateEnumeration(int count)
{
var dictionary = (Dictionary)(GenericIDictionaryFactory(count));
@@ -662,19 +662,8 @@ public void GetAlternateLookup_FailsWhenIncompatible()
Assert.False(dictionary.TryGetAlternateLookup(out _));
}
- public static IEnumerable Dictionary_GetAlternateLookup_OperationsMatchUnderlyingDictionary_MemberData()
- {
- yield return new object[] { EqualityComparer.Default };
- yield return new object[] { StringComparer.Ordinal };
- yield return new object[] { StringComparer.OrdinalIgnoreCase };
- yield return new object[] { StringComparer.InvariantCulture };
- yield return new object[] { StringComparer.InvariantCultureIgnoreCase };
- yield return new object[] { StringComparer.CurrentCulture };
- yield return new object[] { StringComparer.CurrentCultureIgnoreCase };
- }
-
[Theory]
- [MemberData(nameof(Dictionary_GetAlternateLookup_OperationsMatchUnderlyingDictionary_MemberData))]
+ [MemberData(nameof(CollectionTestData.Dictionary_GetAlternateLookup_OperationsMatchUnderlyingDictionary_MemberData), MemberType = typeof(CollectionTestData))]
public void Dictionary_GetAlternateLookup_OperationsMatchUnderlyingDictionary(IEqualityComparer comparer)
{
// Test with a variety of comparers to ensure that the alternate lookup is consistent with the underlying dictionary
diff --git a/src/libraries/System.Collections/tests/Generic/HashSet/HashSet.Generic.Tests.cs b/src/libraries/System.Collections/tests/Generic/HashSet/HashSet.Generic.Tests.cs
index 673fb788101ff7..3af499884f04c2 100644
--- a/src/libraries/System.Collections/tests/Generic/HashSet/HashSet.Generic.Tests.cs
+++ b/src/libraries/System.Collections/tests/Generic/HashSet/HashSet.Generic.Tests.cs
@@ -73,7 +73,7 @@ public void HashSet_Generic_Constructor_NullIEqualityComparer()
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_IEnumerable(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
_ = setLength;
@@ -84,7 +84,7 @@ public void HashSet_Generic_Constructor_IEnumerable(EnumerableType enumerableTyp
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_IEnumerable_WithManyDuplicates(int count)
{
IEnumerable items = CreateEnumerable(EnumerableType.List, null, count, 0, 0);
@@ -94,7 +94,7 @@ public void HashSet_Generic_Constructor_IEnumerable_WithManyDuplicates(int count
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_HashSet_SparselyFilled(int count)
{
HashSet source = (HashSet)CreateEnumerable(EnumerableType.HashSet, null, count, 0, 0);
@@ -115,7 +115,7 @@ public void HashSet_Generic_Constructor_IEnumerable_Null()
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_IEnumerable_IEqualityComparer(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
_ = setLength;
@@ -158,7 +158,7 @@ public void HashSetResized_CapacityChanged()
#region RemoveWhere
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_RemoveWhere_AllElements(int setLength)
{
HashSet set = (HashSet)GenericISetFactory(setLength);
@@ -167,7 +167,7 @@ public void HashSet_Generic_RemoveWhere_AllElements(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_RemoveWhere_NoElements(int setLength)
{
HashSet set = (HashSet)GenericISetFactory(setLength);
@@ -191,7 +191,7 @@ public void HashSet_Generic_RemoveWhere_NewObject() // Regression Dev10_624201
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_RemoveWhere_NullMatchPredicate(int setLength)
{
HashSet set = (HashSet)GenericISetFactory(setLength);
@@ -248,7 +248,7 @@ public void HashHet_Generic_TrimExcess_LargePopulatedHashSet_TrimCapacityIsLessT
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_TrimExcess_OnValidSetThatHasntBeenRemovedFrom(int setLength)
{
HashSet set = (HashSet)GenericISetFactory(setLength);
@@ -256,7 +256,7 @@ public void HashSet_Generic_TrimExcess_OnValidSetThatHasntBeenRemovedFrom(int se
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_TrimExcess_Repeatedly(int setLength)
{
HashSet set = (HashSet)GenericISetFactory(setLength);
@@ -268,7 +268,7 @@ public void HashSet_Generic_TrimExcess_Repeatedly(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
{
if (setLength > 0)
@@ -287,7 +287,7 @@ public void HashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_TrimExcess_AfterClearingAndAddingSomeElementsBack(int setLength)
{
if (setLength > 0)
@@ -305,7 +305,7 @@ public void HashSet_Generic_TrimExcess_AfterClearingAndAddingSomeElementsBack(in
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int setLength)
{
if (setLength > 0)
@@ -327,7 +327,7 @@ public void HashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int
#region CopyTo
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_CopyTo_NegativeCount_ThrowsArgumentOutOfRangeException(int count)
{
HashSet set = (HashSet)GenericISetFactory(count);
@@ -337,7 +337,7 @@ public void HashSet_Generic_CopyTo_NegativeCount_ThrowsArgumentOutOfRangeExcepti
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_CopyTo_NoIndexDefaultsToZero(int count)
{
HashSet set = (HashSet)GenericISetFactory(count);
@@ -540,7 +540,7 @@ public void CanBeCastedToISet()
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_int(int capacity)
{
HashSet set = new HashSet(capacity);
@@ -548,7 +548,7 @@ public void HashSet_Generic_Constructor_int(int capacity)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_int_AddUpToAndBeyondCapacity(int capacity)
{
HashSet set = new HashSet(capacity);
@@ -580,7 +580,7 @@ public void HashSet_Generic_Constructor_int_Negative_ThrowsArgumentOutOfRangeExc
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_int_IEqualityComparer(int capacity)
{
IEqualityComparer comparer = GetIEqualityComparer();
@@ -593,7 +593,7 @@ public void HashSet_Generic_Constructor_int_IEqualityComparer(int capacity)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void HashSet_Generic_Constructor_int_IEqualityComparer_AddUpToAndBeyondCapacity(int capacity)
{
IEqualityComparer comparer = GetIEqualityComparer();
@@ -677,7 +677,7 @@ public void HashSet_Generic_TryGetValue_NotContains_OverwriteOutputParam()
#region EnsureCapacity
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration(int setLength)
{
HashSet set = (HashSet)(GenericISetFactory(setLength));
@@ -828,7 +828,7 @@ public void EnsureCapacity_Generic_GrowCapacityWithFreeList(int setLength)
#region Remove
[Theory]
- [MemberData(nameof(ValidPositiveCollectionSizes))]
+ [MemberData(nameof(ValidPositiveCollectionSizes), MemberType = typeof(TestBase))]
public void Remove_NonDefaultComparer_ComparerUsed(int capacity)
{
var c = new TrackingEqualityComparer();
@@ -910,22 +910,8 @@ static void TestComparerSerialization(IEqualityComparer eq
#region UnionWith
- public static IEnumerable UnionWith_HashSet_TestData()
- {
- foreach (int count in new[] { 0, 1, 75 })
- {
- foreach (bool destinationEmpty in new[] { true, false })
- {
- foreach (bool sourceSparseFilled in new[] { true, false })
- {
- yield return new object[] { count, destinationEmpty, sourceSparseFilled };
- }
- }
- }
- }
-
[Theory]
- [MemberData(nameof(UnionWith_HashSet_TestData))]
+ [MemberData(nameof(CollectionTestData.UnionWith_HashSet_TestData), MemberType = typeof(CollectionTestData))]
public void HashSet_Generic_UnionWith_HashSet(int count, bool destinationEmpty, bool sourceSparseFilled)
{
HashSet source = (HashSet)CreateEnumerable(EnumerableType.HashSet, null, count, 0, 0);
diff --git a/src/libraries/System.Collections/tests/Generic/LinkedList/LinkedList.Generic.Tests.cs b/src/libraries/System.Collections/tests/Generic/LinkedList/LinkedList.Generic.Tests.cs
index 7f0998cac8789e..f5906bef93b247 100644
--- a/src/libraries/System.Collections/tests/Generic/LinkedList/LinkedList.Generic.Tests.cs
+++ b/src/libraries/System.Collections/tests/Generic/LinkedList/LinkedList.Generic.Tests.cs
@@ -491,7 +491,7 @@ private void VerifyRemovedNode(LinkedList linkedList, T[] linkedListValues, L
#region Constructor_IEnumerable
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void LinkedList_Generic_Constructor_IEnumerable(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
_ = setLength;
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.AddRange.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.AddRange.cs
index c0309d046580e9..68580e194e8512 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.AddRange.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.AddRange.cs
@@ -15,7 +15,7 @@ public abstract partial class List_Generic_Tests : IList_Generic_Tests
// Has tests that pass a variably sized TestCollection and MyEnumerable to the AddRange function
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void AddRange(EnumerableType enumerableType, int listLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
List list = GenericListFactory(listLength);
@@ -37,7 +37,7 @@ public void AddRange(EnumerableType enumerableType, int listLength, int enumerab
}
[Theory]
- [MemberData(nameof(ListTestData))]
+ [MemberData(nameof(ListTestData), MemberType = typeof(TestBase))]
public void AddRange_Span(EnumerableType enumerableType, int listLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
List list = GenericListFactory(listLength);
@@ -66,7 +66,7 @@ public void AddRange_NullList_ThrowsArgumentNullException()
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void AddRange_NullEnumerable_ThrowsArgumentNullException(int count)
{
List list = GenericListFactory(count);
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.BinarySearch.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.BinarySearch.cs
index efe199acc7eed1..ec97a93dffca09 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.BinarySearch.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.BinarySearch.cs
@@ -13,7 +13,7 @@ namespace System.Collections.Tests
public abstract partial class List_Generic_Tests : IList_Generic_Tests
{
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void BinarySearch_ForEveryItemWithoutDuplicates(int count)
{
List list = GenericListFactory(count);
@@ -32,7 +32,7 @@ public void BinarySearch_ForEveryItemWithoutDuplicates(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void BinarySearch_ForEveryItemWithDuplicates(int count)
{
if (count > 0)
@@ -52,7 +52,7 @@ public void BinarySearch_ForEveryItemWithDuplicates(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void BinarySearch_Validations(int count)
{
List list = GenericListFactory(count);
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Constructor.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Constructor.cs
index 209dccdb828d17..0b5ea23b192d15 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Constructor.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Constructor.cs
@@ -45,7 +45,7 @@ public void Constructor_NegativeCapacity_ThrowsArgumentOutOfRangeException(int c
}
[Theory]
- [MemberData(nameof(EnumerableTestData))]
+ [MemberData(nameof(EnumerableTestData), MemberType = typeof(TestBase))]
public void Constructor_IEnumerable(EnumerableType enumerableType, int listLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
{
_ = listLength;
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.EnsureCapacity.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.EnsureCapacity.cs
index ce2956ab7f5516..9d029da61e67ba 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.EnsureCapacity.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.EnsureCapacity.cs
@@ -12,7 +12,7 @@ namespace System.Collections.Tests
public abstract partial class List_Generic_Tests : IList_Generic_Tests
{
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void EnsureCapacity_RequestingLargerCapacity_DoesNotInvalidateEnumeration(int count)
{
List list = GenericListFactory(count);
@@ -40,14 +40,8 @@ public void EnsureCapacity_NegativeCapacityRequested_Throws()
AssertExtensions.Throws("capacity", () => list.EnsureCapacity(-1));
}
- public static IEnumerable EnsureCapacity_LargeCapacity_Throws_MemberData()
- {
- yield return new object[] { 5, Array.MaxLength + 1 };
- yield return new object[] { 1, int.MaxValue };
- }
-
[Theory]
- [MemberData(nameof(EnsureCapacity_LargeCapacity_Throws_MemberData))]
+ [MemberData(nameof(CollectionTestData.EnsureCapacity_LargeCapacity_Throws_MemberData), MemberType = typeof(CollectionTestData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51411", TestRuntimes.Mono)]
public void EnsureCapacity_LargeCapacity_Throws(int count, int requestCapacity)
{
@@ -69,7 +63,7 @@ public void EnsureCapacity_RequestedCapacitySmallerThanOrEqualToCurrent_Capacity
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void EnsureCapacity_RequestedCapacitySmallerThanOrEqualToCount_CapacityUnchanged(int count)
{
List list = GenericListFactory(count);
@@ -97,7 +91,7 @@ public void EnsureCapacity_CapacityIsAtLeastTheRequested(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void EnsureCapacity_RequestingLargerCapacity_DoesNotImpactListContent(int count)
{
List list = GenericListFactory(count);
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Find.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Find.cs
index 5d2c7ded26c521..da3002ec3d1ade 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Find.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.Find.cs
@@ -17,7 +17,7 @@ public abstract partial class List_Generic_Tests : IList_Generic_Tests
private readonly Predicate _alwaysFalseDelegate = (T item) => false;
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindVerifyExceptions(int count)
{
List list = GenericListFactory(count);
@@ -37,7 +37,7 @@ public void FindVerifyExceptions(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexInt_VerifyExceptions(int count)
{
List list = GenericListFactory(count);
@@ -71,7 +71,7 @@ public void FindLastIndexInt_VerifyExceptions(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexIntInt_VerifyExceptions(int count)
{
List list = GenericListFactory(count);
@@ -129,7 +129,7 @@ index and count
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexIntInt_VerifyExceptions(int count)
{
List list = GenericListFactory(count);
@@ -189,7 +189,7 @@ index and count
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexInt_VerifyExceptions(int count)
{
List list = GenericListFactory(count);
@@ -218,7 +218,7 @@ public void FindIndexInt_VerifyExceptions(int count)
#region Find
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Find_VerifyVanilla(int count)
{
List list = GenericListFactory(count);
@@ -252,7 +252,7 @@ public void Find_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void Find_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -313,7 +313,7 @@ public void Find_ListSizeCanBeChanged()
#region FindLast
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLast_VerifyVanilla(int count)
{
List list = GenericListFactory(count);
@@ -351,7 +351,7 @@ public void FindLast_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLast_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -390,7 +390,7 @@ public void FindLast_VerifyDuplicates(int count)
#region FindIndex
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndex_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -421,7 +421,7 @@ public void FindIndex_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndex_VerifyDuplicates(int count)
{
List list = GenericListFactory(count);
@@ -456,7 +456,7 @@ public void FindIndex_VerifyDuplicates(int count)
#region FindIndex(int, pred)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexInt_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -509,7 +509,7 @@ public void FindIndexInt_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexInt_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -554,7 +554,7 @@ public void FindIndexInt_VerifyDuplicates(int count)
#region FindIndex(int, int, pred)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexIntInt_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -632,7 +632,7 @@ public void FindIndexIntInt_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindIndexIntInt_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -677,7 +677,7 @@ public void FindIndexIntInt_VerifyDuplicates(int count)
#region FindLastIndex
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndex_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -706,7 +706,7 @@ public void FindLastIndex_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndex_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -741,7 +741,7 @@ public void FindLastIndex_VerifyDuplicates(int count)
#region FindLastIndex(int, pred)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexInt_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -793,7 +793,7 @@ public void FindLastIndexInt_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexInt_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -838,7 +838,7 @@ public void FindLastIndexInt_VerifyDuplicates(int count)
#region FindLastIndex(int, int, pred)
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexIntInt_VerifyVanilla(int count)
{
T expectedItem = default(T);
@@ -919,7 +919,7 @@ public void FindLastIndexIntInt_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindLastIndexIntInt_VerifyDuplicates(int count)
{
T expectedItem = default(T);
@@ -954,7 +954,7 @@ public void FindLastIndexIntInt_VerifyDuplicates(int count)
#region FindAll
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindAll_VerifyVanilla(int count)
{
List list = GenericListFactory(count);
@@ -978,7 +978,7 @@ public void FindAll_VerifyVanilla(int count)
}
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void FindAll_VerifyDuplicates(int count)
{
List list = GenericListFactory(count);
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.ForEach.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.ForEach.cs
index 58f4210bc0b4ce..abe01e5a4a15dc 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.ForEach.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.ForEach.cs
@@ -12,7 +12,7 @@ namespace System.Collections.Tests
public abstract partial class List_Generic_Tests : IList_Generic_Tests
{
[Theory]
- [MemberData(nameof(ValidCollectionSizes))]
+ [MemberData(nameof(ValidCollectionSizes), MemberType = typeof(TestBase))]
public void ForEach_Verify(int count)
{
List list = GenericListFactory(count);
diff --git a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.IndexOf.cs b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.IndexOf.cs
index 7583d8e1b77810..c586838bda50b7 100644
--- a/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.IndexOf.cs
+++ b/src/libraries/System.Collections/tests/Generic/List/List.Generic.Tests.IndexOf.cs
@@ -15,68 +15,35 @@ public abstract partial class List_Generic_Tests : IList_Generic_Tests
#region Helpers
public delegate int IndexOfDelegate(List list, T value);
- public enum IndexOfMethod
- {
- IndexOf_T,
- IndexOf_T_int,
- IndexOf_T_int_int,
- LastIndexOf_T,
- LastIndexOf_T_int,
- LastIndexOf_T_int_int,
- };
-
- private IndexOfDelegate IndexOfDelegateFromType(IndexOfMethod methodType)
+
+ private IndexOfDelegate IndexOfDelegateFromType(CollectionTestData.IndexOfMethod methodType)
{
switch (methodType)
{
- case (IndexOfMethod.IndexOf_T):
+ case (CollectionTestData.IndexOfMethod.IndexOf_T):
return ((List list, T value) => { return list.IndexOf(value); });
- case (IndexOfMethod.IndexOf_T_int):
+ case (CollectionTestData.IndexOfMethod.IndexOf_T_int):
return ((List list, T value) => { return list.IndexOf(value, 0); });
- case (IndexOfMethod.IndexOf_T_int_int):
+ case (CollectionTestData.IndexOfMethod.IndexOf_T_int_int):
return ((List list, T value) => { return list.IndexOf(value, 0, list.Count); });
- case (IndexOfMethod.LastIndexOf_T):
+ case (CollectionTestData.IndexOfMethod.LastIndexOf_T):
return ((List list, T value) => { return list.LastIndexOf(value); });
- case (IndexOfMethod.LastIndexOf_T_int):
+ case (CollectionTestData.IndexOfMethod.LastIndexOf_T_int):
return ((List list, T value) => { return list.LastIndexOf(value, list.Count - 1); });
- case (IndexOfMethod.LastIndexOf_T_int_int):
+ case (CollectionTestData.IndexOfMethod.LastIndexOf_T_int_int):
return ((List list, T value) => { return list.LastIndexOf(value, list.Count - 1, list.Count); });
default:
throw new Exception("Invalid IndexOfMethod");
}
}
- ///