Skip to content
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 @@ -5,6 +5,7 @@

namespace System.Runtime.InteropServices
{
[ComVisible(true)]
public class StandardOleMarshalObject : MarshalByRefObject, IMarshal
{
private static readonly Guid CLSID_StdMarshal = new Guid("00000017-0000-0000-c000-000000000046");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<Compile Include="System\Runtime\InteropServices\ProgIdAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\RuntimeEnvironmentTests.cs" />
<Compile Include="System\Runtime\InteropServices\SafeBufferTests.cs" />
<Compile Include="System\Runtime\InteropServices\StandardOleMarshalObjectTests.cs" />
<Compile Include="System\Runtime\InteropServices\StructLayoutAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\TypeIdentifierAttributeTests.cs" />
<Compile Include="System\Runtime\InteropServices\UnknownWrapperTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

namespace System.Runtime.InteropServices.Tests
{
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBuiltInComEnabled))]
public class StandardOleMarshalObjectTests
{
private static readonly Guid IID_IDispatch = new Guid("00020400-0000-0000-C000-000000000046");
[Fact]
public void CanGetIDispatchOfDerivedObject()
{
IntPtr disp = Marshal.GetIDispatchForObject(new DerivedObject());
Assert.NotEqual(IntPtr.Zero, disp);
Marshal.Release(disp);
}

[Fact]
public void CanQueryInterfaceForIDispatchOfDerivedObject()
{
IntPtr unk = Marshal.GetIUnknownForObject(new DerivedObject());
Assert.NotEqual(IntPtr.Zero, unk);

int hr = Marshal.QueryInterface(unk, IID_IDispatch, out IntPtr disp);
Assert.Equal(0, hr);
Assert.NotEqual(IntPtr.Zero, disp);

Marshal.Release(disp);
Marshal.Release(unk);
}

[ComVisible(true)]
public sealed class DerivedObject : StandardOleMarshalObject
{
}
}
}
Loading