Why does typedef alias to BSTR become StringBuilder?

Apr 29, 2010 at 1:12 PM
Edited Apr 29, 2010 at 1:13 PM

I've noticed that if I have a COM interface declaring an out parameter such as

HRESULT MyMethod([out] BSTR *outVal);

The interop contains an "out string outVal" as expected;

int MyMethod(out string outVal);

But if I have:

typedef BSTR MyStringType;

HRESULT MyMethod([out] MyStringType *outVal);

The interop becomes:

int MyMethod(StringBuilder outVal);

Is this behavior really correct? I would expect an "out string" as usual.

Adding the following line below line 536 of TypeConverter.cs in the released source code seems to fix the problem:

m_nativeIndirections += builtinType.m_nativeIndirections;

Any thoughts on this?

Regards, Peter.