Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@ public void ChangeWrapperHandleStrength_NullObject_ThrowsArgumentNullException()
AssertExtensions.Throws<ArgumentNullException>("otp", () => Marshal.ChangeWrapperHandleStrength(null, fIsWeak: false));
}

#if !netstandard // TODO: Enable for netstandard2.1
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
[PlatformSpecific(TestPlatforms.Windows)]
public void ChangeWrapperHandleStrength_ObjectNotCollectible_ThrowsNotSupportedException()
{
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type type = typeBuilder.CreateType();

object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.ChangeWrapperHandleStrength(o, fIsWeak: true));
}
#endif

[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void ChangeWrapperHandleStrength_Unix_ThrowsPlatformNotSupportedException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,6 @@ public void GetComInterfaceForObject_InvalidObject_ThrowsArgumentException(objec
AssertExtensions.Throws<ArgumentException>("o", () => Marshal.GetComInterfaceForObject<object, NonGenericInterface>(o));
}

#if !netstandard // TODO: Enable for netstandard2.1
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetComInterfaceForObject_ObjectNotCollectible_ThrowsNotSupportedException()
{
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type type = typeBuilder.CreateType();

object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.GetComInterfaceForObject(o, typeof(NonGenericInterface)));
Assert.Throws<NotSupportedException>(() => Marshal.GetComInterfaceForObject(o, typeof(NonGenericInterface), CustomQueryInterfaceMode.Allow));
Assert.Throws<NotSupportedException>(() => Marshal.GetComInterfaceForObject<object, NonGenericInterface>(o));
}
#endif

[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetTypedObjectForIUnknown_UncastableType_ThrowsInvalidCastException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ public void GetIDispatchForObject_NullObject_ThrowsArgumentNullException()
AssertExtensions.Throws<ArgumentNullException>("o", () => Marshal.GetIDispatchForObject(null));
}

#if !netstandard // TODO: Enable for netstandard2.1
[ConditionalFact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Marshal.GetIDispatchForObject is not implemented in .NET Core.")]
public void GetIDispatchForObject_ObjectNotCollectible_ThrowsNotSupportedException()
{
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type type = typeBuilder.CreateType();

object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.GetIDispatchForObject(o));
}
#endif

[Theory]
[MemberData(nameof(GetIDispatchForObject_Invalid_TestData))]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "Marshal.GetIDispatchForObject is not implemented in .NET Core.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,5 @@ public void GetIUnknownForObject_NullObject_ThrowsArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException>("o", () => Marshal.GetIUnknownForObject(null));
}

#if !netstandard // TODO: Enable for netstandard2.1
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetIUnknownForObject_ObjectNotCollectible_ThrowsNotSupportedException()
{
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type type = typeBuilder.CreateType();

object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.GetIUnknownForObject(o));
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,31 +449,6 @@ public static void GetNativeVariantForObject_CantCastToObject_ThrowsInvalidCastE
}
}

#if !netstandard // TODO: Enable for netstandard2.1
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetNativeVariantForObject_ObjectNotCollectible_ThrowsNotSupportedException()
{
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type type = typeBuilder.CreateType();

object o = Activator.CreateInstance(type);

var v = new Variant();
IntPtr pNative = Marshal.AllocHGlobal(Marshal.SizeOf(v));
try
{
Assert.Throws<NotSupportedException>(() => Marshal.GetNativeVariantForObject(o, pNative));
}
finally
{
Marshal.FreeHGlobal(pNative);
}
}
#endif

public struct StructWithValue
{
public int Value;
Expand Down