Skip to content

Commit

Permalink
Fix component model aot test (#73734)
Browse files Browse the repository at this point in the history
* Partial fix for ComponentModel.TypeConverter tests

* Fix ComponentModel.TypeConverter tests

* enable the test proj

* FB

* working around a test build fail

* Update src/libraries/System.ComponentModel.TypeConverter/tests/BindableAttributeTests.cs

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>

* Update src/libraries/tests.proj

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
  • Loading branch information
LakshanF and MichalStrehovsky committed Aug 12, 2022
1 parent afc9675 commit b14a213
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal ExecutionDomain(ReflectionDomainSetup executionDomainSetup, ExecutionEn
public Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, IList<string> defaultAssemblyNames)
{
if (typeName == null)
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(typeName));

if (typeName.Length == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace System.ComponentModel.Tests
[Collection(nameof(DisableParallelization))] // manipulates cache
public class TypeDescriptorTests
{
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_InvokeObject_GetProviderReturnsExpected()
{
var instance = new object();
Expand Down Expand Up @@ -47,7 +47,7 @@ public void AddProvider_InvokeObject_GetProviderReturnsExpected()
mockProvider2.Verify(p => p.IsSupportedType(typeof(int)), Times.Once());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_InvokeObjectMultipleTimes_Refreshes()
{
var instance = new object();
Expand Down Expand Up @@ -96,7 +96,7 @@ public void AddProvider_InvokeObjectMultipleTimes_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_InvokeType_GetProviderReturnsExpected()
{
Type type = typeof(AddProvider_InvokeType_GetProviderReturnsExpectedType);
Expand Down Expand Up @@ -133,7 +133,7 @@ public void AddProvider_InvokeType_GetProviderReturnsExpected()
private class AddProvider_InvokeType_GetProviderReturnsExpectedType { }


[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_InvokeTypeMultipleTimes_Refreshes()
{
var type = typeof(AddProvider_InvokeTypeMultipleTimes_RefreshesType);
Expand Down Expand Up @@ -184,28 +184,28 @@ public void AddProvider_InvokeTypeMultipleTimes_Refreshes()

private class AddProvider_InvokeTypeMultipleTimes_RefreshesType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_NullProvider_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.AddProvider(null, new object()));
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.AddProvider(null, typeof(int)));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_NullInstance_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("instance", () => TypeDescriptor.AddProvider(mockProvider.Object, (object)null));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProvider_NullType_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("type", () => TypeDescriptor.AddProvider(mockProvider.Object, null));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_InvokeObject_GetProviderReturnsExpected()
{
var instance = new object();
Expand Down Expand Up @@ -239,7 +239,7 @@ public void AddProviderTransparent_InvokeObject_GetProviderReturnsExpected()
mockProvider2.Verify(p => p.IsSupportedType(typeof(int)), Times.Once());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_InvokeObjectMultipleTimes_Refreshes()
{
var instance = new object();
Expand Down Expand Up @@ -288,7 +288,7 @@ public void AddProviderTransparent_InvokeObjectMultipleTimes_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_InvokeType_GetProviderReturnsExpected()
{
Type type = typeof(AddProviderTransparent_InvokeType_GetProviderReturnsExpectedType);
Expand Down Expand Up @@ -324,7 +324,7 @@ public void AddProviderTransparent_InvokeType_GetProviderReturnsExpected()

private class AddProviderTransparent_InvokeType_GetProviderReturnsExpectedType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_InvokeTypeMultipleTimes_Refreshes()
{
var type = typeof(AddProviderTransparent_InvokeTypeMultipleTimes_RefreshesType);
Expand Down Expand Up @@ -375,21 +375,21 @@ public void AddProviderTransparent_InvokeTypeMultipleTimes_Refreshes()

private class AddProviderTransparent_InvokeTypeMultipleTimes_RefreshesType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_NullProvider_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.AddProviderTransparent(null, new object()));
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.AddProviderTransparent(null, typeof(int)));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_NullInstance_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("instance", () => TypeDescriptor.AddProviderTransparent(mockProvider.Object, (object)null));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void AddProviderTransparent_NullType_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Expand Down Expand Up @@ -548,7 +548,7 @@ public void GetPropertiesFiltersByAttribute()
Assert.Equal(1, properties.Count);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeObject_RemovesProvider()
{
var instance = new object();
Expand Down Expand Up @@ -603,7 +603,7 @@ public void RemoveProvider_InvokeObject_RemovesProvider()
mockProvider3.Verify(p => p.IsSupportedType(typeof(int)), Times.Once());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeObjectWithProviders_Refreshes()
{
var instance = new object();
Expand Down Expand Up @@ -640,7 +640,7 @@ public void RemoveProvider_InvokeObjectWithProviders_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeObjectWithoutProviders_Refreshes()
{
var instance = new object();
Expand All @@ -665,7 +665,7 @@ public void RemoveProvider_InvokeObjectWithoutProviders_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeType_RemovesProvider()
{
Type type = typeof(RemoveProvider_InvokeType_RemovesProviderType);
Expand Down Expand Up @@ -722,7 +722,7 @@ public void RemoveProvider_InvokeType_RemovesProvider()

private class RemoveProvider_InvokeType_RemovesProviderType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeTypeWithProviders_Refreshes()
{
Type type = typeof(RemoveProvider_InvokeObjectWithProviders_RefreshesType);
Expand Down Expand Up @@ -761,7 +761,7 @@ public void RemoveProvider_InvokeTypeWithProviders_Refreshes()

private class RemoveProvider_InvokeObjectWithProviders_RefreshesType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_InvokeTypeWithoutProviders_Refreshes()
{
Type type = typeof(RemoveProvider_InvokeTypeWithoutProviders_RefreshesType);
Expand Down Expand Up @@ -795,22 +795,22 @@ public void RemoveProvider_NullProvider_ThrowsArgumentNullException()
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.RemoveProvider(null, typeof(int)));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_NullInstance_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("instance", () => TypeDescriptor.RemoveProvider(mockProvider.Object, (object)null));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProvider_NullType_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("type", () => TypeDescriptor.RemoveProvider(mockProvider.Object, null));
}


[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeObject_RemovesProvider()
{
var instance = new object();
Expand Down Expand Up @@ -865,7 +865,7 @@ public void RemoveProviderTransparent_InvokeObject_RemovesProvider()
mockProvider3.Verify(p => p.IsSupportedType(typeof(int)), Times.Once());
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeObjectWithProviders_Refreshes()
{
var instance = new object();
Expand Down Expand Up @@ -902,7 +902,7 @@ public void RemoveProviderTransparent_InvokeObjectWithProviders_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeObjectWithoutProviders_Refreshes()
{
var instance = new object();
Expand All @@ -927,7 +927,7 @@ public void RemoveProviderTransparent_InvokeObjectWithoutProviders_Refreshes()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeType_RemovesProvider()
{
Type type = typeof(RemoveProviderTransparent_InvokeType_RemovesProviderType);
Expand Down Expand Up @@ -984,7 +984,7 @@ public void RemoveProviderTransparent_InvokeType_RemovesProvider()

private class RemoveProviderTransparent_InvokeType_RemovesProviderType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeTypeWithProviders_Refreshes()
{
Type type = typeof(RemoveProviderTransparent_InvokeObjectWithProviders_RefreshesType);
Expand Down Expand Up @@ -1023,7 +1023,7 @@ public void RemoveProviderTransparent_InvokeTypeWithProviders_Refreshes()

private class RemoveProviderTransparent_InvokeObjectWithProviders_RefreshesType { }

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_InvokeTypeWithoutProviders_Refreshes()
{
Type type = typeof(RemoveProviderTransparent_InvokeTypeWithoutProviders_RefreshesType);
Expand Down Expand Up @@ -1057,14 +1057,14 @@ public void RemoveProviderTransparent_NullProvider_ThrowsArgumentNullException()
Assert.Throws<ArgumentNullException>("provider", () => TypeDescriptor.RemoveProviderTransparent(null, typeof(int)));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_NullInstance_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Assert.Throws<ArgumentNullException>("instance", () => TypeDescriptor.RemoveProviderTransparent(mockProvider.Object, (object)null));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void RemoveProviderTransparent_NullType_ThrowsArgumentNullException()
{
var mockProvider = new Mock<TypeDescriptionProvider>(MockBehavior.Strict);
Expand Down Expand Up @@ -1111,7 +1111,7 @@ public void RemoveSingleAssociation()
Assert.NotEqual(firstAssociatedObject, firstAssociation);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] // Mock will try to JIT
public void SortDescriptorArray_Invoke_ReturnsExpected()
{
var notADescriptor1 = new object();
Expand Down
Loading

0 comments on commit b14a213

Please sign in to comment.