-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{A824F4CD-935B-4496-A1B2-C3664936DA7B}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Compile Include="System\Runtime\InteropServices\Marshal\GenerateGuidForTypeTests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GenerateProgIdForTypeTests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GetComObjectDataTests.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\GetDelegateForFunctionPointerTests.nonnetstandard.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GetExceptionPointersTests.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\GetFunctionPointerForDelegateTests.nonnetstandard.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GetHINSTANCETests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GetIDispatchForObjectTests.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\GetTypedObjectForIUnknownTests.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\ReadWrite\ByteTests.nonnetstandard.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\ReadWrite\Int16Tests.nonnetstandard.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\ReadWrite\Int32Tests.nonnetstandard.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\ReadWrite\Int64Tests.nonnetstandard.cs" />
- <Compile Include="System\Runtime\InteropServices\Marshal\ReadWrite\IntPtrTests.nonnetstandard.cs" />
<Compile Include="System\Runtime\InteropServices\Marshal\SetComObjectDataTests.cs" />
<Compile Include="System\Runtime\InteropServices\TypeLibFuncAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\TypeLibImportClassAttributeTests.cs" />
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()
object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.ChangeWrapperHandleStrength(o, fIsWeak: true));
}
+#endif
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
yield return new object[] { typeof(GenericClass<>).GetTypeInfo().GenericTypeParameters[0] };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
yield return new object[] { typeBuilder };
+#endif
}
[Theory]
yield return new object[] { typeof(ClassWithGuidAttribute) };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type collectibleType = typeBuilder.CreateType();
yield return new object[] { collectibleType };
+#endif
}
[Theory]
yield return new object[] { typeof(GenericClass<>) };
yield return new object[] { typeof(GenericClass<>).GetTypeInfo().GenericTypeParameters[0] };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type collectibleType = typeBuilder.CreateType();
yield return new object[] { collectibleType };
+#endif
}
[Theory]
namespace System.Runtime.InteropServices.Tests
{
- public partial class GetDelegateForFunctionPointerTests
+ public class GetDelegateForFunctionPointerTests
{
[Theory]
[InlineData(typeof(NonGenericDelegate))]
VerifyDelegate(functionDelegate, targetMethod);
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void GetDelegateForFunctionPointer_CollectibleType_ReturnsExpected()
+ {
+ MethodInfo targetMethod = typeof(GetDelegateForFunctionPointerTests).GetMethod(nameof(Method));
+ Delegate d = targetMethod.CreateDelegate(typeof(NonGenericDelegate));
+ IntPtr ptr = Marshal.GetFunctionPointerForDelegate(d);
+
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, typeof(MulticastDelegate));
+ ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(object), typeof(IntPtr) });
+ constructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+
+ MethodBuilder methodBuilder = typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, targetMethod.ReturnType, targetMethod.GetParameters().Select(p => p.ParameterType).ToArray());
+ methodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+
+ Type type = typeBuilder.CreateType();
+
+ Delegate functionDelegate = Marshal.GetDelegateForFunctionPointer(ptr, type);
+ GC.KeepAlive(d);
+ VerifyDelegate(functionDelegate, targetMethod);
+ }
+#endif
+
[Fact]
public void GetDelegateForFunctionPointer_Generic_ReturnsExpected()
{
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Runtime.InteropServices.Tests.Common;
-using Xunit;
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class GetDelegateForFunctionPointerTests
- {
- [Fact]
- public void GetDelegateForFunctionPointer_CollectibleType_ReturnsExpected()
- {
- MethodInfo targetMethod = typeof(GetDelegateForFunctionPointerTests).GetMethod(nameof(Method));
- Delegate d = targetMethod.CreateDelegate(typeof(NonGenericDelegate));
- IntPtr ptr = Marshal.GetFunctionPointerForDelegate(d);
-
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, typeof(MulticastDelegate));
- ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(object), typeof(IntPtr) });
- constructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
-
- MethodBuilder methodBuilder = typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, targetMethod.ReturnType, targetMethod.GetParameters().Select(p => p.ParameterType).ToArray());
- methodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
-
- Type type = typeBuilder.CreateType();
-
- Delegate functionDelegate = Marshal.GetDelegateForFunctionPointer(ptr, type);
- GC.KeepAlive(d);
- VerifyDelegate(functionDelegate, targetMethod);
- }
- }
-}
namespace System.Runtime.InteropServices.Tests
{
- public partial class GetFunctionPointerForDelegateTests
+ public class GetFunctionPointerForDelegateTests
{
[Fact]
public void GetFunctionPointerForDelegate_NormalDelegateNonGeneric_ReturnsExpected()
AssertExtensions.Throws<ArgumentException>("delegate", () => Marshal.GetFunctionPointerForDelegate(d));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void GetFunctionPointerForDelegate_DelegateCollectible_ThrowsNotSupportedException()
+ {
+ MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method));
+
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, typeof(MulticastDelegate));
+ ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(object), typeof(IntPtr) });
+ constructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+
+ MethodBuilder methodBuilder = typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, targetMethod.ReturnType, targetMethod.GetParameters().Select(p => p.ParameterType).ToArray());
+ methodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+
+ Type type = typeBuilder.CreateType();
+
+ Delegate d = targetMethod.CreateDelegate(type);
+ Assert.Throws<NotSupportedException>(() => Marshal.GetFunctionPointerForDelegate(d));
+ }
+#endif
+
public delegate void GenericDelegate<T>(T t);
public delegate void NonGenericDelegate(string t);
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class GetFunctionPointerForDelegateTests
- {
- [Fact]
- public void GetFunctionPointerForDelegate_DelegateCollectible_ThrowsNotSupportedException()
- {
- MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method));
-
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, typeof(MulticastDelegate));
- ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(object), typeof(IntPtr) });
- constructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
-
- MethodBuilder methodBuilder = typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, targetMethod.ReturnType, targetMethod.GetParameters().Select(p => p.ParameterType).ToArray());
- methodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
-
- Type type = typeBuilder.CreateType();
-
- Delegate d = targetMethod.CreateDelegate(type);
- Assert.Throws<NotSupportedException>(() => Marshal.GetFunctionPointerForDelegate(d));
- }
- }
-}
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.")]
object o = Activator.CreateInstance(type);
Assert.Throws<NotSupportedException>(() => Marshal.GetIDispatchForObject(o));
}
+#endif
[Theory]
[MemberData(nameof(GetIDispatchForObject_Invalid_TestData))]
}
}
+#if !netstandard // TODO: Enable for netstandard2.1
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetNativeVariantForObject_ObjectNotCollectible_ThrowsNotSupportedException()
Marshal.FreeHGlobal(pNative);
}
}
+#endif
public struct StructWithValue
{
yield return new object[] { typeof(GenericClass<>) };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
yield return new object[] { typeBuilder };
+#endif
}
[Theory]
yield return new object[] { new KeyValuePair<string, int>("key", 10) };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
Type collectibleComImportObject = comImportTypeBuilder.CreateType();
yield return new object[] { collectibleComImportObject };
+#endif
}
[Theory]
AssertExtensions.Throws<ArgumentException>("structureType", () => Marshal.PtrToStructure((IntPtr)1, structureType));
}
+#if !netstandard // TODO: Enable for netstandard2.1
[Fact]
public void PtrToStructure_NonRuntimeType_ThrowsArgumentException()
{
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
AssertExtensions.Throws<ArgumentException>("structureType", "type", () => Marshal.PtrToStructure((IntPtr)1, (Type)typeBuilder));
}
+#endif
public static IEnumerable<object[]> PtrToStructure_NonBlittableType_TestData()
{
namespace System.Runtime.InteropServices.Tests
{
- public partial class ByteTests
+ public class ByteTests
{
[Theory]
[InlineData(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, byte.MaxValue })]
Assert.Throws<AccessViolationException>(() => Marshal.ReadByte(null, 2));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void ReadByte_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadByte(collectibleObject, 0));
+ }
+#endif
+
[Fact]
public void WriteByte_ZeroPointer_ThrowsException()
{
Assert.Throws<AccessViolationException>(() => Marshal.WriteByte(null, 2, 0));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void WriteByte_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteByte(collectibleObject, 0, 0));
+ }
+#endif
+
public struct BlittableStruct
{
public byte value1;
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-#pragma warning disable CS0618 // Type or member is obsolete
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class ByteTests
- {
- [Fact]
- public void ReadByte_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadByte(collectibleObject, 0));
- }
-
- [Fact]
- public void WriteByte_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteByte(collectibleObject, 0, 0));
- }
- }
-}
-
-#pragma warning restore CS0618 // Type or member is obsolete
namespace System.Runtime.InteropServices.Tests
{
- public partial class Int16Tests
+ public class Int16Tests
{
[Theory]
[InlineData(new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, short.MaxValue })]
Assert.Throws<AccessViolationException>(() => Marshal.ReadInt16(null, 2));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void ReadInt16_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt16(collectibleObject, 0));
+ }
+#endif
+
[Fact]
public void WriteInt16_ZeroPointer_ThrowsException()
{
Assert.Throws<AccessViolationException>(() => Marshal.WriteInt16(null, 2, 0));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void WriteInt16_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt16(collectibleObject, 0, 0));
+ }
+#endif
+
public struct BlittableStruct
{
public short value1;
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-#pragma warning disable CS0618 // Type or member is obsolete
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class Int16Tests
- {
- [Fact]
- public void ReadInt16_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt16(collectibleObject, 0));
- }
-
- [Fact]
- public void WriteInt16_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt16(collectibleObject, 0, 0));
- }
- }
-}
-
-#pragma warning restore CS0618 // Type or member is obsolete
namespace System.Runtime.InteropServices.Tests
{
- public partial class Int32Tests
+ public class Int32Tests
{
[Theory]
[InlineData(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, int.MaxValue })]
Assert.Throws<AccessViolationException>(() => Marshal.ReadInt32(null, 2));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void ReadInt32_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt32(collectibleObject, 0));
+ }
+#endif
+
[Fact]
public void WriteInt32_ZeroPointer_ThrowsException()
{
Assert.Throws<AccessViolationException>(() => Marshal.WriteInt32(null, 2, 0));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void WriteInt32_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt32(collectibleObject, 0, 0));
+ }
+#endif
+
public struct BlittableStruct
{
public int value1;
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-#pragma warning disable CS0618 // Type or member is obsolete
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class Int32Tests
- {
- [Fact]
- public void ReadInt32_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt32(collectibleObject, 0));
- }
-
- [Fact]
- public void WriteInt32_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt32(collectibleObject, 0, 0));
- }
- }
-}
-
-#pragma warning restore CS0618 // Type or member is obsolete
namespace System.Runtime.InteropServices.Tests
{
- public partial class Int64Tests
+ public class Int64Tests
{
[Theory]
[InlineData(new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, long.MaxValue })]
Assert.Throws<AccessViolationException>(() => Marshal.ReadInt64(null, 2));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void ReadInt64_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt64(collectibleObject, 0));
+ }
+#endif
+
[Fact]
public void WriteInt64_ZeroPointer_ThrowsException()
{
Assert.Throws<AccessViolationException>(() => Marshal.WriteInt64(null, 2, 0));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void WriteInt64_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt64(collectibleObject, 0, 0));
+ }
+#endif
+
public struct BlittableStruct
{
public long value1;
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-#pragma warning disable CS0618 // Type or member is obsolete
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class Int64Tests
- {
- [Fact]
- public void ReadInt64_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadInt64(collectibleObject, 0));
- }
-
- [Fact]
- public void WriteInt64_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteInt64(collectibleObject, 0, 0));
- }
- }
-}
-
-#pragma warning restore CS0618 // Type or member is obsolete
namespace System.Runtime.InteropServices.Tests
{
- public partial class IntPtrTests
+ public class IntPtrTests
{
public static IEnumerable<object[]> ReadWrite_TestData()
{
Assert.Throws<AccessViolationException>(() => Marshal.ReadIntPtr(null, 2));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void ReadIntPtr_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadIntPtr(collectibleObject, 0));
+ }
+#endif
+
[Fact]
public void WriteIntPtr_ZeroPointer_ThrowsException()
{
Assert.Throws<AccessViolationException>(() => Marshal.WriteIntPtr(null, 2, (IntPtr)0));
}
+#if !netstandard // TODO: Enable for netstandard2.1
+ [Fact]
+ public void WriteIntPtr_NotReadable_ThrowsArgumentException()
+ {
+ AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
+ ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
+ TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
+ Type collectibleType = typeBuilder.CreateType();
+ object collectibleObject = Activator.CreateInstance(collectibleType);
+
+ AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteIntPtr(collectibleObject, 0, IntPtr.Zero));
+ }
+#endif
+
public struct BlittableStruct
{
public IntPtr value1;
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using Xunit;
-
-#pragma warning disable CS0618 // Type or member is obsolete
-
-namespace System.Runtime.InteropServices.Tests
-{
- public partial class IntPtrTests
- {
- [Fact]
- public void ReadIntPtr_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.ReadIntPtr(collectibleObject, 0));
- }
-
- [Fact]
- public void WriteIntPtr_NotReadable_ThrowsArgumentException()
- {
- AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect);
- ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
- TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
- Type collectibleType = typeBuilder.CreateType();
- object collectibleObject = Activator.CreateInstance(collectibleType);
-
- AssertExtensions.Throws<ArgumentException>(null, () => Marshal.WriteIntPtr(collectibleObject, 0, IntPtr.Zero));
- }
- }
-}
-
-#pragma warning restore CS0618 // Type or member is obsolete
yield return new object[] { typeof(GenericClass<>).GetTypeInfo().GenericTypeParameters[0], null };
+#if !netstandard // TODO: Enable for netstandard2.1
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module");
TypeBuilder typeBuilder = moduleBuilder.DefineType("Type");
yield return new object[] { typeBuilder, "t" };
+#endif
yield return new object[] { typeof(TestStructWithFxdLPSTRSAFld), null };
}