forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move System.Runtime.InteropServices partial facade into FxCore\Open
Checked in by erme [tfs-changeset: 1460707]
- Loading branch information
1 parent
41cf973
commit dc7af37
Showing
16 changed files
with
695 additions
and
0 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
src/System.Runtime.InteropServices/src/Resources/Strings.resx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<data name="InvalidOperation_HCCountOverflow" xml:space="preserve"> | ||
<value>Handle collector count overflows or underflows.</value> | ||
</data> | ||
<data name="ArgumentOutOfRange_NeedNonNegNumRequired" xml:space="preserve"> | ||
<value>Non-negative number required.</value> | ||
</data> | ||
<data name="Argument_InvalidThreshold" xml:space="preserve"> | ||
<value>maximumThreshold cannot be less than initialThreshold.</value> | ||
</data> | ||
<data name="Arg_NeedNonNegNumRequired" xml:space="preserve"> | ||
<value>Non-negative number required.</value> | ||
</data> | ||
<data name="Arg_InvalidThreshold" xml:space="preserve"> | ||
<value>maximumThreshold cannot be less than initialThreshold.</value> | ||
</data> | ||
</root> |
42 changes: 42 additions & 0 deletions
42
src/System.Runtime.InteropServices/src/System.Runtime.InteropServices.CoreCLR.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>System.Runtime.InteropServices</AssemblyName> | ||
<AssemblyVersion>4.0.20.0</AssemblyVersion> | ||
<OutputType>Library</OutputType> | ||
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly> | ||
<NuGetTargetFrameworkMoniker>ASP.NetCore, version=v5.0</NuGetTargetFrameworkMoniker> | ||
</PropertyGroup> | ||
|
||
<!-- Default configurations to help VS understand the configurations --> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Debug|AnyCPU' " /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Release|AnyCPU' " /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Debug|AnyCPU' " /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Release|AnyCPU' " /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Debug|AnyCPU' " /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Release|AnyCPU' " /> | ||
|
||
<ItemGroup> | ||
<Compile Include="System\Runtime\InteropServices\ComAwareEventInfo.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\HandleCollector.CoreCLR.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\DefaultParameterValueAttribute.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\HandleCollector.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\ADVF.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\DATADIR.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\DVASPECT.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\FORMATETC.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\IAdviseSink.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\IEnumFORMATETC.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\STATDATA.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\STGMEDIUM.cs" /> | ||
<Compile Include="System\Runtime\InteropServices\ComTypes\TYMED.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="project.json" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
</Project> |
134 changes: 134 additions & 0 deletions
134
src/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComAwareEventInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace System.Runtime.InteropServices | ||
{ | ||
[System.Security.SecuritySafeCritical] | ||
public class ComAwareEventInfo : System.Reflection.EventInfo | ||
{ | ||
private System.Reflection.EventInfo _innerEventInfo; | ||
|
||
public ComAwareEventInfo(Type type, string eventName) | ||
{ | ||
_innerEventInfo = type.GetEvent(eventName); | ||
} | ||
|
||
[System.Security.SecuritySafeCritical] | ||
public override void AddEventHandler(object target, Delegate handler) | ||
{ | ||
if (Marshal.IsComObject(target)) | ||
{ | ||
// retrieve sourceIid and dispid | ||
Guid sourceIid; | ||
int dispid; | ||
GetDataForComInvocation(_innerEventInfo, out sourceIid, out dispid); | ||
System.Runtime.InteropServices.ComEventsHelper.Combine(target, sourceIid, dispid, handler); | ||
} | ||
else | ||
{ | ||
// we are dealing with a managed object - just add the delegate through reflection | ||
_innerEventInfo.AddEventHandler(target, handler); | ||
} | ||
} | ||
|
||
[System.Security.SecuritySafeCritical] | ||
public override void RemoveEventHandler(object target, Delegate handler) | ||
{ | ||
if (Marshal.IsComObject(target)) | ||
{ | ||
// retrieve sourceIid and dispid | ||
Guid sourceIid; | ||
int dispid; | ||
GetDataForComInvocation(_innerEventInfo, out sourceIid, out dispid); | ||
|
||
System.Runtime.InteropServices.ComEventsHelper.Remove(target, sourceIid, dispid, handler); | ||
} | ||
else | ||
{ | ||
// we are dealing with a managed object - just add the delegate through relection | ||
_innerEventInfo.RemoveEventHandler(target, handler); | ||
} | ||
} | ||
|
||
public override System.Reflection.EventAttributes Attributes | ||
{ | ||
get { return _innerEventInfo.Attributes; } | ||
} | ||
|
||
public override System.Reflection.MethodInfo GetAddMethod(bool nonPublic) | ||
{ | ||
return _innerEventInfo.GetAddMethod(nonPublic); | ||
} | ||
|
||
public override System.Reflection.MethodInfo GetRaiseMethod(bool nonPublic) | ||
{ | ||
return _innerEventInfo.GetRaiseMethod(nonPublic); | ||
} | ||
|
||
public override System.Reflection.MethodInfo GetRemoveMethod(bool nonPublic) | ||
{ | ||
return _innerEventInfo.GetRemoveMethod(nonPublic); | ||
} | ||
|
||
public override Type DeclaringType | ||
{ | ||
get { return _innerEventInfo.DeclaringType; } | ||
} | ||
|
||
public override object[] GetCustomAttributes(Type attributeType, bool inherit) | ||
{ | ||
return _innerEventInfo.GetCustomAttributes(attributeType, inherit); | ||
} | ||
|
||
public override object[] GetCustomAttributes(bool inherit) | ||
{ | ||
return _innerEventInfo.GetCustomAttributes(inherit); | ||
} | ||
|
||
public override bool IsDefined(Type attributeType, bool inherit) | ||
{ | ||
return _innerEventInfo.IsDefined(attributeType, inherit); | ||
} | ||
|
||
public override string Name | ||
{ | ||
get { return _innerEventInfo.Name; } | ||
} | ||
|
||
public override Type ReflectedType | ||
{ | ||
get { return _innerEventInfo.ReflectedType; } | ||
} | ||
|
||
private static void GetDataForComInvocation(System.Reflection.EventInfo eventInfo, out Guid sourceIid, out int dispid) | ||
{ | ||
object[] comEventInterfaces = eventInfo.DeclaringType.GetCustomAttributes(typeof(ComEventInterfaceAttribute), false); | ||
|
||
if (comEventInterfaces == null || comEventInterfaces.Length == 0) | ||
{ | ||
// TODO: event strings need to be localizable | ||
throw new InvalidOperationException("event invocation for COM objects requires interface to be attributed with ComSourceInterfaceGuidAttribute"); | ||
} | ||
|
||
if (comEventInterfaces.Length > 1) | ||
{ | ||
// TODO: event strings need to be localizable | ||
throw new System.Reflection.AmbiguousMatchException("more than one ComSourceInterfaceGuidAttribute found"); | ||
} | ||
|
||
Type sourceItf = ((ComEventInterfaceAttribute)comEventInterfaces[0]).SourceInterface; | ||
Guid guid = sourceItf.GUID; | ||
|
||
System.Reflection.MethodInfo methodInfo = sourceItf.GetMethod(eventInfo.Name); | ||
Attribute dispIdAttribute = Attribute.GetCustomAttribute(methodInfo, typeof(DispIdAttribute)); | ||
if (dispIdAttribute == null) | ||
{ | ||
// TODO: event strings need to be localizable | ||
throw new InvalidOperationException("event invocation for COM objects requires event to be attributed with DispIdAttribute"); | ||
} | ||
|
||
sourceIid = guid; | ||
dispid = ((DispIdAttribute)dispIdAttribute).Value; | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IAdviseSink.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace System.Runtime.InteropServices.ComTypes | ||
{ | ||
/// <devdoc> | ||
/// The IAdviseSink interface enables containers and other objects to | ||
/// receive notifications of data changes, view changes, and compound-document | ||
/// changes occurring in objects of interest. Container applications, for | ||
/// example, require such notifications to keep cached presentations of their | ||
/// linked and embedded objects up-to-date. Calls to IAdviseSink methods are | ||
/// asynchronous, so the call is sent and then the next instruction is executed | ||
/// without waiting for the call's return. | ||
/// </devdoc> | ||
[ComImport] | ||
[Guid("0000010F-0000-0000-C000-000000000046")] | ||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface IAdviseSink | ||
{ | ||
/// <devdoc> | ||
/// Called by the server to notify a data object's currently registered | ||
/// advise sinks that data in the object has changed. | ||
/// </devdoc> | ||
[PreserveSig] | ||
void OnDataChange([In] ref FORMATETC format, [In] ref STGMEDIUM stgmedium); | ||
|
||
/// <devdoc> | ||
/// Notifies an object's registered advise sinks that its view has changed. | ||
/// </devdoc> | ||
[PreserveSig] | ||
void OnViewChange(int aspect, int index); | ||
|
||
/// <devdoc> | ||
/// Called by the server to notify all registered advisory sinks that | ||
/// the object has been renamed. | ||
/// </devdoc> | ||
[PreserveSig] | ||
void OnRename(IMoniker moniker); | ||
|
||
/// <devdoc> | ||
/// Called by the server to notify all registered advisory sinks that | ||
/// the object has been saved. | ||
/// </devdoc> | ||
[PreserveSig] | ||
void OnSave(); | ||
|
||
/// <devdoc> | ||
/// Called by the server to notify all registered advisory sinks that the | ||
/// object has changed from the running to the loaded state. | ||
/// </devdoc> | ||
[PreserveSig] | ||
void OnClose(); | ||
} | ||
} |
Oops, something went wrong.