Skip to content

Commit

Permalink
Remove defunct netfx tests (#96435)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Jan 7, 2024
1 parent c1de4ba commit 21b4a85
Show file tree
Hide file tree
Showing 36 changed files with 190 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ protected override IDictionary NonGenericIDictionaryFactory()
return new Dictionary<string, string>();
}

protected override ModifyOperation ModifyEnumeratorThrows => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorThrows : ModifyOperation.Add | ModifyOperation.Insert;
protected override ModifyOperation ModifyEnumeratorThrows => ModifyOperation.Add | ModifyOperation.Insert;

protected override ModifyOperation ModifyEnumeratorAllowed => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorAllowed : ModifyOperation.Overwrite | ModifyOperation.Remove | ModifyOperation.Clear;
protected override ModifyOperation ModifyEnumeratorAllowed => ModifyOperation.Overwrite | ModifyOperation.Remove | ModifyOperation.Clear;

/// <summary>
/// Creates an object that is dependent on the seed given. The object may be either
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ protected override IEnumerable NonGenericIEnumerableFactory(int count)
protected override bool Enumerator_Empty_UsesSingletonInstance => true;
protected override bool Enumerator_Current_UndefinedOperation_Throws => true;

protected override ModifyOperation ModifyEnumeratorThrows => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorThrows : (base.ModifyEnumeratorAllowed & ~ModifyOperation.Remove);
protected override ModifyOperation ModifyEnumeratorThrows => base.ModifyEnumeratorAllowed & ~ModifyOperation.Remove;

protected override ModifyOperation ModifyEnumeratorAllowed => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorAllowed : ModifyOperation.Overwrite | ModifyOperation.Remove;
protected override ModifyOperation ModifyEnumeratorAllowed => ModifyOperation.Overwrite | ModifyOperation.Remove;

/// <summary>
/// Returns a set of ModifyEnumerable delegates that modify the enumerable passed to them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public abstract class HashSet_Generic_Tests<T> : ISet_Generic_Tests<T>

protected override bool ResetImplemented => true;

protected override ModifyOperation ModifyEnumeratorThrows => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorThrows : (base.ModifyEnumeratorAllowed & ~(ModifyOperation.Remove | ModifyOperation.Clear));
protected override ModifyOperation ModifyEnumeratorThrows => base.ModifyEnumeratorAllowed & ~(ModifyOperation.Remove | ModifyOperation.Clear);

protected override ModifyOperation ModifyEnumeratorAllowed => PlatformDetection.IsNetFramework ? base.ModifyEnumeratorAllowed : ModifyOperation.Overwrite | ModifyOperation.Remove | ModifyOperation.Clear;
protected override ModifyOperation ModifyEnumeratorAllowed => ModifyOperation.Overwrite | ModifyOperation.Remove | ModifyOperation.Clear;

protected override ISet<T> GenericISetFactory()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,15 @@ public class AssociationAttributeTests
[InlineData("TestName", "TestThisKey", "TestOtherKey", new string[] { "TestThisKey" }, new string[] { "TestOtherKey" })]
[InlineData(null, "", " \t \r \n", new string[] { "" }, new string[] { "\t\r\n" })]
[InlineData(null, null, null, new string[0], new string[0])]
[InlineData("Name", "ThisKey1, ThisKey2, ThisKey3", "OtherKey1, OtherKey2",new string[] { "ThisKey1", "ThisKey2", "ThisKey3" }, new string[] { "OtherKey1", "OtherKey2" })]
[InlineData("Name", "ThisKey1, ThisKey2, ThisKey3", "OtherKey1, OtherKey2", new string[] { "ThisKey1", "ThisKey2", "ThisKey3" }, new string[] { "OtherKey1", "OtherKey2" })]
public void Ctor_String_String_String(string name, string thisKey, string otherKey, string[] expectedThisKeyMembers, string[] expectedOtherKeyMembers)
{
var attribute = new AssociationAttribute(name, thisKey, otherKey);
Assert.Equal(name, attribute.Name);
Assert.Equal(thisKey, attribute.ThisKey);
Assert.Equal(otherKey, attribute.OtherKey);
if (PlatformDetection.IsNetFramework && thisKey == null)
{
Assert.Throws<NullReferenceException>(() => attribute.ThisKeyMembers);
}
else
{
Assert.Equal(expectedThisKeyMembers, attribute.ThisKeyMembers);
}
if (PlatformDetection.IsNetFramework && otherKey == null)
{
Assert.Throws<NullReferenceException>(() => attribute.OtherKeyMembers);
}
else
{
Assert.Equal(expectedOtherKeyMembers, attribute.OtherKeyMembers);
}
Assert.Equal(expectedThisKeyMembers, attribute.ThisKeyMembers);
Assert.Equal(expectedOtherKeyMembers, attribute.OtherKeyMembers);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,7 @@ public void FormatErrorMessage_PerformedValidation_DoesNotContainName()
public static void RequiresValidationContext_Get_ReturnsExpected(string method, bool expected)
{
CustomValidationAttribute attribute = GetAttribute(method);

// The .NET Framework has a bug where CustomValidationAttribute doesn't
// validate the context. See https://github.com/dotnet/runtime/issues/21100.
if (PlatformDetection.IsNetFramework)
{
Assert.False(attribute.RequiresValidationContext);
}
else
{
Assert.Equal(expected, attribute.RequiresValidationContext);
}
Assert.Equal(expected, attribute.RequiresValidationContext);
}

public static IEnumerable<object[]> BadlyFormed_TestData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static IEnumerable<object[]> Ctor_String_TestData()

// .NET Core fixed a bug where whitespace strings were allowed as CustomDataType.
// See https://github.com/dotnet/runtime/issues/15690.
yield return new object[] { " ", PlatformDetection.IsNetFramework };
yield return new object[] { " ", false };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ protected override IEnumerable<TestCase> InvalidValues()
yield return new TestCase(new PhoneAttribute(), "425-555-1212 ext. xyz");
yield return new TestCase(new PhoneAttribute(), "-.()");
yield return new TestCase(new PhoneAttribute(), "ext.123 1");

// By design, certain phone numbers are reported as valid with .NET Core, whereas .NET Framework
// considers them invalid. See https://github.com/dotnet/runtime/issues/20884.
if (PlatformDetection.IsNetFramework)
{
yield return new TestCase(new PhoneAttribute(), "+4+2+5+-+5+5+5+-+1+2++1+2++");
yield return new TestCase(new PhoneAttribute(), "425-555-1212 ");
yield return new TestCase(new PhoneAttribute(), " \r \n 1 \t ");
yield return new TestCase(new PhoneAttribute(), "1-.()");
yield return new TestCase(new PhoneAttribute(), "(425555-1212");
yield return new TestCase(new PhoneAttribute(), ")425555-1212");
}
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@ public static IEnumerable<object[]> Equals_TestData()
yield return new object[] { attribute, new CategoryAttribute("category"), true };
yield return new object[] { attribute, new CategoryAttribute("category2"), false };
yield return new object[] { attribute, new CategoryAttribute(string.Empty), false };
// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { attribute, new CategoryAttribute(null), false };
}

// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute(null), true };
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute("category"), false };
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute(string.Empty), false };
}

yield return new object[] { attribute, new CategoryAttribute(null), false };
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute(null), true };
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute("category"), false };
yield return new object[] { new CategoryAttribute(null), new CategoryAttribute(string.Empty), false };
yield return new object[] { new CategoryAttribute("category"), new object(), false };
yield return new object[] { new CategoryAttribute("category"), null, false };
yield return new object[] { new CategoryAttribute(null), new object(), false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,10 @@ public static IEnumerable<object[]> Equals_TestData()
yield return new object[] { attribute, new DescriptionAttribute("description"), true };
yield return new object[] { attribute, new DescriptionAttribute("description2"), false };
yield return new object[] { attribute, new DescriptionAttribute(""), false };
// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { attribute, new DescriptionAttribute(null), false };
}

// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute(null), true };
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute("description"), false };
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute(""), false };
}

yield return new object[] { attribute, new DescriptionAttribute(null), false };
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute(null), true };
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute("description"), false };
yield return new object[] { new DescriptionAttribute(null), new DescriptionAttribute(""), false };
yield return new object[] { new DescriptionAttribute("description"), new object(), false };
yield return new object[] { new DescriptionAttribute("description"), null, false };
yield return new object[] { new DescriptionAttribute(null), new object(), false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@ public static IEnumerable<object[]> Equals_TestData()
yield return new object[] { attribute, new DesignerCategoryAttribute("category"), true };
yield return new object[] { attribute, new DesignerCategoryAttribute("category2"), false };
yield return new object[] { attribute, new DesignerCategoryAttribute(string.Empty), false };
// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { attribute, new DesignerCategoryAttribute(null), false };
}

// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(null), true };
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute("category"), false };
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(string.Empty), false };
}

yield return new object[] { attribute, new DesignerCategoryAttribute(null), false };
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(null), true };
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute("category"), false };
yield return new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(string.Empty), false };
yield return new object[] { new DesignerCategoryAttribute("category"), new object(), false };
yield return new object[] { new DesignerCategoryAttribute("category"), null, false };
yield return new object[] { new DesignerCategoryAttribute(null), new object(), false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,10 @@ public static IEnumerable<object[]> Equals_TestData()
yield return new object[] { attribute, new DisplayNameAttribute("name"), true };
yield return new object[] { attribute, new DisplayNameAttribute("name2"), false };
yield return new object[] { attribute, new DisplayNameAttribute(""), false };
// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { attribute, new DisplayNameAttribute(null), false };
}

// .NET Framework throws a NullReferenceException.
if (!PlatformDetection.IsNetFramework)
{
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute(null), true };
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute(""), false };
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute("name"), false };
}

yield return new object[] { attribute, new DisplayNameAttribute(null), false };
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute(null), true };
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute(""), false };
yield return new object[] { new DisplayNameAttribute(null), new DisplayNameAttribute("name"), false };
yield return new object[] { new DisplayNameAttribute("name"), new object(), false };
yield return new object[] { new DisplayNameAttribute("name"), null, false };
yield return new object[] { new DisplayNameAttribute(null), new object(), false };
Expand Down
10 changes: 1 addition & 9 deletions src/libraries/System.Console/tests/WindowAndCursorProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,7 @@ public static void Title_Set_Windows(int lengthOfTitle)
string newTitle = new string('a', int.Parse(lengthOfTitleString));
Console.Title = newTitle;

if (newTitle.Length >= 511 && !PlatformDetection.IsNetCore && PlatformDetection.IsWindows10Version1703OrGreater && !PlatformDetection.IsWindows10Version1709OrGreater)
{
// RS2 has a bug when getting the window title when the title length is longer than 513 character
Assert.Throws<IOException>(() => Console.Title);
}
else
{
Assert.Equal(newTitle, Console.Title);
}
Assert.Equal(newTitle, Console.Title);
}, lengthOfTitle.ToString()).Dispose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public void PrivateDelegate(bool useInterpreter)
Assert.Equal(42, del.DynamicInvoke());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetFramework), nameof(PlatformDetection.IsNotMonoRuntime), nameof(PlatformDetection.IsNotNativeAot))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime), nameof(PlatformDetection.IsNotNativeAot))]
public void ValidateThatInterpreterWithSimpleTypeUsesNonDynamicThunk()
{
Expression<Action> action = () => Console.WriteLine("");
Expand All @@ -959,7 +959,7 @@ public void ValidateThatInterpreterWithSimpleTypeUsesNonDynamicThunk()
Assert.True(func2.Compile(preferInterpretation:true).Method.GetType().Name == "RuntimeMethodInfo");
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetFramework), nameof(PlatformDetection.IsNotMonoRuntime), nameof(PlatformDetection.IsNotNativeAot))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime), nameof(PlatformDetection.IsNotNativeAot))]
public void ValidateThatInterpreterWithSimpleTypeUsesDynamicThunk()
{
Expression<Action<object,object,object>> complexaction = (object o1, object o2, object o3) => Console.WriteLine("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,9 @@ public static void Name_GetSet_Success()
c1.Name = "hello";
Assert.Equal("hello", c1.Name);

if (!PlatformDetection.IsNetFramework)
{
Cookie c2 = new Cookie();
c2.Name = "hello world";
Assert.Equal("hello world", c2.Name);
}
Cookie c2 = new Cookie();
c2.Name = "hello world";
Assert.Equal("hello world", c2.Name);
}

[Theory]
Expand Down
Loading

0 comments on commit 21b4a85

Please sign in to comment.