You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -26,10 +26,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{A824F4CD-935B-4496-A1B2-C3664936DA7B}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{EC6AA4D9-B3E8-4CCA-8AB1-8BBFD89266AE}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{EC6AA4D9-B3E8-4CCA-8AB1-8BBFD89266AE}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{EC6AA4D9-B3E8-4CCA-8AB1-8BBFD89266AE}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
|
||||
@@ -67,4 +67,13 @@
|
||||
<data name="Arg_InvalidThreshold" xml:space="preserve">
|
||||
<value>maximumThreshold cannot be less than initialThreshold.</value>
|
||||
</data>
|
||||
<data name="InvalidOperation_NoComEventInterfaceAttribute" xml:space="preserve">
|
||||
<value>Event invocation for COM objects requires the declaring interface of the event to be attributed with ComEventInterfaceAttribute.</value>
|
||||
</data>
|
||||
<data name="AmbiguousMatch_MultipleEventInterfaceAttributes" xml:space="preserve">
|
||||
<value>More than one ComEventInterfaceAttribute was found on the declaring interface of the event.</value>
|
||||
</data>
|
||||
<data name="InvalidOperation_NoDispIdAttribute" xml:space="preserve">
|
||||
<value>Event invocation for COM objects requires event to be attributed with DispIdAttribute.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -23,20 +23,20 @@
|
||||
<Compile Include="System\Runtime\InteropServices\Attributes.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComAwareEventInfo.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComEventInterfaceAttribute.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\DefaultParameterValueAttribute.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\HandleCollector.cs" />
|
||||
<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\RuntimeEnvironment.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\advf.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\datadir.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\dvaspect.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\formatetc.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\IAdviseSink.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\IDataObject.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\IEnumFormatETC.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\IEnumFormatETC.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\IEnumSTATDATA.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" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\statdata.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\stgmedium.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComTypes\tymed.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
|
||||
<Compile Include="System\Runtime\InteropServices\AssemblyRegistrationFlags.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ExporterEventKind.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\RegistrationClassContext.cs" />
|
||||
|
||||
@@ -8,15 +8,10 @@ namespace System.Runtime.CompilerServices
|
||||
{
|
||||
[Serializable]
|
||||
[System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
|
||||
public sealed partial class IUnknownConstantAttribute : System.Runtime.CompilerServices.CustomConstantAttribute
|
||||
public sealed partial class IUnknownConstantAttribute : CustomConstantAttribute
|
||||
{
|
||||
public IUnknownConstantAttribute() { }
|
||||
public override object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return new UnknownWrapper(null);
|
||||
}
|
||||
}
|
||||
|
||||
public override object Value => new UnknownWrapper(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,21 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Runtime.InteropServices
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
|
||||
public sealed class AutomationProxyAttribute : Attribute
|
||||
{
|
||||
public AutomationProxyAttribute(bool val)
|
||||
{
|
||||
Value = val;
|
||||
}
|
||||
public AutomationProxyAttribute(bool val) => Value = val;
|
||||
|
||||
public bool Value { get; }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
|
||||
public sealed class ComAliasNameAttribute : Attribute
|
||||
{
|
||||
public ComAliasNameAttribute(string alias)
|
||||
{
|
||||
Value = alias;
|
||||
}
|
||||
public ComAliasNameAttribute(string alias) => Value = alias;
|
||||
|
||||
public string Value { get; }
|
||||
}
|
||||
|
||||
@@ -59,21 +53,19 @@ namespace System.Runtime.InteropServices
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, Inherited = false)]
|
||||
[Obsolete("This attribute is deprecated and will be removed in a future version.", false)]
|
||||
[Obsolete("This attribute is deprecated and will be removed in a future version.", error: false)]
|
||||
public sealed class IDispatchImplAttribute : Attribute
|
||||
{
|
||||
public IDispatchImplAttribute(short implType)
|
||||
public IDispatchImplAttribute(short implType) : this((IDispatchImplType)implType)
|
||||
{
|
||||
Value = (IDispatchImplType)implType;
|
||||
}
|
||||
public IDispatchImplAttribute(IDispatchImplType implType)
|
||||
{
|
||||
Value = implType;
|
||||
}
|
||||
|
||||
public IDispatchImplAttribute(IDispatchImplType implType) => Value = implType;
|
||||
|
||||
public IDispatchImplType Value { get; }
|
||||
}
|
||||
|
||||
[Obsolete("The IDispatchImplAttribute is deprecated.", false)]
|
||||
[Obsolete("The IDispatchImplAttribute is deprecated.", error: false)]
|
||||
public enum IDispatchImplType
|
||||
{
|
||||
CompatibleImpl = 2,
|
||||
@@ -84,10 +76,8 @@ namespace System.Runtime.InteropServices
|
||||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
|
||||
public sealed class ImportedFromTypeLibAttribute : Attribute
|
||||
{
|
||||
public ImportedFromTypeLibAttribute(String tlbFile)
|
||||
{
|
||||
Value = tlbFile;
|
||||
}
|
||||
public ImportedFromTypeLibAttribute(string tlbFile) => Value = tlbFile;
|
||||
|
||||
public string Value { get; }
|
||||
}
|
||||
|
||||
@@ -117,7 +107,7 @@ namespace System.Runtime.InteropServices
|
||||
public int MinorVersion { get; }
|
||||
}
|
||||
|
||||
[Obsolete("This attribute has been deprecated. Application Domains no longer respect Activation Context boundaries in IDispatch calls.", false)]
|
||||
[Obsolete("This attribute has been deprecated. Application Domains no longer respect Activation Context boundaries in IDispatch calls.", error: false)]
|
||||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
|
||||
public sealed class SetWin32ContextInIDispatchAttribute : Attribute
|
||||
{
|
||||
@@ -129,10 +119,8 @@ namespace System.Runtime.InteropServices
|
||||
[AttributeUsage(AttributeTargets.Interface, Inherited = false)]
|
||||
public sealed class TypeLibImportClassAttribute : Attribute
|
||||
{
|
||||
public TypeLibImportClassAttribute(Type importClass)
|
||||
{
|
||||
Value = importClass.ToString();
|
||||
}
|
||||
public TypeLibImportClassAttribute(Type importClass) => Value = importClass.ToString();
|
||||
|
||||
public string Value { get; }
|
||||
}
|
||||
|
||||
@@ -192,16 +180,18 @@ namespace System.Runtime.InteropServices
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, Inherited = false)]
|
||||
public sealed class TypeLibTypeAttribute : Attribute
|
||||
public sealed class TypeLibTypeAttribute : Attribute
|
||||
{
|
||||
public TypeLibTypeAttribute(TypeLibTypeFlags flags)
|
||||
{
|
||||
Value = flags;
|
||||
}
|
||||
|
||||
public TypeLibTypeAttribute(short flags)
|
||||
{
|
||||
Value = (TypeLibTypeFlags)flags;
|
||||
}
|
||||
|
||||
public TypeLibTypeFlags Value { get; }
|
||||
}
|
||||
|
||||
@@ -212,10 +202,12 @@ namespace System.Runtime.InteropServices
|
||||
{
|
||||
Value = flags;
|
||||
}
|
||||
|
||||
public TypeLibFuncAttribute(short flags)
|
||||
{
|
||||
Value = (TypeLibFuncFlags)flags;
|
||||
}
|
||||
|
||||
public TypeLibFuncFlags Value { get; }
|
||||
}
|
||||
|
||||
@@ -226,15 +218,17 @@ namespace System.Runtime.InteropServices
|
||||
{
|
||||
Value = flags;
|
||||
}
|
||||
|
||||
public TypeLibVarAttribute(short flags)
|
||||
{
|
||||
Value = (TypeLibVarFlags)flags;
|
||||
}
|
||||
|
||||
public TypeLibVarFlags Value { get; }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
[ComVisible(true)]
|
||||
public sealed class TypeLibVersionAttribute : Attribute
|
||||
{
|
||||
public TypeLibVersionAttribute(int major, int minor)
|
||||
|
||||
@@ -2,28 +2,30 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security;
|
||||
|
||||
namespace System.Runtime.InteropServices
|
||||
{
|
||||
[System.Security.SecuritySafeCritical]
|
||||
public class ComAwareEventInfo : System.Reflection.EventInfo
|
||||
[SecuritySafeCritical]
|
||||
public class ComAwareEventInfo : EventInfo
|
||||
{
|
||||
private System.Reflection.EventInfo _innerEventInfo;
|
||||
private EventInfo _innerEventInfo;
|
||||
|
||||
public ComAwareEventInfo(Type type, string eventName)
|
||||
{
|
||||
_innerEventInfo = type.GetEvent(eventName);
|
||||
}
|
||||
|
||||
[System.Security.SecuritySafeCritical]
|
||||
[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);
|
||||
GetDataForComInvocation(_innerEventInfo, out Guid sourceIid, out int dispid);
|
||||
ComEventsHelper.Combine(target, sourceIid, dispid, handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -32,17 +34,15 @@ namespace System.Runtime.InteropServices
|
||||
}
|
||||
}
|
||||
|
||||
[System.Security.SecuritySafeCritical]
|
||||
[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);
|
||||
GetDataForComInvocation(_innerEventInfo, out Guid sourceIid, out int dispid);
|
||||
|
||||
System.Runtime.InteropServices.ComEventsHelper.Remove(target, sourceIid, dispid, handler);
|
||||
ComEventsHelper.Remove(target, sourceIid, dispid, handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -51,30 +51,17 @@ namespace System.Runtime.InteropServices
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Reflection.EventAttributes Attributes
|
||||
{
|
||||
get { return _innerEventInfo.Attributes; }
|
||||
}
|
||||
public override EventAttributes Attributes => _innerEventInfo.Attributes;
|
||||
|
||||
public override System.Reflection.MethodInfo GetAddMethod(bool nonPublic)
|
||||
{
|
||||
return _innerEventInfo.GetAddMethod(nonPublic);
|
||||
}
|
||||
public override MethodInfo GetAddMethod(bool nonPublic) => _innerEventInfo.GetAddMethod(nonPublic);
|
||||
|
||||
public override System.Reflection.MethodInfo GetRaiseMethod(bool nonPublic)
|
||||
{
|
||||
return _innerEventInfo.GetRaiseMethod(nonPublic);
|
||||
}
|
||||
public override MethodInfo[] GetOtherMethods(bool nonPublic) => _innerEventInfo.GetOtherMethods(nonPublic);
|
||||
|
||||
public override System.Reflection.MethodInfo GetRemoveMethod(bool nonPublic)
|
||||
{
|
||||
return _innerEventInfo.GetRemoveMethod(nonPublic);
|
||||
}
|
||||
public override MethodInfo GetRaiseMethod(bool nonPublic) => _innerEventInfo.GetRaiseMethod(nonPublic);
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return _innerEventInfo.DeclaringType; }
|
||||
}
|
||||
public override MethodInfo GetRemoveMethod(bool nonPublic) => _innerEventInfo.GetRemoveMethod(nonPublic);
|
||||
|
||||
public override Type DeclaringType => _innerEventInfo.DeclaringType;
|
||||
|
||||
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
||||
{
|
||||
@@ -86,46 +73,43 @@ namespace System.Runtime.InteropServices
|
||||
return _innerEventInfo.GetCustomAttributes(inherit);
|
||||
}
|
||||
|
||||
public override IList<CustomAttributeData> GetCustomAttributesData() => _innerEventInfo.GetCustomAttributesData();
|
||||
|
||||
public override bool IsDefined(Type attributeType, bool inherit)
|
||||
{
|
||||
return _innerEventInfo.IsDefined(attributeType, inherit);
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return _innerEventInfo.Name; }
|
||||
}
|
||||
public override int MetadataToken => _innerEventInfo.MetadataToken;
|
||||
|
||||
public override Type ReflectedType
|
||||
{
|
||||
get { return _innerEventInfo.ReflectedType; }
|
||||
}
|
||||
public override Module Module => _innerEventInfo.Module;
|
||||
|
||||
private static void GetDataForComInvocation(System.Reflection.EventInfo eventInfo, out Guid sourceIid, out int dispid)
|
||||
public override string Name => _innerEventInfo.Name;
|
||||
|
||||
public override Type ReflectedType => _innerEventInfo.ReflectedType;
|
||||
|
||||
private static void GetDataForComInvocation(EventInfo eventInfo, out Guid sourceIid, out int dispid)
|
||||
{
|
||||
object[] comEventInterfaces = eventInfo.DeclaringType.GetCustomAttributes(typeof(ComEventInterfaceAttribute), false);
|
||||
object[] comEventInterfaces = eventInfo.DeclaringType.GetCustomAttributes(typeof(ComEventInterfaceAttribute), inherit: 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");
|
||||
throw new InvalidOperationException(SR.InvalidOperation_NoComEventInterfaceAttribute);
|
||||
}
|
||||
|
||||
if (comEventInterfaces.Length > 1)
|
||||
{
|
||||
// TODO: event strings need to be localizable
|
||||
throw new System.Reflection.AmbiguousMatchException("more than one ComSourceInterfaceGuidAttribute found");
|
||||
throw new AmbiguousMatchException(SR.AmbiguousMatch_MultipleEventInterfaceAttributes);
|
||||
}
|
||||
|
||||
Type sourceItf = ((ComEventInterfaceAttribute)comEventInterfaces[0]).SourceInterface;
|
||||
Guid guid = sourceItf.GUID;
|
||||
Type sourceInterface = ((ComEventInterfaceAttribute)comEventInterfaces[0]).SourceInterface;
|
||||
Guid guid = sourceInterface.GUID;
|
||||
|
||||
System.Reflection.MethodInfo methodInfo = sourceItf.GetMethod(eventInfo.Name);
|
||||
MethodInfo methodInfo = sourceInterface.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");
|
||||
throw new InvalidOperationException(SR.InvalidOperation_NoDispIdAttribute);
|
||||
}
|
||||
|
||||
sourceIid = guid;
|
||||
|
||||
@@ -2,23 +2,18 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Runtime.InteropServices
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Interface, Inherited = false)]
|
||||
public sealed class ComEventInterfaceAttribute : Attribute
|
||||
{
|
||||
internal Type _SourceInterface;
|
||||
internal Type _EventProvider;
|
||||
|
||||
public ComEventInterfaceAttribute(Type SourceInterface, Type EventProvider)
|
||||
{
|
||||
_SourceInterface = SourceInterface;
|
||||
_EventProvider = EventProvider;
|
||||
this.SourceInterface = SourceInterface;
|
||||
this.EventProvider = EventProvider;
|
||||
}
|
||||
|
||||
public Type SourceInterface { get { return _SourceInterface; } }
|
||||
public Type EventProvider { get { return _EventProvider; } }
|
||||
public Type SourceInterface { get; }
|
||||
public Type EventProvider { get; }
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,11 @@ namespace System.Runtime.InteropServices
|
||||
// from other languages. This is particularly useful for
|
||||
// methods defined in COM interop interfaces.
|
||||
//
|
||||
[AttributeUsageAttribute(AttributeTargets.Parameter)]
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class DefaultParameterValueAttribute : Attribute
|
||||
{
|
||||
public DefaultParameterValueAttribute(object value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
public DefaultParameterValueAttribute(object value) => Value = value;
|
||||
|
||||
public object Value { get { return _value; } }
|
||||
|
||||
private object _value;
|
||||
public object Value { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ namespace System.Runtime.InteropServices
|
||||
{
|
||||
public sealed class HandleCollector
|
||||
{
|
||||
private const int deltaPercent = 10; // this is used for increasing the threshold.
|
||||
private string _name;
|
||||
private const int DeltaPercent = 10; // this is used for increasing the threshold.
|
||||
private int _initialThreshold;
|
||||
private int _maximumThreshold;
|
||||
private int _threshold;
|
||||
private int _handleCount;
|
||||
|
||||
@@ -40,28 +38,20 @@ namespace System.Runtime.InteropServices
|
||||
throw new ArgumentException(SR.Arg_InvalidThreshold);
|
||||
}
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
_name = String.Empty;
|
||||
}
|
||||
|
||||
Name = name ?? string.Empty;
|
||||
_initialThreshold = initialThreshold;
|
||||
_maximumThreshold = maximumThreshold;
|
||||
MaximumThreshold = maximumThreshold;
|
||||
_threshold = initialThreshold;
|
||||
_handleCount = 0;
|
||||
}
|
||||
|
||||
public int Count { get { return _handleCount; } }
|
||||
public int Count => _handleCount;
|
||||
|
||||
public int InitialThreshold { get { return _initialThreshold; } }
|
||||
public int InitialThreshold => _initialThreshold;
|
||||
|
||||
public int MaximumThreshold { get { return _maximumThreshold; } }
|
||||
public int MaximumThreshold { get; }
|
||||
|
||||
public string Name { get { return _name; } }
|
||||
public string Name { get; }
|
||||
|
||||
public void Add()
|
||||
{
|
||||
@@ -76,7 +66,7 @@ namespace System.Runtime.InteropServices
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_threshold = _handleCount + (_handleCount / deltaPercent);
|
||||
_threshold = _handleCount + (_handleCount / DeltaPercent);
|
||||
gen_collect = _gc_gen;
|
||||
if (_gc_gen < 2)
|
||||
{
|
||||
@@ -108,8 +98,8 @@ namespace System.Runtime.InteropServices
|
||||
throw new InvalidOperationException(SR.InvalidOperation_HCCountOverflow);
|
||||
}
|
||||
|
||||
int newThreshold = _handleCount + _handleCount / deltaPercent;
|
||||
if (newThreshold < (_threshold - _threshold / deltaPercent))
|
||||
int newThreshold = _handleCount + _handleCount / DeltaPercent;
|
||||
if (newThreshold < (_threshold - _threshold / DeltaPercent))
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -10,17 +9,10 @@ namespace System.Runtime.InteropServices
|
||||
{
|
||||
public static class RuntimeEnvironment
|
||||
{
|
||||
public static string SystemConfigurationFile
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
public static bool FromGlobalAccessCache(System.Reflection.Assembly a)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public static string SystemConfigurationFile => throw new PlatformNotSupportedException();
|
||||
|
||||
public static bool FromGlobalAccessCache(Assembly a) => false;
|
||||
|
||||
public static string GetRuntimeDirectory()
|
||||
{
|
||||
string runtimeDirectory = typeof(object).Assembly.Location;
|
||||
@@ -30,17 +22,11 @@ namespace System.Runtime.InteropServices
|
||||
}
|
||||
return Path.GetDirectoryName(runtimeDirectory) + Path.DirectorySeparatorChar;
|
||||
}
|
||||
public static System.IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
public static string GetSystemVersion()
|
||||
{
|
||||
return typeof(object).Assembly.ImageRuntimeVersion;
|
||||
}
|
||||
|
||||
public static IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid) => throw new PlatformNotSupportedException();
|
||||
|
||||
public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid) => throw new PlatformNotSupportedException();
|
||||
|
||||
public static string GetSystemVersion() => typeof(object).Assembly.ImageRuntimeVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netcoreapp;
|
||||
netcoreapp-Windows_NT;
|
||||
netfx-Windows_NT;
|
||||
uap-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -4,36 +4,79 @@
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{A824F4CD-935B-4496-A1B2-C3664936DA7B}</ProjectGuid>
|
||||
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="System\Runtime\InteropServices\AllowReversePInvokeCallsAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ArrayWithOffsetTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\BestFitMappingAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\BStrWrapperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\CallingConventionTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ClassInterfaceAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\CoClassAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComAliasNameAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComAwareEventInfoTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComAwareEventInfoTests.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComCompatibleVersionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComConversionLossAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComDefaultInterfaceAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComEventInterfaceAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComEventsHelperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComRegisterFunctionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComSourceInterfacesAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComUnregisterFunctionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComVisibleAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\CurrencyWrapperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DefaultCharSetAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DefaultDllImportSearchPathsAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DefaultParameterValueAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DispatchWrapperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DispIdAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\DllImportAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ErrorWrapperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\GCHandleTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\GuidAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\HandleCollectorTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\HandleRefTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\IDispatchImplAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\InterfaceTypeAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\LCIDConversionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\MarshalAsAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\MarshalTests.cs" />
|
||||
<!-- Helpers -->
|
||||
<Compile Include="System\Runtime\InteropServices\MarshalTests.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
|
||||
<Compile Condition="'$(TargetGroup)' != 'uap'" Include="System\Runtime\InteropServices\PrimaryInteropAssemblyAttributeTests.cs" />
|
||||
<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\SetWin32ContextInIDispatchAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeIdentifierAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\UnknownWrapperTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\UnmanagedFunctionPointerAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\VariantWrapperTests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="System\Runtime\InteropServices\RuntimeEnvironmentTest.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\AllowReversePInvokeCallsAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\CallingConventionTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComAliasNameAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComCompatibleVersionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComConversionLossAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComRegisterFunctionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComUnregisterFunctionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ComVisibleAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\HandleRefTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\LCIDConversionAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\PrimaryInteropAssemblyAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ProgIdAttributeTests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs">
|
||||
<Link>System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
|
||||
<Link>Common\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
|
||||
<Compile Include="System\Runtime\InteropServices\AutomationProxyAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ImportedFromTypeLibAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\ManagedToNativeComInteropStubAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeLibFuncAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeLibImportClassAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeLibTypeAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeLibVarAttributeTests.cs" />
|
||||
<Compile Include="System\Runtime\InteropServices\TypeLibVersionAttributeTests.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.CompilerServices.Tests
|
||||
{
|
||||
public class IUnknownConstantAttributeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Ctor_Default()
|
||||
{
|
||||
var attribute = new IUnknownConstantAttribute();
|
||||
#pragma warning disable 0618 // UnknownWrapper is marked as Obsolete.
|
||||
UnknownWrapper wrapper = Assert.IsType<UnknownWrapper>(attribute.Value);
|
||||
#pragma warning restore 0618
|
||||
Assert.Null(wrapper.WrappedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,15 @@ namespace System.Runtime.InteropServices.Tests
|
||||
public class AllowReversePInvokeCallsAttributeTests
|
||||
{
|
||||
[AllowReversePInvokeCalls]
|
||||
private int Func(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
private int Func(int a, int b) => a + b;
|
||||
|
||||
[Fact]
|
||||
public void Exists()
|
||||
{
|
||||
var type = typeof(AllowReversePInvokeCallsAttributeTests);
|
||||
var method = type.GetTypeInfo().DeclaredMethods.Single(m => m.Name == "Func");
|
||||
var attr = method.GetCustomAttributes(typeof(AllowReversePInvokeCallsAttribute), false).OfType<AllowReversePInvokeCallsAttribute>().SingleOrDefault();
|
||||
Assert.NotNull(attr);
|
||||
Type type = typeof(AllowReversePInvokeCallsAttributeTests);
|
||||
MethodInfo method = type.GetTypeInfo().DeclaredMethods.Single(m => m.Name == "Func");
|
||||
AllowReversePInvokeCallsAttribute attribute = Assert.Single(method.GetCustomAttributes< AllowReversePInvokeCallsAttribute>(inherit: false));
|
||||
Assert.NotNull(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
public class ArrayWithOffsetTests
|
||||
{
|
||||
public static IEnumerable<object[]> Ctor_Array_Offset_TestData()
|
||||
{
|
||||
yield return new object[] { null, 0, 0 };
|
||||
yield return new object[] { new int[2], -1, 8 };
|
||||
yield return new object[] { new int[2], 2, 8 };
|
||||
yield return new object[] { new int[2], 3, 8 };
|
||||
yield return new object[] { new byte[4], 1, 4 };
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Ctor_Array_Offset_TestData))]
|
||||
public void Ctor_Array_Offset(object array, int offset, int expectedHashCode)
|
||||
{
|
||||
var arrayWithOffset = new ArrayWithOffset(array, offset);
|
||||
Assert.Equal(array, arrayWithOffset.GetArray());
|
||||
Assert.Equal(offset, arrayWithOffset.GetOffset());
|
||||
Assert.Equal(expectedHashCode, arrayWithOffset.GetHashCode());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ctor_NotAnArray_ThrowsArgumentException()
|
||||
{
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => new ArrayWithOffset("array", 2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ctor_MultidimensionalArray_ThrowsArgumentException()
|
||||
{
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => new ArrayWithOffset(new int[1, 2], 2));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, -1)]
|
||||
[InlineData(null, 1)]
|
||||
[InlineData(new int[] { 1 }, 5)]
|
||||
public void Ctor_InvalidOffset_ThrowsIndexOutOfRangeException(object array, int offset)
|
||||
{
|
||||
Assert.Throws<IndexOutOfRangeException>(() => new ArrayWithOffset(array, offset));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> NonPrimitiveArray_TestData()
|
||||
{
|
||||
yield return new object[] { new object[0] };
|
||||
yield return new object[] { new string[0] };
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(NonPrimitiveArray_TestData))]
|
||||
public void Ctor_NonPrimitiveArray_ThrowsArgumentException(object array)
|
||||
{
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => new ArrayWithOffset(array, 0));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Equals_TestData()
|
||||
{
|
||||
int[] array = new int[2];
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), new ArrayWithOffset(array, 0), true };
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), new ArrayWithOffset(new int[2], 0), false };
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), new ArrayWithOffset(null, 0), false };
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), new ArrayWithOffset(array, 1), false };
|
||||
|
||||
yield return new object[] { new ArrayWithOffset(null, 0), new ArrayWithOffset(null, 0), true };
|
||||
yield return new object[] { new ArrayWithOffset(null, 0), new ArrayWithOffset(new int[2], 0), false };
|
||||
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), new object(), false };
|
||||
yield return new object[] { new ArrayWithOffset(array, 0), null, false };
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Equals_TestData))]
|
||||
public void Equals_Object_ReturnsExpected(ArrayWithOffset arrayWithOffset, object other, bool expected)
|
||||
{
|
||||
Assert.Equal(expected, arrayWithOffset.Equals(other));
|
||||
if (other is ArrayWithOffset otherArrayWithOffset)
|
||||
{
|
||||
Assert.Equal(expected, arrayWithOffset == otherArrayWithOffset);
|
||||
Assert.Equal(!expected, arrayWithOffset != otherArrayWithOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
public class AutomationProxyAttributeTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void Ctor_Val(bool val)
|
||||
{
|
||||
var attribute = new AutomationProxyAttribute(val);
|
||||
Assert.Equal(val, attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
#pragma warning disable 0618 // BStrWrapper is marked as Obsolete.
|
||||
public class BStrWrapperTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("Value")]
|
||||
public void Ctor_StringValue(string value)
|
||||
{
|
||||
var wrapper = new BStrWrapper(value);
|
||||
Assert.Equal(value, wrapper.WrappedObject);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("Value")]
|
||||
public void Ctor_ObjectValue(object value)
|
||||
{
|
||||
var wrapper = new BStrWrapper(value);
|
||||
Assert.Equal(value, wrapper.WrappedObject);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ctor_NonStringObjectValue_ThrowsInvalidCastException()
|
||||
{
|
||||
Assert.Throws<InvalidCastException>(() => new BStrWrapper(1));
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0618
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
public class BestFitMappingAttributeTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void Ctor_BestFitMapping(bool bestFitMapping)
|
||||
{
|
||||
var attribute = new BestFitMappingAttribute(bestFitMapping);
|
||||
Assert.Equal(bestFitMapping, attribute.BestFitMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,21 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
public class CallingConventionTests
|
||||
{
|
||||
[Fact]
|
||||
public void Values()
|
||||
[Theory]
|
||||
[InlineData(CallingConvention.Winapi, 1)]
|
||||
[InlineData(CallingConvention.Cdecl, 2)]
|
||||
[InlineData(CallingConvention.StdCall, 3)]
|
||||
[InlineData(CallingConvention.ThisCall, 4)]
|
||||
[InlineData(CallingConvention.FastCall, 5)]
|
||||
public void CallingConvention_Get_ReturnsExpected(CallingConvention convention, int expected)
|
||||
{
|
||||
Assert.Equal(1, (int)CallingConvention.Winapi);
|
||||
Assert.Equal(2, (int)CallingConvention.Cdecl);
|
||||
Assert.Equal(3, (int)CallingConvention.StdCall);
|
||||
Assert.Equal(4, (int)CallingConvention.ThisCall);
|
||||
Assert.Equal(5, (int)CallingConvention.FastCall);
|
||||
Assert.Equal(expected, (int)convention);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Runtime.InteropServices.Tests
|
||||
{
|
||||
public class ClassInterfaceAttributeTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(-1)]
|
||||
[InlineData(0)]
|
||||
[InlineData(4)]
|
||||
public void Ctor_ShortClassInterfaceType(ClassInterfaceType classInterfaceType)
|
||||
{
|
||||
var attribute = new ClassInterfaceAttribute(classInterfaceType);
|
||||
Assert.Equal(classInterfaceType, attribute.Value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((ClassInterfaceType)(-1))]
|
||||
[InlineData(ClassInterfaceType.None)]
|
||||
[InlineData((ClassInterfaceType)4)]
|
||||
public void Ctor_ClassInterfaceType(ClassInterfaceType classInterfaceType)
|
||||
{
|
||||
var attribute = new ClassInterfaceAttribute(classInterfaceType);
|
||||
Assert.Equal(classInterfaceType, attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user