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

Conversation

@Anipik
Copy link

@Anipik Anipik commented Jul 9, 2018

@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
Copy link
Member

@stephentoub stephentoub Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being added to src/Common/src? Is it going to be consumed into projects other than System.Runtime.InteropServices? Seems like it should either a) be in System.Runtime.InteropServices's directory, or b) be in src/Common/src/Interop/... somewhere... and I don't believe there's any reason it needs to remain in the Microsoft.Win32 namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in desktop it looks like this was the only consumer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephentoub What are your thoughts on the System.Runtime.InteropServices.ComTypes namespace? COM tends to be a four letter word, but that namespace really represents this interface's provenance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really doesn't matter since it is an internal-only interface. IMHO I'd just put it in the same namespace as the type that uses it.

return NativeMethods.E_NOTIMPL;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any tests we can add as part of this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added issue #30952 to track this.

{
internal static partial class Ole32
{
[DllImport("ole32.dll")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interop.Libraries.Ole32


namespace Microsoft.Win32
{
internal partial interface IMarshal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal types should not be in refererence assembly.

{
public class StandardOleMarshalObject : MarshalByRefObject, IMarshal
{
private static readonly Guid Clsid_StdMarshal = new Guid("00000017-0000-0000-c000-000000000046");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public partial class StandardOleMarshalObject : MarshalByRefObject, Microsoft.Win32.IMarshal
{
protected StandardOleMarshalObject() { }
int Microsoft.Win32.IMarshal.GetUnmarshalClass(ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out Guid pCid) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, these are effectively not public.

int DisconnectObject(int dwReserved);
}

internal static class NativeMethods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to be too dogmatic, but there is no way these constants aren't already defined somewhere. Is it possible to use them?

<Compile Include="System\Runtime\InteropServices\ExporterEventKind.cs" />
<Compile Include="System\Runtime\InteropServices\RegistrationClassContext.cs" />
<Compile Include="System\Runtime\InteropServices\RegistrationConnectionType.cs" />
<Compile Include="System\Runtime\InteropServices\StandardOleMarshalObject.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose these types aren't for uap scenario. Could you add a condition for these types?

// we must not wrap pStandardMarshal with an RCW because that would trigger QIs for random IIDs and the marshaler
// (aka stub manager object) does not really handle these well and we would risk triggering an AppVerifier break
IntPtr vtable = *(IntPtr*)pStandardMarshal.ToPointer();
IntPtr method = *((IntPtr*)vtable.ToPointer() + 5); // GetMarshalSizeMax is 5th slot
Copy link
Contributor

@luqunl luqunl Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetMarshalSizeMax is 5th slot

typo? it should be MarshalInterface is 5th slot

Marshal.Release(pUnknown);
}
}
throw new InvalidOperationException(string.Format(SR.StandardOleMarshalObjectGetMarshalerFailed, riid.ToString()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This doesn't feel correct. These COM methods are marked as [PreserveSig] but in here we are going to throw exception. since it works in desktop, maybe we just keep it as it is.

<Compile Include="System\Runtime\InteropServices\ComEventInterfaceAttribute.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="System\Runtime\InteropServices\DefaultParameterValueAttribute.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="System\Runtime\InteropServices\HandleCollector.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="System\Runtime\InteropServices\IMarshal.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
Copy link
Member

@jkotas jkotas Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to exclude this for uapaot? CoGetStandardMarshal is allowed for UWP apps in https://docs.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-cogetstandardmarshal.

We have been keeping the netcoreapp and uap surface in sync.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of this. I did this because of #30931 (comment)
I will revert this

@Anipik Anipik merged commit f70599a into dotnet:master Jul 11, 2018
@Anipik
Copy link
Author

Anipik commented Jul 11, 2018

Merging this one and an issue has been added to track the tests (Most Probably tests will be added in coreclr).

@Anipik Anipik deleted the standardOle branch July 11, 2018 22:34
@karelz karelz added this to the 3.0 milestone Jul 19, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Porting IMarshal

* Writing ref File and minor changes

* ported from .netfx

* formatting and adding aditional files

* Minor fixes

* Feedback addressed


Commit migrated from dotnet/corefx@f70599a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants