Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Opt COM methods out of the new Windows instance-method handling. #23974

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/vm/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3956,7 +3956,10 @@ static void CreateNDirectStubWorker(StubState* pss,
BOOL fMarshalReturnValueFirst = FALSE;

BOOL fReverseWithReturnBufferArg = FALSE;
bool isInstanceMethod = fStubNeedsCOM || fThisCall;
// Only consider ThisCall methods to be instance methods.
// Techinically COM methods are also instance methods, but we don't want to change the behavior of the built-in
// COM abi work because there are many users that rely on the current behavior (for example WPF).
bool isInstanceMethod = fThisCall;

// We can only change fMarshalReturnValueFirst to true when we are NOT doing HRESULT-swapping!
// When we are HRESULT-swapping, the managed return type is actually the type of the last parameter and not the return type.
Expand Down
35 changes: 0 additions & 35 deletions tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void Run()
this.Marshal_Float(a / 100f, b / 100f);
this.Marshal_Double(a / 100.0, b / 100.0);
this.Marshal_ManyInts();
this.Marshal_Struct_Return();
}

static private bool EqualByBound(float expected, float actual)
Expand Down Expand Up @@ -201,39 +200,5 @@ private void Marshal_ManyInts()
Console.WriteLine($"{expected.GetType().Name} 12 test invariant: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 = {expected}");
Assert.IsTrue(expected == this.server.Add_ManyInts12(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
}

private void Marshal_Struct_Return()
{
Console.WriteLine("Struct return from member function marshalling with struct > 4 bytes");
{
var width = 1.0f;
var height = 2.0f;
Server.Contract.SizeF result = this.server.MakeSize(width, height);

Assert.AreEqual(width, result.width);
Assert.AreEqual(height, result.height);
}
Console.WriteLine("Struct return from member function marshalling with struct <= 4 bytes");
{
byte width = 1;
byte height = 2;
Server.Contract.Size result = this.server.MakeSizeSmall(width, height);

Assert.AreEqual(width, result.width);
Assert.AreEqual(height, result.height);
}
Console.WriteLine("Struct return from member function marshalling with struct > 8 bytes");
{
var x = 1.0f;
var y = 2.0f;
var z = 3.0f;
var w = 4.0f;
Server.Contract.HFA_4 result = this.server.MakeHFA(x, y ,z, w);
Assert.AreEqual(x, result.x);
Assert.AreEqual(y, result.y);
Assert.AreEqual(z, result.z);
Assert.AreEqual(w, result.w);
}
}
}
}
15 changes: 0 additions & 15 deletions tests/src/Interop/COM/NETServer/NumericTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,4 @@ public int Add_ManyInts12(int i1, int i2, int i3, int i4, int i5, int i6, int i7
{
return i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12;
}

public Server.Contract.SizeF MakeSize(float width, float height)
{
return new Server.Contract.SizeF { width = width, height = height };
}

public Server.Contract.Size MakeSizeSmall(byte width, byte height)
{
return new Server.Contract.Size { width = width, height = height };
}

public Server.Contract.HFA_4 MakeHFA(float x, float y, float z, float w)
{
return new Server.Contract.HFA_4 {x = x, y = y, z = z, w = w};
}
}
21 changes: 0 additions & 21 deletions tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,6 @@ namespace
THROW_IF_FAILED(numericTesting->Add_ManyInts12(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, &result));
THROW_FAIL_IF_FALSE(result == expected);
}

void MarshalStructReturn(_In_ INumericTesting* numericTesting)
{
{
::printf("Marshal struct return type with size > 4 bytes\n");
float width = 1.0f;
float height = 2.0f;
SizeF size = numericTesting->MakeSize(width, height);
THROW_FAIL_IF_FALSE(width == size.width);
THROW_FAIL_IF_FALSE(height == size.height);
}
{
::printf("Marshal struct return type with size < 4 bytes\n");
BYTE width = 1;
BYTE height = 2;
Size size = numericTesting->MakeSizeSmall(width, height);
THROW_FAIL_IF_FALSE(width == size.width);
THROW_FAIL_IF_FALSE(height == size.height);
}
}
}

void Run_NumericTests()
Expand Down Expand Up @@ -265,5 +245,4 @@ void Run_NumericTests()
MarshalFloat(numericTesting, (float)a / 100.f, (float)b / 100.f);
MarshalDouble(numericTesting, (double)a / 100.0, (double)b / 100.0);
MarshalManyInts(numericTesting);
MarshalStructReturn(numericTesting);
}
24 changes: 0 additions & 24 deletions tests/src/Interop/COM/NativeServer/NumericTesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,30 +283,6 @@ class NumericTesting : public UnknownImpl, public INumericTesting
return S_OK;
}

virtual COM_DECLSPEC_NOTHROW SizeF STDMETHODCALLTYPE MakeSize(
/*[in]*/ float width,
/*[in]*/ float height)
{
return { width, height };
}

virtual COM_DECLSPEC_NOTHROW Size STDMETHODCALLTYPE MakeSizeSmall(
/*[in]*/ BYTE width,
/*[in]*/ BYTE height)
{
return { width, height };
}

virtual COM_DECLSPEC_NOTHROW HFA_4 STDMETHODCALLTYPE MakeHFA(
/*[in]*/ float x,
/*[in]*/ float y,
/*[in]*/ float z,
/*[in]*/ float w
)
{
return { x, y, z, w };
}

public: // IUnknown
STDMETHOD(QueryInterface)(
/* [in] */ REFIID riid,
Expand Down
8 changes: 0 additions & 8 deletions tests/src/Interop/COM/ServerContracts/Server.Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public interface INumericTesting

int Add_ManyInts11(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11);
int Add_ManyInts12(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12);

[PreserveSig]
SizeF MakeSize(float width, float height);
[PreserveSig]
Size MakeSizeSmall(byte width, byte height);

[PreserveSig]
HFA_4 MakeHFA(float x, float y, float z, float w);
}

[ComVisible(true)]
Expand Down
11 changes: 0 additions & 11 deletions tests/src/Interop/COM/ServerContracts/Server.Contracts.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,6 @@ INumericTesting : IUnknown
/*[in]*/ int i11,
/*[in]*/ int i12,
/*[out]*/ int * result ) = 0;
virtual COM_DECLSPEC_NOTHROW SizeF STDMETHODCALLTYPE MakeSize(
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved
/*[in]*/ float width,
/*[in]*/ float height) = 0;
virtual COM_DECLSPEC_NOTHROW Size STDMETHODCALLTYPE MakeSizeSmall(
/*[in]*/ BYTE width,
/*[in]*/ BYTE height) = 0;
virtual COM_DECLSPEC_NOTHROW HFA_4 STDMETHODCALLTYPE MakeHFA(
/*[in]*/ float x,
/*[in]*/ float y,
/*[in]*/ float z,
/*[in]*/ float w) = 0;
};

struct __declspec(uuid("7731cb31-e063-4cc8-bcd2-d151d6bc8f43"))
Expand Down