summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Runtime')
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/AccessedThroughPropertyAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/AssemblyAttributesGoHere.cs43
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs60
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/CompilationRelaxations.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs366
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/DecoratedNameAttribute.cs18
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/DiscardableAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/ITuple.cs22
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IndexerNameAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsVolatile.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs57
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs12
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs13
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/ExceptionServices/CorruptingExceptionCommon.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/GcSettings.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs353
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/COMException.cs13
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CallingConvention.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CharSet.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsMethod.cs72
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs118
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerable.cs28
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerator.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IExpando.cs31
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IReflect.cs79
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs13
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Expando/IExpando.cs12
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ExtensibleClassFactory.cs40
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs146
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/HandleRef.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomAdapter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomFactory.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomMarshaler.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/IException.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/IRegistrationServices.cs50
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ITypeLibConverter.cs122
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/LayoutKind.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs538
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs31
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs33
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ObjectCreationDelegate.cs24
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs1059
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs81
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs15
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs15
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventItfInfo.cs53
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventProviderWriter.cs774
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventSinkHelperWriter.cs298
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/NameSpaceExtractor.cs21
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/TCEAdapterGenerator.cs141
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIBindCtx.cs46
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPoint.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPointContainer.cs27
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnectionPoints.cs32
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnections.cs42
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumMoniker.cs33
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumString.cs32
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumVARIANT.cs35
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerable.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerator.cs32
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIExpando.cs33
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIMoniker.cs60
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIPersistFile.cs36
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIReflect.cs79
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIRunningObjectTable.cs32
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMIStream.cs57
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeComp.cs52
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeInfo.cs330
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeLib.cs71
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Variant.cs658
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs62
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs42
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs100
-rw-r--r--src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs41
-rw-r--r--src/mscorlib/src/System/Runtime/MemoryFailPoint.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/ProfileOptimization.cs50
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs480
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/IFormatter.cs41
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISerializationSurrogate.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISurrogateSelector.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/MemberHolder.cs51
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs210
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationBinder.cs29
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationFieldInfo.cs136
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs59
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs28
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/TargetFrameworkId.cs28
132 files changed, 500 insertions, 7593 deletions
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/AccessedThroughPropertyAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/AccessedThroughPropertyAttribute.cs
index b0010fd7bd..34e66beade 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/AccessedThroughPropertyAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/AccessedThroughPropertyAttribute.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.CompilerServices
using System;
[AttributeUsage(AttributeTargets.Field)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AccessedThroughPropertyAttribute : Attribute
{
private readonly string propertyName;
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/AssemblyAttributesGoHere.cs b/src/mscorlib/src/System/Runtime/CompilerServices/AssemblyAttributesGoHere.cs
deleted file mode 100644
index c021353475..0000000000
--- a/src/mscorlib/src/System/Runtime/CompilerServices/AssemblyAttributesGoHere.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-namespace System.Runtime.CompilerServices {
-
- using System;
-
- // NOTE TO DEVELOPERS: These classes are used by ALink (the assembly linker).
- // They're used for metadata tokens for making multi-module assemblies.
- // Do not randomly touch these classes.
- [System.Runtime.CompilerServices.FriendAccessAllowed]
- internal sealed class AssemblyAttributesGoHere
- {
-
- internal AssemblyAttributesGoHere()
- {
- }
- }
- [System.Runtime.CompilerServices.FriendAccessAllowed]
- internal sealed class AssemblyAttributesGoHereS
- {
- internal AssemblyAttributesGoHereS()
- {
- }
- }
- [System.Runtime.CompilerServices.FriendAccessAllowed]
- internal sealed class AssemblyAttributesGoHereM
- {
- internal AssemblyAttributesGoHereM()
- {
- }
- }
- [System.Runtime.CompilerServices.FriendAccessAllowed]
- internal sealed class AssemblyAttributesGoHereSM
- {
- internal AssemblyAttributesGoHereSM()
- {
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
index 6a16462383..afb0c22778 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
@@ -18,7 +18,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Runtime.ExceptionServices;
using System.Security;
-using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
@@ -840,36 +839,6 @@ namespace System.Runtime.CompilerServices
// This method is copy&pasted into the public Start methods to avoid size overhead of valuetype generic instantiations.
// Ideally, we would build intrinsics to get the raw ref address and raw code address of MoveNext, and just use the shared implementation.
-#if false
- /// <summary>Initiates the builder's execution with the associated state machine.</summary>
- /// <typeparam name="TStateMachine">Specifies the type of the state machine.</typeparam>
- /// <param name="stateMachine">The state machine instance, passed by reference.</param>
- /// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument is null (Nothing in Visual Basic).</exception>
- [DebuggerStepThrough]
- internal static void Start<TStateMachine>(ref TStateMachine stateMachine)
- where TStateMachine : IAsyncStateMachine
- {
- if (stateMachine == null) throw new ArgumentNullException(nameof(stateMachine));
- Contract.EndContractBlock();
-
- // Run the MoveNext method within a copy-on-write ExecutionContext scope.
- // This allows us to undo any ExecutionContext changes made in MoveNext,
- // so that they won't "leak" out of the first await.
-
- Thread currentThread = Thread.CurrentThread;
- ExecutionContextSwitcher ecs = default(ExecutionContextSwitcher);
- RuntimeHelpers.PrepareConstrainedRegions();
- try
- {
- ExecutionContext.EstablishCopyOnWriteScope(currentThread, ref ecs);
- stateMachine.MoveNext();
- }
- finally
- {
- ecs.Undo(currentThread);
- }
- }
-#endif
/// <summary>Associates the builder with the state machine it represents.</summary>
/// <param name="stateMachine">The heap-allocated state machine object.</param>
@@ -906,12 +875,12 @@ namespace System.Runtime.CompilerServices
Debugger.NotifyOfCrossThreadDependency();
// The builder needs to flow ExecutionContext, so capture it.
- var capturedContext = ExecutionContext.FastCapture(); // ok to use FastCapture as we haven't made any permission demands/asserts
+ var capturedContext = ExecutionContext.Capture();
// If the ExecutionContext is the default context, try to use a cached delegate, creating one if necessary.
Action action;
MoveNextRunner runner;
- if (capturedContext != null && capturedContext.IsPreAllocatedDefault)
+ if (capturedContext == ExecutionContext.Default)
{
// Get the cached delegate, and if it's non-null, return it.
action = m_defaultContextAction;
@@ -1046,12 +1015,8 @@ namespace System.Runtime.CompilerServices
if (m_context != null)
{
- try
- {
- // Use the context and callback to invoke m_stateMachine.MoveNext.
- ExecutionContext.Run(m_context, InvokeMoveNextCallback, m_stateMachine, preserveSyncCtx: true);
- }
- finally { m_context.Dispose(); }
+ // Use the context and callback to invoke m_stateMachine.MoveNext.
+ ExecutionContext.Run(m_context, InvokeMoveNextCallback, m_stateMachine);
}
else
{
@@ -1076,24 +1041,11 @@ namespace System.Runtime.CompilerServices
internal void RunWithDefaultContext()
{
Debug.Assert(m_stateMachine != null, "The state machine must have been set before calling Run.");
- ExecutionContext.Run(ExecutionContext.PreAllocatedDefault, InvokeMoveNextCallback, m_stateMachine, preserveSyncCtx: true);
+ ExecutionContext.Run(ExecutionContext.Default, InvokeMoveNextCallback, m_stateMachine);
}
/// <summary>Gets a delegate to the InvokeMoveNext method.</summary>
- protected static ContextCallback InvokeMoveNextCallback
- {
- get { return s_invokeMoveNext ?? (s_invokeMoveNext = InvokeMoveNext); }
- }
-
- /// <summary>Cached delegate used with ExecutionContext.Run.</summary>
- private static ContextCallback s_invokeMoveNext; // lazily-initialized due to SecurityCritical attribution
-
- /// <summary>Invokes the MoveNext method on the supplied IAsyncStateMachine.</summary>
- /// <param name="stateMachine">The IAsyncStateMachine machine instance.</param>
- private static void InvokeMoveNext(object stateMachine)
- {
- ((IAsyncStateMachine)stateMachine).MoveNext();
- }
+ protected static readonly ContextCallback InvokeMoveNextCallback = sm => ((IAsyncStateMachine)sm).MoveNext();
}
/// <summary>
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/CompilationRelaxations.cs b/src/mscorlib/src/System/Runtime/CompilerServices/CompilationRelaxations.cs
index 5e4f19410b..c3679b610c 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/CompilationRelaxations.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/CompilationRelaxations.cs
@@ -13,7 +13,6 @@ namespace System.Runtime.CompilerServices
/// IMPORTANT: Keep this in sync with corhdr.h
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum CompilationRelaxations : int
{
NoStringInterning = 0x0008, // Start in 0x0008, we had other non public flags in this enum before,
@@ -23,7 +22,6 @@ namespace System.Runtime.CompilerServices
[Serializable]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Method)]
-[System.Runtime.InteropServices.ComVisible(true)]
public class CompilationRelaxationsAttribute : Attribute
{
private int m_relaxations; // The relaxations.
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs
index 65755f6baa..1cd830cfca 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs
@@ -18,7 +18,6 @@ namespace System.Runtime.CompilerServices
{
[Serializable]
[AttributeUsage(AttributeTargets.Class)]
- [System.Runtime.InteropServices.ComVisible(true)]
public class CompilerGlobalScopeAttribute : Attribute
{
public CompilerGlobalScopeAttribute () {}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
index 74559673bb..4b2648ba6f 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
@@ -46,7 +46,6 @@
** expose the full public surface area.
**
**
-**
** Thread safety guarantees:
**
** ConditionalWeakTable is fully thread-safe and requires no
@@ -60,6 +59,7 @@
** may be delayed until appdomain shutdown.
===========================================================*/
+using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
@@ -67,8 +67,7 @@ using System.Threading;
namespace System.Runtime.CompilerServices
{
#region ConditionalWeakTable
- [ComVisible(false)]
- public sealed class ConditionalWeakTable<TKey, TValue>
+ public sealed class ConditionalWeakTable<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>
where TKey : class
where TValue : class
{
@@ -76,6 +75,7 @@ namespace System.Runtime.CompilerServices
private const int InitialCapacity = 8; // Initial length of the table. Must be a power of two.
private readonly object _lock; // This lock protects all mutation of data in the table. Readers do not take this lock.
private volatile Container _container; // The actual storage for the table; swapped out as the table grows.
+ private int _activeEnumeratorRefCount; // The number of outstanding enumerators on the table
#endregion
#region Constructors
@@ -190,6 +190,34 @@ namespace System.Runtime.CompilerServices
}
}
+ //--------------------------------------------------------------------------------------------
+ // Clear all the key/value pairs
+ //--------------------------------------------------------------------------------------------
+ public void Clear()
+ {
+ lock (_lock)
+ {
+ // To clear, we would prefer to simply drop the existing container
+ // and replace it with an empty one, as that's overall more efficient.
+ // However, if there are any active enumerators, we don't want to do
+ // that as it will end up removing all of the existing entries and
+ // allowing new items to be added at the same indices when the container
+ // is filled and replaced, and one of the guarantees we try to make with
+ // enumeration is that new items added after enumeration starts won't be
+ // included in the enumeration. As such, if there are active enumerators,
+ // we simply use the container's removal functionality to remove all of the
+ // keys; then when the table is resized, if there are still active enumerators,
+ // these empty slots will be maintained.
+ if (_activeEnumeratorRefCount > 0)
+ {
+ _container.RemoveAllKeys();
+ }
+ else
+ {
+ _container = new Container(this);
+ }
+ }
+ }
//--------------------------------------------------------------------------------------------
// key: key of the value to find. Cannot be null.
@@ -256,6 +284,148 @@ namespace System.Runtime.CompilerServices
public delegate TValue CreateValueCallback(TKey key);
+ //--------------------------------------------------------------------------------------------
+ // Gets an enumerator for the table. The returned enumerator will not extend the lifetime of
+ // any object pairs in the table, other than the one that's Current. It will not return entries
+ // that have already been collected, nor will it return entries added after the enumerator was
+ // retrieved. It may not return all entries that were present when the enumerat was retrieved,
+ // however, such as not returning entries that were collected or removed after the enumerator
+ // was retrieved but before they were enumerated.
+ //--------------------------------------------------------------------------------------------
+ IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
+ {
+ lock (_lock)
+ {
+ Container c = _container;
+ return c == null || c.FirstFreeEntry == 0 ?
+ ((IEnumerable<KeyValuePair<TKey, TValue>>)Array.Empty<KeyValuePair<TKey, TValue>>()).GetEnumerator() :
+ new Enumerator(this);
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable<KeyValuePair<TKey, TValue>>)this).GetEnumerator();
+
+ /// <summary>Provides an enumerator for the table.</summary>
+ private sealed class Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>
+ {
+ // The enumerator would ideally hold a reference to the Container and the end index within that
+ // container. However, the safety of the CWT depends on the only reference to the Container being
+ // from the CWT itself; the Container then employs a two-phase finalization scheme, where the first
+ // phase nulls out that parent CWT's reference, guaranteeing that the second time it's finalized there
+ // can be no other existing references to it in use that would allow for concurrent usage of the
+ // native handles with finalization. We would break that if we allowed this Enumerator to hold a
+ // reference to the Container. Instead, the Enumerator holds a reference to the CWT rather than to
+ // the Container, and it maintains the CWT._activeEnumeratorRefCount field to track whether there
+ // are outstanding enumerators that have yet to be disposed/finalized. If there aren't any, the CWT
+ // behaves as it normally does. If there are, certain operations are affected, in particular resizes.
+ // Normally when the CWT is resized, it enumerates the contents of the table looking for indices that
+ // contain entries which have been collected or removed, and it frees those up, effectively moving
+ // down all subsequent entries in the container (not in the existing container, but in a replacement).
+ // This, however, would cause the enumerator's understanding of indices to break. So, as long as
+ // there is any outstanding enumerator, no compaction is performed.
+
+ private ConditionalWeakTable<TKey, TValue> _table; // parent table, set to null when disposed
+ private readonly int _maxIndexInclusive; // last index in the container that should be enumerated
+ private int _currentIndex = -1; // the current index into the container
+ private KeyValuePair<TKey, TValue> _current; // the current entry set by MoveNext and returned from Current
+
+ public Enumerator(ConditionalWeakTable<TKey, TValue> table)
+ {
+ Debug.Assert(table != null, "Must provide a valid table");
+ Debug.Assert(Monitor.IsEntered(table._lock), "Must hold the _lock lock to construct the enumerator");
+ Debug.Assert(table._container != null, "Should not be used on a finalized table");
+ Debug.Assert(table._container.FirstFreeEntry > 0, "Should have returned an empty enumerator instead");
+
+ // Store a reference to the parent table and increase its active enumerator count.
+ _table = table;
+ Debug.Assert(table._activeEnumeratorRefCount >= 0, "Should never have a negative ref count before incrementing");
+ table._activeEnumeratorRefCount++;
+
+ // Store the max index to be enumerated.
+ _maxIndexInclusive = table._container.FirstFreeEntry - 1;
+ _currentIndex = -1;
+ }
+
+ ~Enumerator() { Dispose(); }
+
+ public void Dispose()
+ {
+ // Use an interlocked operation to ensure that only one thread can get access to
+ // the _table for disposal and thus only decrement the ref count once.
+ ConditionalWeakTable<TKey, TValue> table = Interlocked.Exchange(ref _table, null);
+ if (table != null)
+ {
+ // Ensure we don't keep the last current alive unnecessarily
+ _current = default(KeyValuePair<TKey, TValue>);
+
+ // Decrement the ref count that was incremented when constructed
+ lock (table._lock)
+ {
+ table._activeEnumeratorRefCount--;
+ Debug.Assert(table._activeEnumeratorRefCount >= 0, "Should never have a negative ref count after decrementing");
+ }
+
+ // Finalization is purely to decrement the ref count. We can suppress it now.
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ public bool MoveNext()
+ {
+ // Start by getting the current table. If it's already been disposed, it will be null.
+ ConditionalWeakTable<TKey, TValue> table = _table;
+ if (table != null)
+ {
+ // Once have the table, we need to lock to synchronize with other operations on
+ // the table, like adding.
+ lock (table._lock)
+ {
+ // From the table, we have to get the current container. This could have changed
+ // since we grabbed the enumerator, but the index-to-pair mapping should not have
+ // due to there being at least one active enumerator. If the table (or rather its
+ // container at the time) has already been finalized, this will be null.
+ Container c = table._container;
+ if (c != null)
+ {
+ // We have the container. Find the next entry to return, if there is one.
+ // We need to loop as we may try to get an entry that's already been removed
+ // or collected, in which case we try again.
+ while (_currentIndex < _maxIndexInclusive)
+ {
+ _currentIndex++;
+ TKey key;
+ TValue value;
+ if (c.TryGetEntry(_currentIndex, out key, out value))
+ {
+ _current = new KeyValuePair<TKey, TValue>(key, value);
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // Nothing more to enumerate.
+ return false;
+ }
+
+ public KeyValuePair<TKey, TValue> Current
+ {
+ get
+ {
+ if (_currentIndex < 0)
+ {
+ ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen();
+ }
+ return _current;
+ }
+ }
+
+ object IEnumerator.Current => Current;
+
+ public void Reset() { }
+ }
+
#endregion
#region Internal members
@@ -305,17 +475,6 @@ namespace System.Runtime.CompilerServices
}
}
- //--------------------------------------------------------------------------------------------
- // Clear all the key/value pairs
- //--------------------------------------------------------------------------------------------
- internal void Clear()
- {
- lock (_lock)
- {
- _container = new Container(this);
- }
- }
-
#endregion
#region Private Members
@@ -435,6 +594,8 @@ namespace System.Runtime.CompilerServices
internal bool HasCapacity => _firstFreeEntry < _entries.Length;
+ internal int FirstFreeEntry => _firstFreeEntry;
+
//----------------------------------------------------------------------------------------
// Worker for adding a new key/value pair.
// Preconditions:
@@ -508,6 +669,44 @@ namespace System.Runtime.CompilerServices
return -1;
}
+ //----------------------------------------------------------------------------------------
+ // Gets the entry at the specified entry index.
+ //----------------------------------------------------------------------------------------
+ internal bool TryGetEntry(int index, out TKey key, out TValue value)
+ {
+ if (index < _entries.Length)
+ {
+ object oKey, oValue;
+ _entries[index].depHnd.GetPrimaryAndSecondary(out oKey, out oValue);
+ GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
+
+ if (oKey != null)
+ {
+ key = JitHelpers.UnsafeCast<TKey>(oKey);
+ value = JitHelpers.UnsafeCast<TValue>(oValue);
+ return true;
+ }
+ }
+
+ key = default(TKey);
+ value = default(TValue);
+ return false;
+ }
+
+ //----------------------------------------------------------------------------------------
+ // Removes all of the keys in the table.
+ //----------------------------------------------------------------------------------------
+ internal void RemoveAllKeys()
+ {
+ for (int i = 0; i < _firstFreeEntry; i++)
+ {
+ RemoveIndex(i);
+ }
+ }
+
+ //----------------------------------------------------------------------------------------
+ // Removes the specified key from the table, if it exists.
+ //----------------------------------------------------------------------------------------
internal bool Remove(TKey key)
{
VerifyIntegrity();
@@ -516,22 +715,27 @@ namespace System.Runtime.CompilerServices
int entryIndex = FindEntry(key, out value);
if (entryIndex != -1)
{
- ref Entry entry = ref _entries[entryIndex];
-
- // We do not free the handle here, as we may be racing with readers who already saw the hash code.
- // Instead, we simply overwrite the entry's hash code, so subsequent reads will ignore it.
- // The handle will be free'd in Container's finalizer, after the table is resized or discarded.
- Volatile.Write(ref entry.HashCode, -1);
-
- // Also, clear the key to allow GC to collect objects pointed to by the entry
- entry.depHnd.SetPrimary(null);
-
+ RemoveIndex(entryIndex);
return true;
}
return false;
}
+ private void RemoveIndex(int entryIndex)
+ {
+ Debug.Assert(entryIndex >= 0 && entryIndex < _firstFreeEntry);
+
+ ref Entry entry = ref _entries[entryIndex];
+
+ // We do not free the handle here, as we may be racing with readers who already saw the hash code.
+ // Instead, we simply overwrite the entry's hash code, so subsequent reads will ignore it.
+ // The handle will be free'd in Container's finalizer, after the table is resized or discarded.
+ Volatile.Write(ref entry.HashCode, -1);
+
+ // Also, clear the key to allow GC to collect objects pointed to by the entry
+ entry.depHnd.SetPrimary(null);
+ }
internal void UpdateValue(int entryIndex, TValue newValue)
{
@@ -556,25 +760,33 @@ namespace System.Runtime.CompilerServices
//----------------------------------------------------------------------------------------
internal Container Resize()
{
- // Start by assuming we won't resize.
- int newSize = _buckets.Length;
+ Debug.Assert(!HasCapacity);
- // If any expired or removed keys exist, we won't resize.
bool hasExpiredEntries = false;
- for (int entriesIndex = 0; entriesIndex < _entries.Length; entriesIndex++)
+ int newSize = _buckets.Length;
+
+ if (_parent == null || _parent._activeEnumeratorRefCount == 0)
{
- if (_entries[entriesIndex].HashCode == -1)
+ // If any expired or removed keys exist, we won't resize.
+ // If there any active enumerators, though, we don't want
+ // to compact and thus have no expired entries.
+ for (int entriesIndex = 0; entriesIndex < _entries.Length; entriesIndex++)
{
- // the entry was removed
- hasExpiredEntries = true;
- break;
- }
+ ref Entry entry = ref _entries[entriesIndex];
- if (_entries[entriesIndex].depHnd.IsAllocated && _entries[entriesIndex].depHnd.GetPrimary() == null)
- {
- // the entry has expired
- hasExpiredEntries = true;
- break;
+ if (entry.HashCode == -1)
+ {
+ // the entry was removed
+ hasExpiredEntries = true;
+ break;
+ }
+
+ if (entry.depHnd.IsAllocated && entry.depHnd.GetPrimary() == null)
+ {
+ // the entry has expired
+ hasExpiredEntries = true;
+ break;
+ }
}
}
@@ -585,44 +797,73 @@ namespace System.Runtime.CompilerServices
}
return Resize(newSize);
- }
+ }
internal Container Resize(int newSize)
{
+ Debug.Assert(newSize >= _buckets.Length);
Debug.Assert(IsPowerOfTwo(newSize));
// Reallocate both buckets and entries and rebuild the bucket and entries from scratch.
// This serves both to scrub entries with expired keys and to put the new entries in the proper bucket.
int[] newBuckets = new int[newSize];
- for (int bucketIndex = 0; bucketIndex < newSize; bucketIndex++)
+ for (int bucketIndex = 0; bucketIndex < newBuckets.Length; bucketIndex++)
{
newBuckets[bucketIndex] = -1;
}
Entry[] newEntries = new Entry[newSize];
int newEntriesIndex = 0;
+ bool activeEnumerators = _parent != null && _parent._activeEnumeratorRefCount > 0;
// Migrate existing entries to the new table.
- for (int entriesIndex = 0; entriesIndex < _entries.Length; entriesIndex++)
+ if (activeEnumerators)
{
- int hashCode = _entries[entriesIndex].HashCode;
- DependentHandle depHnd = _entries[entriesIndex].depHnd;
- if (hashCode != -1 && depHnd.IsAllocated)
+ // There's at least one active enumerator, which means we don't want to
+ // remove any expired/removed entries, in order to not affect existing
+ // entries indices. Copy over the entries while rebuilding the buckets list,
+ // as the buckets are dependent on the buckets list length, which is changing.
+ for (; newEntriesIndex < _entries.Length; newEntriesIndex++)
{
- if (depHnd.GetPrimary() != null)
- {
- // Entry is used and has not expired. Link it into the appropriate bucket list.
- newEntries[newEntriesIndex].HashCode = hashCode;
- newEntries[newEntriesIndex].depHnd = depHnd;
- int bucket = hashCode & (newBuckets.Length - 1);
- newEntries[newEntriesIndex].Next = newBuckets[bucket];
- newBuckets[bucket] = newEntriesIndex;
- newEntriesIndex++;
- }
- else
+ ref Entry oldEntry = ref _entries[newEntriesIndex];
+ ref Entry newEntry = ref newEntries[newEntriesIndex];
+ int hashCode = oldEntry.HashCode;
+
+ newEntry.HashCode = hashCode;
+ newEntry.depHnd = oldEntry.depHnd;
+ int bucket = hashCode & (newBuckets.Length - 1);
+ newEntry.Next = newBuckets[bucket];
+ newBuckets[bucket] = newEntriesIndex;
+ }
+ }
+ else
+ {
+ // There are no active enumerators, which means we want to compact by
+ // removing expired/removed entries.
+ for (int entriesIndex = 0; entriesIndex < _entries.Length; entriesIndex++)
+ {
+ ref Entry oldEntry = ref _entries[entriesIndex];
+ int hashCode = oldEntry.HashCode;
+ DependentHandle depHnd = oldEntry.depHnd;
+ if (hashCode != -1 && depHnd.IsAllocated)
{
- // Pretend the item was removed, so that this container's finalizer
- // will clean up this dependent handle.
- Volatile.Write(ref _entries[entriesIndex].HashCode, -1);
+ if (depHnd.GetPrimary() != null)
+ {
+ ref Entry newEntry = ref newEntries[newEntriesIndex];
+
+ // Entry is used and has not expired. Link it into the appropriate bucket list.
+ newEntry.HashCode = hashCode;
+ newEntry.depHnd = depHnd;
+ int bucket = hashCode & (newBuckets.Length - 1);
+ newEntry.Next = newBuckets[bucket];
+ newBuckets[bucket] = newEntriesIndex;
+ newEntriesIndex++;
+ }
+ else
+ {
+ // Pretend the item was removed, so that this container's finalizer
+ // will clean up this dependent handle.
+ Volatile.Write(ref oldEntry.HashCode, -1);
+ }
}
}
}
@@ -632,6 +873,14 @@ namespace System.Runtime.CompilerServices
// while the old container may still be in use. As such, we store a reference from the old container
// to the new one, which will keep the new container alive as long as the old one is.
var newContainer = new Container(_parent, newBuckets, newEntries, newEntriesIndex);
+ if (activeEnumerators)
+ {
+ // If there are active enumerators, both the old container and the new container may be storing
+ // the same entries with -1 hash codes, which the finalizer will clean up even if the container
+ // is not the active container for the table. To prevent that, we want to stop the old container
+ // from being finalized, as it no longer has any responsibility for any cleanup.
+ GC.SuppressFinalize(this);
+ }
_oldKeepAlive = newContainer; // once this is set, the old container's finalizer will not free transferred dependent handles
GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
@@ -815,7 +1064,6 @@ namespace System.Runtime.CompilerServices
// This struct intentionally does no self-synchronization. It's up to the caller to
// to use DependentHandles in a thread-safe way.
//=========================================================================================
- [ComVisible(false)]
internal struct DependentHandle
{
#region Constructors
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
index c912095bda..1a5dcfdc11 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.CompilerServices
{
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited=false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public abstract class CustomConstantAttribute : Attribute
{
public abstract Object Value { get; }
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
index 4362aa84a1..148d916be1 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.CompilerServices
{
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited=false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class DateTimeConstantAttribute : CustomConstantAttribute
{
public DateTimeConstantAttribute(long ticks)
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
index 7bfaa7aafd..f05191840d 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
@@ -14,7 +14,6 @@ namespace System.Runtime.CompilerServices
{
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited=false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class DecimalConstantAttribute : Attribute
{
[CLSCompliant(false)]
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DecoratedNameAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DecoratedNameAttribute.cs
deleted file mode 100644
index 75558d4e7e..0000000000
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DecoratedNameAttribute.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.CompilerServices
-{
- [AttributeUsage(AttributeTargets.All),
- ComVisible(false)]
- internal sealed class DecoratedNameAttribute : Attribute
- {
- public DecoratedNameAttribute(string decoratedName)
- {}
- }
-}
-
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DiscardableAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DiscardableAttribute.cs
index 303151f576..3fda4624d4 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DiscardableAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/DiscardableAttribute.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.CompilerServices {
using System;
// Custom attribute to indicating a TypeDef is a discardable attribute
-[System.Runtime.InteropServices.ComVisible(true)]
public class DiscardableAttribute : Attribute
{
public DiscardableAttribute()
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ITuple.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ITuple.cs
new file mode 100644
index 0000000000..cafee11f8a
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/ITuple.cs
@@ -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.
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>
+ /// This interface is required for types that want to be indexed into by dynamic patterns.
+ /// </summary>
+ public interface ITuple
+ {
+ /// <summary>
+ /// The number of positions in this data structure.
+ /// </summary>
+ int Length { get; }
+
+ /// <summary>
+ /// Get the element at position <param name="index"/>.
+ /// </summary>
+ object this[int index] { get; }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/IndexerNameAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/IndexerNameAttribute.cs
index 0323fe0cf6..c32be6f3a2 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/IndexerNameAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/IndexerNameAttribute.cs
@@ -8,7 +8,6 @@ namespace System.Runtime.CompilerServices
[Serializable]
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class IndexerNameAttribute: Attribute
{
public IndexerNameAttribute(String indexerName)
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/IsVolatile.cs b/src/mscorlib/src/System/Runtime/CompilerServices/IsVolatile.cs
index ea2fe032c6..5287e82b7b 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/IsVolatile.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/IsVolatile.cs
@@ -4,7 +4,6 @@
namespace System.Runtime.CompilerServices
{
-[System.Runtime.InteropServices.ComVisible(true)]
public static class IsVolatile
{
// no instantiation, please!
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs
index d081d70070..b4991110f8 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs
@@ -12,7 +12,6 @@ namespace System.Runtime.CompilerServices {
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodImplOptions
{
Unmanaged = System.Reflection.MethodImplAttributes.Unmanaged,
@@ -21,14 +20,12 @@ namespace System.Runtime.CompilerServices {
InternalCall = System.Reflection.MethodImplAttributes.InternalCall,
Synchronized = System.Reflection.MethodImplAttributes.Synchronized,
NoInlining = System.Reflection.MethodImplAttributes.NoInlining,
- [System.Runtime.InteropServices.ComVisible(false)]
AggressiveInlining = System.Reflection.MethodImplAttributes.AggressiveInlining,
NoOptimization = System.Reflection.MethodImplAttributes.NoOptimization,
// **** If you add something, update internal MethodImplAttribute(MethodImplAttributes methodImplAttributes)! ****
}
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodCodeType
{
IL = System.Reflection.MethodImplAttributes.IL,
@@ -41,7 +38,6 @@ namespace System.Runtime.CompilerServices {
// Custom attribute to specify additional method properties.
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
-[System.Runtime.InteropServices.ComVisible(true)]
sealed public class MethodImplAttribute : Attribute
{
internal MethodImplOptions _val;
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
index 926eb6c3cb..509e527ecb 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
@@ -18,7 +18,6 @@ namespace System.Runtime.CompilerServices {
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Threading;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
@@ -131,7 +130,6 @@ namespace System.Runtime.CompilerServices {
// Note: this method is not part of the CER support, and is not to be confused with ProbeForSufficientStack
// below.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern void EnsureSufficientExecutionStack();
// This method ensures that there is sufficient stack to execute the average Framework function.
@@ -139,7 +137,6 @@ namespace System.Runtime.CompilerServices {
// Note: this method is not part of the CER support, and is not to be confused with ProbeForSufficientStack
// below.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern bool TryEnsureSufficientExecutionStack();
public static void ProbeForSufficientStack()
@@ -148,7 +145,6 @@ namespace System.Runtime.CompilerServices {
// This method is a marker placed immediately before a try clause to mark the corresponding catch and finally blocks as
// constrained. There's no code here other than the probe because most of the work is done at JIT time when we spot a call to this routine.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegions()
{
ProbeForSufficientStack();
@@ -156,7 +152,6 @@ namespace System.Runtime.CompilerServices {
// When we detect a CER with no calls, we can point the JIT to this non-probing version instead
// as we don't need to probe.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegionsNoOP()
{
}
@@ -168,7 +163,6 @@ namespace System.Runtime.CompilerServices {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData);
- [PrePrepareMethod]
internal static void ExecuteBackoutCodeHelper(Object backoutCode, Object userData, bool exceptionThrown)
{
((CleanupCode)backoutCode)(userData, exceptionThrown);
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
index d2691df6b9..e3b2d2ce62 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
@@ -15,7 +15,6 @@ namespace System.Runtime.CompilerServices {
using System;
using System.Runtime.Serialization;
using System.Runtime.Remoting;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
[Serializable]
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
index 98a81ea470..f01900a5bf 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
@@ -44,7 +44,6 @@ using System.Diagnostics.Contracts;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
-using System.Security.Permissions;
using System.Diagnostics.Tracing;
// NOTE: For performance reasons, initialization is not verified. If a developer
@@ -198,21 +197,19 @@ namespace System.Runtime.CompilerServices
/// <exception cref="System.ArgumentNullException">The <paramref name="continuation"/> argument is null (Nothing in Visual Basic).</exception>
/// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
/// <remarks>This method is intended for compiler user rather than use directly in code.</remarks>
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
internal static void OnCompletedInternal(Task task, Action continuation, bool continueOnCapturedContext, bool flowExecutionContext)
{
if (continuation == null) throw new ArgumentNullException(nameof(continuation));
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
// If TaskWait* ETW events are enabled, trace a beginning event for this await
// and set up an ending event to be traced when the asynchronous await completes.
- if ( TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled)
+ if (TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled)
{
continuation = OutputWaitEtwEvents(task, continuation);
}
// Set the continuation onto the awaited task.
- task.SetContinuationForAwait(continuation, continueOnCapturedContext, flowExecutionContext, ref stackMark);
+ task.SetContinuationForAwait(continuation, continueOnCapturedContext, flowExecutionContext);
}
/// <summary>
@@ -244,7 +241,7 @@ namespace System.Runtime.CompilerServices
(currentTaskAtBegin != null ? currentTaskAtBegin.m_taskScheduler.Id : TaskScheduler.Default.Id),
(currentTaskAtBegin != null ? currentTaskAtBegin.Id : 0),
task.Id, TplEtwProvider.TaskWaitBehavior.Asynchronous,
- (continuationTask != null ? continuationTask.Id : 0), System.Threading.Thread.GetDomainID());
+ (continuationTask != null ? continuationTask.Id : 0));
}
// Create a continuation action that outputs the end event and then invokes the user
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs
new file mode 100644
index 0000000000..65b120e6b4
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs
@@ -0,0 +1,57 @@
+// 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;
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>
+ /// Indicates that the use of <see cref="System.ValueTuple"/> on a member is meant to be treated as a tuple with element names.
+ /// </summary>
+ [CLSCompliant(false)]
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Event)]
+ public sealed class TupleElementNamesAttribute : Attribute
+ {
+ private readonly string[] _transformNames;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
+ /// cref="TupleElementNamesAttribute"/> class.
+ /// </summary>
+ /// <param name="transformNames">
+ /// Specifies, in a pre-order depth-first traversal of a type's
+ /// construction, which <see cref="System.ValueType"/> occurrences are
+ /// meant to carry element names.
+ /// </param>
+ /// <remarks>
+ /// This constructor is meant to be used on types that contain an
+ /// instantiation of <see cref="System.ValueType"/> that contains
+ /// element names. For instance, if <c>C</c> is a generic type with
+ /// two type parameters, then a use of the constructed type <c>C{<see
+ /// cref="System.ValueTuple{T1, T2}"/>, <see
+ /// cref="System.ValueTuple{T1, T2, T3}"/></c> might be intended to
+ /// treat the first type argument as a tuple with element names and the
+ /// second as a tuple without element names. In which case, the
+ /// appropriate attribute specification should use a
+ /// <c>transformNames</c> value of <c>{ "name1", "name2", null, null,
+ /// null }</c>.
+ /// </remarks>
+ public TupleElementNamesAttribute(string[] transformNames)
+ {
+ if (transformNames == null)
+ {
+ throw new ArgumentNullException(nameof(transformNames));
+ }
+
+ _transformNames = transformNames;
+ }
+
+ /// <summary>
+ /// Specifies, in a pre-order depth-first traversal of a type's
+ /// construction, which <see cref="System.ValueTuple"/> elements are
+ /// meant to carry element names.
+ /// </summary>
+ public IList<string> TransformNames => _transformNames;
+ }
+} \ No newline at end of file
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs
index d9e067bd4c..147c103047 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs
@@ -26,18 +26,6 @@ namespace System.Runtime.CompilerServices
}
}
- internal static TypeForwardedToAttribute[] GetCustomAttribute(RuntimeAssembly assembly)
- {
- Type[] types = null;
- RuntimeAssembly.GetForwardedTypes(assembly.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref types));
-
- TypeForwardedToAttribute[] attributes = new TypeForwardedToAttribute[types.Length];
- for (int i = 0; i < types.Length; ++i)
- attributes[i] = new TypeForwardedToAttribute(types[i]);
-
- return attributes;
- }
-
}
}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs b/src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs
index b212f4555b..adfa015161 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs
@@ -76,5 +76,18 @@ namespace System.Runtime.CompilerServices
// See getILIntrinsicImplementationForUnsafe for how this happens.
throw new InvalidOperationException();
}
+
+ /// <summary>
+ /// Initializes a block of memory at the given location with a given initial value
+ /// without assuming architecture dependent alignment of the address.
+ /// </summary>
+ [NonVersionable]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)
+ {
+ // The body of this function will be replaced by the EE with unsafe code!!!
+ // See getILIntrinsicImplementationForUnsafe for how this happens.
+ throw new InvalidOperationException();
+ }
}
}
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
index 86789bf12d..92d1b4f95b 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
@@ -28,7 +28,6 @@ using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
-using System.Security.Permissions;
namespace System.Runtime.CompilerServices
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
index c1346f7527..080e42f46f 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
@@ -216,7 +216,6 @@ namespace System.Runtime.CompilerServices {
extern static bool IsAddressInStack(IntPtr ptr);
#endif
-#if FEATURE_SPAN_OF_T
static internal bool ByRefLessThan<T>(ref T refA, ref T refB)
{
// The body of this function will be replaced by the EE with unsafe code!!!
@@ -239,6 +238,5 @@ namespace System.Runtime.CompilerServices {
typeof(ArrayPinningHelper).ToString(); // Type used by the actual method body
throw new InvalidOperationException();
}
-#endif // FEATURE_SPAN_OF_T
}
}
diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/CorruptingExceptionCommon.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/CorruptingExceptionCommon.cs
index e12df10462..f04ddf065a 100644
--- a/src/mscorlib/src/System/Runtime/ExceptionServices/CorruptingExceptionCommon.cs
+++ b/src/mscorlib/src/System/Runtime/ExceptionServices/CorruptingExceptionCommon.cs
@@ -1,7 +1,6 @@
// 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.
-#if FEATURE_CORRUPTING_EXCEPTIONS
/*=============================================================================
**
@@ -28,4 +27,3 @@ namespace System.Runtime.ExceptionServices {
}
}
}
-#endif // FEATURE_CORRUPTING_EXCEPTIONS
diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs
index b084891768..1b3e25b8b2 100644
--- a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs
+++ b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs
@@ -13,7 +13,6 @@
** <owner>gkhanna</owner>
**
=============================================================================*/
-#if FEATURE_EXCEPTION_NOTIFICATIONS
namespace System.Runtime.ExceptionServices {
using System;
using System.Runtime.ConstrainedExecution;
@@ -30,7 +29,6 @@ namespace System.Runtime.ExceptionServices {
// Returns the exception object pertaining to the first chance exception
public Exception Exception
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return m_Exception; }
}
@@ -38,4 +36,3 @@ namespace System.Runtime.ExceptionServices {
private Exception m_Exception;
}
}
-#endif // FEATURE_EXCEPTION_NOTIFICATIONS \ No newline at end of file
diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs
index 905f12dfb5..e8eb6916b7 100644
--- a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs
+++ b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs
@@ -15,7 +15,6 @@
**
=============================================================================*/
-#if FEATURE_EXCEPTIONDISPATCHINFO
namespace System.Runtime.ExceptionServices {
using System;
@@ -132,4 +131,3 @@ namespace System.Runtime.ExceptionServices {
}
}
}
-#endif // FEATURE_EXCEPTIONDISPATCHINFO
diff --git a/src/mscorlib/src/System/Runtime/GcSettings.cs b/src/mscorlib/src/System/Runtime/GcSettings.cs
index 91997f5297..11143c5ee2 100644
--- a/src/mscorlib/src/System/Runtime/GcSettings.cs
+++ b/src/mscorlib/src/System/Runtime/GcSettings.cs
@@ -7,7 +7,6 @@ namespace System.Runtime {
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
// These settings are the same format as in clr\src\vm\gcpriv.h
@@ -37,17 +36,15 @@ namespace System.Runtime {
Succeeded = 0,
NoGCInProgress = 1 // NoGCRegion is in progress, can't change pause mode.
};
-
+
public static GCLatencyMode LatencyMode
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return (GCLatencyMode)(GC.GetGCLatencyMode());
}
// We don't want to allow this API when hosted.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
set
{
if ((value < GCLatencyMode.Batch) || (value > GCLatencyMode.SustainedLowLatency))
@@ -63,14 +60,12 @@ namespace System.Runtime {
public static GCLargeObjectHeapCompactionMode LargeObjectHeapCompactionMode
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return (GCLargeObjectHeapCompactionMode)(GC.GetLOHCompactionMode());
}
// We don't want to allow this API when hosted.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
set
{
if ((value < GCLargeObjectHeapCompactionMode.Default) ||
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs b/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
index 77db3a7f2c..fc15f4e1a7 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.InteropServices {
using System.Runtime.Versioning;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct ArrayWithOffset
{
//private ArrayWithOffset()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs b/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
index 2de7304a0b..b5bde22057 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
@@ -12,7 +12,6 @@ namespace System.Runtime.InteropServices{
using System.Diagnostics.Contracts;
[AttributeUsage(AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class UnmanagedFunctionPointerAttribute : Attribute
{
CallingConvention m_callingConvention;
@@ -33,7 +32,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(false)]
public sealed class TypeIdentifierAttribute : Attribute
{
public TypeIdentifierAttribute() { }
@@ -57,7 +55,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Event, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class DispIdAttribute : Attribute
{
internal int _val;
@@ -69,19 +66,16 @@ namespace System.Runtime.InteropServices{
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ComInterfaceType
{
InterfaceIsDual = 0,
InterfaceIsIUnknown = 1,
InterfaceIsIDispatch = 2,
- [System.Runtime.InteropServices.ComVisible(false)]
InterfaceIsIInspectable = 3,
}
[AttributeUsage(AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class InterfaceTypeAttribute : Attribute
{
internal ComInterfaceType _val;
@@ -97,7 +91,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComDefaultInterfaceAttribute : Attribute
{
internal Type _val;
@@ -111,7 +104,6 @@ namespace System.Runtime.InteropServices{
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ClassInterfaceType
{
None = 0,
@@ -120,7 +112,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ClassInterfaceAttribute : Attribute
{
internal ClassInterfaceType _val;
@@ -137,7 +128,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComVisibleAttribute : Attribute
{
internal bool _val;
@@ -148,20 +138,7 @@ namespace System.Runtime.InteropServices{
public bool Value { get { return _val; } }
}
- [AttributeUsage(AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeLibImportClassAttribute : Attribute
- {
- internal String _importClassName;
- public TypeLibImportClassAttribute(Type importClass)
- {
- _importClassName = importClass.ToString();
- }
- public String Value { get { return _importClassName; } }
- }
-
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
+ [AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class LCIDConversionAttribute : Attribute
{
internal int _val;
@@ -169,29 +146,10 @@ namespace System.Runtime.InteropServices{
{
_val = lcid;
}
- public int Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComRegisterFunctionAttribute : Attribute
- {
- public ComRegisterFunctionAttribute()
- {
- }
+ public int Value { get {return _val;} }
}
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComUnregisterFunctionAttribute : Attribute
- {
- public ComUnregisterFunctionAttribute()
- {
- }
- }
-
- [AttributeUsage(AttributeTargets.Class, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
+ [AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class ProgIdAttribute : Attribute
{
internal String _val;
@@ -199,50 +157,10 @@ namespace System.Runtime.InteropServices{
{
_val = progId;
}
- public String Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ImportedFromTypeLibAttribute : Attribute
- {
- internal String _val;
- public ImportedFromTypeLibAttribute(String tlbFile)
- {
- _val = tlbFile;
- }
public String Value { get {return _val;} }
}
- [Obsolete("The IDispatchImplAttribute is deprecated.", false)]
- [Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum IDispatchImplType
- {
- SystemDefinedImpl = 0,
- InternalImpl = 1,
- CompatibleImpl = 2,
- }
-
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, Inherited = false)]
- [Obsolete("This attribute is deprecated and will be removed in a future version.", false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class IDispatchImplAttribute : Attribute
- {
- internal IDispatchImplType _val;
- public IDispatchImplAttribute(IDispatchImplType implType)
- {
- _val = implType;
- }
- public IDispatchImplAttribute(short implType)
- {
- _val = (IDispatchImplType)implType;
- }
- public IDispatchImplType Value { get {return _val;} }
- }
-
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComSourceInterfacesAttribute : Attribute
{
internal String _val;
@@ -269,126 +187,7 @@ namespace System.Runtime.InteropServices{
public String Value { get {return _val;} }
}
- [AttributeUsage(AttributeTargets.All, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComConversionLossAttribute : Attribute
- {
- public ComConversionLossAttribute()
- {
- }
- }
-
-[Serializable]
-[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum TypeLibTypeFlags
- {
- FAppObject = 0x0001,
- FCanCreate = 0x0002,
- FLicensed = 0x0004,
- FPreDeclId = 0x0008,
- FHidden = 0x0010,
- FControl = 0x0020,
- FDual = 0x0040,
- FNonExtensible = 0x0080,
- FOleAutomation = 0x0100,
- FRestricted = 0x0200,
- FAggregatable = 0x0400,
- FReplaceable = 0x0800,
- FDispatchable = 0x1000,
- FReverseBind = 0x2000,
- }
-
-[Serializable]
-[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum TypeLibFuncFlags
- {
- FRestricted = 0x0001,
- FSource = 0x0002,
- FBindable = 0x0004,
- FRequestEdit = 0x0008,
- FDisplayBind = 0x0010,
- FDefaultBind = 0x0020,
- FHidden = 0x0040,
- FUsesGetLastError = 0x0080,
- FDefaultCollelem = 0x0100,
- FUiDefault = 0x0200,
- FNonBrowsable = 0x0400,
- FReplaceable = 0x0800,
- FImmediateBind = 0x1000,
- }
-
-[Serializable]
-[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum TypeLibVarFlags
- {
- FReadOnly = 0x0001,
- FSource = 0x0002,
- FBindable = 0x0004,
- FRequestEdit = 0x0008,
- FDisplayBind = 0x0010,
- FDefaultBind = 0x0020,
- FHidden = 0x0040,
- FRestricted = 0x0080,
- FDefaultCollelem = 0x0100,
- FUiDefault = 0x0200,
- FNonBrowsable = 0x0400,
- FReplaceable = 0x0800,
- FImmediateBind = 0x1000,
- }
-
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeLibTypeAttribute : Attribute
- {
- internal TypeLibTypeFlags _val;
- public TypeLibTypeAttribute(TypeLibTypeFlags flags)
- {
- _val = flags;
- }
- public TypeLibTypeAttribute(short flags)
- {
- _val = (TypeLibTypeFlags)flags;
- }
- public TypeLibTypeFlags Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeLibFuncAttribute : Attribute
- {
- internal TypeLibFuncFlags _val;
- public TypeLibFuncAttribute(TypeLibFuncFlags flags)
- {
- _val = flags;
- }
- public TypeLibFuncAttribute(short flags)
- {
- _val = (TypeLibFuncFlags)flags;
- }
- public TypeLibFuncFlags Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Field, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeLibVarAttribute : Attribute
- {
- internal TypeLibVarFlags _val;
- public TypeLibVarAttribute(TypeLibVarFlags flags)
- {
- _val = flags;
- }
- public TypeLibVarAttribute(short flags)
- {
- _val = (TypeLibVarFlags)flags;
- }
- public TypeLibVarFlags Value { get {return _val;} }
- }
-
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum VarEnum
{
VT_EMPTY = 0,
@@ -438,7 +237,6 @@ namespace System.Runtime.InteropServices{
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
// Note that this enum should remain in-sync with the CorNativeType enum in corhdr.h
public enum UnmanagedType
{
@@ -512,18 +310,14 @@ namespace System.Runtime.InteropServices{
Error = 0x2d,
- [System.Runtime.InteropServices.ComVisible(false)]
IInspectable = 0x2e,
- [System.Runtime.InteropServices.ComVisible(false)]
HString = 0x2f, // Windows Runtime HSTRING
- [System.Runtime.InteropServices.ComVisible(false)]
LPUTF8Str = 0x30, // UTF8 string
}
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.ReturnValue, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class MarshalAsAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
@@ -622,15 +416,12 @@ namespace System.Runtime.InteropServices{
public int SizeConst; // constant C
// Fields used with SubType = CustomMarshaler
- [System.Runtime.InteropServices.ComVisible(true)]
public String MarshalType; // Name of marshaler class
- [System.Runtime.InteropServices.ComVisible(true)]
public Type MarshalTypeRef; // Type of marshaler class
public String MarshalCookie; // cookie to pass to marshaler
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComImportAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeType type)
@@ -652,7 +443,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class GuidAttribute : Attribute
{
internal String _val;
@@ -664,7 +454,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class PreserveSigAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeMethodInfo method)
@@ -686,7 +475,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class InAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
@@ -704,7 +492,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class OutAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
@@ -722,7 +509,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class OptionalAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
@@ -752,7 +538,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
- [System.Runtime.InteropServices.ComVisible(false)]
public sealed class DefaultDllImportSearchPathsAttribute : Attribute
{
internal DllImportSearchPath _paths;
@@ -765,7 +550,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class DllImportAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeMethodInfo method)
@@ -859,7 +643,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class StructLayoutAttribute : Attribute
{
private const int DEFAULT_PACKING_SIZE = 8;
@@ -931,7 +714,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Field, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class FieldOffsetAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
@@ -958,49 +740,7 @@ namespace System.Runtime.InteropServices{
public int Value { get { return _val; } }
}
- [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComAliasNameAttribute : Attribute
- {
- internal String _val;
- public ComAliasNameAttribute(String alias)
- {
- _val = alias;
- }
- public String Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class AutomationProxyAttribute : Attribute
- {
- internal bool _val;
- public AutomationProxyAttribute(bool val)
- {
- _val = val;
- }
- public bool Value { get {return _val;} }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class PrimaryInteropAssemblyAttribute : Attribute
- {
- internal int _major;
- internal int _minor;
-
- public PrimaryInteropAssemblyAttribute(int major, int minor)
- {
- _major = major;
- _minor = minor;
- }
-
- public int MajorVersion { get {return _major;} }
- public int MinorVersion { get {return _minor;} }
- }
-
[AttributeUsage(AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class CoClassAttribute : Attribute
{
internal Type _CoClass;
@@ -1013,65 +753,7 @@ namespace System.Runtime.InteropServices{
public Type CoClass { get { return _CoClass; } }
}
- [AttributeUsage(AttributeTargets.Interface, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComEventInterfaceAttribute : Attribute
- {
- internal Type _SourceInterface;
- internal Type _EventProvider;
-
- public ComEventInterfaceAttribute(Type SourceInterface, Type EventProvider)
- {
- _SourceInterface = SourceInterface;
- _EventProvider = EventProvider;
- }
-
- public Type SourceInterface { get {return _SourceInterface;} }
- public Type EventProvider { get {return _EventProvider;} }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeLibVersionAttribute : Attribute
- {
- internal int _major;
- internal int _minor;
-
- public TypeLibVersionAttribute(int major, int minor)
- {
- _major = major;
- _minor = minor;
- }
-
- public int MajorVersion { get {return _major;} }
- public int MinorVersion { get {return _minor;} }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ComCompatibleVersionAttribute : Attribute
- {
- internal int _major;
- internal int _minor;
- internal int _build;
- internal int _revision;
-
- public ComCompatibleVersionAttribute(int major, int minor, int build, int revision)
- {
- _major = major;
- _minor = minor;
- _build = build;
- _revision = revision;
- }
-
- public int MajorVersion { get {return _major;} }
- public int MinorVersion { get {return _minor;} }
- public int BuildNumber { get {return _build;} }
- public int RevisionNumber { get {return _revision;} }
- }
-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class BestFitMappingAttribute : Attribute
{
internal bool _bestFitMapping;
@@ -1086,7 +768,6 @@ namespace System.Runtime.InteropServices{
}
[AttributeUsage(AttributeTargets.Module, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class DefaultCharSetAttribute : Attribute
{
internal CharSet _CharSet;
@@ -1098,33 +779,5 @@ namespace System.Runtime.InteropServices{
public CharSet CharSet { get { return _CharSet; } }
}
-
- [Obsolete("This attribute has been deprecated. Application Domains no longer respect Activation Context boundaries in IDispatch calls.", false)]
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SetWin32ContextInIDispatchAttribute : Attribute
- {
- public SetWin32ContextInIDispatchAttribute()
- {
- }
- }
-
- [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
- [System.Runtime.InteropServices.ComVisible(false)]
- public sealed class ManagedToNativeComInteropStubAttribute : Attribute
- {
- internal Type _classType;
- internal String _methodName;
-
- public ManagedToNativeComInteropStubAttribute(Type classType, String methodName)
- {
- _classType = classType;
- _methodName = methodName;
- }
-
- public Type ClassType { get { return _classType; } }
- public String MethodName { get { return _methodName; } }
- }
-
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
index 1673c913a6..d36f8cfa39 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
@@ -15,10 +15,8 @@ namespace System.Runtime.InteropServices {
using System;
using System.Security;
- using System.Security.Permissions;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class BStrWrapper
{
public BStrWrapper(String value)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs b/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
index fd500fdbce..87e6be6d4e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
@@ -21,7 +21,6 @@ namespace System.Runtime.InteropServices {
// Exception for COM Interop errors where we don't recognize the HResult.
//
- [ComVisible(true)]
[Serializable]
public class COMException : ExternalException {
public COMException()
@@ -46,18 +45,6 @@ namespace System.Runtime.InteropServices {
SetErrorCode(errorCode);
}
- internal COMException(int hresult)
- : base(Win32Native.GetMessage(hresult))
- {
- SetErrorCode(hresult);
- }
-
- internal COMException(String message, int hresult, Exception inner)
- : base(message, inner)
- {
- SetErrorCode(hresult);
- }
-
protected COMException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CallingConvention.cs b/src/mscorlib/src/System/Runtime/InteropServices/CallingConvention.cs
index cf4eb48af0..2ef1cf496e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/CallingConvention.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/CallingConvention.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.InteropServices {
using System;
// Used for the CallingConvention named argument to the DllImport attribute
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConvention
{
Winapi = 1,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CharSet.cs b/src/mscorlib/src/System/Runtime/InteropServices/CharSet.cs
index 3c0710a558..e60d676557 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/CharSet.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/CharSet.cs
@@ -13,7 +13,6 @@ namespace System.Runtime.InteropServices {
// Generally you probably want to use Auto, which does the
// right thing 99% of the time.
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum CharSet
{
None = 1, // User didn't specify how to marshal strings.
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsMethod.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsMethod.cs
index 2da0c5eea3..c2f56b0580 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsMethod.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsMethod.cs
@@ -45,52 +45,6 @@ namespace System.Runtime.InteropServices {
get { return _d; }
set { _d = value; }
}
-
- public object Invoke(object[] args) {
- if (_d == null)
- return null;
-
- if (_once == false) {
- PreProcessSignature();
- _once = true;
- }
-
- if (_cachedTargetTypes != null && _expectedParamsCount == args.Length) {
- for (int i = 0; i < _expectedParamsCount; i++) {
- if (_cachedTargetTypes[i] != null) {
- args[i] = Enum.ToObject(_cachedTargetTypes[i], args[i]);
- }
- }
- }
-
- return _d.DynamicInvoke(args);
- }
-
- private void PreProcessSignature() {
- ParameterInfo[] parameters = _d.Method.GetParameters();
- _expectedParamsCount = parameters.Length;
-
- Type[] enumTypes = new Type[_expectedParamsCount];
-
- bool needToHandleCoercion = false;
-
- for (int i = 0; i < _expectedParamsCount; i++) {
- ParameterInfo pi = parameters[i];
- // recognize only 'ref Enum' signatures and cache
- // both enum type and the underlying type.
- if (pi.ParameterType.IsByRef &&
- pi.ParameterType.HasElementType &&
- pi.ParameterType.GetElementType().IsEnum) {
-
- needToHandleCoercion = true;
- enumTypes[i] = pi.ParameterType.GetElementType();
- }
- }
-
- if (needToHandleCoercion == true) {
- _cachedTargetTypes = enumTypes;
- }
- }
}
#region private fields
@@ -145,15 +99,9 @@ namespace System.Runtime.InteropServices {
return methods;
}
-
- #endregion
-
- #region public properties / methods
-
- internal int DispId {
- get { return _dispid; }
- }
+#endregion
+#region public properties / methods
internal bool Empty {
get { return _delegateWrappers == null || _delegateWrappers.Length == 0; }
@@ -225,22 +173,6 @@ namespace System.Runtime.InteropServices {
_delegateWrappers = newDelegateWrappers;
}
- internal object Invoke(object[] args) {
- BCLDebug.Assert(Empty == false, "event sink is executed but delegates list is empty");
-
- // Issue: see code:ComEventsHelper#ComEventsRetValIssue
- object result = null;
- DelegateWrapper[] invocationList = _delegateWrappers;
- foreach (DelegateWrapper wrapper in invocationList) {
- if (wrapper == null || wrapper.Delegate == null)
- continue;
-
- result = wrapper.Invoke(args);
- }
-
- return result;
- }
-
#endregion
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs
index 05978a607f..f2b22e3ceb 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs
@@ -16,7 +16,7 @@ namespace System.Runtime.InteropServices {
using System.Diagnostics;
// see code:ComEventsHelper#ComEventsArchitecture
- internal class ComEventsSink : NativeMethods.IDispatch, ICustomQueryInterface
+ internal class ComEventsSink : ICustomQueryInterface
{
#region private fields
@@ -108,122 +108,6 @@ namespace System.Runtime.InteropServices {
#endregion
-
-#region IDispatch Members
-
- void NativeMethods.IDispatch.GetTypeInfoCount(out uint pctinfo) {
- pctinfo = 0;
- }
-
- void NativeMethods.IDispatch.GetTypeInfo(uint iTInfo, int lcid, out IntPtr info) {
- throw new NotImplementedException();
- }
-
- void NativeMethods.IDispatch.GetIDsOfNames(ref Guid iid, string[] names, uint cNames, int lcid, int[] rgDispId) {
- throw new NotImplementedException();
- }
-
- private const VarEnum VT_BYREF_VARIANT = VarEnum.VT_BYREF | VarEnum.VT_VARIANT;
- private const VarEnum VT_TYPEMASK = (VarEnum) 0x0fff;
- private const VarEnum VT_BYREF_TYPEMASK = VT_TYPEMASK | VarEnum.VT_BYREF;
-
- private static unsafe Variant *GetVariant(Variant *pSrc)
- {
- if (pSrc->VariantType == VT_BYREF_VARIANT)
- {
- // For VB6 compatibility reasons, if the VARIANT is a VT_BYREF | VT_VARIANT that
- // contains another VARIANT with VT_BYREF | VT_VARIANT, then we need to extract the
- // inner VARIANT and use it instead of the outer one. Note that if the inner VARIANT
- // is VT_BYREF | VT_VARIANT | VT_ARRAY, it will pass the below test too.
- Variant *pByRefVariant = (Variant *)pSrc->AsByRefVariant;
- if ((pByRefVariant->VariantType & VT_BYREF_TYPEMASK) == VT_BYREF_VARIANT)
- return (Variant *)pByRefVariant;
- }
-
- return pSrc;
- }
-
- unsafe void NativeMethods.IDispatch.Invoke(
- int dispid,
- ref Guid riid,
- int lcid,
- ComTypes.INVOKEKIND wFlags,
- ref ComTypes.DISPPARAMS pDispParams,
- IntPtr pvarResult,
- IntPtr pExcepInfo,
- IntPtr puArgErr) {
-
- ComEventsMethod method = FindMethod(dispid);
- if (method == null)
- return;
-
- // notice the unsafe pointers we are using. This is to avoid unnecessary
- // arguments marshalling. see code:ComEventsHelper#ComEventsArgsMarshalling
-
- object [] args = new object[pDispParams.cArgs];
- int [] byrefsMap = new int[pDispParams.cArgs];
- bool [] usedArgs = new bool[pDispParams.cArgs];
-
- Variant* pvars = (Variant*)pDispParams.rgvarg;
- int* pNamedArgs = (int*)pDispParams.rgdispidNamedArgs;
-
- // copy the named args (positional) as specified
- int i;
- int pos;
- for (i = 0; i < pDispParams.cNamedArgs; i++) {
- pos = pNamedArgs[i];
-
- Variant* pvar = GetVariant(&pvars[i]);
- args[pos] = pvar->ToObject();
- usedArgs[pos] = true;
-
- if (pvar->IsByRef) {
- byrefsMap[pos] = i;
- } else {
- byrefsMap[pos] = -1;
- }
- }
-
- // copy the rest of the arguments in the reverse order
- pos = 0;
- for (; i < pDispParams.cArgs; i++) {
- // find the next unassigned argument
- while (usedArgs[pos]) {
- ++pos;
- }
-
- Variant* pvar = GetVariant(&pvars[pDispParams.cArgs - 1 - i]);
- args[pos] = pvar->ToObject();
-
- if (pvar->IsByRef)
- byrefsMap[pos] = pDispParams.cArgs - 1 - i;
- else
- byrefsMap[pos] = -1;
-
- pos++;
- }
-
- // Do the actual delegate invocation
- object result;
- result = method.Invoke(args);
-
- // convert result to VARIANT
- if (pvarResult != IntPtr.Zero) {
- Marshal.GetNativeVariantForObject(result, pvarResult);
- }
-
- // Now we need to marshal all the byrefs back
- for (i = 0; i < pDispParams.cArgs; i++) {
- int idxToPos = byrefsMap[i];
- if (idxToPos == -1)
- continue;
-
- GetVariant(&pvars[idxToPos])->CopyFromIndirect(args[i]);
- }
- }
-
-#endregion
-
static Guid IID_IManagedObject = new Guid("{C3FCC19E-A970-11D2-8B5A-00A0C9B7C9C4}");
CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv) {
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
index 3be2a56da5..c61d1b21be 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
@@ -9,7 +9,6 @@ namespace System.Runtime.InteropServices {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum ComMemberType
{
Method = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerable.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerable.cs
deleted file mode 100644
index 1a13399a88..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerable.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: IEnumerable
-**
-**
-** Purpose:
-** This interface is redefined here since the original IEnumerable interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IEnumerable interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices.ComTypes
-{
- using System;
-
- [Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
- internal interface IEnumerable
- {
- [DispId(-4)]
- System.Collections.IEnumerator GetEnumerator();
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerator.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerator.cs
deleted file mode 100644
index aea2017b1e..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IEnumerator.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: IEnumerator
-**
-**
-** Purpose:
-** This interface is redefined here since the original IEnumerator interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IEnumerator interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices.ComTypes
-{
- using System;
-
- [Guid("496B0ABF-CDEE-11d3-88E8-00902754C43A")]
- internal interface IEnumerator
- {
- bool MoveNext();
-
- Object Current
- {
- get;
- }
-
- void Reset();
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IExpando.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IExpando.cs
deleted file mode 100644
index ad4ed0b8be..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IExpando.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: IExpando
-**
-**
-** Purpose:
-** This interface is redefined here since the original IExpando interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IExpando interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices.ComTypes
-{
- using System;
- using System.Reflection;
-
- [Guid("AFBF15E6-C37C-11d2-B88E-00A0C9B471B8")]
- internal interface IExpando : IReflect
- {
- FieldInfo AddField(String name);
- PropertyInfo AddProperty(String name);
- MethodInfo AddMethod(String name, Delegate method);
- void RemoveMember(MemberInfo m);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IReflect.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IReflect.cs
deleted file mode 100644
index c86f961d01..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/IReflect.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: IReflect
-**
-**
-** Purpose:
-** This interface is redefined here since the original IReflect interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IReflect interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices.ComTypes
-{
- using System;
- using System.Reflection;
- using CultureInfo = System.Globalization.CultureInfo;
-
- [Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
- internal interface IReflect
- {
- MethodInfo GetMethod(String name,BindingFlags bindingAttr,Binder binder,
- Type[] types,ParameterModifier[] modifiers);
-
- MethodInfo GetMethod(String name,BindingFlags bindingAttr);
-
- MethodInfo[] GetMethods(
- BindingFlags bindingAttr);
-
- FieldInfo GetField(
- String name,
- BindingFlags bindingAttr);
-
- FieldInfo[] GetFields(
- BindingFlags bindingAttr);
-
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr);
-
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr,
- Binder binder,
- Type returnType,
- Type[] types,
- ParameterModifier[] modifiers);
-
- PropertyInfo[] GetProperties(
- BindingFlags bindingAttr);
-
- MemberInfo[] GetMember(
- String name,
- BindingFlags bindingAttr);
-
- MemberInfo[] GetMembers(
- BindingFlags bindingAttr);
-
- Object InvokeMember(
- String name,
- BindingFlags invokeAttr,
- Binder binder,
- Object target,
- Object[] args,
- ParameterModifier[] modifiers,
- CultureInfo culture,
- String[] namedParameters);
-
- Type UnderlyingSystemType
- {
- get;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs
index 700e059293..840270141b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs
@@ -48,7 +48,6 @@
using System;
using System.Reflection;
using System.Threading;
-using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Runtime.ConstrainedExecution;
@@ -150,7 +149,6 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
private bool _isClosed; // Set by SetHandleAsInvalid or Close/Dispose/finalization.
// Creates a CriticalHandle class. Users must then set the Handle property or allow P/Invoke marshaling to set it implicitly.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandle(IntPtr invalidHandleValue)
{
handle = invalidHandleValue;
@@ -167,13 +165,11 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
// Adding an empty default constructor for annotation purposes
private CriticalHandle(){}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~CriticalHandle()
{
Dispose(false);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void Cleanup()
{
if (IsClosed)
@@ -197,10 +193,8 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private extern void FireCustomerDebugProbe();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected void SetHandle(IntPtr handle) {
this.handle = handle;
}
@@ -208,7 +202,6 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
// Returns whether the handle has been explicitly marked as closed
// (Close/Dispose) or invalid (SetHandleAsInvalid).
public bool IsClosed {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return _isClosed; }
}
@@ -217,22 +210,18 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
// know what an invalid handle looks like, so this method is abstract and
// must be provided by a derived type.
public abstract bool IsInvalid {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Close() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Dispose()
{
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected virtual void Dispose(bool disposing)
{
Cleanup();
@@ -242,7 +231,6 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
// your handle is invalid and you want to record that information.
// An example is calling a syscall and getting back ERROR_INVALID_HANDLE.
// This method will normally leak handles!
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void SetHandleAsInvalid()
{
_isClosed = true;
@@ -257,7 +245,6 @@ public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
// The boolean returned should be true for success and false if a
// catastrophic error occurred and you wish to trigger a diagnostic for
// debugging purposes (the SafeHandleCriticalFailure MDA).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected abstract bool ReleaseHandle();
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
index 470e7b20dd..304419e5b0 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.InteropServices {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class CurrencyWrapper
{
public CurrencyWrapper(Decimal obj)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs
index 47b7542caf..ccf25af0f9 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs
@@ -15,10 +15,8 @@ namespace System.Runtime.InteropServices {
using System;
using System.Security;
- using System.Security.Permissions;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DispatchWrapper
{
public DispatchWrapper(Object obj)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs
index a9fa58f65f..da02893b1e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs
@@ -14,10 +14,8 @@
namespace System.Runtime.InteropServices {
using System;
- using System.Security.Permissions;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ErrorWrapper
{
public ErrorWrapper(int errorCode)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Expando/IExpando.cs b/src/mscorlib/src/System/Runtime/InteropServices/Expando/IExpando.cs
index 62b65d1aff..429ce13918 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Expando/IExpando.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Expando/IExpando.cs
@@ -17,22 +17,12 @@ namespace System.Runtime.InteropServices.Expando {
using System.Reflection;
[Guid("AFBF15E6-C37C-11d2-B88E-00A0C9B471B8")]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface IExpando : IReflect
+ internal interface IExpando : IReflect
{
// Add a new Field to the reflection object. The field has
// name as its name.
FieldInfo AddField(String name);
- // Add a new Property to the reflection object. The property has
- // name as its name.
- PropertyInfo AddProperty(String name);
-
- // Add a new Method to the reflection object. The method has
- // name as its name and method is a delegate
- // to the method.
- MethodInfo AddMethod(String name, Delegate method);
-
// Removes the specified member.
void RemoveMember(MemberInfo m);
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ExtensibleClassFactory.cs b/src/mscorlib/src/System/Runtime/InteropServices/ExtensibleClassFactory.cs
deleted file mode 100644
index a12a38ec6d..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ExtensibleClassFactory.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: Methods used to customize the creation of managed objects that
-** extend from unmanaged objects.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices {
- using System.Runtime.InteropServices;
- using System.Runtime.Remoting;
- using System.Runtime.CompilerServices;
- using System.Runtime.Versioning;
-
- using System;
-[System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ExtensibleClassFactory
- {
-
- // Prevent instantiation.
- private ExtensibleClassFactory() {}
-
- // Register a delegate that will be called whenever an instance of a managed
- // type that extends from an unmanaged type needs to allocate the aggregated
- // unmanaged object. This delegate is expected to allocate and aggregate the
- // unmanaged object and is called in place of a CoCreateInstance. This
- // routine must be called in the context of the static initializer for the
- // class for which the callbacks will be made.
- // It is not legal to register this callback from a class that has any
- // parents that have already registered a callback.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void RegisterObjectCreationCallback(ObjectCreationDelegate callback);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs b/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs
index 70a6dfe366..7e1f395e4e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs
@@ -20,7 +20,6 @@ namespace System.Runtime.InteropServices {
// Base exception for COM Interop errors &; Structured Exception Handler
// exceptions.
//
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class ExternalException : SystemException {
public ExternalException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
index 5530819c5f..598fee0618 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
@@ -5,18 +5,20 @@
namespace System.Runtime.InteropServices
{
using System;
- using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Threading;
- using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
+#if BIT64
+ using nint = System.Int64;
+#else
+ using nint = System.Int32;
+#endif
// These are the types of handles used by the EE.
// IMPORTANT: These must match the definitions in ObjectHandle.h in the EE.
// IMPORTANT: If new values are added to the enum the GCHandle::MaxHandleType
// constant must be updated.
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum GCHandleType
{
Weak = 0,
@@ -40,7 +42,6 @@ namespace System.Runtime.InteropServices
//
[StructLayout(LayoutKind.Sequential)]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct GCHandle
{
// IMPORTANT: This must be kept in sync with the GCHandleType enum.
@@ -60,20 +61,23 @@ namespace System.Runtime.InteropServices
{
// Make sure the type parameter is within the valid range for the enum.
if ((uint)type > (uint)MaxHandleType)
- throw new ArgumentOutOfRangeException(nameof(type), Environment.GetResourceString("ArgumentOutOfRange_Enum"));
+ ThrowArgumentOutOfRangeException_ArgumentOutOfRange_Enum();
Contract.EndContractBlock();
- m_handle = InternalAlloc(value, type);
+ IntPtr handle = InternalAlloc(value, type);
- // Record if the handle is pinned.
if (type == GCHandleType.Pinned)
- SetIsPinned();
- }
+ {
+ // Record if the handle is pinned.
+ handle = (IntPtr)((nint)handle | 1);
+ }
+
+ m_handle = handle;
+ }
// Used in the conversion functions below.
internal GCHandle(IntPtr handle)
{
- InternalCheckDomain(handle);
m_handle = handle;
}
@@ -93,36 +97,21 @@ namespace System.Runtime.InteropServices
return new GCHandle(value, type);
}
-
// Frees a GC handle.
public void Free()
{
- // Copy the handle instance member to a local variable. This is required to prevent
- // race conditions releasing the handle.
- IntPtr handle = m_handle;
-
// Free the handle if it hasn't already been freed.
- if (handle != IntPtr.Zero && Interlocked.CompareExchange(ref m_handle, IntPtr.Zero, handle) == handle)
- {
+ IntPtr handle = Interlocked.Exchange(ref m_handle, IntPtr.Zero);
+ ValidateHandle(handle);
#if MDA_SUPPORTED
- // If this handle was passed out to unmanaged code, we need to remove it
- // from the cookie table.
- // NOTE: the entry in the cookie table must be released before the
- // internal handle is freed to prevent a race with reusing GC handles.
- if (s_probeIsActive)
- s_cookieTable.RemoveHandleIfPresent(handle);
-#endif
-
-#if BIT64
- InternalFree((IntPtr)(((long)handle) & ~1L));
-#else // BIT64 (32)
- InternalFree((IntPtr)(((int)handle) & ~1));
+ // If this handle was passed out to unmanaged code, we need to remove it
+ // from the cookie table.
+ // NOTE: the entry in the cookie table must be released before the
+ // internal handle is freed to prevent a race with reusing GC handles.
+ if (s_probeIsActive)
+ s_cookieTable.RemoveHandleIfPresent(handle);
#endif
- }
- else
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotInitialized"));
- }
+ InternalFree(GetHandleValue(handle));
}
// Target property - allows getting / updating of the handle's referent.
@@ -130,23 +119,17 @@ namespace System.Runtime.InteropServices
{
get
{
- // Check if the handle was never initialized or was freed.
- if (m_handle == IntPtr.Zero)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotInitialized"));
-
+ ValidateHandle();
return InternalGet(GetHandleValue());
}
set
{
- // Check if the handle was never initialized or was freed.
- if (m_handle == IntPtr.Zero)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotInitialized"));
-
+ ValidateHandle();
InternalSet(GetHandleValue(), value, IsPinned());
}
}
-
+
// Retrieve the address of an object in a Pinned handle. This throws
// an exception if the handle is any type other than Pinned.
public IntPtr AddrOfPinnedObject()
@@ -154,9 +137,7 @@ namespace System.Runtime.InteropServices
// Check if the handle was not a pinned handle.
if (!IsPinned())
{
- // Check if the handle was never initialized for was freed.
- if (m_handle == IntPtr.Zero)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotInitialized"));
+ ValidateHandle();
// You can only get the address of pinned handles.
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotPinned"));
@@ -167,30 +148,23 @@ namespace System.Runtime.InteropServices
}
// Determine whether this handle has been allocated or not.
- public bool IsAllocated
- {
- get
- {
- return m_handle != IntPtr.Zero;
- }
- }
+ public bool IsAllocated => !m_handle.IsNull();
// Used to create a GCHandle from an int. This is intended to
// be used with the reverse conversion.
public static explicit operator GCHandle(IntPtr value)
{
- return FromIntPtr(value);
+ ValidateHandle(value);
+ return new GCHandle(value);
}
public static GCHandle FromIntPtr(IntPtr value)
{
- if (value == IntPtr.Zero)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotInitialized"));
+ ValidateHandle(value);
Contract.EndContractBlock();
- IntPtr handle = value;
-
#if MDA_SUPPORTED
+ IntPtr handle = value;
if (s_probeIsActive)
{
// Make sure this cookie matches up with a GCHandle we've passed out a cookie for.
@@ -201,10 +175,10 @@ namespace System.Runtime.InteropServices
Mda.FireInvalidGCHandleCookieProbe(value);
return new GCHandle(IntPtr.Zero);
}
+ return new GCHandle(handle);
}
#endif
-
- return new GCHandle(handle);
+ return new GCHandle(value);
}
// Used to get the internal integer representation of the handle out.
@@ -256,29 +230,19 @@ namespace System.Runtime.InteropServices
internal IntPtr GetHandleValue()
{
-#if BIT64
- return new IntPtr(((long)m_handle) & ~1L);
-#else // !BIT64 (32)
- return new IntPtr(((int)m_handle) & ~1);
-#endif
+ return GetHandleValue(m_handle);
}
- internal bool IsPinned()
+ private static IntPtr GetHandleValue(IntPtr handle)
{
-#if BIT64
- return (((long)m_handle) & 1) != 0;
-#else // !BIT64 (32)
- return (((int)m_handle) & 1) != 0;
-#endif
+ // Remove Pin flag
+ return new IntPtr((nint)handle & ~(nint)1);
}
- internal void SetIsPinned()
+ internal bool IsPinned()
{
-#if BIT64
- m_handle = new IntPtr(((long)m_handle) | 1L);
-#else // !BIT64 (32)
- m_handle = new IntPtr(((int)m_handle) | 1);
-#endif
+ // Check Pin flag
+ return ((nint)m_handle & 1) != 0;
}
// Internal native calls that this implementation uses.
@@ -294,10 +258,6 @@ namespace System.Runtime.InteropServices
internal static extern Object InternalCompareExchange(IntPtr handle, Object value, Object oldValue, bool isPinned);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern IntPtr InternalAddrOfPinnedObject(IntPtr handle);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern void InternalCheckDomain(IntPtr handle);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern GCHandleType InternalGetHandleType(IntPtr handle);
// The actual integer handle value that the EE uses internally.
private IntPtr m_handle;
@@ -307,5 +267,29 @@ namespace System.Runtime.InteropServices
static private volatile GCHandleCookieTable s_cookieTable = null;
static private volatile bool s_probeIsActive = false;
#endif
+
+ private void ValidateHandle()
+ {
+ // Check if the handle was never initialized or was freed.
+ if (m_handle.IsNull())
+ ThrowInvalidOperationException_HandleIsNotInitialized();
+ }
+
+ private static void ValidateHandle(IntPtr handle)
+ {
+ // Check if the handle was never initialized or was freed.
+ if (handle.IsNull())
+ ThrowInvalidOperationException_HandleIsNotInitialized();
+ }
+
+ private static void ThrowArgumentOutOfRangeException_ArgumentOutOfRange_Enum()
+ {
+ throw ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.type, ExceptionResource.ArgumentOutOfRange_Enum);
+ }
+
+ private static void ThrowInvalidOperationException_HandleIsNotInitialized()
+ {
+ throw ThrowHelper.GetInvalidOperationException(ExceptionResource.InvalidOperation_HandleIsNotInitialized);
+ }
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/HandleRef.cs b/src/mscorlib/src/System/Runtime/InteropServices/HandleRef.cs
index d76750fdd7..b1171025ee 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/HandleRef.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/HandleRef.cs
@@ -7,7 +7,6 @@ namespace System.Runtime.InteropServices
using System;
- [System.Runtime.InteropServices.ComVisible(true)]
public struct HandleRef
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ICustomAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/ICustomAdapter.cs
index 00abf7b3bf..002c48a171 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ICustomAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ICustomAdapter.cs
@@ -15,7 +15,6 @@
namespace System.Runtime.InteropServices {
using System;
-[System.Runtime.InteropServices.ComVisible(true)]
public interface ICustomAdapter
{
[return:MarshalAs(UnmanagedType.IUnknown)] Object GetUnderlyingObject();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ICustomFactory.cs b/src/mscorlib/src/System/Runtime/InteropServices/ICustomFactory.cs
index 33d2556bd0..8e7af10b6e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ICustomFactory.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ICustomFactory.cs
@@ -8,7 +8,6 @@ namespace System.Runtime.InteropServices {
using System;
-[System.Runtime.InteropServices.ComVisible(true)]
public interface ICustomFactory
{
MarshalByRefObject CreateInstance(Type serverType);
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ICustomMarshaler.cs b/src/mscorlib/src/System/Runtime/InteropServices/ICustomMarshaler.cs
index 4db4acceeb..d9ed289145 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ICustomMarshaler.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ICustomMarshaler.cs
@@ -15,7 +15,6 @@
namespace System.Runtime.InteropServices {
using System;
-[System.Runtime.InteropServices.ComVisible(true)]
public interface ICustomMarshaler
{
Object MarshalNativeToManaged( IntPtr pNativeData );
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs b/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs
index c7d7937895..5675b1f2d6 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs
@@ -19,7 +19,6 @@ namespace System.Runtime.InteropServices {
// The enum of the return value of IQuerable.GetInterface
//====================================================================
[Serializable]
- [System.Runtime.InteropServices.ComVisible(false)]
public enum CustomQueryInterfaceResult
{
Handled = 0,
@@ -30,7 +29,6 @@ namespace System.Runtime.InteropServices {
//====================================================================
// The interface for customizing IQueryInterface
//====================================================================
- [System.Runtime.InteropServices.ComVisible(false)]
public interface ICustomQueryInterface
{
CustomQueryInterfaceResult GetInterface([In]ref Guid iid, out IntPtr ppv);
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/IException.cs b/src/mscorlib/src/System/Runtime/InteropServices/IException.cs
index 2330365834..895aa54781 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/IException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/IException.cs
@@ -17,13 +17,11 @@ namespace System.Runtime.InteropServices {
using System;
using System.Reflection;
using System.Runtime.Serialization;
- using System.Security.Permissions;
[GuidAttribute("b36b5c63-42ef-38bc-a07e-0b34c98f164a")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
[CLSCompliant(false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _Exception
+ internal interface _Exception
{
//
// This method is intentionally included in CoreCLR to make Exception.get_InnerException "newslot virtual final".
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/IRegistrationServices.cs b/src/mscorlib/src/System/Runtime/InteropServices/IRegistrationServices.cs
deleted file mode 100644
index f2f7c61843..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/IRegistrationServices.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: This interface provides services for registering and unregistering
-** a managed server for use by COM.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices {
-
- using System;
- using System.Reflection;
- using System.Security;
- using System.Security.Permissions;
-
- [Flags()]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum AssemblyRegistrationFlags
- {
- None = 0x00000000,
- SetCodeBase = 0x00000001,
- }
-
- [Guid("CCBD682C-73A5-4568-B8B0-C7007E11ABA2")]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface IRegistrationServices
- {
- bool RegisterAssembly(Assembly assembly, AssemblyRegistrationFlags flags);
-
- bool UnregisterAssembly(Assembly assembly);
-
- Type[] GetRegistrableTypesInAssembly(Assembly assembly);
-
- String GetProgIdForType(Type type);
-
- void RegisterTypeForComClients(Type type, ref Guid g);
-
- Guid GetManagedCategoryGuid();
-
- bool TypeRequiresRegistration(Type type);
-
- bool TypeRepresentsComType(Type type);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ITypeLibConverter.cs b/src/mscorlib/src/System/Runtime/InteropServices/ITypeLibConverter.cs
index a7b6889c55..afa934caaf 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ITypeLibConverter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ITypeLibConverter.cs
@@ -21,126 +21,4 @@ namespace System.Runtime.InteropServices {
using System;
using System.Reflection;
using System.Reflection.Emit;
-
-[Serializable]
-[Flags()]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum TypeLibImporterFlags
- {
- None = 0x00000000,
- PrimaryInteropAssembly = 0x00000001,
- UnsafeInterfaces = 0x00000002,
- SafeArrayAsSystemArray = 0x00000004,
- TransformDispRetVals = 0x00000008,
- PreventClassMembers = 0x00000010,
- SerializableValueClasses = 0x00000020,
- ImportAsX86 = 0x00000100,
- ImportAsX64 = 0x00000200,
- ImportAsItanium = 0x00000400,
- ImportAsAgnostic = 0x00000800,
- ReflectionOnlyLoading = 0x00001000,
- NoDefineVersionResource = 0x00002000,
- ImportAsArm = 0x00004000,
- }
-
-[Serializable]
-[Flags()]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum TypeLibExporterFlags
- {
- None = 0x00000000,
- OnlyReferenceRegistered = 0x00000001,
- CallerResolvedReferences = 0x00000002,
- OldNames = 0x00000004,
- ExportAs32Bit = 0x00000010,
- ExportAs64Bit = 0x00000020,
- }
-
- [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum ImporterEventKind
- {
- NOTIF_TYPECONVERTED = 0,
- NOTIF_CONVERTWARNING = 1,
- ERROR_REFTOINVALIDTYPELIB = 2,
- }
-
- [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum ExporterEventKind
- {
- NOTIF_TYPECONVERTED = 0,
- NOTIF_CONVERTWARNING = 1,
- ERROR_REFTOINVALIDASSEMBLY = 2
- }
-
- [GuidAttribute("F1C3BF76-C3E4-11d3-88E7-00902754C43A")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ITypeLibImporterNotifySink
- {
- void ReportEvent(
- ImporterEventKind eventKind,
- int eventCode,
- String eventMsg);
- Assembly ResolveRef(
- [MarshalAs(UnmanagedType.Interface)] Object typeLib);
- }
-
- [GuidAttribute("F1C3BF77-C3E4-11d3-88E7-00902754C43A")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ITypeLibExporterNotifySink
- {
- void ReportEvent(
- ExporterEventKind eventKind,
- int eventCode,
- String eventMsg);
-
- [return : MarshalAs(UnmanagedType.Interface)]
- Object ResolveRef(
- Assembly assembly);
- }
-
- [GuidAttribute("F1C3BF78-C3E4-11d3-88E7-00902754C43A")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ITypeLibConverter
- {
- AssemblyBuilder ConvertTypeLibToAssembly(
- [MarshalAs(UnmanagedType.Interface)] Object typeLib,
- String asmFileName,
- TypeLibImporterFlags flags,
- ITypeLibImporterNotifySink notifySink,
- byte[] publicKey,
- StrongNameKeyPair keyPair,
- String asmNamespace,
- Version asmVersion);
-
- [return : MarshalAs(UnmanagedType.Interface)]
- Object ConvertAssemblyToTypeLib(
- Assembly assembly,
- String typeLibName,
- TypeLibExporterFlags flags,
- ITypeLibExporterNotifySink notifySink);
-
- bool GetPrimaryInteropAssembly(Guid g, Int32 major, Int32 minor, Int32 lcid, out String asmName, out String asmCodeBase);
-
- AssemblyBuilder ConvertTypeLibToAssembly([MarshalAs(UnmanagedType.Interface)] Object typeLib,
- String asmFileName,
- int flags,
- ITypeLibImporterNotifySink notifySink,
- byte[] publicKey,
- StrongNameKeyPair keyPair,
- bool unsafeInterfaces);
- }
-
- [GuidAttribute("FA1F3615-ACB9-486d-9EAC-1BEF87E36B09")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ITypeLibExporterNameProvider
- {
- [return : MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)]
- String[] GetNames();
- }
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
index ac8258b872..760210bc28 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class InvalidComObjectException : SystemException {
public InvalidComObjectException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
index 60c9aa67b4..4ca3da5619 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
@@ -15,7 +15,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class InvalidOleVariantTypeException : SystemException {
public InvalidOleVariantTypeException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/LayoutKind.cs b/src/mscorlib/src/System/Runtime/InteropServices/LayoutKind.cs
index 231779872e..f7def3a8e9 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/LayoutKind.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/LayoutKind.cs
@@ -7,7 +7,6 @@
namespace System.Runtime.InteropServices {
using System;
// Used in the StructLayoutAttribute class
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public enum LayoutKind
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
index 3a79650bd9..9e9103b9c2 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
@@ -19,7 +19,6 @@ namespace System.Runtime.InteropServices
using System.Reflection;
using System.Reflection.Emit;
using System.Security;
- using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Runtime.Remoting;
@@ -76,7 +75,6 @@ namespace System.Runtime.InteropServices
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static bool IsNotWin32Atom(IntPtr ptr)
{
#if FEATURE_PAL
@@ -213,7 +211,6 @@ namespace System.Runtime.InteropServices
//====================================================================
// SizeOf()
//====================================================================
- [System.Runtime.InteropServices.ComVisible(true)]
public static int SizeOf(Object structure)
{
if (structure == null)
@@ -253,7 +250,6 @@ namespace System.Runtime.InteropServices
/// </summary>
/// <typeparam name="T">Provide a value type to figure out its size</typeparam>
/// <returns>The aligned size of T in bytes.</returns>
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static uint AlignedSizeOf<T>() where T : struct
{
uint size = SizeOfType(typeof(T));
@@ -271,13 +267,11 @@ namespace System.Runtime.InteropServices
// Type must be a value type with no object reference fields. We only
// assert this, due to the lack of a suitable generic constraint.
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern uint SizeOfType(Type type);
// Type must be a value type with no object reference fields. We only
// assert this, due to the lack of a suitable generic constraint.
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern uint AlignedSizeOfType(Type type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -470,7 +464,6 @@ namespace System.Runtime.InteropServices
throw new PlatformNotSupportedException();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static unsafe int ReadInt32(IntPtr ptr, int ofs)
{
try
@@ -500,13 +493,11 @@ namespace System.Runtime.InteropServices
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int ReadInt32(IntPtr ptr)
{
return ReadInt32(ptr,0);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr([MarshalAs(UnmanagedType.AsAny),In] Object ptr, int ofs)
{
#if BIT64
@@ -516,7 +507,6 @@ namespace System.Runtime.InteropServices
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr(IntPtr ptr, int ofs)
{
#if BIT64
@@ -526,7 +516,6 @@ namespace System.Runtime.InteropServices
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr(IntPtr ptr)
{
#if BIT64
@@ -574,7 +563,6 @@ namespace System.Runtime.InteropServices
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static long ReadInt64(IntPtr ptr)
{
return ReadInt64(ptr,0);
@@ -768,7 +756,6 @@ namespace System.Runtime.InteropServices
// GetLastWin32Error
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int GetLastWin32Error();
@@ -776,14 +763,12 @@ namespace System.Runtime.InteropServices
// SetLastWin32Error
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern void SetLastWin32Error(int error);
//====================================================================
// GetHRForLastWin32Error
//====================================================================
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int GetHRForLastWin32Error()
{
int dwLastError = GetLastWin32Error();
@@ -830,34 +815,6 @@ namespace System.Runtime.InteropServices
}
}
- //====================================================================
- // NumParamBytes
- //====================================================================
- public static int NumParamBytes(MethodInfo m)
- {
- if (m == null)
- throw new ArgumentNullException(nameof(m));
- Contract.EndContractBlock();
-
- RuntimeMethodInfo rmi = m as RuntimeMethodInfo;
- if (rmi == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"));
-
- return InternalNumParamBytes(rmi);
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern int InternalNumParamBytes(IRuntimeMethodInfo m);
-
- //====================================================================
- // Win32 Exception stuff
- // These are mostly interesting for Structured exception handling,
- // but need to be exposed for all exceptions (not just SEHException).
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers();
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern int GetExceptionCode();
@@ -868,7 +825,6 @@ namespace System.Runtime.InteropServices
// "fDeleteOld" is true, this routine will call DestroyStructure() first.
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- [System.Runtime.InteropServices.ComVisible(true)]
public static extern void StructureToPtr(Object structure, IntPtr ptr, bool fDeleteOld);
public static void StructureToPtr<T>(T structure, IntPtr ptr, bool fDeleteOld)
@@ -879,7 +835,6 @@ namespace System.Runtime.InteropServices
//====================================================================
// Marshals data from a native memory block to a preallocated structure class.
//====================================================================
- [System.Runtime.InteropServices.ComVisible(true)]
public static void PtrToStructure(IntPtr ptr, Object structure)
{
PtrToStructureHelper(ptr, structure, false);
@@ -894,7 +849,6 @@ namespace System.Runtime.InteropServices
// Creates a new instance of "structuretype" and marshals data from a
// native memory block to it.
//====================================================================
- [System.Runtime.InteropServices.ComVisible(true)]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static Object PtrToStructure(IntPtr ptr, Type structureType)
{
@@ -935,7 +889,6 @@ namespace System.Runtime.InteropServices
// "structureclass" is used to provide layout information.
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [System.Runtime.InteropServices.ComVisible(true)]
public static extern void DestroyStructure(IntPtr ptr, Type structuretype);
public static void DestroyStructure<T>(IntPtr ptr)
@@ -1015,45 +968,8 @@ namespace System.Runtime.InteropServices
//====================================================================
- // This method is intended for compiler code generators rather
- // than applications.
- //====================================================================
- [ObsoleteAttribute("The GetUnmanagedThunkForManagedMethodPtr method has been deprecated and will be removed in a future release.", false)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern IntPtr GetUnmanagedThunkForManagedMethodPtr(IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature);
-
- //====================================================================
- // This method is intended for compiler code generators rather
- // than applications.
- //====================================================================
- [ObsoleteAttribute("The GetManagedThunkForUnmanagedMethodPtr method has been deprecated and will be removed in a future release.", false)]
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern IntPtr GetManagedThunkForUnmanagedMethodPtr(IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature);
-
- //====================================================================
- // The hosting APIs allow a sophisticated host to schedule fibers
- // onto OS threads, so long as they notify the runtime of this
- // activity. A fiber cookie can be redeemed for its managed Thread
- // object by calling the following service.
- //====================================================================
- [ObsoleteAttribute("The GetThreadFromFiberCookie method has been deprecated. Use the hosting API to perform this operation.", false)]
- public static Thread GetThreadFromFiberCookie(int cookie)
- {
- if (cookie == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_ArgumentZero"), nameof(cookie));
- Contract.EndContractBlock();
-
- return InternalGetThreadFromFiberCookie(cookie);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern Thread InternalGetThreadFromFiberCookie(int cookie);
-
-
- //====================================================================
// Memory allocation and deallocation.
//====================================================================
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static IntPtr AllocHGlobal(IntPtr cb)
{
// For backwards compatibility on 32 bit platforms, ensure we pass values between
@@ -1077,13 +993,11 @@ namespace System.Runtime.InteropServices
return pNewMem;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static IntPtr AllocHGlobal(int cb)
{
return AllocHGlobal((IntPtr)cb);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void FreeHGlobal(IntPtr hglobal)
{
if (IsNotWin32Atom(hglobal)) {
@@ -1192,185 +1106,6 @@ namespace System.Runtime.InteropServices
internal static extern int GetHRForException_WinRT(Exception e);
internal static readonly Guid ManagedNameGuid = new Guid("{0F21F359-AB84-41E8-9A78-36D110E6D2F9}");
-
- //====================================================================
- // Given a managed object that wraps a UCOMITypeLib, return its name
- //====================================================================
- [Obsolete("Use System.Runtime.InteropServices.Marshal.GetTypeLibName(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.", false)]
- public static String GetTypeLibName(UCOMITypeLib pTLB)
- {
- return GetTypeLibName((ITypeLib)pTLB);
- }
-
-
- //====================================================================
- // Given a managed object that wraps an ITypeLib, return its name
- //====================================================================
- public static String GetTypeLibName(ITypeLib typelib)
- {
- if (typelib == null)
- throw new ArgumentNullException(nameof(typelib));
- Contract.EndContractBlock();
-
- String strTypeLibName = null;
- String strDocString = null;
- int dwHelpContext = 0;
- String strHelpFile = null;
-
- typelib.GetDocumentation(-1, out strTypeLibName, out strDocString, out dwHelpContext, out strHelpFile);
-
- return strTypeLibName;
- }
-
- //====================================================================
- // Internal version of GetTypeLibName
- // Support GUID_ManagedName which aligns with TlbImp
- //====================================================================
- internal static String GetTypeLibNameInternal(ITypeLib typelib)
- {
- if (typelib == null)
- throw new ArgumentNullException(nameof(typelib));
- Contract.EndContractBlock();
-
- // Try GUID_ManagedName first
- ITypeLib2 typeLib2 = typelib as ITypeLib2;
- if (typeLib2 != null)
- {
- Guid guid = ManagedNameGuid;
- object val;
-
- try
- {
- typeLib2.GetCustData(ref guid, out val);
- }
- catch(Exception)
- {
- val = null;
- }
-
- if (val != null && val.GetType() == typeof(string))
- {
- string customManagedNamespace = (string)val;
- customManagedNamespace = customManagedNamespace.Trim();
- if (customManagedNamespace.EndsWith(".DLL", StringComparison.OrdinalIgnoreCase))
- customManagedNamespace = customManagedNamespace.Substring(0, customManagedNamespace.Length - 4);
- else if (customManagedNamespace.EndsWith(".EXE", StringComparison.OrdinalIgnoreCase))
- customManagedNamespace = customManagedNamespace.Substring(0, customManagedNamespace.Length - 4);
- return customManagedNamespace;
- }
- }
-
- return GetTypeLibName(typelib);
- }
-
-
- //====================================================================
- // Given an managed object that wraps an UCOMITypeLib, return its guid
- //====================================================================
- [Obsolete("Use System.Runtime.InteropServices.Marshal.GetTypeLibGuid(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.", false)]
- public static Guid GetTypeLibGuid(UCOMITypeLib pTLB)
- {
- return GetTypeLibGuid((ITypeLib)pTLB);
- }
-
- //====================================================================
- // Given an managed object that wraps an ITypeLib, return its guid
- //====================================================================
- public static Guid GetTypeLibGuid(ITypeLib typelib)
- {
- Guid result = new Guid ();
- FCallGetTypeLibGuid (ref result, typelib);
- return result;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void FCallGetTypeLibGuid(ref Guid result, ITypeLib pTLB);
-
- //====================================================================
- // Given a managed object that wraps a UCOMITypeLib, return its lcid
- //====================================================================
- [Obsolete("Use System.Runtime.InteropServices.Marshal.GetTypeLibLcid(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.", false)]
- public static int GetTypeLibLcid(UCOMITypeLib pTLB)
- {
- return GetTypeLibLcid((ITypeLib)pTLB);
- }
-
- //====================================================================
- // Given a managed object that wraps an ITypeLib, return its lcid
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern int GetTypeLibLcid(ITypeLib typelib);
-
- //====================================================================
- // Given a managed object that wraps an ITypeLib, return it's
- // version information.
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern void GetTypeLibVersion(ITypeLib typeLibrary, out int major, out int minor);
-
- //====================================================================
- // Given a managed object that wraps an ITypeInfo, return its guid.
- //====================================================================
- internal static Guid GetTypeInfoGuid(ITypeInfo typeInfo)
- {
- Guid result = new Guid ();
- FCallGetTypeInfoGuid (ref result, typeInfo);
- return result;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void FCallGetTypeInfoGuid(ref Guid result, ITypeInfo typeInfo);
-
- //====================================================================
- // Given a assembly, return the TLBID that will be generated for the
- // typelib exported from the assembly.
- //====================================================================
- public static Guid GetTypeLibGuidForAssembly(Assembly asm)
- {
- if (asm == null)
- throw new ArgumentNullException(nameof(asm));
- Contract.EndContractBlock();
-
- RuntimeAssembly rtAssembly = asm as RuntimeAssembly;
- if (rtAssembly == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), nameof(asm));
-
- Guid result = new Guid();
- FCallGetTypeLibGuidForAssembly(ref result, rtAssembly);
- return result;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void FCallGetTypeLibGuidForAssembly(ref Guid result, RuntimeAssembly asm);
-
- //====================================================================
- // Given a assembly, return the version number of the type library
- // that would be exported from the assembly.
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetTypeLibVersionForAssembly(RuntimeAssembly inputAssembly, out int majorVersion, out int minorVersion);
-
- public static void GetTypeLibVersionForAssembly(Assembly inputAssembly, out int majorVersion, out int minorVersion)
- {
- if (inputAssembly == null)
- throw new ArgumentNullException(nameof(inputAssembly));
- Contract.EndContractBlock();
-
- RuntimeAssembly rtAssembly = inputAssembly as RuntimeAssembly;
- if (rtAssembly == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), nameof(inputAssembly));
-
- _GetTypeLibVersionForAssembly(rtAssembly, out majorVersion, out minorVersion);
- }
-
- //====================================================================
- // Given a managed object that wraps an UCOMITypeInfo, return its name
- //====================================================================
- [Obsolete("Use System.Runtime.InteropServices.Marshal.GetTypeInfoName(ITypeInfo pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.", false)]
- public static String GetTypeInfoName(UCOMITypeInfo pTI)
- {
- return GetTypeInfoName((ITypeInfo)pTI);
- }
//====================================================================
// Given a managed object that wraps an ITypeInfo, return its name
@@ -1391,65 +1126,6 @@ namespace System.Runtime.InteropServices
return strTypeLibName;
}
- //====================================================================
- // Internal version of GetTypeInfoName
- // Support GUID_ManagedName which aligns with TlbImp
- //====================================================================
- internal static String GetTypeInfoNameInternal(ITypeInfo typeInfo, out bool hasManagedName)
- {
- if (typeInfo == null)
- throw new ArgumentNullException(nameof(typeInfo));
- Contract.EndContractBlock();
-
- // Try ManagedNameGuid first
- ITypeInfo2 typeInfo2 = typeInfo as ITypeInfo2;
- if (typeInfo2 != null)
- {
- Guid guid = ManagedNameGuid;
- object val;
-
- try
- {
- typeInfo2.GetCustData(ref guid, out val);
- }
- catch(Exception)
- {
- val = null;
- }
-
- if (val != null && val.GetType() == typeof(string))
- {
- hasManagedName = true;
- return (string)val;
- }
- }
-
- hasManagedName = false;
- return GetTypeInfoName(typeInfo);
- }
-
- //====================================================================
- // Get the corresponding managed name as converted by TlbImp
- // Used to get the type using GetType() from imported assemblies
- //====================================================================
- internal static String GetManagedTypeInfoNameInternal(ITypeLib typeLib, ITypeInfo typeInfo)
- {
- bool hasManagedName;
- string name = GetTypeInfoNameInternal(typeInfo, out hasManagedName);
- if (hasManagedName)
- return name;
- else
- return GetTypeLibNameInternal(typeLib) + "." + name;
- }
-
- //====================================================================
- // If a type with the specified GUID is loaded, this method will
- // return the reflection type that represents it. Otherwise it returns
- // NULL.
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern Type GetLoadedTypeForGUID(ref Guid guid);
-
// This method is identical to Type.GetTypeFromCLSID. Since it's interop specific, we expose it
// on Marshal for more consistent API surface.
public static Type GetTypeFromCLSID(Guid clsid)
@@ -1458,12 +1134,6 @@ namespace System.Runtime.InteropServices
}
//====================================================================
- // map Type to ITypeInfo*
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern IntPtr /* ITypeInfo* */ GetITypeInfoForType(Type t);
-
- //====================================================================
// return the IUnknown* for an Object if the current context
// is the one where the RCW was first seen. Will return null
// otherwise.
@@ -1473,11 +1143,6 @@ namespace System.Runtime.InteropServices
return GetIUnknownForObjectNative(o, false);
}
- public static IntPtr /* IUnknown* */ GetIUnknownForObjectInContext(Object o)
- {
- return GetIUnknownForObjectNative(o, true);
- }
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern IntPtr /* IUnknown* */ GetIUnknownForObjectNative(Object o, bool onlyInContext);
@@ -1499,18 +1164,6 @@ namespace System.Runtime.InteropServices
}
#if FEATURE_COMINTEROP
- //====================================================================
- // return the IDispatch* for an Object if the current context
- // is the one where the RCW was first seen. Will return null
- // otherwise.
- //====================================================================
- public static IntPtr /* IUnknown* */ GetIDispatchForObjectInContext(Object o)
- {
- return GetIDispatchForObjectNative(o, true);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern IntPtr /* IUnknown* */ GetIDispatchForObjectNative(Object o, bool onlyInContext);
//====================================================================
// return the IUnknown* representing the interface for the Object
@@ -1537,17 +1190,6 @@ namespace System.Runtime.InteropServices
return GetComInterfaceForObjectNative(o, T, false, bEnableCustomizedQueryInterface);
}
- //====================================================================
- // return the IUnknown* representing the interface for the Object
- // Object o should support Type T if the current context
- // is the one where the RCW was first seen. Will return null
- // otherwise.
- //====================================================================
- public static IntPtr /* IUnknown* */ GetComInterfaceForObjectInContext(Object o, Type t)
- {
- return GetComInterfaceForObjectNative(o, t, true, true);
- }
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern IntPtr /* IUnknown* */ GetComInterfaceForObjectNative(Object o, Type t, bool onlyInContext, bool fEnalbeCustomizedQueryInterface);
@@ -1892,21 +1534,6 @@ namespace System.Runtime.InteropServices
private static extern Object InternalCreateWrapperOfType(Object o, Type t);
//====================================================================
- // There may be a thread-based cache of COM components. This service can
- // force the aggressive release of the current thread's cache.
- //====================================================================
- [Obsolete("This API did not perform any operation and will be removed in future versions of the CLR.", false)]
- public static void ReleaseThreadCache()
- {
- }
-
- //====================================================================
- // check if the type is visible from COM.
- //====================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern bool IsTypeVisibleFromCom(Type t);
-
- //====================================================================
// IUnknown Helpers
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -1915,7 +1542,6 @@ namespace System.Runtime.InteropServices
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern int /* ULONG */ AddRef(IntPtr /* IUnknown */ pUnk );
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int /* ULONG */ Release(IntPtr /* IUnknown */ pUnk );
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -1958,45 +1584,6 @@ namespace System.Runtime.InteropServices
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern int GetStartComSlot(Type t);
- /// <summary>
- /// <para>Returns the last valid COM slot that GetMethodInfoForSlot will work on. </para>
- /// </summary>
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern int GetEndComSlot(Type t);
-
- /// <summary>
- /// <para>Returns the MemberInfo that COM callers calling through the exposed
- /// vtable on the given slot will be calling. The slot should take into account
- /// if the exposed interface is IUnknown based or IDispatch based.
- /// For classes, the lookup is done on the default interface that will be
- /// exposed for the class. </para>
- /// </summary>
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern MemberInfo GetMethodInfoForComSlot(Type t, int slot, ref ComMemberType memberType);
-
- /// <summary>
- /// <para>Returns the COM slot for a memeber info, taking into account whether
- /// the exposed interface is IUnknown based or IDispatch based</para>
- /// </summary>
- public static int GetComSlotForMethodInfo(MemberInfo m)
- {
- if (m== null)
- throw new ArgumentNullException(nameof(m));
-
- if (!(m is RuntimeMethodInfo))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(m));
-
- if (!m.DeclaringType.IsInterface)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeInterfaceMethod"), nameof(m));
- if (m.DeclaringType.IsGenericType)
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(m));
- Contract.EndContractBlock();
-
- return InternalGetComSlotForMethodInfo((IRuntimeMethodInfo)m);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int InternalGetComSlotForMethodInfo(IRuntimeMethodInfo m);
#endif // FEATURE_COMINTEROP
//====================================================================
@@ -2069,38 +1656,6 @@ namespace System.Runtime.InteropServices
return obj;
}
- //====================================================================
- // This method gets the currently running object.
- //====================================================================
- public static Object GetActiveObject(String progID)
- {
- Object obj = null;
- Guid clsid;
-
- // Call CLSIDFromProgIDEx first then fall back on CLSIDFromProgID if
- // CLSIDFromProgIDEx doesn't exist.
- try
- {
- CLSIDFromProgIDEx(progID, out clsid);
- }
-// catch
- catch(Exception)
- {
- CLSIDFromProgID(progID, out clsid);
- }
-
- GetActiveObject(ref clsid, IntPtr.Zero, out obj);
- return obj;
- }
-
- [DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void CLSIDFromProgIDEx([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);
-
- [DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);
-
[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)]
[SuppressUnmanagedCodeSecurity]
private static extern void CreateBindCtx(UInt32 reserved, out IBindCtx ppbc);
@@ -2113,19 +1668,6 @@ namespace System.Runtime.InteropServices
[SuppressUnmanagedCodeSecurity]
private static extern void BindMoniker(IMoniker pmk, UInt32 grfOpt, ref Guid iidResult, [MarshalAs(UnmanagedType.Interface)] out Object ppvResult);
- [DllImport(Microsoft.Win32.Win32Native.OLEAUT32, PreserveSig = false)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void GetActiveObject(ref Guid rclsid, IntPtr reserved, [MarshalAs(UnmanagedType.Interface)] out Object ppunk);
-
- //========================================================================
- // Private method called from remoting to support ServicedComponents.
- //========================================================================
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern bool InternalSwitchCCW(Object oldtp, Object newtp);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern Object InternalWrapIUnknownWithComObject(IntPtr i);
-
//========================================================================
// Private method called from EE upon use of license/ICF2 marshaling.
//========================================================================
@@ -2156,86 +1698,6 @@ namespace System.Runtime.InteropServices
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object GetNativeActivationFactory(Type type);
- //========================================================================
- // Methods allowing retrieval of the IIDs exposed by an underlying WinRT
- // object, as specified by the object's IInspectable::GetIids()
- //========================================================================
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern void _GetInspectableIids(ObjectHandleOnStack obj, ObjectHandleOnStack guids);
-
- internal static System.Guid[] GetInspectableIids(object obj)
- {
- System.Guid[] result = null;
- System.__ComObject comObj = obj as System.__ComObject;
- if (comObj != null)
- {
- _GetInspectableIids(JitHelpers.GetObjectHandleOnStack(ref comObj),
- JitHelpers.GetObjectHandleOnStack(ref result));
- }
-
- return result;
- }
-
- //========================================================================
- // Methods allowing retrieval of the cached WinRT type corresponding to
- // the specified GUID
- //========================================================================
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern void _GetCachedWinRTTypeByIid(
- ObjectHandleOnStack appDomainObj,
- System.Guid iid,
- out IntPtr rthHandle);
-
- internal static System.Type GetCachedWinRTTypeByIid(
- System.AppDomain ad,
- System.Guid iid)
- {
- IntPtr rthHandle;
- _GetCachedWinRTTypeByIid(JitHelpers.GetObjectHandleOnStack(ref ad),
- iid,
- out rthHandle);
- System.Type res = Type.GetTypeFromHandleUnsafe(rthHandle);
- return res;
- }
-
-
- //========================================================================
- // Methods allowing retrieval of the WinRT types cached in the specified
- // app domain
- //========================================================================
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- private static extern void _GetCachedWinRTTypes(
- ObjectHandleOnStack appDomainObj,
- ref int epoch,
- ObjectHandleOnStack winrtTypes);
-
- internal static System.Type[] GetCachedWinRTTypes(
- System.AppDomain ad,
- ref int epoch)
- {
- System.IntPtr[] res = null;
-
- _GetCachedWinRTTypes(JitHelpers.GetObjectHandleOnStack(ref ad),
- ref epoch,
- JitHelpers.GetObjectHandleOnStack(ref res));
-
- System.Type[] result = new System.Type[res.Length];
- for (int i = 0; i < res.Length; ++i)
- {
- result[i] = Type.GetTypeFromHandleUnsafe(res[i]);
- }
-
- return result;
- }
-
- internal static System.Type[] GetCachedWinRTTypes(
- System.AppDomain ad)
- {
- int dummyEpoch = 0;
- return GetCachedWinRTTypes(ad, ref dummyEpoch);
- }
-
-
#endif // FEATURE_COMINTEROP
public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
index b916778019..ec1014ecf8 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class MarshalDirectiveException : SystemException {
public MarshalDirectiveException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs b/src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs
index 650ea65697..818034ee34 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs
@@ -18,42 +18,11 @@ namespace System.Runtime.InteropServices {
[
System.Security.SuppressUnmanagedCodeSecurity,
- DllImport("oleaut32.dll", PreserveSig = false),
- System.Security.SecurityCritical
- ]
- internal static extern void VariantClear(IntPtr variant);
-
- [
- System.Security.SuppressUnmanagedCodeSecurity,
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("00020400-0000-0000-C000-000000000046")
]
internal interface IDispatch {
-
- void GetTypeInfoCount(out uint pctinfo);
-
- void GetTypeInfo(uint iTInfo, int lcid, out IntPtr info);
-
- void GetIDsOfNames(
- ref Guid iid,
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 2)]
- string[] names,
- uint cNames,
- int lcid,
- [Out]
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I4, SizeParamIndex = 2)]
- int[] rgDispId);
-
- void Invoke(
- int dispIdMember,
- ref Guid riid,
- int lcid,
- ComTypes.INVOKEKIND wFlags,
- ref ComTypes.DISPPARAMS pDispParams,
- IntPtr pvarResult,
- IntPtr pExcepInfo,
- IntPtr puArgErr);
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs b/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
index 0c8ae7649c..ae974460f7 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
@@ -8,91 +8,76 @@ namespace System.Runtime.InteropServices
{
public static partial class Marshal
{
- [System.Security.SecurityCritical]
public static int GetHRForException(Exception e)
{
return (e != null) ? e.HResult : 0;
}
- [System.Security.SecurityCriticalAttribute]
public static int AddRef(System.IntPtr pUnk)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static bool AreComObjectsAvailableForCleanup()
{
return false;
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr CreateAggregatedObject(System.IntPtr pOuter, object o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static Object BindToMoniker(String monikerName)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static void CleanupUnusedObjectsInCurrentContext()
{
return;
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr CreateAggregatedObject<T>(System.IntPtr pOuter, T o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static object CreateWrapperOfType(object o, System.Type t)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static TWrapper CreateWrapperOfType<T, TWrapper>(T o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static void ChangeWrapperHandleStrength(Object otp, bool fIsWeak)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static int FinalReleaseComObject(object o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr GetComInterfaceForObject(object o, System.Type T)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr GetComInterfaceForObject(object o, System.Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr GetComInterfaceForObject<T, TInterface>(T o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr GetHINSTANCE(System.Reflection.Module m)
{
if (m == null)
@@ -102,61 +87,51 @@ namespace System.Runtime.InteropServices
return (System.IntPtr) (-1);
}
- [System.Security.SecurityCriticalAttribute]
public static System.IntPtr GetIUnknownForObject(object o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static void GetNativeVariantForObject(object obj, System.IntPtr pDstNativeVariant)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static void GetNativeVariantForObject<T>(T obj, System.IntPtr pDstNativeVariant)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static Object GetTypedObjectForIUnknown(System.IntPtr pUnk, System.Type t)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static object GetObjectForIUnknown(System.IntPtr pUnk)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static object GetObjectForNativeVariant(System.IntPtr pSrcNativeVariant)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static T GetObjectForNativeVariant<T>(System.IntPtr pSrcNativeVariant)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static object[] GetObjectsForNativeVariants(System.IntPtr aSrcNativeVariant, int cVars)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static T[] GetObjectsForNativeVariants<T>(System.IntPtr aSrcNativeVariant, int cVars)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static int GetStartComSlot(System.Type t)
{
throw new PlatformNotSupportedException();
@@ -167,13 +142,11 @@ namespace System.Runtime.InteropServices
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static string GetTypeInfoName(System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static object GetUniqueObjectForIUnknown(System.IntPtr unknown)
{
throw new PlatformNotSupportedException();
@@ -184,25 +157,21 @@ namespace System.Runtime.InteropServices
return false;
}
- [System.Security.SecurityCriticalAttribute]
public static int QueryInterface(System.IntPtr pUnk, ref System.Guid iid, out System.IntPtr ppv)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static int Release(System.IntPtr pUnk)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static int ReleaseComObject(object o)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static void ZeroFreeBSTR(System.IntPtr s)
{
throw new PlatformNotSupportedException();
@@ -227,13 +196,11 @@ namespace System.Runtime.InteropServices
public static class ComEventsHelper
{
- [System.Security.SecurityCriticalAttribute]
public static void Combine(object rcw, System.Guid iid, int dispid, System.Delegate d)
{
throw new PlatformNotSupportedException();
}
- [System.Security.SecurityCriticalAttribute]
public static System.Delegate Remove(object rcw, System.Guid iid, int dispid, System.Delegate d)
{
throw new PlatformNotSupportedException();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ObjectCreationDelegate.cs b/src/mscorlib/src/System/Runtime/InteropServices/ObjectCreationDelegate.cs
deleted file mode 100644
index f011253e1e..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/ObjectCreationDelegate.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-** Delegate: ObjectCreationDelegate
-**
-**
-** Purpose: Delegate called to create a classic COM object as an alternative to
-** CoCreateInstance.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices {
-
- // Delegate called when a managed object wishes to instantiate its unmanaged
- // portion. The IUnknown of the managed object (the aggregator) is passed as a
- // parameter and the delegate should return the IUnknown of the unmanaged object
- // (the aggregatee). Both are passed as int's to avoid any marshalling.
-[System.Runtime.InteropServices.ComVisible(true)]
- public delegate IntPtr ObjectCreationDelegate(IntPtr aggregator);
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs b/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
deleted file mode 100644
index 0105866415..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
+++ /dev/null
@@ -1,1059 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: This class provides services for registering and unregistering
-** a managed server for use by COM.
-**
-**
-**
-**
-** Change the way how to register and unregister a managed server
-**
-=============================================================================*/
-namespace System.Runtime.InteropServices {
-
- using System;
- using System.Collections;
- using System.IO;
- using System.Reflection;
- using System.Security;
- using System.Security.Permissions;
- using System.Text;
- using System.Threading;
- using Microsoft.Win32;
- using System.Runtime.CompilerServices;
- using System.Globalization;
- using System.Runtime.Versioning;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
- [Flags]
- public enum RegistrationClassContext
- {
-
-
- InProcessServer = 0x1,
- InProcessHandler = 0x2,
- LocalServer = 0x4,
- InProcessServer16 = 0x8,
- RemoteServer = 0x10,
- InProcessHandler16 = 0x20,
- Reserved1 = 0x40,
- Reserved2 = 0x80,
- Reserved3 = 0x100,
- Reserved4 = 0x200,
- NoCodeDownload = 0x400,
- Reserved5 = 0x800,
- NoCustomMarshal = 0x1000,
- EnableCodeDownload = 0x2000,
- NoFailureLog = 0x4000,
- DisableActivateAsActivator = 0x8000,
- EnableActivateAsActivator = 0x10000,
- FromDefaultContext = 0x20000
- }
-
-
- [Flags]
- public enum RegistrationConnectionType
- {
- SingleUse = 0,
- MultipleUse = 1,
- MultiSeparate = 2,
- Suspended = 4,
- Surrogate = 8,
- }
-
- [Guid("475E398F-8AFA-43a7-A3BE-F4EF8D6787C9")]
- [ClassInterface(ClassInterfaceType.None)]
-[System.Runtime.InteropServices.ComVisible(true)]
- public class RegistrationServices : IRegistrationServices
- {
- #region Constants
-
- private const String strManagedCategoryGuid = "{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}";
- private const String strDocStringPrefix = "";
- private const String strManagedTypeThreadingModel = "Both";
- private const String strComponentCategorySubKey = "Component Categories";
- private const String strManagedCategoryDescription = ".NET Category";
- private const String strImplementedCategoriesSubKey = "Implemented Categories";
- private const String strMsCorEEFileName = "mscoree.dll";
- private const String strRecordRootName = "Record";
- private const String strClsIdRootName = "CLSID";
- private const String strTlbRootName = "TypeLib";
- private static Guid s_ManagedCategoryGuid = new Guid(strManagedCategoryGuid);
-
- #endregion
-
-
- #region IRegistrationServices
-
- public virtual bool RegisterAssembly(Assembly assembly, AssemblyRegistrationFlags flags)
- {
- // Validate the arguments.
- if (assembly == null)
- throw new ArgumentNullException(nameof(assembly));
-
- if (assembly.ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsmLoadedForReflectionOnly"));
- Contract.EndContractBlock();
-
- RuntimeAssembly rtAssembly = assembly as RuntimeAssembly;
- if (rtAssembly == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"));
-
- // Retrieve the assembly names.
- String strAsmName = assembly.FullName;
- if (strAsmName == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoAsmName"));
-
- // Retrieve the assembly codebase.
- String strAsmCodeBase = null;
- if ((flags & AssemblyRegistrationFlags.SetCodeBase) != 0)
- {
- strAsmCodeBase = rtAssembly.GetCodeBase(false);
- if (strAsmCodeBase == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoAsmCodeBase"));
- }
-
- // Go through all the registerable types in the assembly and register them.
- Type[] aTypes = GetRegistrableTypesInAssembly(assembly);
- int NumTypes = aTypes.Length;
-
- String strAsmVersion = rtAssembly.GetVersion().ToString();
-
- // Retrieve the runtime version used to build the assembly.
- String strRuntimeVersion = assembly.ImageRuntimeVersion;
-
- for (int cTypes = 0; cTypes < NumTypes; cTypes++)
- {
- if (IsRegisteredAsValueType(aTypes[cTypes]))
- RegisterValueType(aTypes[cTypes], strAsmName, strAsmVersion, strAsmCodeBase, strRuntimeVersion);
- else if (TypeRepresentsComType(aTypes[cTypes]))
- RegisterComImportedType(aTypes[cTypes], strAsmName, strAsmVersion, strAsmCodeBase, strRuntimeVersion);
- else
- RegisterManagedType(aTypes[cTypes], strAsmName, strAsmVersion, strAsmCodeBase, strRuntimeVersion);
-
- CallUserDefinedRegistrationMethod(aTypes[cTypes], true);
- }
-
- // If this assembly has the PIA attribute, then register it as a PIA.
- Object[] aPIAAttrs = assembly.GetCustomAttributes(typeof(PrimaryInteropAssemblyAttribute), false);
- int NumPIAAttrs = aPIAAttrs.Length;
- for (int cPIAAttrs = 0; cPIAAttrs < NumPIAAttrs; cPIAAttrs++)
- RegisterPrimaryInteropAssembly(rtAssembly, strAsmCodeBase, (PrimaryInteropAssemblyAttribute)aPIAAttrs[cPIAAttrs]);
-
- // Return value indicating if we actually registered any types.
- if (aTypes.Length > 0 || NumPIAAttrs > 0)
- return true;
- else
- return false;
- }
-
- public virtual bool UnregisterAssembly(Assembly assembly)
- {
- // Validate the arguments.
- if (assembly == null)
- throw new ArgumentNullException(nameof(assembly));
-
- if (assembly.ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsmLoadedForReflectionOnly"));
- Contract.EndContractBlock();
-
- RuntimeAssembly rtAssembly = assembly as RuntimeAssembly;
- if (rtAssembly == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"));
-
- bool bAllVersionsGone = true;
-
- // Go through all the registrable types in the assembly and register them.
- Type[] aTypes = GetRegistrableTypesInAssembly(assembly);
- int NumTypes = aTypes.Length;
-
- // Retrieve the assembly version
- String strAsmVersion = rtAssembly.GetVersion().ToString();
- for (int cTypes = 0;cTypes < NumTypes;cTypes++)
- {
- CallUserDefinedRegistrationMethod(aTypes[cTypes], false);
-
- if (IsRegisteredAsValueType(aTypes[cTypes]))
- {
- if (!UnregisterValueType(aTypes[cTypes], strAsmVersion))
- bAllVersionsGone = false;
- }
- else if (TypeRepresentsComType(aTypes[cTypes]))
- {
- if (!UnregisterComImportedType(aTypes[cTypes], strAsmVersion))
- bAllVersionsGone = false;
- }
- else
- {
- if (!UnregisterManagedType(aTypes[cTypes], strAsmVersion))
- bAllVersionsGone = false;
- }
- }
-
- // If this assembly has the PIA attribute, then unregister it as a PIA.
- Object[] aPIAAttrs = assembly.GetCustomAttributes(typeof(PrimaryInteropAssemblyAttribute),false);
- int NumPIAAttrs = aPIAAttrs.Length;
- if (bAllVersionsGone)
- {
- for (int cPIAAttrs = 0;cPIAAttrs < NumPIAAttrs;cPIAAttrs++)
- UnregisterPrimaryInteropAssembly(assembly, (PrimaryInteropAssemblyAttribute)aPIAAttrs[cPIAAttrs]);
- }
-
- // Return value indicating if we actually un-registered any types.
- if (aTypes.Length > 0 || NumPIAAttrs > 0)
- return true;
- else
- return false;
- }
-
- public virtual Type[] GetRegistrableTypesInAssembly(Assembly assembly)
- {
- // Validate the arguments.
- if (assembly == null)
- throw new ArgumentNullException(nameof(assembly));
- Contract.EndContractBlock();
-
- if (!(assembly is RuntimeAssembly))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), nameof(assembly));
-
- // Retrieve the list of types in the assembly.
- Type[] aTypes = assembly.GetExportedTypes();
- int NumTypes = aTypes.Length;
-
- // Create an array list that will be filled in.
- ArrayList TypeList = new ArrayList();
-
- // Register all the types that require registration.
- for (int cTypes = 0; cTypes < NumTypes; cTypes++)
- {
- Type CurrentType = aTypes[cTypes];
- if (TypeRequiresRegistration(CurrentType))
- TypeList.Add(CurrentType);
- }
-
- // Copy the array list to an array and return it.
- Type[] RetArray = new Type[TypeList.Count];
- TypeList.CopyTo(RetArray);
- return RetArray;
- }
-
- public virtual String GetProgIdForType(Type type)
- {
- return Marshal.GenerateProgIdForType(type);
- }
-
- public virtual void RegisterTypeForComClients(Type type, ref Guid g)
- {
-#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
- if(type == null)
- throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
- if((type as RuntimeType) == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),nameof(type));
- if(!TypeRequiresRegistration(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),nameof(type));
-
- // Call the native method to do CoRegisterClassObject
- RegisterTypeForComClientsNative(type, ref g);
-#else // FEATURE_COMINTEROP_MANAGED_ACTIVATION
- throw new NotImplementedException("CoreCLR_REMOVED -- managed activation removed");
-#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
- }
-
- public virtual Guid GetManagedCategoryGuid()
- {
- return s_ManagedCategoryGuid;
- }
-
- public virtual bool TypeRequiresRegistration(Type type)
- {
- return TypeRequiresRegistrationHelper(type);
- }
-
- public virtual bool TypeRepresentsComType(Type type)
- {
- // If the type is not a COM import, then it does not represent a COM type.
- if (!type.IsCOMObject)
- return false;
-
- // If it is marked as tdImport, then it represents a COM type directly.
- if (type.IsImport)
- return true;
-
- // If the type is derived from a tdImport class and has the same GUID as the
- // imported class, then it represents a COM type.
- Type baseComImportType = GetBaseComImportType(type);
- Debug.Assert(baseComImportType != null, "baseComImportType != null");
- if (Marshal.GenerateGuidForType(type) == Marshal.GenerateGuidForType(baseComImportType))
- return true;
-
- return false;
- }
-
- #endregion
-
-
- #region Public methods not on IRegistrationServices
- [ComVisible(false)]
- public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
- {
-#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
- if (type == null)
- throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
- if ((type as RuntimeType) == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),nameof(type));
- if (!TypeRequiresRegistration(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),nameof(type));
-
- // Call the native method to do CoRegisterClassObject
- return RegisterTypeForComClientsExNative(type, classContext, flags);
-#else // FEATURE_COMINTEROP_MANAGED_ACTIVATION
- throw new NotImplementedException("CoreCLR_REMOVED -- managed activation removed");
-#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
- }
-
- [ComVisible(false)]
- public virtual void UnregisterTypeForComClients(int cookie)
- {
- // Call the native method to do CoRevokeClassObject.
- CoRevokeClassObject(cookie);
- }
-
- #endregion
-
-
- #region Internal helpers
-
- internal static bool TypeRequiresRegistrationHelper(Type type)
- {
- // If the type is not a class or a value class, then it does not get registered.
- if (!type.IsClass && !type.IsValueType)
- return false;
-
- // If the type is abstract then it does not get registered.
- if (type.IsAbstract)
- return false;
-
- // If the does not have a public default constructor then is not creatable from COM so
- // it does not require registration unless it is a value class.
- if (!type.IsValueType && type.GetConstructor(BindingFlags.Instance | BindingFlags.Public,null,Array.Empty<Type>(),null) == null)
- return false;
-
- // All other conditions are met so check to see if the type is visible from COM.
- return Marshal.IsTypeVisibleFromCom(type);
- }
-
- #endregion
-
-
- #region Private helpers
-
- private void RegisterValueType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
- {
- // Retrieve some information that will be used during the registration process.
- String strRecordId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
-
- // Create the HKEY_CLASS_ROOT\Record key.
- using (RegistryKey RecordRootKey = Registry.ClassesRoot.CreateSubKey(strRecordRootName))
- {
- // Create the HKEY_CLASS_ROOT\Record\<RecordID> key.
- using (RegistryKey RecordKey = RecordRootKey.CreateSubKey(strRecordId))
- {
- // Create the HKEY_CLASS_ROOT\Record\<RecordId>\<version> key.
- using (RegistryKey RecordVersionKey = RecordKey.CreateSubKey(strAsmVersion))
- {
- // Set the class value.
- RecordVersionKey.SetValue("Class", type.FullName);
-
- // Set the assembly value.
- RecordVersionKey.SetValue("Assembly", strAsmName);
-
- // Set the runtime version value.
- RecordVersionKey.SetValue("RuntimeVersion", strRuntimeVersion);
-
- // Set the assembly code base value if a code base was specified.
- if (strAsmCodeBase != null)
- RecordVersionKey.SetValue("CodeBase", strAsmCodeBase);
- }
- }
- }
- }
-
- private void RegisterManagedType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
- {
- //
- // Retrieve some information that will be used during the registration process.
- //
-
- String strDocString = strDocStringPrefix + type.FullName;
- String strClsId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
- String strProgId = GetProgIdForType(type);
-
-
- //
- // Write the actual type information in the registry.
- //
-
- if (strProgId != String.Empty)
- {
- // Create the HKEY_CLASS_ROOT\<wzProgId> key.
- using (RegistryKey TypeNameKey = Registry.ClassesRoot.CreateSubKey(strProgId))
- {
- TypeNameKey.SetValue("", strDocString);
-
- // Create the HKEY_CLASS_ROOT\<wzProgId>\CLSID key.
- using (RegistryKey ProgIdClsIdKey = TypeNameKey.CreateSubKey("CLSID"))
- {
- ProgIdClsIdKey.SetValue("", strClsId);
- }
- }
- }
-
- // Create the HKEY_CLASS_ROOT\CLSID key.
- using (RegistryKey ClsIdRootKey = Registry.ClassesRoot.CreateSubKey(strClsIdRootName))
- {
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID> key.
- using (RegistryKey ClsIdKey = ClsIdRootKey.CreateSubKey(strClsId))
- {
- ClsIdKey.SetValue("", strDocString);
-
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\InprocServer32 key.
- using (RegistryKey InProcServerKey = ClsIdKey.CreateSubKey("InprocServer32"))
- {
- InProcServerKey.SetValue("", strMsCorEEFileName);
- InProcServerKey.SetValue("ThreadingModel", strManagedTypeThreadingModel);
- InProcServerKey.SetValue("Class", type.FullName);
- InProcServerKey.SetValue("Assembly", strAsmName);
- InProcServerKey.SetValue("RuntimeVersion", strRuntimeVersion);
- if (strAsmCodeBase != null)
- InProcServerKey.SetValue("CodeBase", strAsmCodeBase);
-
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\InprocServer32\<Version> subkey
- using (RegistryKey VersionSubKey = InProcServerKey.CreateSubKey(strAsmVersion))
- {
- VersionSubKey.SetValue("Class", type.FullName);
- VersionSubKey.SetValue("Assembly", strAsmName);
- VersionSubKey.SetValue("RuntimeVersion", strRuntimeVersion);
- if (strAsmCodeBase != null)
- VersionSubKey.SetValue("CodeBase", strAsmCodeBase);
- }
-
- if (strProgId != String.Empty)
- {
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\ProdId key.
- using (RegistryKey ProgIdKey = ClsIdKey.CreateSubKey("ProgId"))
- {
- ProgIdKey.SetValue("", strProgId);
- }
- }
- }
-
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\Implemented Categories\<Managed Category Guid> key.
- using (RegistryKey CategoryKey = ClsIdKey.CreateSubKey(strImplementedCategoriesSubKey))
- {
- using (RegistryKey ManagedCategoryKey = CategoryKey.CreateSubKey(strManagedCategoryGuid)) {}
- }
- }
- }
-
-
- //
- // Ensure that the managed category exists.
- //
-
- EnsureManagedCategoryExists();
- }
-
- private void RegisterComImportedType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
- {
- // Retrieve some information that will be used during the registration process.
- String strClsId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
-
- // Create the HKEY_CLASS_ROOT\CLSID key.
- using (RegistryKey ClsIdRootKey = Registry.ClassesRoot.CreateSubKey(strClsIdRootName))
- {
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID> key.
- using (RegistryKey ClsIdKey = ClsIdRootKey.CreateSubKey(strClsId))
- {
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\InProcServer32 key.
- using (RegistryKey InProcServerKey = ClsIdKey.CreateSubKey("InprocServer32"))
- {
- // Set the class value.
- InProcServerKey.SetValue("Class", type.FullName);
-
- // Set the assembly value.
- InProcServerKey.SetValue("Assembly", strAsmName);
-
- // Set the runtime version value.
- InProcServerKey.SetValue("RuntimeVersion", strRuntimeVersion);
-
- // Set the assembly code base value if a code base was specified.
- if (strAsmCodeBase != null)
- InProcServerKey.SetValue("CodeBase", strAsmCodeBase);
-
- // Create the HKEY_CLASS_ROOT\CLSID\<CLSID>\InprocServer32\<Version> subkey
- using (RegistryKey VersionSubKey = InProcServerKey.CreateSubKey(strAsmVersion))
- {
- VersionSubKey.SetValue("Class", type.FullName);
- VersionSubKey.SetValue("Assembly", strAsmName);
- VersionSubKey.SetValue("RuntimeVersion", strRuntimeVersion);
- if (strAsmCodeBase != null)
- VersionSubKey.SetValue("CodeBase", strAsmCodeBase);
- }
- }
- }
- }
- }
-
- private bool UnregisterValueType(Type type, String strAsmVersion)
- {
- bool bAllVersionsGone = true;
-
- // Try to open the HKEY_CLASS_ROOT\Record key.
- String strRecordId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
-
- using (RegistryKey RecordRootKey = Registry.ClassesRoot.OpenSubKey(strRecordRootName, true))
- {
- if (RecordRootKey != null)
- {
- // Open the HKEY_CLASS_ROOT\Record\{RecordId} key.
- using (RegistryKey RecordKey = RecordRootKey.OpenSubKey(strRecordId,true))
- {
- if (RecordKey != null)
- {
- using (RegistryKey VersionSubKey = RecordKey.OpenSubKey(strAsmVersion,true))
- {
- if (VersionSubKey != null)
- {
- // Delete the values we created.
- VersionSubKey.DeleteValue("Assembly",false);
- VersionSubKey.DeleteValue("Class",false);
- VersionSubKey.DeleteValue("CodeBase",false);
- VersionSubKey.DeleteValue("RuntimeVersion",false);
-
- // delete the version sub key if no value or subkeys under it
- if ((VersionSubKey.SubKeyCount == 0) && (VersionSubKey.ValueCount == 0))
- RecordKey.DeleteSubKey(strAsmVersion);
- }
- }
-
- // If there are sub keys left then there are versions left.
- if (RecordKey.SubKeyCount != 0)
- bAllVersionsGone = false;
-
- // If there are no other values or subkeys then we can delete the HKEY_CLASS_ROOT\Record\{RecordId}.
- if ((RecordKey.SubKeyCount == 0) && (RecordKey.ValueCount == 0))
- RecordRootKey.DeleteSubKey(strRecordId);
- }
- }
-
- // If there are no other values or subkeys then we can delete the HKEY_CLASS_ROOT\Record.
- if ((RecordRootKey.SubKeyCount == 0) && (RecordRootKey.ValueCount == 0))
- Registry.ClassesRoot.DeleteSubKey(strRecordRootName);
- }
- }
-
- return bAllVersionsGone;
- }
-
- // UnregisterManagedType
- //
- // Return :
- // true: All versions are gone.
- // false: Some versions are still left in registry
- private bool UnregisterManagedType(Type type,String strAsmVersion)
- {
- bool bAllVersionsGone = true;
-
- //
- // Create the CLSID string.
- //
-
- String strClsId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
- String strProgId = GetProgIdForType(type);
-
-
- //
- // Remove the entries under HKEY_CLASS_ROOT\CLSID key.
- //
-
- using (RegistryKey ClsIdRootKey = Registry.ClassesRoot.OpenSubKey(strClsIdRootName, true))
- {
- if (ClsIdRootKey != null)
- {
- //
- // Remove the entries under HKEY_CLASS_ROOT\CLSID\<CLSID> key.
- //
-
- using (RegistryKey ClsIdKey = ClsIdRootKey.OpenSubKey(strClsId, true))
- {
- if (ClsIdKey != null)
- {
- //
- // Remove the entries in the HKEY_CLASS_ROOT\CLSID\<CLSID>\InprocServer32 key.
- //
-
- using (RegistryKey InProcServerKey = ClsIdKey.OpenSubKey("InprocServer32", true))
- {
- if (InProcServerKey != null)
- {
- //
- // Remove the entries in HKEY_CLASS_ROOT\CLSID\<CLSID>\InprocServer32\<Version>
- //
-
- using (RegistryKey VersionSubKey = InProcServerKey.OpenSubKey(strAsmVersion, true))
- {
- if (VersionSubKey != null)
- {
- // Delete the values we created
- VersionSubKey.DeleteValue("Assembly",false);
- VersionSubKey.DeleteValue("Class",false);
- VersionSubKey.DeleteValue("RuntimeVersion",false);
- VersionSubKey.DeleteValue("CodeBase",false);
-
- // If there are no other values or subkeys then we can delete the VersionSubKey.
- if ((VersionSubKey.SubKeyCount == 0) && (VersionSubKey.ValueCount == 0))
- InProcServerKey.DeleteSubKey(strAsmVersion);
- }
- }
-
- // If there are sub keys left then there are versions left.
- if (InProcServerKey.SubKeyCount != 0)
- bAllVersionsGone = false;
-
- // If there are no versions left, then delete the threading model and default value.
- if (bAllVersionsGone)
- {
- InProcServerKey.DeleteValue("",false);
- InProcServerKey.DeleteValue("ThreadingModel",false);
- }
-
- InProcServerKey.DeleteValue("Assembly",false);
- InProcServerKey.DeleteValue("Class",false);
- InProcServerKey.DeleteValue("RuntimeVersion",false);
- InProcServerKey.DeleteValue("CodeBase",false);
-
- // If there are no other values or subkeys then we can delete the InProcServerKey.
- if ((InProcServerKey.SubKeyCount == 0) && (InProcServerKey.ValueCount == 0))
- ClsIdKey.DeleteSubKey("InprocServer32");
- }
- }
-
- // remove HKEY_CLASS_ROOT\CLSID\<CLSID>\ProgId
- // and HKEY_CLASS_ROOT\CLSID\<CLSID>\Implemented Category
- // only when all versions are removed
- if (bAllVersionsGone)
- {
- // Delete the value we created.
- ClsIdKey.DeleteValue("",false);
-
- if (strProgId != String.Empty)
- {
- //
- // Remove the entries in the HKEY_CLASS_ROOT\CLSID\<CLSID>\ProgId key.
- //
-
- using (RegistryKey ProgIdKey = ClsIdKey.OpenSubKey("ProgId", true))
- {
- if (ProgIdKey != null)
- {
- // Delete the value we created.
- ProgIdKey.DeleteValue("",false);
-
- // If there are no other values or subkeys then we can delete the ProgIdSubKey.
- if ((ProgIdKey.SubKeyCount == 0) && (ProgIdKey.ValueCount == 0))
- ClsIdKey.DeleteSubKey("ProgId");
- }
- }
- }
-
-
- //
- // Remove entries in the HKEY_CLASS_ROOT\CLSID\<CLSID>\Implemented Categories\<Managed Category Guid> key.
- //
-
- using (RegistryKey CategoryKey = ClsIdKey.OpenSubKey(strImplementedCategoriesSubKey, true))
- {
- if (CategoryKey != null)
- {
- using (RegistryKey ManagedCategoryKey = CategoryKey.OpenSubKey(strManagedCategoryGuid, true))
- {
- if (ManagedCategoryKey != null)
- {
- // If there are no other values or subkeys then we can delete the ManagedCategoryKey.
- if ((ManagedCategoryKey.SubKeyCount == 0) && (ManagedCategoryKey.ValueCount == 0))
- CategoryKey.DeleteSubKey(strManagedCategoryGuid);
- }
- }
-
- // If there are no other values or subkeys then we can delete the CategoryKey.
- if ((CategoryKey.SubKeyCount == 0) && (CategoryKey.ValueCount == 0))
- ClsIdKey.DeleteSubKey(strImplementedCategoriesSubKey);
- }
- }
- }
-
- // If there are no other values or subkeys then we can delete the ClsIdKey.
- if ((ClsIdKey.SubKeyCount == 0) && (ClsIdKey.ValueCount == 0))
- ClsIdRootKey.DeleteSubKey(strClsId);
- }
- }
-
- // If there are no other values or subkeys then we can delete the CLSID key.
- if ((ClsIdRootKey.SubKeyCount == 0) && (ClsIdRootKey.ValueCount == 0))
- Registry.ClassesRoot.DeleteSubKey(strClsIdRootName);
- }
-
-
- //
- // Remove the entries under HKEY_CLASS_ROOT\<wzProgId> key.
- //
-
- if (bAllVersionsGone)
- {
- if (strProgId != String.Empty)
- {
- using (RegistryKey TypeNameKey = Registry.ClassesRoot.OpenSubKey(strProgId, true))
- {
- if (TypeNameKey != null)
- {
- // Delete the values we created.
- TypeNameKey.DeleteValue("",false);
-
-
- //
- // Remove the entries in the HKEY_CLASS_ROOT\<wzProgId>\CLSID key.
- //
-
- using (RegistryKey ProgIdClsIdKey = TypeNameKey.OpenSubKey("CLSID", true))
- {
- if (ProgIdClsIdKey != null)
- {
- // Delete the values we created.
- ProgIdClsIdKey.DeleteValue("",false);
-
- // If there are no other values or subkeys then we can delete the ProgIdClsIdKey.
- if ((ProgIdClsIdKey.SubKeyCount == 0) && (ProgIdClsIdKey.ValueCount == 0))
- TypeNameKey.DeleteSubKey("CLSID");
- }
- }
-
- // If there are no other values or subkeys then we can delete the TypeNameKey.
- if ((TypeNameKey.SubKeyCount == 0) && (TypeNameKey.ValueCount == 0))
- Registry.ClassesRoot.DeleteSubKey(strProgId);
- }
- }
- }
- }
- }
-
- return bAllVersionsGone;
- }
-
- // UnregisterComImportedType
- // Return:
- // true: All version information are gone.
- // false: There are still some version left in registry
- private bool UnregisterComImportedType(Type type, String strAsmVersion)
- {
- bool bAllVersionsGone = true;
-
- String strClsId = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
-
- // Try to open the HKEY_CLASS_ROOT\CLSID key.
- using (RegistryKey ClsIdRootKey = Registry.ClassesRoot.OpenSubKey(strClsIdRootName, true))
- {
- if (ClsIdRootKey != null)
- {
- // Try to open the HKEY_CLASS_ROOT\CLSID\<CLSID> key.
- using (RegistryKey ClsIdKey = ClsIdRootKey.OpenSubKey(strClsId, true))
- {
- if (ClsIdKey != null)
- {
- // Try to open the HKEY_CLASS_ROOT\CLSID\<CLSID>\InProcServer32 key.
- using (RegistryKey InProcServerKey = ClsIdKey.OpenSubKey("InprocServer32", true))
- {
- if (InProcServerKey != null)
- {
- // Delete the values we created.
- InProcServerKey.DeleteValue("Assembly",false);
- InProcServerKey.DeleteValue("Class",false);
- InProcServerKey.DeleteValue("RuntimeVersion",false);
- InProcServerKey.DeleteValue("CodeBase",false);
-
- // Try to open the entries in HKEY_CLASS_ROOT\CLSID\<CLSID>\InProcServer32\<Version>
- using (RegistryKey VersionSubKey = InProcServerKey.OpenSubKey(strAsmVersion,true))
- {
- if (VersionSubKey != null)
- {
- // Delete the value we created
- VersionSubKey.DeleteValue("Assembly",false);
- VersionSubKey.DeleteValue("Class",false);
- VersionSubKey.DeleteValue("RuntimeVersion",false);
- VersionSubKey.DeleteValue("CodeBase",false);
-
- // If there are no other values or subkeys then we can delete the VersionSubKey
- if ((VersionSubKey.SubKeyCount == 0) && (VersionSubKey.ValueCount == 0))
- InProcServerKey.DeleteSubKey(strAsmVersion);
- }
- }
-
- // If there are sub keys left then there are versions left.
- if (InProcServerKey.SubKeyCount != 0)
- bAllVersionsGone = false;
-
- // If there are no other values or subkeys then we can delete the InProcServerKey.
- if ((InProcServerKey.SubKeyCount == 0) && (InProcServerKey.ValueCount == 0))
- ClsIdKey.DeleteSubKey("InprocServer32");
- }
- }
-
- // If there are no other values or subkeys then we can delete the ClsIdKey.
- if ((ClsIdKey.SubKeyCount == 0) && (ClsIdKey.ValueCount == 0))
- ClsIdRootKey.DeleteSubKey(strClsId);
- }
- }
-
- // If there are no other values or subkeys then we can delete the CLSID key.
- if ((ClsIdRootKey.SubKeyCount == 0) && (ClsIdRootKey.ValueCount == 0))
- Registry.ClassesRoot.DeleteSubKey(strClsIdRootName);
- }
- }
-
- return bAllVersionsGone;
- }
-
- private void RegisterPrimaryInteropAssembly(RuntimeAssembly assembly, String strAsmCodeBase, PrimaryInteropAssemblyAttribute attr)
- {
- // Validate that the PIA has a strong name.
- if (assembly.GetPublicKey().Length == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_PIAMustBeStrongNamed"));
-
- String strTlbId = "{" + Marshal.GetTypeLibGuidForAssembly(assembly).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
- String strVersion = attr.MajorVersion.ToString("x", CultureInfo.InvariantCulture) + "." + attr.MinorVersion.ToString("x", CultureInfo.InvariantCulture);
-
- // Create the HKEY_CLASS_ROOT\TypeLib key.
- using (RegistryKey TypeLibRootKey = Registry.ClassesRoot.CreateSubKey(strTlbRootName))
- {
- // Create the HKEY_CLASS_ROOT\TypeLib\<TLBID> key.
- using (RegistryKey TypeLibKey = TypeLibRootKey.CreateSubKey(strTlbId))
- {
- // Create the HKEY_CLASS_ROOT\TypeLib\<TLBID>\<Major.Minor> key.
- using (RegistryKey VersionSubKey = TypeLibKey.CreateSubKey(strVersion))
- {
- // Create the HKEY_CLASS_ROOT\TypeLib\<TLBID>\PrimaryInteropAssembly key.
- VersionSubKey.SetValue("PrimaryInteropAssemblyName", assembly.FullName);
- if (strAsmCodeBase != null)
- VersionSubKey.SetValue("PrimaryInteropAssemblyCodeBase", strAsmCodeBase);
- }
- }
- }
- }
-
- private void UnregisterPrimaryInteropAssembly(Assembly assembly, PrimaryInteropAssemblyAttribute attr)
- {
- String strTlbId = "{" + Marshal.GetTypeLibGuidForAssembly(assembly).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
- String strVersion = attr.MajorVersion.ToString("x", CultureInfo.InvariantCulture) + "." + attr.MinorVersion.ToString("x", CultureInfo.InvariantCulture);
-
- // Try to open the HKEY_CLASS_ROOT\TypeLib key.
- using (RegistryKey TypeLibRootKey = Registry.ClassesRoot.OpenSubKey(strTlbRootName, true))
- {
- if (TypeLibRootKey != null)
- {
- // Try to open the HKEY_CLASS_ROOT\TypeLib\<TLBID> key.
- using (RegistryKey TypeLibKey = TypeLibRootKey.OpenSubKey(strTlbId, true))
- {
- if (TypeLibKey != null)
- {
- // Try to open the HKEY_CLASS_ROOT\TypeLib<TLBID>\<Major.Minor> key.
- using (RegistryKey VersionSubKey = TypeLibKey.OpenSubKey(strVersion, true))
- {
- if (VersionSubKey != null)
- {
- // Delete the values we created.
- VersionSubKey.DeleteValue("PrimaryInteropAssemblyName",false);
- VersionSubKey.DeleteValue("PrimaryInteropAssemblyCodeBase",false);
-
- // If there are no other values or subkeys then we can delete the VersionKey.
- if ((VersionSubKey.SubKeyCount == 0) && (VersionSubKey.ValueCount == 0))
- TypeLibKey.DeleteSubKey(strVersion);
- }
- }
-
- // If there are no other values or subkeys then we can delete the TypeLibKey.
- if ((TypeLibKey.SubKeyCount == 0) && (TypeLibKey.ValueCount == 0))
- TypeLibRootKey.DeleteSubKey(strTlbId);
- }
- }
-
- // If there are no other values or subkeys then we can delete the TypeLib key.
- if ((TypeLibRootKey.SubKeyCount == 0) && (TypeLibRootKey.ValueCount == 0))
- Registry.ClassesRoot.DeleteSubKey(strTlbRootName);
- }
- }
- }
-
- private void EnsureManagedCategoryExists()
- {
- if (!ManagedCategoryExists())
- {
- // Create the HKEY_CLASS_ROOT\Component Category key.
- using (RegistryKey ComponentCategoryKey = Registry.ClassesRoot.CreateSubKey(strComponentCategorySubKey))
- {
- // Create the HKEY_CLASS_ROOT\Component Category\<Managed Category Guid> key.
- using (RegistryKey ManagedCategoryKey = ComponentCategoryKey.CreateSubKey(strManagedCategoryGuid))
- {
- ManagedCategoryKey.SetValue("0", strManagedCategoryDescription);
- }
- }
- }
- }
-
- private static bool ManagedCategoryExists()
- {
- using (RegistryKey componentCategoryKey = Registry.ClassesRoot.OpenSubKey(strComponentCategorySubKey,
- false))
- {
- if (componentCategoryKey == null)
- return false;
- using (RegistryKey managedCategoryKey = componentCategoryKey.OpenSubKey(strManagedCategoryGuid,
- false))
- {
- if (managedCategoryKey == null)
- return false;
- object value = managedCategoryKey.GetValue("0");
- if (value == null || value.GetType() != typeof(string))
- return false;
- string stringValue = (string)value;
- if (stringValue != strManagedCategoryDescription)
- return false;
- }
- }
-
- return true;
- }
-
- private void CallUserDefinedRegistrationMethod(Type type, bool bRegister)
- {
- bool bFunctionCalled = false;
-
- // Retrieve the attribute type to use to determine if a function is the requested user defined
- // registration function.
- Type RegFuncAttrType = null;
- if(bRegister)
- RegFuncAttrType = typeof(ComRegisterFunctionAttribute);
- else
- RegFuncAttrType = typeof(ComUnregisterFunctionAttribute);
-
- for(Type currType = type; !bFunctionCalled && currType != null; currType = currType.BaseType)
- {
- // Retrieve all the methods.
- MethodInfo[] aMethods = currType.GetMethods(BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static);
- int NumMethods = aMethods.Length;
-
- // Go through all the methods and check for the ComRegisterMethod custom attribute.
- for(int cMethods = 0;cMethods < NumMethods;cMethods++)
- {
- MethodInfo CurrentMethod = aMethods[cMethods];
-
- // Check to see if the method has the custom attribute.
- if(CurrentMethod.GetCustomAttributes(RegFuncAttrType, true).Length != 0)
- {
- // Check to see if the method is static before we call it.
- if(!CurrentMethod.IsStatic)
- {
- if(bRegister)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NonStaticComRegFunction",CurrentMethod.Name,currType.Name));
- else
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NonStaticComUnRegFunction",CurrentMethod.Name,currType.Name));
- }
-
- // Finally check that the signature is string ret void.
- ParameterInfo[] aParams = CurrentMethod.GetParameters();
- if (CurrentMethod.ReturnType != typeof(void) ||
- aParams == null ||
- aParams.Length != 1 ||
- (aParams[0].ParameterType != typeof(String) && aParams[0].ParameterType != typeof(Type)))
- {
- if(bRegister)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_InvalidComRegFunctionSig",CurrentMethod.Name,currType.Name));
- else
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_InvalidComUnRegFunctionSig",CurrentMethod.Name,currType.Name));
- }
-
- // There can only be one register and one unregister function per type.
- if(bFunctionCalled)
- {
- if(bRegister)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MultipleComRegFunctions",currType.Name));
- else
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MultipleComUnRegFunctions",currType.Name));
- }
-
- // The function is valid so set up the arguments to call it.
- Object[] objs = new Object[1];
- if(aParams[0].ParameterType == typeof(String))
- {
- // We are dealing with the string overload of the function.
- objs[0] = "HKEY_CLASSES_ROOT\\CLSID\\{" + Marshal.GenerateGuidForType(type).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
- }
- else
- {
- // We are dealing with the type overload of the function.
- objs[0] = type;
- }
-
- // Invoke the COM register function.
- CurrentMethod.Invoke(null, objs);
-
- // Mark the function as having been called.
- bFunctionCalled = true;
- }
- }
- }
- }
-
- private Type GetBaseComImportType(Type type)
- {
- for (; type != null && !type.IsImport; type = type.BaseType);
- return type;
- }
-
- private bool IsRegisteredAsValueType(Type type)
- {
- if (!type.IsValueType)
- return false;
-
- return true;
- }
-
- #endregion
-
-
- #region FCalls and DllImports
-
-#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
- // GUID versioning can be controlled by using the GuidAttribute or
- // letting the runtime generate it based on type and assembly strong name.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void RegisterTypeForComClientsNative(Type type,ref Guid g);
-
- // GUID versioning can be controlled by using the GuidAttribute or
- // letting the runtime generate it based on type and assembly strong name.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int RegisterTypeForComClientsExNative(Type t, RegistrationClassContext clsContext, RegistrationConnectionType flags);
-#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
-
- [DllImport(Win32Native.OLE32,CharSet=CharSet.Auto,PreserveSig=false)]
- private static extern void CoRevokeClassObject(int cookie);
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs b/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
index a5c058da43..28abe0cb3b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
@@ -17,7 +17,6 @@ using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
-using System.Security.Permissions;
using System.Reflection;
using Microsoft.Win32;
using System.Runtime.Versioning;
@@ -25,96 +24,18 @@ using StackCrawlMark = System.Threading.StackCrawlMark;
namespace System.Runtime.InteropServices
{
- [System.Runtime.InteropServices.ComVisible(true)]
- static public class RuntimeEnvironment {
+ static internal class RuntimeEnvironment {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern String GetModuleFileName();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern String GetDeveloperPath();
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern String GetHostBindingFile();
-
- public static bool FromGlobalAccessCache(Assembly a)
- {
- return a.GlobalAssemblyCache;
- }
-
[MethodImpl (MethodImplOptions.NoInlining)]
public static String GetSystemVersion()
{
return Assembly.GetExecutingAssembly().ImageRuntimeVersion;
}
- public static String GetRuntimeDirectory()
- {
- String dir = GetRuntimeDirectoryImpl();
- new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand();
- return dir;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern String GetRuntimeDirectoryImpl();
-
- // Returns the system ConfigurationFile
- public static String SystemConfigurationFile {
- get {
- StringBuilder sb = new StringBuilder(Path.MaxPath);
- sb.Append(GetRuntimeDirectory());
- sb.Append(AppDomainSetup.RuntimeConfigurationFile);
- String path = sb.ToString();
-
- // Do security check
- new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand();
-
- return path;
- }
- }
-
#if FEATURE_COMINTEROP
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern IntPtr GetRuntimeInterfaceImpl(
- [In, MarshalAs(UnmanagedType.LPStruct)] Guid clsid,
- [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
-
- //
- // This function does the equivalent of calling GetInterface(clsid, riid) on the
- // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of
- // CLSIDs and IIDs supported by this method.
- //
- // Returns unmanaged pointer to requested interface on success. Throws
- // COMException with failed HR if there is a QI failure.
- //
- [ComVisible(false)]
- public static IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid)
- {
- return GetRuntimeInterfaceImpl(clsid, riid);
- }
-
- //
- // This function does the equivalent of calling GetInterface(clsid, riid) on the
- // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of
- // CLSIDs and IIDs supported by this method.
- //
- // Returns an RCW to requested interface on success. Throws
- // COMException with failed HR if there is a QI failure.
- //
- [ComVisible(false)]
- public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)
- {
- IntPtr p = IntPtr.Zero;
- try {
- p = GetRuntimeInterfaceImpl(clsid, riid);
- return Marshal.GetObjectForIUnknown(p);
- } finally {
- if(p != IntPtr.Zero) {
- Marshal.Release(p);
- }
- }
- }
#endif // FEATURE_COMINTEROP
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
index b418d914ed..72b98738ae 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
@@ -17,7 +17,6 @@ namespace System.Runtime.InteropServices {
using System.Runtime.Serialization;
// Exception for Structured Exception Handler exceptions.
//
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class SEHException : ExternalException {
public SEHException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
index 0f4caa21a1..12bf7e7e47 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
@@ -15,7 +15,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class SafeArrayRankMismatchException : SystemException {
public SafeArrayRankMismatchException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
index a5711c1ade..050772af2c 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class SafeArrayTypeMismatchException : SystemException {
public SafeArrayTypeMismatchException()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
index eba67ae74e..ee5c3d8e87 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs
@@ -69,7 +69,6 @@
namespace System.Runtime.InteropServices
{
using System;
-using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
@@ -175,7 +174,6 @@ using System.Diagnostics.Contracts;
/// the pointer from within the SafeBuffer. You must set
/// pointer to null before calling this method.</param>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void AcquirePointer(ref byte* pointer)
{
if (_numBytes == Uninitialized)
@@ -194,7 +192,6 @@ using System.Diagnostics.Contracts;
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void ReleasePointer()
{
if (_numBytes == Uninitialized)
@@ -212,7 +209,6 @@ using System.Diagnostics.Contracts;
/// may have to consider alignment.</param>
/// <returns>An instance of T read from memory.</returns>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public T Read<T>(ulong byteOffset) where T : struct {
if (_numBytes == Uninitialized)
throw NotInitialized();
@@ -240,7 +236,6 @@ using System.Diagnostics.Contracts;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void ReadArray<T>(ulong byteOffset, T[] array, int index, int count)
where T : struct
{
@@ -287,7 +282,6 @@ using System.Diagnostics.Contracts;
/// may have to consider alignment.</param>
/// <param name="value">The value type to write to memory.</param>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void Write<T>(ulong byteOffset, T value) where T : struct {
if (_numBytes == Uninitialized)
throw NotInitialized();
@@ -312,7 +306,6 @@ using System.Diagnostics.Contracts;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void WriteArray<T>(ulong byteOffset, T[] array, int index, int count)
where T : struct
{
@@ -355,7 +348,6 @@ using System.Diagnostics.Contracts;
/// </summary>
[CLSCompliant(false)]
public ulong ByteLength {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get {
if (_numBytes == Uninitialized)
throw NotInitialized();
@@ -367,7 +359,6 @@ using System.Diagnostics.Contracts;
/* No indexer. The perf would be misleadingly bad. People should use
* AcquirePointer and ReleasePointer instead. */
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void SpaceCheck(byte* ptr, ulong sizeInBytes)
{
if ((ulong)_numBytes < sizeInBytes)
@@ -376,13 +367,11 @@ using System.Diagnostics.Contracts;
NotEnoughRoom();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static void NotEnoughRoom()
{
throw new ArgumentException(Environment.GetResourceString("Arg_BufferTooSmall"));
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static InvalidOperationException NotInitialized()
{
Debug.Assert(false, "Uninitialized SafeBuffer! Someone needs to call Initialize before using this instance!");
@@ -391,7 +380,6 @@ using System.Diagnostics.Contracts;
// FCALL limitations mean we can't have generic FCALL methods. However, we can pass
// TypedReferences to FCALL methods.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void GenericPtrToStructure<T>(byte* ptr, out T structure, uint sizeofT) where T : struct
{
structure = default(T); // Dummy assignment to silence the compiler
@@ -399,17 +387,14 @@ using System.Diagnostics.Contracts;
}
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void PtrToStructureNative(byte* ptr, /*out T*/ TypedReference structure, uint sizeofT);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void GenericStructureToPtr<T>(ref T structure, byte* ptr, uint sizeofT) where T : struct
{
StructureToPtrNative(__makeref(structure), ptr, sizeofT);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void StructureToPtrNative(/*ref T*/ TypedReference structure, byte* ptr, uint sizeofT);
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs
index ed9910e4e4..591caa2877 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs
@@ -19,7 +19,6 @@ namespace System.Runtime.InteropServices {
using System;
using System.Reflection;
using System.Threading;
-using System.Security.Permissions;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.IO;
@@ -154,7 +153,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// Creates a SafeHandle class. Users must then set the Handle property.
// To prevent the SafeHandle from being freed, write a subclass that
// doesn't define a finalizer.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandle(IntPtr invalidHandleValue, bool ownsHandle)
{
handle = invalidHandleValue;
@@ -190,11 +188,9 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
Dispose(false);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern void InternalFinalize();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected void SetHandle(IntPtr handle) {
this.handle = handle;
}
@@ -213,33 +209,27 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// any way, this can lead to a handle recycling security attack (i.e. an
// untrusted caller can query data on the handle you've just returned
// and get back information for an entirely unrelated resource).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public IntPtr DangerousGetHandle()
{
return handle;
}
public bool IsClosed {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return (_state & 1) == 1; }
}
public abstract bool IsInvalid {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Close() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Dispose() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected virtual void Dispose(bool disposing)
{
if (disposing)
@@ -248,7 +238,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
InternalFinalize();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void InternalDispose();
@@ -256,7 +245,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// your handle is invalid and you want to record that information.
// An example is calling a syscall and getting back ERROR_INVALID_HANDLE.
// This method will normally leak handles!
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void SetHandleAsInvalid();
@@ -268,7 +256,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// The boolean returned should be true for success and false if the runtime
// should fire a SafeHandleCriticalFailure MDA (CustomerDebugProbe) if that
// MDA is enabled.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected abstract bool ReleaseHandle();
// Add a reason why this handle should not be relinquished (i.e. have
@@ -284,7 +271,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// when the method is interrupted prior to processing by a thread abort or
// when the handle has already been (or is in the process of being)
// released.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousAddRef(ref bool success);
@@ -297,7 +283,6 @@ public abstract class SafeHandle : CriticalFinalizerObject, IDisposable
// constitutes a potential security hole (via handle recycling) as well as a
// correctness problem -- so don't ever expose Dangerous* calls out to
// untrusted code.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousRelease();
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventItfInfo.cs b/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventItfInfo.cs
deleted file mode 100644
index 29b094c9e8..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventItfInfo.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices.TCEAdapterGen {
-
- using System;
- using System.Reflection;
- using System.Collections;
-
- internal class EventItfInfo
- {
- public EventItfInfo(String strEventItfName,
- String strSrcItfName,
- String strEventProviderName,
- RuntimeAssembly asmImport,
- RuntimeAssembly asmSrcItf)
- {
- m_strEventItfName = strEventItfName;
- m_strSrcItfName = strSrcItfName;
- m_strEventProviderName = strEventProviderName;
- m_asmImport = asmImport;
- m_asmSrcItf = asmSrcItf;
- }
-
- public Type GetEventItfType()
- {
- Type t = m_asmImport.GetType(m_strEventItfName, true, false);
- if (t != null && !t.IsVisible)
- t = null;
- return t;
- }
-
- public Type GetSrcItfType()
- {
- Type t = m_asmSrcItf.GetType(m_strSrcItfName, true, false);
- if (t != null && !t.IsVisible)
- t = null;
- return t;
- }
-
- public String GetEventProviderName()
- {
- return m_strEventProviderName;
- }
-
- private String m_strEventItfName;
- private String m_strSrcItfName;
- private String m_strEventProviderName;
- private RuntimeAssembly m_asmImport;
- private RuntimeAssembly m_asmSrcItf;
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventProviderWriter.cs b/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventProviderWriter.cs
deleted file mode 100644
index 160a0ab491..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventProviderWriter.cs
+++ /dev/null
@@ -1,774 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices.TCEAdapterGen {
- using System.Runtime.InteropServices.ComTypes;
- using ubyte = System.Byte;
- using System;
- using System.Reflection;
- using System.Reflection.Emit;
- using System.Collections;
- using System.Threading;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
- internal class EventProviderWriter
- {
- private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
-
- private readonly Type[] MonitorEnterParamTypes = new Type[] { typeof(Object), Type.GetType("System.Boolean&") };
-
- public EventProviderWriter( ModuleBuilder OutputModule, String strDestTypeName, Type EventItfType, Type SrcItfType, Type SinkHelperType )
- {
- m_OutputModule = OutputModule;
- m_strDestTypeName = strDestTypeName;
- m_EventItfType = EventItfType;
- m_SrcItfType = SrcItfType;
- m_SinkHelperType = SinkHelperType;
- }
-
- public Type Perform()
- {
- // Create the event provider class.
- TypeBuilder OutputTypeBuilder = m_OutputModule.DefineType(
- m_strDestTypeName,
- TypeAttributes.Sealed | TypeAttributes.NotPublic,
- typeof(Object),
- new Type[]{m_EventItfType, typeof(IDisposable)}
- );
-
- // Create the event source field.
- FieldBuilder fbCPC = OutputTypeBuilder.DefineField(
- "m_ConnectionPointContainer",
- typeof(IConnectionPointContainer),
- FieldAttributes.Private
- );
-
- // Create array of event sink helpers.
- FieldBuilder fbSinkHelper = OutputTypeBuilder.DefineField(
- "m_aEventSinkHelpers",
- typeof(ArrayList),
- FieldAttributes.Private
- );
-
- // Define the connection point field.
- FieldBuilder fbEventCP = OutputTypeBuilder.DefineField(
- "m_ConnectionPoint",
- typeof(IConnectionPoint),
- FieldAttributes.Private
- );
-
- // Define the InitXXX method.
- MethodBuilder InitSrcItfMethodBuilder =
- DefineInitSrcItfMethod( OutputTypeBuilder, m_SrcItfType, fbSinkHelper, fbEventCP, fbCPC );
-
- // Process all the methods in the event interface.
- MethodInfo[] aMethods = TCEAdapterGenerator.GetNonPropertyMethods(m_SrcItfType);
- for ( int cMethods = 0; cMethods < aMethods.Length; cMethods++ )
- {
- if ( m_SrcItfType == aMethods[cMethods].DeclaringType )
- {
- // Define the add_XXX method.
- MethodBuilder AddEventMethodBuilder = DefineAddEventMethod(
- OutputTypeBuilder, aMethods[cMethods], m_SinkHelperType, fbSinkHelper, fbEventCP, InitSrcItfMethodBuilder );
-
- // Define the remove_XXX method.
- MethodBuilder RemoveEventMethodBuilder = DefineRemoveEventMethod(
- OutputTypeBuilder, aMethods[cMethods], m_SinkHelperType, fbSinkHelper, fbEventCP );
- }
- }
-
- // Define the constructor.
- DefineConstructor( OutputTypeBuilder, fbCPC );
-
- // Define the finalize method.
- MethodBuilder FinalizeMethod = DefineFinalizeMethod( OutputTypeBuilder, m_SinkHelperType, fbSinkHelper, fbEventCP );
-
- // Define the Dispose method.
- DefineDisposeMethod( OutputTypeBuilder, FinalizeMethod);
-
- return OutputTypeBuilder.CreateType();
- }
-
- private MethodBuilder DefineAddEventMethod( TypeBuilder OutputTypeBuilder, MethodInfo SrcItfMethod, Type SinkHelperClass, FieldBuilder fbSinkHelperArray, FieldBuilder fbEventCP, MethodBuilder mbInitSrcItf )
- {
- Type[] aParamTypes;
-
- // Find the delegate on the event sink helper.
- FieldInfo DelegateField = SinkHelperClass.GetField( "m_" + SrcItfMethod.Name + "Delegate" );
- Debug.Assert(DelegateField != null, "Unable to find the field m_" + SrcItfMethod.Name + "Delegate on the sink helper");
-
- // Find the cookie on the event sink helper.
- FieldInfo CookieField = SinkHelperClass.GetField( "m_dwCookie" );
- Debug.Assert(CookieField != null, "Unable to find the field m_dwCookie on the sink helper");
-
- // Retrieve the sink helper's constructor.
- ConstructorInfo SinkHelperCons = SinkHelperClass.GetConstructor(EventProviderWriter.DefaultLookup | BindingFlags.NonPublic, null, Array.Empty<Type>(), null );
- Debug.Assert(SinkHelperCons != null, "Unable to find the constructor for the sink helper");
-
- // Retrieve the IConnectionPoint.Advise method.
- MethodInfo CPAdviseMethod = typeof(IConnectionPoint).GetMethod( "Advise" );
- Debug.Assert(CPAdviseMethod != null, "Unable to find the method ConnectionPoint.Advise");
-
- // Retrieve the ArrayList.Add method.
- aParamTypes = new Type[1];
- aParamTypes[0] = typeof(Object);
- MethodInfo ArrayListAddMethod = typeof(ArrayList).GetMethod( "Add", aParamTypes, null );
- Debug.Assert(ArrayListAddMethod != null, "Unable to find the method ArrayList.Add");
-
- // Retrieve the Monitor.Enter() method.
- MethodInfo MonitorEnterMethod = typeof(Monitor).GetMethod( "Enter", MonitorEnterParamTypes, null );
- Debug.Assert(MonitorEnterMethod != null, "Unable to find the method Monitor.Enter()");
-
- // Retrieve the Monitor.Exit() method.
- aParamTypes[0] = typeof(Object);
- MethodInfo MonitorExitMethod = typeof(Monitor).GetMethod( "Exit", aParamTypes, null );
- Debug.Assert(MonitorExitMethod != null, "Unable to find the method Monitor.Exit()");
-
- // Define the add_XXX method.
- Type[] parameterTypes;
- parameterTypes = new Type[1];
- parameterTypes[0] = DelegateField.FieldType;
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod(
- "add_" + SrcItfMethod.Name,
- MethodAttributes.Public | MethodAttributes.Virtual,
- null,
- parameterTypes );
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Define a label for the m_IFooEventsCP comparision.
- Label EventCPNonNullLabel = il.DefineLabel();
-
- // Declare the local variables.
- LocalBuilder ltSinkHelper = il.DeclareLocal( SinkHelperClass );
- LocalBuilder ltCookie = il.DeclareLocal( typeof(Int32) );
- LocalBuilder ltLockTaken = il.DeclareLocal( typeof(bool) );
-
- // Generate the following code:
- // try {
- il.BeginExceptionBlock();
-
- // Generate the following code:
- // Monitor.Enter(this, ref lockTaken);
- il.Emit(OpCodes.Ldarg, (short)0);
- il.Emit(OpCodes.Ldloca_S, ltLockTaken);
- il.Emit(OpCodes.Call, MonitorEnterMethod);
-
- // Generate the following code:
- // if ( m_IFooEventsCP != null ) goto EventCPNonNullLabel;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Brtrue, EventCPNonNullLabel );
-
- // Generate the following code:
- // InitIFooEvents();
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Call, mbInitSrcItf );
-
- // Mark this as label to jump to if the CP is not null.
- il.MarkLabel( EventCPNonNullLabel );
-
- // Generate the following code:
- // IFooEvents_SinkHelper SinkHelper = new IFooEvents_SinkHelper;
- il.Emit( OpCodes.Newobj, SinkHelperCons );
- il.Emit( OpCodes.Stloc, ltSinkHelper );
-
- // Generate the following code:
- // dwCookie = 0;
- il.Emit( OpCodes.Ldc_I4_0 );
- il.Emit( OpCodes.Stloc, ltCookie );
-
- // Generate the following code:
- // m_IFooEventsCP.Advise( SinkHelper, dwCookie );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Ldloc, ltSinkHelper );
- il.Emit( OpCodes.Castclass, typeof(Object) );
- il.Emit( OpCodes.Ldloca, ltCookie );
- il.Emit( OpCodes.Callvirt, CPAdviseMethod );
-
- // Generate the following code:
- // SinkHelper.m_dwCookie = dwCookie;
- il.Emit( OpCodes.Ldloc, ltSinkHelper );
- il.Emit( OpCodes.Ldloc, ltCookie );
- il.Emit( OpCodes.Stfld, CookieField );
-
- // Generate the following code:
- // SinkHelper.m_FooDelegate = d;
- il.Emit( OpCodes.Ldloc, ltSinkHelper );
- il.Emit( OpCodes.Ldarg, (short)1 );
- il.Emit( OpCodes.Stfld, DelegateField );
-
- // Generate the following code:
- // m_aIFooEventsHelpers.Add( SinkHelper );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelperArray );
- il.Emit( OpCodes.Ldloc, ltSinkHelper );
- il.Emit( OpCodes.Castclass, typeof(Object) );
- il.Emit( OpCodes.Callvirt, ArrayListAddMethod );
- il.Emit( OpCodes.Pop );
-
- // Generate the following code:
- // } finally {
- il.BeginFinallyBlock();
-
- // Generate the following code:
- // if (lockTaken)
- // Monitor.Exit(this);
- Label skipExit = il.DefineLabel();
- il.Emit( OpCodes.Ldloc, ltLockTaken );
- il.Emit( OpCodes.Brfalse_S, skipExit );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Call, MonitorExitMethod );
- il.MarkLabel(skipExit);
-
- // Generate the following code:
- // }
- il.EndExceptionBlock();
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
-
- return Meth;
- }
-
- private MethodBuilder DefineRemoveEventMethod( TypeBuilder OutputTypeBuilder, MethodInfo SrcItfMethod, Type SinkHelperClass, FieldBuilder fbSinkHelperArray, FieldBuilder fbEventCP )
- {
- Type[] aParamTypes;
-
- // Find the delegate on the event sink helper.
- FieldInfo DelegateField = SinkHelperClass.GetField( "m_" + SrcItfMethod.Name + "Delegate" );
- Debug.Assert(DelegateField != null, "Unable to find the field m_" + SrcItfMethod.Name + "Delegate on the sink helper");
-
- // Find the cookie on the event sink helper.
- FieldInfo CookieField = SinkHelperClass.GetField( "m_dwCookie" );
- Debug.Assert(CookieField != null, "Unable to find the field m_dwCookie on the sink helper");
-
- // Retrieve the ArrayList.RemoveAt method.
- aParamTypes = new Type[1];
- aParamTypes[0] = typeof(Int32);
- MethodInfo ArrayListRemoveMethod = typeof(ArrayList).GetMethod( "RemoveAt", aParamTypes, null );
- Debug.Assert(ArrayListRemoveMethod != null, "Unable to find the method ArrayList.RemoveAt()");
-
- // Retrieve the ArrayList.Item property get method.
- PropertyInfo ArrayListItemProperty = typeof(ArrayList).GetProperty( "Item" );
- Debug.Assert(ArrayListItemProperty != null, "Unable to find the property ArrayList.Item");
- MethodInfo ArrayListItemGetMethod = ArrayListItemProperty.GetGetMethod();
- Debug.Assert(ArrayListItemGetMethod != null, "Unable to find the get method for property ArrayList.Item");
-
- // Retrieve the ArrayList.Count property get method.
- PropertyInfo ArrayListSizeProperty = typeof(ArrayList).GetProperty( "Count" );
- Debug.Assert(ArrayListSizeProperty != null, "Unable to find the property ArrayList.Count");
- MethodInfo ArrayListSizeGetMethod = ArrayListSizeProperty.GetGetMethod();
- Debug.Assert(ArrayListSizeGetMethod != null, "Unable to find the get method for property ArrayList.Count");
-
- // Retrieve the Delegate.Equals() method.
- aParamTypes[0] = typeof(Delegate);
- MethodInfo DelegateEqualsMethod = typeof(Delegate).GetMethod( "Equals", aParamTypes, null );
- Debug.Assert(DelegateEqualsMethod != null, "Unable to find the method Delegate.Equlals()");
-
- // Retrieve the Monitor.Enter() method.
- MethodInfo MonitorEnterMethod = typeof(Monitor).GetMethod("Enter", MonitorEnterParamTypes, null);
- Debug.Assert(MonitorEnterMethod != null, "Unable to find the method Monitor.Enter()");
-
- // Retrieve the Monitor.Exit() method.
- aParamTypes[0] = typeof(Object);
- MethodInfo MonitorExitMethod = typeof(Monitor).GetMethod( "Exit", aParamTypes, null );
- Debug.Assert(MonitorExitMethod != null, "Unable to find the method Monitor.Exit()");
-
- // Retrieve the ConnectionPoint.Unadvise() method.
- MethodInfo CPUnadviseMethod = typeof(IConnectionPoint).GetMethod( "Unadvise" );
- Debug.Assert(CPUnadviseMethod != null, "Unable to find the method ConnectionPoint.Unadvise()");
-
- // Retrieve the Marshal.ReleaseComObject() method.
- MethodInfo ReleaseComObjectMethod = typeof(Marshal).GetMethod( "ReleaseComObject" );
- Debug.Assert(ReleaseComObjectMethod != null, "Unable to find the method Marshal.ReleaseComObject()");
-
- // Define the remove_XXX method.
- Type[] parameterTypes;
- parameterTypes = new Type[1];
- parameterTypes[0] = DelegateField.FieldType;
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod(
- "remove_" + SrcItfMethod.Name,
- MethodAttributes.Public | MethodAttributes.Virtual,
- null,
- parameterTypes );
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Declare the local variables.
- LocalBuilder ltNumSinkHelpers = il.DeclareLocal( typeof(Int32) );
- LocalBuilder ltSinkHelperCounter = il.DeclareLocal( typeof(Int32) );
- LocalBuilder ltCurrSinkHelper = il.DeclareLocal( SinkHelperClass );
- LocalBuilder ltLockTaken = il.DeclareLocal(typeof(bool));
-
- // Generate the labels for the for loop.
- Label ForBeginLabel = il.DefineLabel();
- Label ForEndLabel = il.DefineLabel();
- Label FalseIfLabel = il.DefineLabel();
- Label MonitorExitLabel = il.DefineLabel();
-
- // Generate the following code:
- // try {
- il.BeginExceptionBlock();
-
- // Generate the following code:
- // Monitor.Enter(this, ref lockTaken);
- il.Emit(OpCodes.Ldarg, (short)0);
- il.Emit(OpCodes.Ldloca_S, ltLockTaken);
- il.Emit(OpCodes.Call, MonitorEnterMethod);
-
- // Generate the following code:
- // if ( m_aIFooEventsHelpers == null ) goto ForEndLabel;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelperArray );
- il.Emit( OpCodes.Brfalse, ForEndLabel );
-
- // Generate the following code:
- // int NumEventHelpers = m_aIFooEventsHelpers.Count;
- // int cEventHelpers = 0;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelperArray );
- il.Emit( OpCodes.Callvirt, ArrayListSizeGetMethod );
- il.Emit( OpCodes.Stloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Stloc, ltSinkHelperCounter );
-
- // Generate the following code:
- // if ( 0 >= NumEventHelpers ) goto ForEndLabel;
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Ldloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Bge, ForEndLabel );
-
- // Mark this as the beginning of the for loop's body.
- il.MarkLabel( ForBeginLabel );
-
- // Generate the following code:
- // CurrentHelper = (IFooEvents_SinkHelper)m_aIFooEventsHelpers.Get( cEventHelpers );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelperArray );
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Callvirt, ArrayListItemGetMethod );
- il.Emit( OpCodes.Castclass, SinkHelperClass );
- il.Emit( OpCodes.Stloc, ltCurrSinkHelper );
-
- // Generate the following code:
- // if ( CurrentHelper.m_FooDelegate )
- il.Emit( OpCodes.Ldloc, ltCurrSinkHelper );
- il.Emit( OpCodes.Ldfld, DelegateField );
- il.Emit( OpCodes.Ldnull );
- il.Emit( OpCodes.Beq, FalseIfLabel );
-
- // Generate the following code:
- // if ( CurrentHelper.m_FooDelegate.Equals( d ) )
- il.Emit( OpCodes.Ldloc, ltCurrSinkHelper );
- il.Emit( OpCodes.Ldfld, DelegateField );
- il.Emit( OpCodes.Ldarg, (short)1 );
- il.Emit( OpCodes.Castclass, typeof(Object) );
- il.Emit( OpCodes.Callvirt, DelegateEqualsMethod );
- il.Emit( OpCodes.Ldc_I4, 0xff );
- il.Emit( OpCodes.And );
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Beq, FalseIfLabel );
-
- // Generate the following code:
- // m_aIFooEventsHelpers.RemoveAt( cEventHelpers );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelperArray );
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Callvirt, ArrayListRemoveMethod );
-
- // Generate the following code:
- // m_IFooEventsCP.Unadvise( CurrentHelper.m_dwCookie );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Ldloc, ltCurrSinkHelper );
- il.Emit( OpCodes.Ldfld, CookieField );
- il.Emit( OpCodes.Callvirt, CPUnadviseMethod );
-
- // Generate the following code:
- // if ( NumEventHelpers > 1) break;
- il.Emit( OpCodes.Ldloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Ldc_I4, 1 );
- il.Emit( OpCodes.Bgt, ForEndLabel );
-
- // Generate the following code:
- // Marshal.ReleaseComObject(m_IFooEventsCP);
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Call, ReleaseComObjectMethod );
- il.Emit( OpCodes.Pop );
-
- // Generate the following code:
- // m_IFooEventsCP = null;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldnull );
- il.Emit( OpCodes.Stfld, fbEventCP );
-
- // Generate the following code:
- // m_aIFooEventsHelpers = null;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldnull );
- il.Emit( OpCodes.Stfld, fbSinkHelperArray );
-
- // Generate the following code:
- // break;
- il.Emit( OpCodes.Br, ForEndLabel );
-
- // Mark this as the label to jump to when the if statement is false.
- il.MarkLabel( FalseIfLabel );
-
- // Generate the following code:
- // cEventHelpers++;
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Ldc_I4, 1 );
- il.Emit( OpCodes.Add );
- il.Emit( OpCodes.Stloc, ltSinkHelperCounter );
-
- // Generate the following code:
- // if ( cEventHelpers < NumEventHelpers ) goto ForBeginLabel;
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Ldloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Blt, ForBeginLabel );
-
- // Mark this as the end of the for loop's body.
- il.MarkLabel( ForEndLabel );
-
- // Generate the following code:
- // } finally {
- il.BeginFinallyBlock();
-
- // Generate the following code:
- // if (lockTaken)
- // Monitor.Exit(this);
- Label skipExit = il.DefineLabel();
- il.Emit(OpCodes.Ldloc, ltLockTaken);
- il.Emit(OpCodes.Brfalse_S, skipExit);
- il.Emit(OpCodes.Ldarg, (short)0);
- il.Emit(OpCodes.Call, MonitorExitMethod);
- il.MarkLabel(skipExit);
-
- // Generate the following code:
- // }
- il.EndExceptionBlock();
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
-
- return Meth;
- }
-
- private MethodBuilder DefineInitSrcItfMethod( TypeBuilder OutputTypeBuilder, Type SourceInterface, FieldBuilder fbSinkHelperArray, FieldBuilder fbEventCP, FieldBuilder fbCPC )
- {
- // Retrieve the constructor info for the array list's default constructor.
- ConstructorInfo DefaultArrayListCons = typeof(ArrayList).GetConstructor(EventProviderWriter.DefaultLookup, null, Array.Empty<Type>(), null );
- Debug.Assert(DefaultArrayListCons != null, "Unable to find the constructor for class ArrayList");
-
- // Temp byte array for Guid
- ubyte[] rgByteGuid = new ubyte[16];
-
- // Retrieve the constructor info for the Guid constructor.
- Type[] aParamTypes = new Type[1];
- aParamTypes[0] = typeof(Byte[]);
- ConstructorInfo ByteArrayGUIDCons = typeof(Guid).GetConstructor(EventProviderWriter.DefaultLookup, null, aParamTypes, null );
- Debug.Assert(ByteArrayGUIDCons != null, "Unable to find the constructor for GUID that accepts a string as argument");
-
- // Retrieve the IConnectionPointContainer.FindConnectionPoint() method.
- MethodInfo CPCFindCPMethod = typeof(IConnectionPointContainer).GetMethod( "FindConnectionPoint" );
- Debug.Assert(CPCFindCPMethod != null, "Unable to find the method ConnectionPointContainer.FindConnectionPoint()");
-
- // Define the Init method itself.
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod(
- "Init",
- MethodAttributes.Private,
- null,
- null );
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Declare the local variables.
- LocalBuilder ltCP = il.DeclareLocal( typeof(IConnectionPoint) );
- LocalBuilder ltEvGuid = il.DeclareLocal( typeof(Guid) );
- LocalBuilder ltByteArrayGuid = il.DeclareLocal( typeof(Byte[]) );
-
- // Generate the following code:
- // IConnectionPoint CP = NULL;
- il.Emit( OpCodes.Ldnull );
- il.Emit( OpCodes.Stloc, ltCP );
-
- // Get unsigned byte array for the GUID of the event interface.
- rgByteGuid = SourceInterface.GUID.ToByteArray();
-
- // Generate the following code:
- // ubyte rgByteArray[] = new ubyte [16];
- il.Emit( OpCodes.Ldc_I4, 0x10 );
- il.Emit( OpCodes.Newarr, typeof(Byte) );
- il.Emit( OpCodes.Stloc, ltByteArrayGuid );
-
- // Generate the following code:
- // rgByteArray[i] = rgByteGuid[i];
- for (int i = 0; i < 16; i++ )
- {
- il.Emit( OpCodes.Ldloc, ltByteArrayGuid );
- il.Emit( OpCodes.Ldc_I4, i );
- il.Emit( OpCodes.Ldc_I4, (int) (rgByteGuid[i]) );
- il.Emit( OpCodes.Stelem_I1);
- }
-
- // Generate the following code:
- // EventItfGuid = Guid( ubyte b[] );
- il.Emit( OpCodes.Ldloca, ltEvGuid );
- il.Emit( OpCodes.Ldloc, ltByteArrayGuid );
- il.Emit( OpCodes.Call, ByteArrayGUIDCons );
-
- // Generate the following code:
- // m_ConnectionPointContainer.FindConnectionPoint( EventItfGuid, CP );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbCPC );
- il.Emit( OpCodes.Ldloca, ltEvGuid );
- il.Emit( OpCodes.Ldloca, ltCP );
- il.Emit( OpCodes.Callvirt, CPCFindCPMethod );
-
- // Generate the following code:
- // m_ConnectionPoint = (IConnectionPoint)CP;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldloc, ltCP );
- il.Emit( OpCodes.Castclass, typeof(IConnectionPoint) );
- il.Emit( OpCodes.Stfld, fbEventCP );
-
- // Generate the following code:
- // m_aEventSinkHelpers = new ArrayList;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Newobj, DefaultArrayListCons );
- il.Emit( OpCodes.Stfld, fbSinkHelperArray );
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
-
- return Meth;
- }
-
- private void DefineConstructor( TypeBuilder OutputTypeBuilder, FieldBuilder fbCPC )
- {
- // Retrieve the constructor info for the base class's constructor.
- ConstructorInfo DefaultBaseClsCons = typeof(Object).GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null );
- Debug.Assert(DefaultBaseClsCons != null, "Unable to find the object's public default constructor");
-
- // Define the default constructor.
- MethodAttributes ctorAttributes = MethodAttributes.SpecialName | (DefaultBaseClsCons.Attributes & MethodAttributes.MemberAccessMask);
- MethodBuilder Cons = OutputTypeBuilder.DefineMethod(
- ".ctor",
- ctorAttributes,
- null,
- new Type[]{typeof(Object)} );
-
- ILGenerator il = Cons.GetILGenerator();
-
- // Generate the call to the base class constructor.
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Call, DefaultBaseClsCons );
-
- // Generate the following code:
- // m_ConnectionPointContainer = (IConnectionPointContainer)EventSource;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldarg, (short)1 );
- il.Emit( OpCodes.Castclass, typeof(IConnectionPointContainer) );
- il.Emit( OpCodes.Stfld, fbCPC );
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
- }
-
- private MethodBuilder DefineFinalizeMethod( TypeBuilder OutputTypeBuilder, Type SinkHelperClass, FieldBuilder fbSinkHelper, FieldBuilder fbEventCP )
- {
- // Find the cookie on the event sink helper.
- FieldInfo CookieField = SinkHelperClass.GetField( "m_dwCookie" );
- Debug.Assert(CookieField != null, "Unable to find the field m_dwCookie on the sink helper");
-
- // Retrieve the ArrayList.Item property get method.
- PropertyInfo ArrayListItemProperty = typeof(ArrayList).GetProperty( "Item" );
- Debug.Assert(ArrayListItemProperty != null, "Unable to find the property ArrayList.Item");
- MethodInfo ArrayListItemGetMethod = ArrayListItemProperty.GetGetMethod();
- Debug.Assert(ArrayListItemGetMethod != null, "Unable to find the get method for property ArrayList.Item");
-
- // Retrieve the ArrayList.Count property get method.
- PropertyInfo ArrayListSizeProperty = typeof(ArrayList).GetProperty( "Count" );
- Debug.Assert(ArrayListSizeProperty != null, "Unable to find the property ArrayList.Count");
- MethodInfo ArrayListSizeGetMethod = ArrayListSizeProperty.GetGetMethod();
- Debug.Assert(ArrayListSizeGetMethod != null, "Unable to find the get method for property ArrayList.Count");
-
- // Retrieve the ConnectionPoint.Unadvise() method.
- MethodInfo CPUnadviseMethod = typeof(IConnectionPoint).GetMethod( "Unadvise" );
- Debug.Assert(CPUnadviseMethod != null, "Unable to find the method ConnectionPoint.Unadvise()");
-
- // Retrieve the Marshal.ReleaseComObject() method.
- MethodInfo ReleaseComObjectMethod = typeof(Marshal).GetMethod( "ReleaseComObject" );
- Debug.Assert(ReleaseComObjectMethod != null, "Unable to find the method Marshal.ReleaseComObject()");
-
- // Retrieve the Monitor.Enter() method.
- MethodInfo MonitorEnterMethod = typeof(Monitor).GetMethod("Enter", MonitorEnterParamTypes, null);
- Debug.Assert(MonitorEnterMethod != null, "Unable to find the method Monitor.Enter()");
-
- // Retrieve the Monitor.Exit() method.
- Type[] aParamTypes = new Type[1];
- aParamTypes[0] = typeof(Object);
- MethodInfo MonitorExitMethod = typeof(Monitor).GetMethod( "Exit", aParamTypes, null );
- Debug.Assert(MonitorExitMethod != null, "Unable to find the method Monitor.Exit()");
-
- // Define the Finalize method itself.
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod( "Finalize", MethodAttributes.Public | MethodAttributes.Virtual, null, null );
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Declare the local variables.
- LocalBuilder ltNumSinkHelpers = il.DeclareLocal( typeof(Int32) );
- LocalBuilder ltSinkHelperCounter = il.DeclareLocal( typeof(Int32) );
- LocalBuilder ltCurrSinkHelper = il.DeclareLocal( SinkHelperClass );
- LocalBuilder ltLockTaken = il.DeclareLocal(typeof(bool));
-
- // Generate the following code:
- // try {
- il.BeginExceptionBlock();
-
- // Generate the following code:
- // Monitor.Enter(this, ref lockTaken);
- il.Emit(OpCodes.Ldarg, (short)0);
- il.Emit(OpCodes.Ldloca_S, ltLockTaken);
- il.Emit(OpCodes.Call, MonitorEnterMethod);
-
- // Generate the labels.
- Label ForBeginLabel = il.DefineLabel();
- Label ReleaseComObjectLabel = il.DefineLabel();
- Label AfterReleaseComObjectLabel = il.DefineLabel();
-
- // Generate the following code:
- // if ( m_IFooEventsCP == null ) goto AfterReleaseComObjectLabel;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Brfalse, AfterReleaseComObjectLabel );
-
- // Generate the following code:
- // int NumEventHelpers = m_aIFooEventsHelpers.Count;
- // int cEventHelpers = 0;
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelper );
- il.Emit( OpCodes.Callvirt, ArrayListSizeGetMethod );
- il.Emit( OpCodes.Stloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Stloc, ltSinkHelperCounter );
-
- // Generate the following code:
- // if ( 0 >= NumEventHelpers ) goto ReleaseComObjectLabel;
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Ldloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Bge, ReleaseComObjectLabel );
-
- // Mark this as the beginning of the for loop's body.
- il.MarkLabel( ForBeginLabel );
-
- // Generate the following code:
- // CurrentHelper = (IFooEvents_SinkHelper)m_aIFooEventsHelpers.Get( cEventHelpers );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbSinkHelper );
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Callvirt, ArrayListItemGetMethod );
- il.Emit( OpCodes.Castclass, SinkHelperClass );
- il.Emit( OpCodes.Stloc, ltCurrSinkHelper );
-
- // Generate the following code:
- // m_IFooEventsCP.Unadvise( CurrentHelper.m_dwCookie );
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Ldloc, ltCurrSinkHelper );
- il.Emit( OpCodes.Ldfld, CookieField );
- il.Emit( OpCodes.Callvirt, CPUnadviseMethod );
-
- // Generate the following code:
- // cEventHelpers++;
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Ldc_I4, 1 );
- il.Emit( OpCodes.Add );
- il.Emit( OpCodes.Stloc, ltSinkHelperCounter );
-
- // Generate the following code:
- // if ( cEventHelpers < NumEventHelpers ) goto ForBeginLabel;
- il.Emit( OpCodes.Ldloc, ltSinkHelperCounter );
- il.Emit( OpCodes.Ldloc, ltNumSinkHelpers );
- il.Emit( OpCodes.Blt, ForBeginLabel );
-
- // Mark this as the end of the for loop's body.
- il.MarkLabel( ReleaseComObjectLabel );
-
- // Generate the following code:
- // Marshal.ReleaseComObject(m_IFooEventsCP);
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbEventCP );
- il.Emit( OpCodes.Call, ReleaseComObjectMethod );
- il.Emit( OpCodes.Pop );
-
- // Mark this as the end of the for loop's body.
- il.MarkLabel( AfterReleaseComObjectLabel );
-
- // Generate the following code:
- // } catch {
- il.BeginCatchBlock(typeof(System.Exception));
- il.Emit( OpCodes.Pop );
-
- // Generate the following code:
- // } finally {
- il.BeginFinallyBlock();
-
- // Generate the following code:
- // if (lockTaken)
- // Monitor.Exit(this);
- Label skipExit = il.DefineLabel();
- il.Emit(OpCodes.Ldloc, ltLockTaken);
- il.Emit(OpCodes.Brfalse_S, skipExit);
- il.Emit(OpCodes.Ldarg, (short)0);
- il.Emit(OpCodes.Call, MonitorExitMethod);
- il.MarkLabel(skipExit);
-
- // Generate the following code:
- // }
- il.EndExceptionBlock();
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
-
- return Meth;
- }
-
- private void DefineDisposeMethod( TypeBuilder OutputTypeBuilder, MethodBuilder FinalizeMethod )
- {
- // Retrieve the method info for GC.SuppressFinalize().
- MethodInfo SuppressFinalizeMethod = typeof(GC).GetMethod("SuppressFinalize");
- Debug.Assert(SuppressFinalizeMethod != null, "Unable to find the GC.SuppressFinalize");
-
- // Define the Finalize method itself.
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod( "Dispose", MethodAttributes.Public | MethodAttributes.Virtual, null, null );
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Generate the following code:
- // Finalize()
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Callvirt, FinalizeMethod );
-
- // Generate the following code:
- // GC.SuppressFinalize()
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Call, SuppressFinalizeMethod );
-
- // Generate the return opcode.
- il.Emit( OpCodes.Ret );
- }
-
- private ModuleBuilder m_OutputModule;
- private String m_strDestTypeName;
- private Type m_EventItfType;
- private Type m_SrcItfType;
- private Type m_SinkHelperType;
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventSinkHelperWriter.cs b/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventSinkHelperWriter.cs
deleted file mode 100644
index 862419cc98..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventSinkHelperWriter.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices.TCEAdapterGen {
- using System.Runtime.InteropServices;
- using System;
- using System.Reflection;
- using System.Reflection.Emit;
- using System.Collections;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- internal class EventSinkHelperWriter
- {
- public static readonly String GeneratedTypeNamePostfix = "_SinkHelper";
-
- public EventSinkHelperWriter( ModuleBuilder OutputModule, Type InputType, Type EventItfType )
- {
- m_InputType = InputType;
- m_OutputModule = OutputModule;
- m_EventItfType = EventItfType;
- }
-
- public Type Perform()
- {
- // Create the output Type.
- Type[] aInterfaces = new Type[1];
- aInterfaces[0] = m_InputType;
- String strFullName = null;
- String strNameSpace = NameSpaceExtractor.ExtractNameSpace( m_EventItfType.FullName );
-
- if (strNameSpace != "")
- strFullName = strNameSpace + ".";
-
- strFullName += m_InputType.Name + GeneratedTypeNamePostfix;
- TypeBuilder OutputTypeBuilder = TCEAdapterGenerator.DefineUniqueType(
- strFullName,
- TypeAttributes.Sealed | TypeAttributes.Public,
- null,
- aInterfaces,
- m_OutputModule
- );
- // Hide the _SinkProvider interface
- TCEAdapterGenerator.SetHiddenAttribute(OutputTypeBuilder);
-
- // Set the class interface to none.
- TCEAdapterGenerator.SetClassInterfaceTypeToNone(OutputTypeBuilder);
-
- // Retrieve the property methods on the input interface and give them a dummy implementation.
- MethodInfo[] pMethods = TCEAdapterGenerator.GetPropertyMethods(m_InputType);
- foreach (MethodInfo method in pMethods)
- {
- DefineBlankMethod(OutputTypeBuilder, method);
- }
-
- // Retrieve the non-property methods on the input interface.
- MethodInfo[] aMethods = TCEAdapterGenerator.GetNonPropertyMethods(m_InputType);
-
- // Allocate an array to contain the delegate fields.
- FieldBuilder[] afbDelegates = new FieldBuilder[aMethods.Length];
- // Process all the methods on the input interface.
- for ( int cMethods = 0; cMethods < aMethods.Length; cMethods++ )
- {
- if ( m_InputType == aMethods[cMethods].DeclaringType )
- {
- // Retrieve the delegate type from the add_XXX method.
- MethodInfo AddMeth = m_EventItfType.GetMethod( "add_" + aMethods[cMethods].Name );
- ParameterInfo[] aParams = AddMeth.GetParameters();
- Debug.Assert(aParams.Length == 1, "All event interface methods must take a single delegate derived type and have a void return type");
- Type DelegateCls = aParams[0].ParameterType;
-
- // Define the delegate instance field.
- afbDelegates[cMethods] = OutputTypeBuilder.DefineField(
- "m_" + aMethods[cMethods].Name + "Delegate",
- DelegateCls,
- FieldAttributes.Public
- );
-
- // Define the event method itself.
- DefineEventMethod( OutputTypeBuilder, aMethods[cMethods], DelegateCls, afbDelegates[cMethods] );
- }
- }
-
- // Create the cookie field.
- FieldBuilder fbCookie = OutputTypeBuilder.DefineField(
- "m_dwCookie",
- typeof(Int32),
- FieldAttributes.Public
- );
-
- // Define the constructor.
- DefineConstructor( OutputTypeBuilder, fbCookie, afbDelegates );
-
- return OutputTypeBuilder.CreateType();
- }
-
- private void DefineBlankMethod(TypeBuilder OutputTypeBuilder, MethodInfo Method)
- {
- ParameterInfo[] PIs = Method.GetParameters();
- Type[] parameters = new Type[PIs.Length];
- for (int i=0; i < PIs.Length; i++)
- {
- parameters[i] = PIs[i].ParameterType;
- }
-
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod(Method.Name,
- Method.Attributes & ~MethodAttributes.Abstract,
- Method.CallingConvention,
- Method.ReturnType,
- parameters);
-
- ILGenerator il = Meth.GetILGenerator();
-
- AddReturn(Method.ReturnType, il, Meth);
-
- il.Emit(OpCodes.Ret);
- }
-
- private void DefineEventMethod( TypeBuilder OutputTypeBuilder, MethodInfo Method, Type DelegateCls, FieldBuilder fbDelegate )
- {
- // Retrieve the method info for the invoke method on the delegate.
- MethodInfo DelegateInvokeMethod = DelegateCls.GetMethod( "Invoke" );
- Debug.Assert(DelegateInvokeMethod != null, "Unable to find method Delegate.Invoke()");
-
- // Retrieve the return type.
- Type ReturnType = Method.ReturnType;
-
- // Define the actual event method.
- ParameterInfo[] paramInfos = Method.GetParameters();
- Type[] parameterTypes;
- if (paramInfos != null)
- {
- parameterTypes = new Type[paramInfos.Length];
- for (int i = 0; i < paramInfos.Length; i++)
- {
- parameterTypes[i] = paramInfos[i].ParameterType;
- }
- }
- else
- parameterTypes = null;
-
- MethodAttributes attr = MethodAttributes.Public | MethodAttributes.Virtual;
- MethodBuilder Meth = OutputTypeBuilder.DefineMethod( Method.Name,
- attr,
- CallingConventions.Standard,
- ReturnType,
- parameterTypes);
-
- // We explicitly do not specify parameter name and attributes since this Type
- // is not meant to be exposed to the user. It is only used internally to do the
- // connection point to TCE mapping.
-
- ILGenerator il = Meth.GetILGenerator();
-
- // Create the exit branch.
- Label ExitLabel = il.DefineLabel();
-
- // Generate the code that verifies that the delegate is not null.
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbDelegate );
- il.Emit( OpCodes.Brfalse, ExitLabel );
-
- // The delegate is not NULL so we need to invoke it.
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldfld, fbDelegate );
-
- // Generate the code to load the arguments before we call invoke.
- ParameterInfo[] aParams = Method.GetParameters();
- for ( int cParams = 0; cParams < aParams.Length; cParams++ )
- {
- il.Emit( OpCodes.Ldarg, (short)(cParams + 1) );
- }
-
- // Generate a tail call to invoke. This will cause the callvirt to return
- // directly to the caller of the current method instead of actually coming
- // back to the current method and returning. This will cause the value returned
- // from the call to the COM server to be returned to the caller of this method.
-
- il.Emit( OpCodes.Callvirt, DelegateInvokeMethod );
- il.Emit( OpCodes.Ret );
-
- // This is the label that will be jumped to if no delegate is present.
- il.MarkLabel( ExitLabel );
-
- AddReturn(ReturnType, il, Meth);
-
- il.Emit( OpCodes.Ret );
-
- }
-
- private void AddReturn(Type ReturnType, ILGenerator il, MethodBuilder Meth)
- {
- // Place a dummy return value on the stack before we return.
- if ( ReturnType == typeof(void) )
- {
- // There is nothing to place on the stack.
- }
- else if ( ReturnType.IsPrimitive )
- {
- switch (System.Type.GetTypeCode(ReturnType))
- {
- case TypeCode.Boolean:
- case TypeCode.Char:
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.UInt16:
- case TypeCode.Int32:
- case TypeCode.UInt32:
- il.Emit( OpCodes.Ldc_I4_0 );
- break;
-
- case TypeCode.Int64:
- case TypeCode.UInt64:
- il.Emit( OpCodes.Ldc_I4_0 );
- il.Emit( OpCodes.Conv_I8 );
- break;
-
- case TypeCode.Single:
- il.Emit( OpCodes.Ldc_R4, 0 );
- break;
-
- case TypeCode.Double:
- il.Emit( OpCodes.Ldc_R4, 0 );
- il.Emit( OpCodes.Conv_R8 );
- break;
-
- default:
- // "TypeCode" does not include IntPtr, so special case it.
- if ( ReturnType == typeof(IntPtr) )
- il.Emit( OpCodes.Ldc_I4_0 );
- else
- Debug.Assert(false, "Unexpected type for Primitive type.");
- break;
- }
- }
- else if ( ReturnType.IsValueType )
- {
- // Allocate stack space for the return value type. Zero-init.
- Meth.InitLocals = true;
- LocalBuilder ltRetVal = il.DeclareLocal( ReturnType );
-
- // Load the value class on the stack.
- il.Emit( OpCodes.Ldloc_S, ltRetVal );
-
- }
- else
- {
- // The return type is a normal type.
- il.Emit( OpCodes.Ldnull );
- }
- }
-
- private void DefineConstructor( TypeBuilder OutputTypeBuilder, FieldBuilder fbCookie, FieldBuilder[] afbDelegates )
- {
- // Retrieve the constructor info for the base classe's constructor.
- ConstructorInfo DefaultBaseClsCons = typeof(Object).GetConstructor(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, Array.Empty<Type>(), null );
- Debug.Assert(DefaultBaseClsCons != null, "Unable to find the constructor for class " + m_InputType.Name);
-
- // Define the default constructor.
- MethodBuilder Cons = OutputTypeBuilder.DefineMethod( ".ctor",
- MethodAttributes.Assembly | MethodAttributes.SpecialName,
- CallingConventions.Standard,
- null,
- null);
-
- ILGenerator il = Cons.GetILGenerator();
-
- // Generate the code to call the constructor of the base class.
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Call, DefaultBaseClsCons );
-
- // Generate the code to set the cookie field to 0.
- il.Emit( OpCodes.Ldarg, (short)0 );
- il.Emit( OpCodes.Ldc_I4, 0 );
- il.Emit( OpCodes.Stfld, fbCookie );
-
- // Generate the code to set all the delegates to NULL.
- for ( int cDelegates = 0; cDelegates < afbDelegates.Length; cDelegates++ )
- {
- if (afbDelegates[cDelegates] != null)
- {
- il.Emit( OpCodes.Ldarg,(short)0 );
- il.Emit( OpCodes.Ldnull );
- il.Emit( OpCodes.Stfld, afbDelegates[cDelegates] );
- }
- }
-
- // Emit the return opcode.
- il.Emit( OpCodes.Ret );
-
- }
-
- private Type m_InputType;
- private Type m_EventItfType;
- private ModuleBuilder m_OutputModule;
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/NameSpaceExtractor.cs b/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/NameSpaceExtractor.cs
deleted file mode 100644
index 8018ad4c66..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/NameSpaceExtractor.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices.TCEAdapterGen {
-
- using System;
- internal static class NameSpaceExtractor
- {
- private static char NameSpaceSeperator = '.';
-
- public static String ExtractNameSpace(String FullyQualifiedTypeName)
- {
- int TypeNameStartPos = FullyQualifiedTypeName.LastIndexOf(NameSpaceSeperator);
- if (TypeNameStartPos == -1)
- return "";
- else
- return FullyQualifiedTypeName.Substring(0, TypeNameStartPos);
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/TCEAdapterGenerator.cs b/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/TCEAdapterGenerator.cs
deleted file mode 100644
index c6e4415246..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/TCEAdapterGenerator.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices.TCEAdapterGen {
- using System.Runtime.InteropServices;
- using System;
- using System.Reflection;
- using System.Reflection.Emit;
- using System.Collections;
- using System.Threading;
-
- internal class TCEAdapterGenerator
- {
- public void Process(ModuleBuilder ModBldr, ArrayList EventItfList)
- {
- // Store the input/output module.
- m_Module = ModBldr;
-
- // Generate the TCE adapters for all the event sources.
- int NumEvItfs = EventItfList.Count;
- for ( int cEventItfs = 0; cEventItfs < NumEvItfs; cEventItfs++ )
- {
- // Retrieve the event interface info.
- EventItfInfo CurrEventItf = (EventItfInfo)EventItfList[cEventItfs];
-
- // Retrieve the information from the event interface info.
- Type EventItfType = CurrEventItf.GetEventItfType();
- Type SrcItfType = CurrEventItf.GetSrcItfType();
- String EventProviderName = CurrEventItf.GetEventProviderName();
-
- // Generate the sink interface helper.
- Type SinkHelperType = new EventSinkHelperWriter( m_Module, SrcItfType, EventItfType ).Perform();
-
- // Generate the event provider.
- new EventProviderWriter( m_Module, EventProviderName, EventItfType, SrcItfType, SinkHelperType ).Perform();
- }
- }
-
- internal static void SetClassInterfaceTypeToNone(TypeBuilder tb)
- {
- // Create the ClassInterface(ClassInterfaceType.None) CA builder if we haven't created it yet.
- if (s_NoClassItfCABuilder == null)
- {
- Type []aConsParams = new Type[1];
- aConsParams[0] = typeof(ClassInterfaceType);
- ConstructorInfo Cons = typeof(ClassInterfaceAttribute).GetConstructor(aConsParams);
-
- Object[] aArgs = new Object[1];
- aArgs[0] = ClassInterfaceType.None;
- s_NoClassItfCABuilder = new CustomAttributeBuilder(Cons, aArgs);
- }
-
- // Set the class interface type to none.
- tb.SetCustomAttribute(s_NoClassItfCABuilder);
- }
-
- internal static TypeBuilder DefineUniqueType(String strInitFullName, TypeAttributes attrs, Type BaseType, Type[] aInterfaceTypes, ModuleBuilder mb)
- {
- String strFullName = strInitFullName;
- int PostFix = 2;
-
- // Find the first unique name for the type.
- for (; mb.GetType(strFullName) != null; strFullName = strInitFullName + "_" + PostFix, PostFix++);
-
- // Define a type with the determined unique name.
- return mb.DefineType(strFullName, attrs, BaseType, aInterfaceTypes);
- }
-
- internal static void SetHiddenAttribute(TypeBuilder tb)
- {
- if (s_HiddenCABuilder == null)
- {
- // Hide the type from Object Browsers
- Type []aConsParams = new Type[1];
- aConsParams[0] = typeof(TypeLibTypeFlags);
- ConstructorInfo Cons = typeof(TypeLibTypeAttribute).GetConstructor(aConsParams);
-
- Object []aArgs = new Object[1];
- aArgs[0] = TypeLibTypeFlags.FHidden;
- s_HiddenCABuilder = new CustomAttributeBuilder(Cons, aArgs);
- }
-
- tb.SetCustomAttribute(s_HiddenCABuilder);
- }
-
- internal static MethodInfo[] GetNonPropertyMethods(Type type)
- {
- MethodInfo[] aMethods = type.GetMethods();
- ArrayList methods = new ArrayList(aMethods);
-
- PropertyInfo[] props = type.GetProperties();
-
- foreach(PropertyInfo prop in props)
- {
- MethodInfo[] accessors = prop.GetAccessors();
- foreach (MethodInfo accessor in accessors)
- {
- for (int i=0; i < methods.Count; i++)
- {
- if ((MethodInfo)methods[i] == accessor)
- methods.RemoveAt(i);
- }
- }
- }
-
- MethodInfo[] retMethods = new MethodInfo[methods.Count];
- methods.CopyTo(retMethods);
-
- return retMethods;
- }
-
- internal static MethodInfo[] GetPropertyMethods(Type type)
- {
- MethodInfo[] aMethods = type.GetMethods();
- ArrayList methods = new ArrayList();
-
- PropertyInfo[] props = type.GetProperties();
-
- foreach(PropertyInfo prop in props)
- {
- MethodInfo[] accessors = prop.GetAccessors();
- foreach (MethodInfo accessor in accessors)
- {
- methods.Add(accessor);
- }
- }
-
- MethodInfo[] retMethods = new MethodInfo[methods.Count];
- methods.CopyTo(retMethods);
-
- return retMethods;
- }
-
-
- private ModuleBuilder m_Module = null;
- private Hashtable m_SrcItfToSrcItfInfoMap = new Hashtable();
- private static volatile CustomAttributeBuilder s_NoClassItfCABuilder = null;
- private static volatile CustomAttributeBuilder s_HiddenCABuilder = null;
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIBindCtx.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIBindCtx.cs
deleted file mode 100644
index 8c6e1bcd64..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIBindCtx.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIBindCtx interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices {
-
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.BIND_OPTS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential)]
-
- public struct BIND_OPTS
- {
- public int cbStruct;
- public int grfFlags;
- public int grfMode;
- public int dwTickCountDeadline;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IBindCtx instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("0000000e-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIBindCtx
- {
- void RegisterObjectBound([MarshalAs(UnmanagedType.Interface)] Object punk);
- void RevokeObjectBound([MarshalAs(UnmanagedType.Interface)] Object punk);
- void ReleaseBoundObjects();
- void SetBindOptions([In()] ref BIND_OPTS pbindopts);
- void GetBindOptions(ref BIND_OPTS pbindopts);
- void GetRunningObjectTable(out UCOMIRunningObjectTable pprot);
- void RegisterObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey, [MarshalAs(UnmanagedType.Interface)] Object punk);
- void GetObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey, [MarshalAs(UnmanagedType.Interface)] out Object ppunk);
- void EnumObjectParam(out UCOMIEnumString ppenum);
- void RevokeObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPoint.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPoint.cs
deleted file mode 100644
index b12e1f7a8c..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPoint.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIConnectionPoint interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IConnectionPoint instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("B196B286-BAB4-101A-B69C-00AA00341D07")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIConnectionPoint
- {
- void GetConnectionInterface(out Guid pIID);
- void GetConnectionPointContainer(out UCOMIConnectionPointContainer ppCPC);
- void Advise([MarshalAs(UnmanagedType.Interface)] Object pUnkSink, out int pdwCookie);
- void Unadvise(int dwCookie);
- void EnumConnections(out UCOMIEnumConnections ppEnum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPointContainer.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPointContainer.cs
deleted file mode 100644
index 212d643e03..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIConnectionPointContainer.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIConnectionPointContainer interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IConnectionPointContainer instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("B196B284-BAB4-101A-B69C-00AA00341D07")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIConnectionPointContainer
- {
- void EnumConnectionPoints(out UCOMIEnumConnectionPoints ppEnum);
- void FindConnectionPoint(ref Guid riid, out UCOMIConnectionPoint ppCP);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnectionPoints.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnectionPoints.cs
deleted file mode 100644
index 5180018088..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnectionPoints.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIEnumConnectionPoints interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumConnectionPoints instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("B196B285-BAB4-101A-B69C-00AA00341D07")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIEnumConnectionPoints
- {
- [PreserveSig]
- int Next(int celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Out] UCOMIConnectionPoint[] rgelt, out int pceltFetched);
- [PreserveSig]
- int Skip(int celt);
- [PreserveSig]
- int Reset();
- void Clone(out UCOMIEnumConnectionPoints ppenum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnections.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnections.cs
deleted file mode 100644
index 87273b34f7..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumConnections.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIEnumConnections interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.CONNECTDATA instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
-
- public struct CONNECTDATA
- {
- [MarshalAs(UnmanagedType.Interface)]
- public Object pUnk;
- public int dwCookie;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumConnections instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("B196B287-BAB4-101A-B69C-00AA00341D07")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIEnumConnections
- {
- [PreserveSig]
- int Next(int celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Out] CONNECTDATA[] rgelt, out int pceltFetched);
- [PreserveSig]
- int Skip(int celt);
- [PreserveSig]
- void Reset();
- void Clone(out UCOMIEnumConnections ppenum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumMoniker.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumMoniker.cs
deleted file mode 100644
index 40787fcd5c..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumMoniker.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIEnumMoniker interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
- using DWORD = System.UInt32;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumMoniker instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00000102-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIEnumMoniker
- {
- [PreserveSig]
- int Next(int celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Out] UCOMIMoniker[] rgelt, out int pceltFetched);
- [PreserveSig]
- int Skip(int celt);
- [PreserveSig]
- int Reset();
- void Clone(out UCOMIEnumMoniker ppenum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumString.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumString.cs
deleted file mode 100644
index 9d0552a0df..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumString.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIEnumString interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumString instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00000101-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIEnumString
- {
- [PreserveSig]
- int Next(int celt, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0), Out] String[] rgelt, out int pceltFetched);
- [PreserveSig]
- int Skip(int celt);
- [PreserveSig]
- int Reset();
- void Clone(out UCOMIEnumString ppenum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumVARIANT.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumVARIANT.cs
deleted file mode 100644
index 0d8585ffdb..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumVARIANT.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIEnumVARIANT interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumVARIANT instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00020404-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIEnumVARIANT
- {
- [PreserveSig]
- int Next(int celt, int rgvar, int pceltFetched);
-
- [PreserveSig]
- int Skip(int celt);
-
- [PreserveSig]
- int Reset();
-
- void Clone(int ppenum);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerable.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerable.cs
deleted file mode 100644
index 81e0133923..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerable.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: UCOMIEnumerable
-**
-**
-** Purpose:
-** This interface is redefined here since the original IEnumerable interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IEnumerable interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices
-{
- using System;
- using System.Collections;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumerable instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
- internal interface UCOMIEnumerable
- {
- [DispId(-4)]
- IEnumerator GetEnumerator();
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerator.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerator.cs
deleted file mode 100644
index af886c46ac..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIEnumerator.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: UCOMIEnumerator
-**
-**
-** Purpose:
-** This interface is redefined here since the original IEnumerator interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IEnumerator interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IEnumerator instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("496B0ABF-CDEE-11d3-88E8-00902754C43A")]
- internal interface UCOMIEnumerator
- {
- bool MoveNext();
- Object Current {
- get;
- }
- void Reset();
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIExpando.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIExpando.cs
deleted file mode 100644
index 2f85c14bc6..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIExpando.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: UCOMIExpando
-**
-**
-** Purpose:
-** This interface is redefined here since the original IExpando interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IExpando interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices
-{
-
- using System;
- using System.Reflection;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IExpando instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("AFBF15E6-C37C-11d2-B88E-00A0C9B471B8")]
- internal interface UCOMIExpando : UCOMIReflect
- {
- FieldInfo AddField(String name);
- PropertyInfo AddProperty(String name);
- MethodInfo AddMethod(String name, Delegate method);
- void RemoveMember(MemberInfo m);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIMoniker.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIMoniker.cs
deleted file mode 100644
index bd5b6f4916..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIMoniker.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIMoniker interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.FILETIME instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential)]
-
- public struct FILETIME
- {
- public int dwLowDateTime;
- public int dwHighDateTime;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IMoniker instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("0000000f-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIMoniker
- {
- // IPersist portion
- void GetClassID(out Guid pClassID);
-
- // IPersistStream portion
- [PreserveSig]
- int IsDirty();
- void Load(UCOMIStream pStm);
- void Save(UCOMIStream pStm, [MarshalAs(UnmanagedType.Bool)] bool fClearDirty);
- void GetSizeMax(out Int64 pcbSize);
-
- // IMoniker portion
- void BindToObject(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [In()] ref Guid riidResult, [MarshalAs(UnmanagedType.Interface)] out Object ppvResult);
- void BindToStorage(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [In()] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out Object ppvObj);
- void Reduce(UCOMIBindCtx pbc, int dwReduceHowFar, ref UCOMIMoniker ppmkToLeft, out UCOMIMoniker ppmkReduced);
- void ComposeWith(UCOMIMoniker pmkRight, [MarshalAs(UnmanagedType.Bool)] bool fOnlyIfNotGeneric, out UCOMIMoniker ppmkComposite);
- void Enum([MarshalAs(UnmanagedType.Bool)] bool fForward, out UCOMIEnumMoniker ppenumMoniker);
- void IsEqual(UCOMIMoniker pmkOtherMoniker);
- void Hash(out int pdwHash);
- void IsRunning(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, UCOMIMoniker pmkNewlyRunning);
- void GetTimeOfLastChange(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, out FILETIME pFileTime);
- void Inverse(out UCOMIMoniker ppmk);
- void CommonPrefixWith(UCOMIMoniker pmkOther, out UCOMIMoniker ppmkPrefix);
- void RelativePathTo(UCOMIMoniker pmkOther, out UCOMIMoniker ppmkRelPath);
- void GetDisplayName(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] out String ppszDisplayName);
- void ParseDisplayName(UCOMIBindCtx pbc, UCOMIMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] String pszDisplayName, out int pchEaten, out UCOMIMoniker ppmkOut);
- void IsSystemMoniker(out int pdwMksys);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIPersistFile.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIPersistFile.cs
deleted file mode 100644
index ac465e771f..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIPersistFile.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIPersistFile interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices {
-
- using System;
- using DWORD = System.UInt32;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IPersistFile instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("0000010b-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIPersistFile
- {
- // IPersist portion
- void GetClassID(out Guid pClassID);
-
- // IPersistFile portion
- [PreserveSig]
- int IsDirty();
- void Load([MarshalAs(UnmanagedType.LPWStr)] String pszFileName, int dwMode);
- void Save([MarshalAs(UnmanagedType.LPWStr)] String pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember);
- void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] String pszFileName);
- void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out String ppszFileName);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIReflect.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIReflect.cs
deleted file mode 100644
index d6cdd6828e..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIReflect.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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.
-
-/*==========================================================================
-**
-** Interface: UCOMIReflect
-**
-**
-** Purpose:
-** This interface is redefined here since the original IReflect interface
-** has all its methods marked as ecall's since it is a managed standard
-** interface. This interface is used from within the runtime to make a call
-** on the COM server directly when it implements the IReflect interface.
-**
-**
-==========================================================================*/
-namespace System.Runtime.InteropServices
-{
- using System;
- using System.Reflection;
- using CultureInfo = System.Globalization.CultureInfo;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IReflect instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
- internal interface UCOMIReflect
- {
- MethodInfo GetMethod(String name,BindingFlags bindingAttr,Binder binder,
- Type[] types,ParameterModifier[] modifiers);
-
- MethodInfo GetMethod(String name,BindingFlags bindingAttr);
-
- MethodInfo[] GetMethods(
- BindingFlags bindingAttr);
-
- FieldInfo GetField(
- String name,
- BindingFlags bindingAttr);
-
- FieldInfo[] GetFields(
- BindingFlags bindingAttr);
-
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr);
-
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr,
- Binder binder,
- Type returnType,
- Type[] types,
- ParameterModifier[] modifiers);
-
- PropertyInfo[] GetProperties(
- BindingFlags bindingAttr);
-
- MemberInfo[] GetMember(
- String name,
- BindingFlags bindingAttr);
-
- MemberInfo[] GetMembers(
- BindingFlags bindingAttr);
-
- Object InvokeMember(
- String name,
- BindingFlags invokeAttr,
- Binder binder,
- Object target,
- Object[] args,
- ParameterModifier[] modifiers,
- CultureInfo culture,
- String[] namedParameters);
-
- Type UnderlyingSystemType {
- get;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIRunningObjectTable.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIRunningObjectTable.cs
deleted file mode 100644
index 8088c0417f..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIRunningObjectTable.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIRunningObjectTable interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IRunningObjectTable instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00000010-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIRunningObjectTable
- {
- void Register(int grfFlags, [MarshalAs(UnmanagedType.Interface)] Object punkObject, UCOMIMoniker pmkObjectName, out int pdwRegister);
- void Revoke(int dwRegister);
- void IsRunning(UCOMIMoniker pmkObjectName);
- void GetObject(UCOMIMoniker pmkObjectName, [MarshalAs(UnmanagedType.Interface)] out Object ppunkObject);
- void NoteChangeTime(int dwRegister, ref FILETIME pfiletime);
- void GetTimeOfLastChange(UCOMIMoniker pmkObjectName, out FILETIME pfiletime);
- void EnumRunning(out UCOMIEnumMoniker ppenumMoniker);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIStream.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMIStream.cs
deleted file mode 100644
index dc2cb53d97..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMIStream.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMIStream interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.STATSTG instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
-
- public struct STATSTG
- {
- public String pwcsName;
- public int type;
- public Int64 cbSize;
- public FILETIME mtime;
- public FILETIME ctime;
- public FILETIME atime;
- public int grfMode;
- public int grfLocksSupported;
- public Guid clsid;
- public int grfStateBits;
- public int reserved;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IStream instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("0000000c-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMIStream
- {
- // ISequentialStream portion
- void Read([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] Byte[] pv, int cb,IntPtr pcbRead);
- void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Byte[] pv, int cb, IntPtr pcbWritten);
-
- // IStream portion
- void Seek(Int64 dlibMove, int dwOrigin, IntPtr plibNewPosition);
- void SetSize(Int64 libNewSize);
- void CopyTo(UCOMIStream pstm, Int64 cb, IntPtr pcbRead, IntPtr pcbWritten);
- void Commit(int grfCommitFlags);
- void Revert();
- void LockRegion(Int64 libOffset, Int64 cb, int dwLockType);
- void UnlockRegion(Int64 libOffset, Int64 cb, int dwLockType);
- void Stat(out STATSTG pstatstg, int grfStatFlag);
- void Clone(out UCOMIStream ppstm);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeComp.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeComp.cs
deleted file mode 100644
index 0ef1e549a5..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeComp.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMITypeComp interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.DESCKIND instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum DESCKIND
- {
- DESCKIND_NONE = 0,
- DESCKIND_FUNCDESC = DESCKIND_NONE + 1,
- DESCKIND_VARDESC = DESCKIND_FUNCDESC + 1,
- DESCKIND_TYPECOMP = DESCKIND_VARDESC + 1,
- DESCKIND_IMPLICITAPPOBJ = DESCKIND_TYPECOMP + 1,
- DESCKIND_MAX = DESCKIND_IMPLICITAPPOBJ + 1
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.BINDPTR instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
-
- public struct BINDPTR
- {
- [FieldOffset(0)]
- public IntPtr lpfuncdesc;
- [FieldOffset(0)]
- public IntPtr lpvardesc;
- [FieldOffset(0)]
- public IntPtr lptcomp;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.ITypeComp instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00020403-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMITypeComp
- {
- void Bind([MarshalAs(UnmanagedType.LPWStr)] String szName, int lHashVal, Int16 wFlags, out UCOMITypeInfo ppTInfo, out DESCKIND pDescKind, out BINDPTR pBindPtr);
- void BindType([MarshalAs(UnmanagedType.LPWStr)] String szName, int lHashVal, out UCOMITypeInfo ppTInfo, out UCOMITypeComp ppTComp);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeInfo.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeInfo.cs
deleted file mode 100644
index e26964f5a3..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeInfo.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMITypeInfo interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.TYPEKIND instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum TYPEKIND
- {
- TKIND_ENUM = 0,
- TKIND_RECORD = TKIND_ENUM + 1,
- TKIND_MODULE = TKIND_RECORD + 1,
- TKIND_INTERFACE = TKIND_MODULE + 1,
- TKIND_DISPATCH = TKIND_INTERFACE + 1,
- TKIND_COCLASS = TKIND_DISPATCH + 1,
- TKIND_ALIAS = TKIND_COCLASS + 1,
- TKIND_UNION = TKIND_ALIAS + 1,
- TKIND_MAX = TKIND_UNION + 1
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.TYPEFLAGS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum TYPEFLAGS : short
- {
- TYPEFLAG_FAPPOBJECT = 0x1,
- TYPEFLAG_FCANCREATE = 0x2,
- TYPEFLAG_FLICENSED = 0x4,
- TYPEFLAG_FPREDECLID = 0x8,
- TYPEFLAG_FHIDDEN = 0x10,
- TYPEFLAG_FCONTROL = 0x20,
- TYPEFLAG_FDUAL = 0x40,
- TYPEFLAG_FNONEXTENSIBLE = 0x80,
- TYPEFLAG_FOLEAUTOMATION = 0x100,
- TYPEFLAG_FRESTRICTED = 0x200,
- TYPEFLAG_FAGGREGATABLE = 0x400,
- TYPEFLAG_FREPLACEABLE = 0x800,
- TYPEFLAG_FDISPATCHABLE = 0x1000,
- TYPEFLAG_FREVERSEBIND = 0x2000,
- TYPEFLAG_FPROXY = 0x4000
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IMPLTYPEFLAGS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum IMPLTYPEFLAGS
- {
- IMPLTYPEFLAG_FDEFAULT = 0x1,
- IMPLTYPEFLAG_FSOURCE = 0x2,
- IMPLTYPEFLAG_FRESTRICTED = 0x4,
- IMPLTYPEFLAG_FDEFAULTVTABLE = 0x8,
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.TYPEATTR instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct TYPEATTR
- {
- // Constant used with the memid fields.
- public const int MEMBER_ID_NIL = unchecked((int)0xFFFFFFFF);
-
- // Actual fields of the TypeAttr struct.
- public Guid guid;
- public Int32 lcid;
- public Int32 dwReserved;
- public Int32 memidConstructor;
- public Int32 memidDestructor;
- public IntPtr lpstrSchema;
- public Int32 cbSizeInstance;
- public TYPEKIND typekind;
- public Int16 cFuncs;
- public Int16 cVars;
- public Int16 cImplTypes;
- public Int16 cbSizeVft;
- public Int16 cbAlignment;
- public TYPEFLAGS wTypeFlags;
- public Int16 wMajorVerNum;
- public Int16 wMinorVerNum;
- public TYPEDESC tdescAlias;
- public IDLDESC idldescType;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.FUNCDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential)]
- public struct FUNCDESC
- {
- public int memid; //MEMBERID memid;
- public IntPtr lprgscode; // /* [size_is(cScodes)] */ SCODE RPC_FAR *lprgscode;
- public IntPtr lprgelemdescParam; // /* [size_is(cParams)] */ ELEMDESC __RPC_FAR *lprgelemdescParam;
- public FUNCKIND funckind; //FUNCKIND funckind;
- public INVOKEKIND invkind; //INVOKEKIND invkind;
- public CALLCONV callconv; //CALLCONV callconv;
- public Int16 cParams; //short cParams;
- public Int16 cParamsOpt; //short cParamsOpt;
- public Int16 oVft; //short oVft;
- public Int16 cScodes; //short cScodes;
- public ELEMDESC elemdescFunc; //ELEMDESC elemdescFunc;
- public Int16 wFuncFlags; //WORD wFuncFlags;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IDLFLAG instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum IDLFLAG : short
- {
- IDLFLAG_NONE = PARAMFLAG.PARAMFLAG_NONE,
- IDLFLAG_FIN = PARAMFLAG.PARAMFLAG_FIN,
- IDLFLAG_FOUT = PARAMFLAG.PARAMFLAG_FOUT,
- IDLFLAG_FLCID = PARAMFLAG.PARAMFLAG_FLCID,
- IDLFLAG_FRETVAL = PARAMFLAG.PARAMFLAG_FRETVAL
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.IDLDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct IDLDESC
- {
- public int dwReserved;
- public IDLFLAG wIDLFlags;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.PARAMFLAG instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum PARAMFLAG :short
- {
- PARAMFLAG_NONE = 0,
- PARAMFLAG_FIN = 0x1,
- PARAMFLAG_FOUT = 0x2,
- PARAMFLAG_FLCID = 0x4,
- PARAMFLAG_FRETVAL = 0x8,
- PARAMFLAG_FOPT = 0x10,
- PARAMFLAG_FHASDEFAULT = 0x20,
- PARAMFLAG_FHASCUSTDATA = 0x40
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.PARAMDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct PARAMDESC
- {
- public IntPtr lpVarValue;
- public PARAMFLAG wParamFlags;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.TYPEDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct TYPEDESC
- {
- public IntPtr lpValue;
- public Int16 vt;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.ELEMDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct ELEMDESC
- {
- public TYPEDESC tdesc;
-
- [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
- [ComVisible(false)]
- public struct DESCUNION
- {
- [FieldOffset(0)]
- public IDLDESC idldesc;
- [FieldOffset(0)]
- public PARAMDESC paramdesc;
- };
- public DESCUNION desc;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.VARDESC instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct VARDESC
- {
- public int memid;
- public String lpstrSchema;
-
- [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
- [ComVisible(false)]
- public struct DESCUNION
- {
- [FieldOffset(0)]
- public int oInst;
- [FieldOffset(0)]
- public IntPtr lpvarValue;
- };
-
- public ELEMDESC elemdescVar;
- public short wVarFlags;
- public VarEnum varkind;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.DISPPARAMS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct DISPPARAMS
- {
- public IntPtr rgvarg;
- public IntPtr rgdispidNamedArgs;
- public int cArgs;
- public int cNamedArgs;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.EXCEPINFO instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public struct EXCEPINFO
- {
- public Int16 wCode;
- public Int16 wReserved;
- [MarshalAs(UnmanagedType.BStr)] public String bstrSource;
- [MarshalAs(UnmanagedType.BStr)] public String bstrDescription;
- [MarshalAs(UnmanagedType.BStr)] public String bstrHelpFile;
- public int dwHelpContext;
- public IntPtr pvReserved;
- public IntPtr pfnDeferredFillIn;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.FUNCKIND instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum FUNCKIND : int
- {
- FUNC_VIRTUAL = 0,
- FUNC_PUREVIRTUAL = 1,
- FUNC_NONVIRTUAL = 2,
- FUNC_STATIC = 3,
- FUNC_DISPATCH = 4
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.INVOKEKIND instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum INVOKEKIND : int
- {
- INVOKE_FUNC = 0x1,
- INVOKE_PROPERTYGET = 0x2,
- INVOKE_PROPERTYPUT = 0x4,
- INVOKE_PROPERTYPUTREF = 0x8
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.CALLCONV instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum CALLCONV : int
- {
- CC_CDECL =1,
- CC_MSCPASCAL=2,
- CC_PASCAL =CC_MSCPASCAL,
- CC_MACPASCAL=3,
- CC_STDCALL =4,
- CC_RESERVED =5,
- CC_SYSCALL =6,
- CC_MPWCDECL =7,
- CC_MPWPASCAL=8,
- CC_MAX =9
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.FUNCFLAGS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum FUNCFLAGS : short
- {
- FUNCFLAG_FRESTRICTED= 0x1,
- FUNCFLAG_FSOURCE = 0x2,
- FUNCFLAG_FBINDABLE = 0x4,
- FUNCFLAG_FREQUESTEDIT = 0x8,
- FUNCFLAG_FDISPLAYBIND = 0x10,
- FUNCFLAG_FDEFAULTBIND = 0x20,
- FUNCFLAG_FHIDDEN = 0x40,
- FUNCFLAG_FUSESGETLASTERROR= 0x80,
- FUNCFLAG_FDEFAULTCOLLELEM= 0x100,
- FUNCFLAG_FUIDEFAULT = 0x200,
- FUNCFLAG_FNONBROWSABLE = 0x400,
- FUNCFLAG_FREPLACEABLE = 0x800,
- FUNCFLAG_FIMMEDIATEBIND = 0x1000
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.VARFLAGS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum VARFLAGS : short
- {
- VARFLAG_FREADONLY =0x1,
- VARFLAG_FSOURCE =0x2,
- VARFLAG_FBINDABLE =0x4,
- VARFLAG_FREQUESTEDIT =0x8,
- VARFLAG_FDISPLAYBIND =0x10,
- VARFLAG_FDEFAULTBIND =0x20,
- VARFLAG_FHIDDEN =0x40,
- VARFLAG_FRESTRICTED =0x80,
- VARFLAG_FDEFAULTCOLLELEM =0x100,
- VARFLAG_FUIDEFAULT =0x200,
- VARFLAG_FNONBROWSABLE =0x400,
- VARFLAG_FREPLACEABLE =0x800,
- VARFLAG_FIMMEDIATEBIND =0x1000
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00020401-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMITypeInfo
- {
- void GetTypeAttr(out IntPtr ppTypeAttr);
- void GetTypeComp(out UCOMITypeComp ppTComp);
- void GetFuncDesc(int index, out IntPtr ppFuncDesc);
- void GetVarDesc(int index, out IntPtr ppVarDesc);
- void GetNames(int memid, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] String[] rgBstrNames, int cMaxNames, out int pcNames);
- void GetRefTypeOfImplType(int index, out int href);
- void GetImplTypeFlags(int index, out int pImplTypeFlags);
- void GetIDsOfNames([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1), In] String[] rgszNames, int cNames, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] int[] pMemId);
- void Invoke([MarshalAs(UnmanagedType.IUnknown)] Object pvInstance, int memid, Int16 wFlags, ref DISPPARAMS pDispParams, out Object pVarResult, out EXCEPINFO pExcepInfo, out int puArgErr);
- void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile);
- void GetDllEntry(int memid, INVOKEKIND invKind, out String pBstrDllName, out String pBstrName, out Int16 pwOrdinal);
- void GetRefTypeInfo(int hRef, out UCOMITypeInfo ppTI);
- void AddressOfMember(int memid, INVOKEKIND invKind, out IntPtr ppv);
- void CreateInstance([MarshalAs(UnmanagedType.IUnknown)] Object pUnkOuter, ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out Object ppvObj);
- void GetMops(int memid, out String pBstrMops);
- void GetContainingTypeLib(out UCOMITypeLib ppTLB, out int pIndex);
- void ReleaseTypeAttr(IntPtr pTypeAttr);
- void ReleaseFuncDesc(IntPtr pFuncDesc);
- void ReleaseVarDesc(IntPtr pVarDesc);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeLib.cs b/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeLib.cs
deleted file mode 100644
index c8b63deff6..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/UCOMITypeLib.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: UCOMITypeLib interface definition.
-**
-**
-=============================================================================*/
-
-namespace System.Runtime.InteropServices
-{
- using System;
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.SYSKIND instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Serializable]
- public enum SYSKIND
- {
- SYS_WIN16 = 0,
- SYS_WIN32 = SYS_WIN16 + 1,
- SYS_MAC = SYS_WIN32 + 1
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.LIBFLAGS instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
-[Serializable]
-[Flags()]
- public enum LIBFLAGS : short
- {
- LIBFLAG_FRESTRICTED = 0x1,
- LIBFLAG_FCONTROL = 0x2,
- LIBFLAG_FHIDDEN = 0x4,
- LIBFLAG_FHASDISKIMAGE = 0x8
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.TYPELIBATTR instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- [Serializable]
- public struct TYPELIBATTR
- {
- public Guid guid;
- public int lcid;
- public SYSKIND syskind;
- public Int16 wMajorVerNum;
- public Int16 wMinorVerNum;
- public LIBFLAGS wLibFlags;
- }
-
- [Obsolete("Use System.Runtime.InteropServices.ComTypes.ITypeLib instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
- [Guid("00020402-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- public interface UCOMITypeLib
- {
- [PreserveSig]
- int GetTypeInfoCount();
- void GetTypeInfo(int index, out UCOMITypeInfo ppTI);
- void GetTypeInfoType(int index, out TYPEKIND pTKind);
- void GetTypeInfoOfGuid(ref Guid guid, out UCOMITypeInfo ppTInfo);
- void GetLibAttr(out IntPtr ppTLibAttr);
- void GetTypeComp(out UCOMITypeComp ppTComp);
- void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile);
- [return : MarshalAs(UnmanagedType.Bool)]
- bool IsName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal);
- void FindName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal, [MarshalAs(UnmanagedType.LPArray), Out] UCOMITypeInfo[] ppTInfo, [MarshalAs(UnmanagedType.LPArray), Out] int[] rgMemId, ref Int16 pcFound);
- [PreserveSig]
- void ReleaseTLibAttr(IntPtr pTLibAttr);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
index 69ef2dcc06..1f70108a02 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.InteropServices {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class UnknownWrapper
{
public UnknownWrapper(Object obj)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Variant.cs b/src/mscorlib/src/System/Runtime/InteropServices/Variant.cs
deleted file mode 100644
index c7bbb78ae6..0000000000
--- a/src/mscorlib/src/System/Runtime/InteropServices/Variant.cs
+++ /dev/null
@@ -1,658 +0,0 @@
-// 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.
-
-namespace System.Runtime.InteropServices {
- using System.Diagnostics;
-
- /// <summary>
- /// Variant is the basic COM type for late-binding. It can contain any other COM data type.
- /// This type definition precisely matches the unmanaged data layout so that the struct can be passed
- /// to and from COM calls.
- /// </summary>
- [StructLayout(LayoutKind.Explicit)]
- internal struct Variant {
-
-#if DEBUG
- static Variant() {
- // Variant size is the size of 4 pointers (16 bytes) on a 32-bit processor,
- // and 3 pointers (24 bytes) on a 64-bit processor.
- int variantSize = Marshal.SizeOf(typeof(Variant));
- if (IntPtr.Size == 4) {
- BCLDebug.Assert(variantSize == (4 * IntPtr.Size), "variant");
- } else {
- BCLDebug.Assert(IntPtr.Size == 8, "variant");
- BCLDebug.Assert(variantSize == (3 * IntPtr.Size), "variant");
- }
- }
-#endif
-
- // Most of the data types in the Variant are carried in _typeUnion
- [FieldOffset(0)] private TypeUnion _typeUnion;
-
- // Decimal is the largest data type and it needs to use the space that is normally unused in TypeUnion._wReserved1, etc.
- // Hence, it is declared to completely overlap with TypeUnion. A Decimal does not use the first two bytes, and so
- // TypeUnion._vt can still be used to encode the type.
- [FieldOffset(0)] private Decimal _decimal;
-
- [StructLayout(LayoutKind.Sequential)]
- private struct TypeUnion {
- internal ushort _vt;
- internal ushort _wReserved1;
- internal ushort _wReserved2;
- internal ushort _wReserved3;
-
- internal UnionTypes _unionTypes;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- private struct Record {
- private IntPtr _record;
- private IntPtr _recordInfo;
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
- [StructLayout(LayoutKind.Explicit)]
- private struct UnionTypes {
- #region Generated Variant union types
-
- // *** BEGIN GENERATED CODE ***
- // generated by function: gen_UnionTypes from: generate_comdispatch.py
-
- [FieldOffset(0)] internal SByte _i1;
- [FieldOffset(0)] internal Int16 _i2;
- [FieldOffset(0)] internal Int32 _i4;
- [FieldOffset(0)] internal Int64 _i8;
- [FieldOffset(0)] internal Byte _ui1;
- [FieldOffset(0)] internal UInt16 _ui2;
- [FieldOffset(0)] internal UInt32 _ui4;
- [FieldOffset(0)] internal UInt64 _ui8;
- [FieldOffset(0)] internal Int32 _int;
- [FieldOffset(0)] internal UInt32 _uint;
- [FieldOffset(0)] internal Int16 _bool;
- [FieldOffset(0)] internal Int32 _error;
- [FieldOffset(0)] internal Single _r4;
- [FieldOffset(0)] internal Double _r8;
- [FieldOffset(0)] internal Int64 _cy;
- [FieldOffset(0)] internal double _date;
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- [FieldOffset(0)] internal IntPtr _bstr;
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- [FieldOffset(0)] internal IntPtr _unknown;
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- [FieldOffset(0)] internal IntPtr _dispatch;
-
- // *** END GENERATED CODE ***
-
- #endregion
-
- [FieldOffset(0)] internal IntPtr _pvarVal;
- [FieldOffset(0)] internal IntPtr _byref;
- [FieldOffset(0)] internal Record _record;
- }
-
- /// <summary>
- /// Primitive types are the basic COM types. It includes valuetypes like ints, but also reference types
- /// like BStrs. It does not include composite types like arrays and user-defined COM types (IUnknown/IDispatch).
- /// </summary>
- internal static bool IsPrimitiveType(VarEnum varEnum) {
- switch(varEnum) {
- #region Generated Variant IsPrimitiveType
-
- // *** BEGIN GENERATED CODE ***
- // generated by function: gen_IsPrimitiveType from: generate_comdispatch.py
-
- case VarEnum.VT_I1:
- case VarEnum.VT_I2:
- case VarEnum.VT_I4:
- case VarEnum.VT_I8:
- case VarEnum.VT_UI1:
- case VarEnum.VT_UI2:
- case VarEnum.VT_UI4:
- case VarEnum.VT_UI8:
- case VarEnum.VT_INT:
- case VarEnum.VT_UINT:
- case VarEnum.VT_BOOL:
- case VarEnum.VT_R4:
- case VarEnum.VT_R8:
- case VarEnum.VT_DECIMAL:
- case VarEnum.VT_DATE:
- case VarEnum.VT_BSTR:
-
- // *** END GENERATED CODE ***
-
- #endregion
- return true;
- }
-
- return false;
- }
-
- unsafe public void CopyFromIndirect(object value) {
-
- VarEnum vt = (VarEnum)(((int)this.VariantType) & ~((int)VarEnum.VT_BYREF));
-
- if (value == null) {
- if (vt == VarEnum.VT_DISPATCH || vt == VarEnum.VT_UNKNOWN || vt == VarEnum.VT_BSTR) {
- *(IntPtr*)this._typeUnion._unionTypes._byref = IntPtr.Zero;
- }
- return;
- }
-
- switch (vt) {
- case VarEnum.VT_I1:
- *(sbyte*)this._typeUnion._unionTypes._byref = (sbyte)value;
- break;
-
- case VarEnum.VT_UI1:
- *(byte*)this._typeUnion._unionTypes._byref = (byte)value;
- break;
-
- case VarEnum.VT_I2:
- *(short*)this._typeUnion._unionTypes._byref = (short)value;
- break;
-
- case VarEnum.VT_UI2:
- *(ushort*)this._typeUnion._unionTypes._byref = (ushort)value;
- break;
-
- case VarEnum.VT_BOOL:
- *(short*)this._typeUnion._unionTypes._byref = (bool)value ? (short)-1 : (short)0;
- break;
-
- case VarEnum.VT_I4:
- case VarEnum.VT_INT:
- *(int*)this._typeUnion._unionTypes._byref = (int)value;
- break;
-
- case VarEnum.VT_UI4:
- case VarEnum.VT_UINT:
- *(uint*)this._typeUnion._unionTypes._byref = (uint)value;
- break;
-
- case VarEnum.VT_ERROR:
- *(int*)this._typeUnion._unionTypes._byref = ((ErrorWrapper)value).ErrorCode;
- break;
-
- case VarEnum.VT_I8:
- *(Int64*)this._typeUnion._unionTypes._byref = (Int64)value;
- break;
-
- case VarEnum.VT_UI8:
- *(UInt64*)this._typeUnion._unionTypes._byref = (UInt64)value;
- break;
-
- case VarEnum.VT_R4:
- *(float*)this._typeUnion._unionTypes._byref = (float)value;
- break;
-
- case VarEnum.VT_R8:
- *(double*)this._typeUnion._unionTypes._byref = (double)value;
- break;
-
- case VarEnum.VT_DATE:
- *(double*)this._typeUnion._unionTypes._byref = ((DateTime)value).ToOADate();
- break;
-
- case VarEnum.VT_UNKNOWN:
- *(IntPtr*)this._typeUnion._unionTypes._byref = Marshal.GetIUnknownForObject(value);
- break;
-
- case VarEnum.VT_DISPATCH:
- *(IntPtr*)this._typeUnion._unionTypes._byref = Marshal.GetIDispatchForObject(value);
- break;
-
- case VarEnum.VT_BSTR:
- *(IntPtr*)this._typeUnion._unionTypes._byref = Marshal.StringToBSTR((string)value);
- break;
-
- case VarEnum.VT_CY:
- *(long*)this._typeUnion._unionTypes._byref = decimal.ToOACurrency((decimal)value);
- break;
-
- case VarEnum.VT_DECIMAL:
- *(decimal*)this._typeUnion._unionTypes._byref = (decimal)value;
- break;
-
- case VarEnum.VT_VARIANT:
- Marshal.GetNativeVariantForObject(value, this._typeUnion._unionTypes._byref);
- break;
-
- default:
- throw new ArgumentException("invalid argument type");
- }
- }
-
- /// <summary>
- /// Get the managed object representing the Variant.
- /// </summary>
- /// <returns></returns>
- public object ToObject() {
- // Check the simple case upfront
- if (IsEmpty) {
- return null;
- }
-
- switch (VariantType) {
- case VarEnum.VT_NULL: return DBNull.Value;
-
- #region Generated Variant ToObject
-
- // *** BEGIN GENERATED CODE ***
- // generated by function: gen_ToObject from: generate_comdispatch.py
-
- case VarEnum.VT_I1: return AsI1;
- case VarEnum.VT_I2: return AsI2;
- case VarEnum.VT_I4: return AsI4;
- case VarEnum.VT_I8: return AsI8;
- case VarEnum.VT_UI1: return AsUi1;
- case VarEnum.VT_UI2: return AsUi2;
- case VarEnum.VT_UI4: return AsUi4;
- case VarEnum.VT_UI8: return AsUi8;
- case VarEnum.VT_INT: return AsInt;
- case VarEnum.VT_UINT: return AsUint;
- case VarEnum.VT_BOOL: return AsBool;
- case VarEnum.VT_ERROR: return AsError;
- case VarEnum.VT_R4: return AsR4;
- case VarEnum.VT_R8: return AsR8;
- case VarEnum.VT_DECIMAL: return AsDecimal;
- case VarEnum.VT_CY: return AsCy;
- case VarEnum.VT_DATE: return AsDate;
- case VarEnum.VT_BSTR: return AsBstr;
- case VarEnum.VT_UNKNOWN: return AsUnknown;
- case VarEnum.VT_DISPATCH: return AsDispatch;
- // VarEnum.VT_VARIANT is handled by Marshal.GetObjectForNativeVariant below
-
- // *** END GENERATED CODE ***
-
- #endregion
-
- default:
- try {
- unsafe {
- fixed (void* pThis = &this) {
- return Marshal.GetObjectForNativeVariant((System.IntPtr)pThis);
- }
- }
- }
- catch (Exception ex) {
- throw new NotImplementedException("Variant.ToObject cannot handle" + VariantType, ex);
- }
- }
- }
-
- /// <summary>
- /// Release any unmanaged memory associated with the Variant
- /// </summary>
- /// <returns></returns>
- public void Clear() {
- // We do not need to call OLE32's VariantClear for primitive types or ByRefs
- // to safe ourselves the cost of interop transition.
- // ByRef indicates the memory is not owned by the VARIANT itself while
- // primitive types do not have any resources to free up.
- // Hence, only safearrays, BSTRs, interfaces and user types are
- // handled differently.
- VarEnum vt = VariantType;
- if ((vt & VarEnum.VT_BYREF) != 0) {
- VariantType = VarEnum.VT_EMPTY;
- } else if (
- ((vt & VarEnum.VT_ARRAY) != 0) ||
- ((vt) == VarEnum.VT_BSTR) ||
- ((vt) == VarEnum.VT_UNKNOWN) ||
- ((vt) == VarEnum.VT_DISPATCH) ||
- ((vt) == VarEnum.VT_VARIANT) ||
- ((vt) == VarEnum.VT_RECORD) ||
- ((vt) == VarEnum.VT_VARIANT)
- ) {
- unsafe {
- fixed (void* pThis = &this) {
- NativeMethods.VariantClear((IntPtr)pThis);
- }
- }
- BCLDebug.Assert(IsEmpty, "variant");
- } else {
- VariantType = VarEnum.VT_EMPTY;
- }
- }
-
- public VarEnum VariantType {
- get {
- return (VarEnum)_typeUnion._vt;
- }
- set {
- _typeUnion._vt = (ushort)value;
- }
- }
-
- internal bool IsEmpty {
- get {
- return _typeUnion._vt == ((ushort)VarEnum.VT_EMPTY);
- }
- }
-
- internal bool IsByRef {
- get {
- return (_typeUnion._vt & ((ushort)VarEnum.VT_BYREF)) != 0;
- }
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
- public void SetAsNULL() {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_NULL;
- }
-
- #region Generated Variant accessors
-
- // *** BEGIN GENERATED CODE ***
- // generated by function: gen_accessors from: generate_comdispatch.py
-
- // VT_I1
-
- public SByte AsI1 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_I1, "variant");
- return _typeUnion._unionTypes._i1;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_I1;
- _typeUnion._unionTypes._i1 = value;
- }
- }
-
- // VT_I2
-
- public Int16 AsI2 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_I2, "variant");
- return _typeUnion._unionTypes._i2;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_I2;
- _typeUnion._unionTypes._i2 = value;
- }
- }
-
- // VT_I4
-
- public Int32 AsI4 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_I4, "variant");
- return _typeUnion._unionTypes._i4;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_I4;
- _typeUnion._unionTypes._i4 = value;
- }
- }
-
- // VT_I8
-
- public Int64 AsI8 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_I8, "variant");
- return _typeUnion._unionTypes._i8;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_I8;
- _typeUnion._unionTypes._i8 = value;
- }
- }
-
- // VT_UI1
-
- public Byte AsUi1 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UI1, "variant");
- return _typeUnion._unionTypes._ui1;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UI1;
- _typeUnion._unionTypes._ui1 = value;
- }
- }
-
- // VT_UI2
-
- public UInt16 AsUi2 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UI2, "variant");
- return _typeUnion._unionTypes._ui2;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UI2;
- _typeUnion._unionTypes._ui2 = value;
- }
- }
-
- // VT_UI4
-
- public UInt32 AsUi4 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UI4, "variant");
- return _typeUnion._unionTypes._ui4;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UI4;
- _typeUnion._unionTypes._ui4 = value;
- }
- }
-
- // VT_UI8
-
- public UInt64 AsUi8 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UI8, "variant");
- return _typeUnion._unionTypes._ui8;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UI8;
- _typeUnion._unionTypes._ui8 = value;
- }
- }
-
- // VT_INT
-
- public Int32 AsInt {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_INT, "variant");
- return _typeUnion._unionTypes._int;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_INT;
- _typeUnion._unionTypes._int = value;
- }
- }
-
- // VT_UINT
-
- public UInt32 AsUint {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UINT, "variant");
- return _typeUnion._unionTypes._uint;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UINT;
- _typeUnion._unionTypes._uint = value;
- }
- }
-
- // VT_BOOL
-
- public bool AsBool {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_BOOL, "variant");
- return _typeUnion._unionTypes._bool != 0;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_BOOL;
- _typeUnion._unionTypes._bool = value ? (short)-1 : (short)0;
- }
- }
-
- // VT_ERROR
-
- public Int32 AsError {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_ERROR, "variant");
- return _typeUnion._unionTypes._error;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_ERROR;
- _typeUnion._unionTypes._error = value;
- }
- }
-
- // VT_R4
-
- public Single AsR4 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_R4, "variant");
- return _typeUnion._unionTypes._r4;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_R4;
- _typeUnion._unionTypes._r4 = value;
- }
- }
-
- // VT_R8
-
- public Double AsR8 {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_R8, "variant");
- return _typeUnion._unionTypes._r8;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_R8;
- _typeUnion._unionTypes._r8 = value;
- }
- }
-
- // VT_DECIMAL
-
- public Decimal AsDecimal {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_DECIMAL, "variant");
- // The first byte of Decimal is unused, but usually set to 0
- Variant v = this;
- v._typeUnion._vt = 0;
- return v._decimal;
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_DECIMAL;
- _decimal = value;
- // _vt overlaps with _decimal, and should be set after setting _decimal
- _typeUnion._vt = (ushort)VarEnum.VT_DECIMAL;
- }
- }
-
- // VT_CY
-
- public Decimal AsCy {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_CY, "variant");
- return Decimal.FromOACurrency(_typeUnion._unionTypes._cy);
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_CY;
- _typeUnion._unionTypes._cy = Decimal.ToOACurrency(value);
- }
- }
-
- // VT_DATE
-
- public DateTime AsDate {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_DATE, "variant");
- return DateTime.FromOADate(_typeUnion._unionTypes._date);
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_DATE;
- _typeUnion._unionTypes._date = value.ToOADate();
- }
- }
-
- // VT_BSTR
-
- public String AsBstr {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_BSTR, "variant");
- return (string)Marshal.PtrToStringBSTR(this._typeUnion._unionTypes._bstr);
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_BSTR;
- this._typeUnion._unionTypes._bstr = Marshal.StringToBSTR(value);
- }
- }
-
- // VT_UNKNOWN
-
- public Object AsUnknown {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_UNKNOWN, "variant");
- if (_typeUnion._unionTypes._unknown == IntPtr.Zero)
- return null;
- return Marshal.GetObjectForIUnknown(_typeUnion._unionTypes._unknown);
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_UNKNOWN;
- if (value == null)
- _typeUnion._unionTypes._unknown = IntPtr.Zero;
- else
- _typeUnion._unionTypes._unknown = Marshal.GetIUnknownForObject(value);
- }
- }
-
- // VT_DISPATCH
-
- public Object AsDispatch {
- get {
- BCLDebug.Assert(VariantType == VarEnum.VT_DISPATCH, "variant");
- if (_typeUnion._unionTypes._dispatch == IntPtr.Zero)
- return null;
- return Marshal.GetObjectForIUnknown(_typeUnion._unionTypes._dispatch);
- }
- set {
- BCLDebug.Assert(IsEmpty, "variant"); // The setter can only be called once as VariantClear might be needed otherwise
- VariantType = VarEnum.VT_DISPATCH;
- if (value == null)
- _typeUnion._unionTypes._dispatch = IntPtr.Zero;
- else
- _typeUnion._unionTypes._dispatch = Marshal.GetIDispatchForObject(value);
- }
- }
-
-
- // *** END GENERATED CODE ***
-
- internal IntPtr AsByRefVariant
- {
- get {
- BCLDebug.Assert(VariantType == (VarEnum.VT_BYREF | VarEnum.VT_VARIANT), "variant");
- return _typeUnion._unionTypes._pvarVal;
- }
- }
-
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs
index 80b24f5529..7fa2420530 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs
@@ -35,7 +35,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[System.Runtime.CompilerServices.FriendAccessAllowed]
internal sealed class WindowsRuntimeImportAttribute : Attribute
{
- public WindowsRuntimeImportAttribute()
+ internal WindowsRuntimeImportAttribute()
{ }
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
index 702e0c9e52..b7dad17a6b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs
@@ -148,15 +148,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return CoerceScalarValue<String>(PropertyType.String);
}
- [Pure]
- public Object GetInspectable()
- {
- if (this.Type != PropertyType.Inspectable)
- throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Inspectable"), __HResults.TYPE_E_TYPEMISMATCH);
- Contract.EndContractBlock();
- return _data;
- }
-
[Pure]
public Guid GetGuid()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
index a5abb4f23e..3a896ecbe3 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
@@ -53,25 +53,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
this.items = CreateKeyValueArray(data.Count, data.GetEnumerator());
}
- internal ConstantSplittableMap(IMapView<TKey, TValue> data)
- {
- if (data == null)
- throw new ArgumentNullException(nameof(data));
-
- if (((UInt32)Int32.MaxValue) < data.Size)
- {
- Exception e = new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingDictionaryTooLarge"));
- e.SetErrorCode(__HResults.E_BOUNDS);
- throw e;
- }
-
- int size = (int)data.Size;
-
- this.firstItemIndex = 0;
- this.lastItemIndex = size - 1;
- this.items = CreateKeyValueArray(size, data.GetEnumerator());
- }
-
private ConstantSplittableMap(KeyValuePair<TKey, TValue>[] items, Int32 firstItemIndex, Int32 lastItemIndex)
{
@@ -94,22 +75,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return kvArray;
}
- private KeyValuePair<TKey, TValue>[] CreateKeyValueArray(Int32 count, IEnumerator<IKeyValuePair<TKey, TValue>> data)
- {
- KeyValuePair<TKey, TValue>[] kvArray = new KeyValuePair<TKey, TValue>[count];
-
- Int32 i = 0;
- while (data.MoveNext())
- {
- IKeyValuePair<TKey, TValue> current = data.Current;
- kvArray[i++] = new KeyValuePair<TKey, TValue>(current.Key, current.Value);
- }
-
- Array.Sort(kvArray, keyValuePairComparator);
-
- return kvArray;
- }
-
public int Count {
get {
@@ -179,14 +144,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
secondPartition = new ConstantSplittableMap<TKey, TValue>(items, pivot + 1, lastItemIndex);
}
- #region IReadOnlyDictionary members
-
- public bool ContainsKey(TKey key)
- {
- KeyValuePair<TKey, TValue> searchKey = new KeyValuePair<TKey, TValue>(key, default(TValue));
- int index = Array.BinarySearch(items, firstItemIndex, Count, searchKey, keyValuePairComparator);
- return index >= 0;
- }
+#region IReadOnlyDictionary members
public bool TryGetValue(TKey key, out TValue value)
{
@@ -203,24 +161,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return true;
}
- public TValue this[TKey key] {
- get {
- return Lookup(key);
- }
- }
-
- public IEnumerable<TKey> Keys {
- get {
- throw new NotImplementedException("NYI");
- }
- }
-
- public IEnumerable<TValue> Values {
- get {
- throw new NotImplementedException("NYI");
- }
- }
-
#endregion IReadOnlyDictionary members
#region IKeyValuePair Enumerator
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
index d575201bb9..9f822d5ced 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
@@ -123,7 +123,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
// We can safely skip access check because this is only used in full trust scenarios.
// And we have already verified that the property accessor is public.
- Debug.Assert(AppDomain.CurrentDomain.PermissionSet.IsUnrestricted());
return rtMethod.UnsafeInvoke(target, BindingFlags.Default, null, args, null);
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
index a77ff005b9..6982911a13 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVector.cs
@@ -57,9 +57,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
void Append(T value);
void RemoveAtEnd();
void Clear();
- [Pure]
- uint GetMany(uint startIndex, [Out] T[] items);
- void ReplaceAll(T[] items);
}
[ComImport]
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs
index 4380369754..627de8d400 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs
@@ -21,7 +21,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static class UnsafeNativeMethods
{
- [DllImport("api-ms-win-core-winrt-error-l1-1-1.dll", PreserveSig = false)]
+ [DllImport("api-ms-win-core-winrt-error-l1-1-0.dll", PreserveSig = false)]
[SuppressUnmanagedCodeSecurity]
internal static extern IRestrictedErrorInfo GetRestrictedErrorInfo();
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs
index a786880fab..551ee65153 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs
@@ -21,12 +21,10 @@ internal static class WindowsRuntimeBufferHelper {
[DllImport(JitHelpers.QCall)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private unsafe extern static void StoreOverlappedPtrInCCW(ObjectHandleOnStack windowsRuntimeBuffer, NativeOverlapped* overlapped);
[FriendAccessAllowed]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void StoreOverlappedInCCW(Object windowsRuntimeBuffer, NativeOverlapped* overlapped) {
StoreOverlappedPtrInCCW(JitHelpers.GetObjectHandleOnStack(ref windowsRuntimeBuffer), overlapped);
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
index a7ad4912de..57655ec861 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
@@ -135,12 +135,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
restTokens = null;
}
- internal EventRegistrationTokenList(EventRegistrationTokenList list)
- {
- firstToken = list.firstToken;
- restTokens = list.restTokens;
- }
-
// Push a new token into this list
// Returns true if you need to copy back this list into the dictionary (so that you
// don't lose change outside the dictionary). false otherwise.
@@ -1203,42 +1197,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
return activationFactory;
}
-#if FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
- // Currently we use only a single class activator since we have a requirement that all class activations come from the same
- // app base and we haven't sorted through the various code sharing implications of spinning up multiple AppDomains. This
- // holds the IWinRTClassActivator* that is used for the process
- private static IntPtr s_pClassActivator = IntPtr.Zero;
-
- internal static IntPtr GetClassActivatorForApplication(string appBase)
- {
- if (s_pClassActivator == IntPtr.Zero)
- {
- AppDomainSetup hostDomainSetup = new AppDomainSetup()
- {
- ApplicationBase = appBase,
- };
-
- AppDomain hostDomain = AppDomain.CreateDomain(Environment.GetResourceString("WinRTHostDomainName", appBase), null, hostDomainSetup);
- WinRTClassActivator activator = (WinRTClassActivator)hostDomain.CreateInstanceAndUnwrap(typeof(WinRTClassActivator).Assembly.FullName, typeof(WinRTClassActivator).FullName);
- IntPtr pActivator = activator.GetIWinRTClassActivator();
-
- if (Interlocked.CompareExchange(ref s_pClassActivator, pActivator, IntPtr.Zero) != IntPtr.Zero)
- {
- Marshal.Release(pActivator);
- activator = null;
-
- try
- {
- AppDomain.Unload(hostDomain);
- }
- catch (CannotUnloadAppDomainException) { }
- }
- }
-
- Marshal.AddRef(s_pClassActivator);
- return s_pClassActivator;
- }
-#endif // FEATURE_COMINTEROP_WINRT_DESKTOP_HOST
#endif // FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
index 9ca959c528..f097c6a0db 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs
@@ -16,94 +16,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime
using System.Runtime.InteropServices;
using System.Security;
- public static class WindowsRuntimeMetadata
+ internal static class WindowsRuntimeMetadata
{
- // Wrapper for Win8 API RoResolveNamespace with default Windows SDK path as installed .winmd files in %WINDIR%\system32\WinMetadata.
- public static IEnumerable<string> ResolveNamespace(string namespaceName, IEnumerable<string> packageGraphFilePaths)
- {
- return ResolveNamespace(namespaceName, null, packageGraphFilePaths);
- }
-
- // Wrapper for Win8 API RoResolveNamespace.
- public static IEnumerable<string> ResolveNamespace(string namespaceName, string windowsSdkFilePath, IEnumerable<string> packageGraphFilePaths)
- {
- if (namespaceName == null)
- throw new ArgumentNullException(nameof(namespaceName));
- Contract.EndContractBlock();
-
- string[] packageGraphFilePathsArray = null;
- if (packageGraphFilePaths != null)
- {
- List<string> packageGraphFilePathsList = new List<string>(packageGraphFilePaths);
- packageGraphFilePathsArray = new string[packageGraphFilePathsList.Count];
-
- int index = 0;
- foreach (string packageGraphFilePath in packageGraphFilePathsList)
- {
- packageGraphFilePathsArray[index] = packageGraphFilePath;
- index++;
- }
- }
-
- string[] retFileNames = null;
- nResolveNamespace(
- namespaceName,
- windowsSdkFilePath,
- packageGraphFilePathsArray,
- ((packageGraphFilePathsArray == null) ? 0 : packageGraphFilePathsArray.Length),
- JitHelpers.GetObjectHandleOnStack(ref retFileNames));
-
- return retFileNames;
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void nResolveNamespace(
- string namespaceName,
- string windowsSdkFilePath,
- string[] packageGraphFilePaths,
- int cPackageGraphFilePaths,
- ObjectHandleOnStack retFileNames);
+ private static EventHandler<DesignerNamespaceResolveEventArgs> DesignerNamespaceResolve;
-#if FEATURE_REFLECTION_ONLY_LOAD
- [method: System.Security.SecurityCritical]
- public static event EventHandler<NamespaceResolveEventArgs> ReflectionOnlyNamespaceResolve;
-
- internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
- {
- EventHandler<NamespaceResolveEventArgs> eventHandler = ReflectionOnlyNamespaceResolve;
- if (eventHandler != null)
- {
- Delegate[] ds = eventHandler.GetInvocationList();
- int len = ds.Length;
- for (int i = 0; i < len; i++)
- {
- NamespaceResolveEventArgs eventArgs = new NamespaceResolveEventArgs(namespaceName, assembly);
-
- ((EventHandler<NamespaceResolveEventArgs>)ds[i])(appDomain, eventArgs);
-
- Collection<Assembly> assembliesCollection = eventArgs.ResolvedAssemblies;
- if (assembliesCollection.Count > 0)
- {
- RuntimeAssembly[] retAssemblies = new RuntimeAssembly[assembliesCollection.Count];
- int retIndex = 0;
- foreach (Assembly asm in assembliesCollection)
- {
- retAssemblies[retIndex] = AppDomain.GetRuntimeAssembly(asm);
- retIndex++;
- }
- return retAssemblies;
- }
- }
- }
-
- return null;
- }
-#endif //FEATURE_REFLECTION_ONLY
-
- [method: System.Security.SecurityCritical]
- public static event EventHandler<DesignerNamespaceResolveEventArgs> DesignerNamespaceResolve;
-
internal static string[] OnDesignerNamespaceResolveEvent(AppDomain appDomain, string namespaceName)
{
EventHandler<DesignerNamespaceResolveEventArgs> eventHandler = DesignerNamespaceResolve;
@@ -142,7 +58,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
#if FEATURE_REFLECTION_ONLY_LOAD
- [ComVisible(false)]
public class NamespaceResolveEventArgs : EventArgs
{
private string _NamespaceName;
@@ -182,20 +97,11 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
#endif //FEATURE_REFLECTION_ONLY
- [ComVisible(false)]
- public class DesignerNamespaceResolveEventArgs : EventArgs
+ internal class DesignerNamespaceResolveEventArgs : EventArgs
{
private string _NamespaceName;
private Collection<string> _ResolvedAssemblyFiles;
- public string NamespaceName
- {
- get
- {
- return _NamespaceName;
- }
- }
-
public Collection<string> ResolvedAssemblyFiles
{
get
diff --git a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
index e158a5aa8a..2be8b13274 100644
--- a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
+++ b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
@@ -13,15 +13,11 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
-#if FEATURE_HOST_ASSEMBLY_RESOLVER
namespace System.Runtime.Loader
{
public abstract class AssemblyLoadContext
{
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern bool OverrideDefaultAssemblyLoadContextForCurrentDomain(IntPtr ptrNativeAssemblyLoadContext);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
@@ -30,16 +26,11 @@ namespace System.Runtime.Loader
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern IntPtr InitializeAssemblyLoadContext(IntPtr ptrAssemblyLoadContext, bool fRepresentsTPALoadContext);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern IntPtr LoadFromAssemblyName(IntPtr ptrNativeAssemblyLoadContext, bool fRepresentsTPALoadContext);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern IntPtr LoadFromStream(IntPtr ptrNativeAssemblyLoadContext, IntPtr ptrAssemblyArray, int iAssemblyArrayLen, IntPtr ptrSymbols, int iSymbolArrayLen, ObjectHandleOnStack retAssembly);
-#if FEATURE_MULTICOREJIT
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
internal static extern void InternalSetProfileRoot(string directoryPath);
@@ -47,7 +38,6 @@ namespace System.Runtime.Loader
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
internal static extern void InternalStartProfile(string profile, IntPtr ptrNativeAssemblyLoadContext);
-#endif // FEATURE_MULTICOREJIT
protected AssemblyLoadContext()
{
@@ -75,7 +65,7 @@ namespace System.Runtime.Loader
// Since unloading an AssemblyLoadContext is not yet implemented, this is a temporary solution to raise the
// Unloading event on process exit. Register for the current AppDomain's ProcessExit event, and the handler will in
// turn raise the Unloading event.
- AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
+ AppContext.Unloading += OnAppContextUnloading;
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
@@ -354,28 +344,6 @@ namespace System.Runtime.Loader
return s_DefaultAssemblyLoadContext;
}
}
-
- // This will be used to set the AssemblyLoadContext for DefaultContext, for the AppDomain,
- // by a host. Once set, the runtime will invoke the LoadFromAssemblyName method against it to perform
- // assembly loads for the DefaultContext.
- //
- // This method will throw if the Default AssemblyLoadContext is already set or the Binding model is already locked.
- public static void InitializeDefaultContext(AssemblyLoadContext context)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- // Try to override the default assembly load context
- if (!AssemblyLoadContext.OverrideDefaultAssemblyLoadContextForCurrentDomain(context.m_pNativeAssemblyLoadContext))
- {
- throw new InvalidOperationException(Environment.GetResourceString("AppDomain_BindingModelIsLocked"));
- }
-
- // Update the managed side as well.
- s_DefaultAssemblyLoadContext = context;
- }
// This call opens and closes the file, but does not add the
// assembly to the domain.
@@ -433,20 +401,16 @@ namespace System.Runtime.Loader
// Set the root directory path for profile optimization.
public void SetProfileOptimizationRoot(string directoryPath)
{
-#if FEATURE_MULTICOREJIT
InternalSetProfileRoot(directoryPath);
-#endif // FEATURE_MULTICOREJIT
}
// Start profile optimization for the specified profile name.
public void StartProfileOptimization(string profile)
{
-#if FEATURE_MULTICOREJIT
InternalStartProfile(profile, m_pNativeAssemblyLoadContext);
-#endif // FEATURE_MULTICOREJI
}
- private void OnProcessExit(object sender, EventArgs e)
+ private void OnAppContextUnloading(object sender, EventArgs e)
{
var unloading = Unloading;
if (unloading != null)
@@ -526,4 +490,3 @@ namespace System.Runtime.Loader
}
}
-#endif // FEATURE_HOST_ASSEMBLY_RESOLVER
diff --git a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
index bd87d9027c..84b8ba9e1e 100644
--- a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
+++ b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs
@@ -20,7 +20,6 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
-using System.Security.Permissions;
using System.Runtime.Versioning;
using System.Diagnostics;
using System.Diagnostics.Contracts;
@@ -394,7 +393,6 @@ namespace System.Runtime
GC.SuppressFinalize(this);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void Dispose(bool disposing)
{
// This is just bookkeeping to ensure multiple threads can really
@@ -472,10 +470,6 @@ namespace System.Runtime
_availPageFile >> 20, _totalFreeAddressSpace >> 20,
_lastKnownFreeAddressSpace >> 20, _reservedMem);
}
-
- public String StackTrace {
- get { return _stackTrace; }
- }
}
#endif
}
diff --git a/src/mscorlib/src/System/Runtime/ProfileOptimization.cs b/src/mscorlib/src/System/Runtime/ProfileOptimization.cs
deleted file mode 100644
index 1e42308ecc..0000000000
--- a/src/mscorlib/src/System/Runtime/ProfileOptimization.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// This class defines entry point for multi-core JIT API
-//
-//
-namespace System.Runtime {
-
- using System;
-
- using System.Reflection;
-
- using System.Security;
- using System.Security.Permissions;
-
- using System.Runtime;
- using System.Runtime.InteropServices;
- using System.Runtime.Versioning;
- using System.Runtime.CompilerServices;
-
-#if FEATURE_MULTICOREJIT
-
- public static class ProfileOptimization
- {
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern void InternalSetProfileRoot(string directoryPath);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern void InternalStartProfile(string profile, IntPtr ptrNativeAssemblyLoadContext);
-
- public static void SetProfileRoot(string directoryPath)
- {
- InternalSetProfileRoot(directoryPath);
- }
-
- public static void StartProfile(string profile)
- {
- InternalStartProfile(profile, IntPtr.Zero);
- }
- }
-
-#endif
-}
-
diff --git a/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs b/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs
index eb5a186b65..6d6d6f3e77 100644
--- a/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs
+++ b/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs
@@ -17,20 +17,16 @@
===========================================================*/
using System;
-using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.Runtime.ConstrainedExecution
{
- [System.Runtime.InteropServices.ComVisible(true)]
public abstract class CriticalFinalizerObject
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalFinalizerObject()
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~CriticalFinalizerObject()
{
}
diff --git a/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs b/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs
index d9774d636b..67c934d034 100644
--- a/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs
@@ -23,7 +23,7 @@ namespace System.Runtime.ConstrainedExecution
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
- public sealed class PrePrepareMethodAttribute : Attribute
+ internal sealed class PrePrepareMethodAttribute : Attribute
{
public PrePrepareMethodAttribute()
{
diff --git a/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs b/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs
index 5555670498..ed3444e15d 100644
--- a/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs
+++ b/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs
@@ -19,10 +19,7 @@ namespace System.Runtime.Remoting
using System;
using System.Runtime.InteropServices;
- [ClassInterface(ClassInterfaceType.AutoDual)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ObjectHandle:
- IObjectHandle
+ public class ObjectHandle
{
private Object WrappedObject;
@@ -30,12 +27,12 @@ namespace System.Runtime.Remoting
{
}
- public ObjectHandle(Object o)
+ internal ObjectHandle(Object o)
{
WrappedObject = o;
}
- public Object Unwrap()
+ internal Object Unwrap()
{
return WrappedObject;
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
index b710ed0b3a..27f7ecf9d2 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs
@@ -17,8 +17,7 @@ namespace System.Runtime.Serialization {
using System.Globalization;
using System.Diagnostics.Contracts;
-[System.Runtime.InteropServices.ComVisible(true)]
- public class FormatterConverter : IFormatterConverter {
+ internal class FormatterConverter : IFormatterConverter {
public FormatterConverter() {
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
index 27c3f15136..c3f9eb4452 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
@@ -18,10 +18,6 @@ namespace System.Runtime.Serialization {
using System.Collections;
using System.Collections.Generic;
using System.Security;
- using System.Security.Permissions;
-#if FEATURE_SERIALIZATION
- using System.Runtime.Serialization.Formatters;
-#endif
using System.Runtime.Remoting;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
@@ -32,211 +28,7 @@ namespace System.Runtime.Serialization {
using System.Diagnostics;
using System.Diagnostics.Contracts;
- [System.Runtime.InteropServices.ComVisible(true)]
public static class FormatterServices {
-#if FEATURE_SERIALIZATION
- internal static Dictionary<MemberHolder, MemberInfo[]> m_MemberInfoTable = new Dictionary<MemberHolder, MemberInfo[]>(32);
- private static bool unsafeTypeForwardersIsEnabled = false;
-
- private static volatile bool unsafeTypeForwardersIsEnabledInitialized = false;
-
- private static Object s_FormatterServicesSyncObject = null;
-
- private static Object formatterServicesSyncObject
- {
- get
- {
- if (s_FormatterServicesSyncObject == null)
- {
- Object o = new Object();
- Interlocked.CompareExchange<Object>(ref s_FormatterServicesSyncObject, o, null);
- }
- return s_FormatterServicesSyncObject;
- }
- }
-
- static FormatterServices()
- {
- // Static initialization touches security critical types, so we need an
- // explicit static constructor to allow us to mark it safe critical.
- }
-
- private static MemberInfo[] GetSerializableMembers(RuntimeType type) {
- // get the list of all fields
- FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
- int countProper = 0;
- for (int i = 0; i < fields.Length; i++) {
- if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
- continue;
- countProper++;
- }
- if (countProper != fields.Length) {
- FieldInfo[] properFields = new FieldInfo[countProper];
- countProper = 0;
- for (int i = 0; i < fields.Length; i++) {
- if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
- continue;
- properFields[countProper] = fields[i];
- countProper++;
- }
- return properFields;
- }
- else
- return fields;
- }
-
- private static bool CheckSerializable(RuntimeType type) {
- if (type.IsSerializable) {
- return true;
- }
- return false;
- }
-
- private static MemberInfo[] InternalGetSerializableMembers(RuntimeType type) {
- List<SerializationFieldInfo> allMembers = null;
- MemberInfo[] typeMembers;
- FieldInfo [] typeFields;
- RuntimeType parentType;
-
- Debug.Assert((object)type != null, "[GetAllSerializableMembers]type!=null");
-
- if (type.IsInterface) {
- return new MemberInfo[0];
- }
-
- if (!(CheckSerializable(type))) {
- throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", type.FullName, type.Module.Assembly.FullName));
- }
-
- //Get all of the serializable members in the class to be serialized.
- typeMembers = GetSerializableMembers(type);
-
- //If this class doesn't extend directly from object, walk its hierarchy and
- //get all of the private and assembly-access fields (e.g. all fields that aren't
- //virtual) and include them in the list of things to be serialized.
- parentType = (RuntimeType)(type.BaseType);
- if (parentType != null && parentType != (RuntimeType)typeof(Object)) {
- RuntimeType[] parentTypes = null;
- int parentTypeCount = 0;
- bool classNamesUnique = GetParentTypes(parentType, out parentTypes, out parentTypeCount);
- if (parentTypeCount > 0){
- allMembers = new List<SerializationFieldInfo>();
- for (int i = 0; i < parentTypeCount;i++){
- parentType = parentTypes[i];
- if (!CheckSerializable(parentType)) {
- throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", parentType.FullName, parentType.Module.Assembly.FullName));
- }
-
- typeFields = parentType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
- String typeName = classNamesUnique ? parentType.Name : parentType.FullName;
- foreach (FieldInfo field in typeFields) {
- // Family and Assembly fields will be gathered by the type itself.
- if (!field.IsNotSerialized) {
- allMembers.Add(new SerializationFieldInfo((RuntimeFieldInfo)field, typeName));
- }
- }
- }
- //If we actually found any new MemberInfo's, we need to create a new MemberInfo array and
- //copy all of the members which we've found so far into that.
- if (allMembers!=null && allMembers.Count>0) {
- MemberInfo[] membersTemp = new MemberInfo[allMembers.Count + typeMembers.Length];
- Array.Copy(typeMembers, membersTemp, typeMembers.Length);
- ((ICollection)allMembers).CopyTo(membersTemp, typeMembers.Length);
- typeMembers = membersTemp;
- }
- }
- }
- return typeMembers;
- }
-
- private static bool GetParentTypes(RuntimeType parentType, out RuntimeType[] parentTypes, out int parentTypeCount){
- //Check if there are any dup class names. Then we need to include as part of
- //typeName to prefix the Field names in SerializationFieldInfo
- /*out*/ parentTypes = null;
- /*out*/ parentTypeCount = 0;
- bool unique = true;
- RuntimeType objectType = (RuntimeType)typeof(object);
- for (RuntimeType t1 = parentType; t1 != objectType; t1 = (RuntimeType)t1.BaseType)
- {
- if (t1.IsInterface) continue;
- string t1Name = t1.Name;
- for(int i=0;unique && i<parentTypeCount;i++){
- string t2Name = parentTypes[i].Name;
- if (t2Name.Length == t1Name.Length && t2Name[0] == t1Name[0] && t1Name == t2Name){
- unique = false;
- break;
- }
- }
- //expand array if needed
- if (parentTypes == null || parentTypeCount == parentTypes.Length){
- RuntimeType[] tempParentTypes = new RuntimeType[Math.Max(parentTypeCount*2, 12)];
- if (parentTypes != null)
- Array.Copy(parentTypes, 0, tempParentTypes, 0, parentTypeCount);
- parentTypes = tempParentTypes;
- }
- parentTypes[parentTypeCount++] = t1;
- }
- return unique;
- }
-
- // Get all of the Serializable members for a particular class. For all practical intents and
- // purposes, this is the non-transient, non-static members (fields and properties). In order to
- // be included, properties must have both a getter and a setter. N.B.: A class
- // which implements ISerializable or has a serialization surrogate may not use all of these members
- // (or may have additional members).
- public static MemberInfo[] GetSerializableMembers(Type type) {
- return GetSerializableMembers(type, new StreamingContext(StreamingContextStates.All));
- }
-
- // Get all of the Serializable Members for a particular class. If we're not cloning, this is all
- // non-transient, non-static fields. If we are cloning, include the transient fields as well since
- // we know that we're going to live inside of the same context.
- public static MemberInfo[] GetSerializableMembers(Type type, StreamingContext context) {
- MemberInfo[] members;
-
- if ((object)type==null) {
- throw new ArgumentNullException(nameof(type));
- }
- Contract.EndContractBlock();
-
- if (!(type is RuntimeType)) {
- throw new SerializationException(Environment.GetResourceString("Serialization_InvalidType", type.ToString()));
- }
-
- MemberHolder mh = new MemberHolder(type, context);
-
- //If we've already gathered the members for this type, just return them.
- if (m_MemberInfoTable.ContainsKey(mh)) {
- return m_MemberInfoTable[mh];
- }
-
- lock (formatterServicesSyncObject) {
- //If we've already gathered the members for this type, just return them.
- if (m_MemberInfoTable.ContainsKey(mh)) {
- return m_MemberInfoTable[mh];
- }
-
- members = InternalGetSerializableMembers((RuntimeType)type);
-
- m_MemberInfoTable[mh] = members;
- }
-
- return members;
- }
-
- static readonly Type[] advancedTypes = new Type[]{
- typeof(System.DelegateSerializationHolder),
- };
-
- public static void CheckTypeSecurity(Type t, TypeFilterLevel securityLevel) {
- if (securityLevel == TypeFilterLevel.Low){
- for(int i=0;i<advancedTypes.Length;i++){
- if (advancedTypes[i].IsAssignableFrom(t))
- throw new SecurityException(Environment.GetResourceString("Serialization_TypeSecurity", advancedTypes[i].FullName, t.FullName));
- }
- }
- }
-#endif // FEATURE_SERIALIZATION
// Gets a new instance of the object. The entire object is initalized to 0 and no
// constructors have been run. **THIS MEANS THAT THE OBJECT MAY NOT BE IN A STATE
@@ -258,188 +50,9 @@ namespace System.Runtime.Serialization {
return nativeGetUninitializedObject((RuntimeType)type);
}
- public static Object GetSafeUninitializedObject(Type type) {
- if ((object)type == null) {
- throw new ArgumentNullException(nameof(type));
- }
- Contract.EndContractBlock();
-
- if (!(type is RuntimeType)) {
- throw new SerializationException(Environment.GetResourceString("Serialization_InvalidType", type.ToString()));
- }
-
- try {
- return nativeGetSafeUninitializedObject((RuntimeType)type);
- }
- catch(SecurityException e) {
- throw new SerializationException(Environment.GetResourceString("Serialization_Security", type.FullName), e);
- }
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern Object nativeGetSafeUninitializedObject(RuntimeType type);
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern Object nativeGetUninitializedObject(RuntimeType type);
-#if FEATURE_SERIALIZATION
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool GetEnableUnsafeTypeForwarders();
-
- internal static bool UnsafeTypeForwardersIsEnabled()
- {
- if (!unsafeTypeForwardersIsEnabledInitialized)
- {
- unsafeTypeForwardersIsEnabled = GetEnableUnsafeTypeForwarders();
- unsafeTypeForwardersIsEnabledInitialized = true;
- }
-
- return unsafeTypeForwardersIsEnabled;
- }
-#endif
private static Binder s_binder = Type.DefaultBinder;
- internal static void SerializationSetValue(MemberInfo fi, Object target, Object value)
- {
- Contract.Requires(fi != null);
-
- RtFieldInfo rtField = fi as RtFieldInfo;
-
- if (rtField != null)
- {
- rtField.CheckConsistency(target);
- rtField.UnsafeSetValue(target, value, BindingFlags.Default, s_binder, null);
- return;
- }
-
- SerializationFieldInfo serField = fi as SerializationFieldInfo;
- if (serField != null)
- {
- serField.InternalSetValue(target, value, BindingFlags.Default, s_binder, null);
- return;
- }
-
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldInfo"));
- }
-
- // Fill in the members of obj with the data contained in data.
- // Returns the number of members populated.
- //
- public static Object PopulateObjectMembers(Object obj, MemberInfo[] members, Object[] data) {
- if (obj==null) {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (members==null) {
- throw new ArgumentNullException(nameof(members));
- }
-
- if (data==null) {
- throw new ArgumentNullException(nameof(data));
- }
-
- if (members.Length!=data.Length) {
- throw new ArgumentException(Environment.GetResourceString("Argument_DataLengthDifferent"));
- }
- Contract.EndContractBlock();
-
- MemberInfo mi;
-
- BCLDebug.Trace("SER", "[PopulateObjectMembers]Enter.");
-
- for (int i=0; i<members.Length; i++) {
- mi = members[i];
-
- if (mi==null) {
- throw new ArgumentNullException(nameof(members), Environment.GetResourceString("ArgumentNull_NullMember", i));
- }
-
- //If we find an empty, it means that the value was never set during deserialization.
- //This is either a forward reference or a null. In either case, this may break some of the
- //invariants mantained by the setter, so we'll do nothing with it for right now.
- if (data[i]!=null) {
- if (mi.MemberType==MemberTypes.Field) {
- SerializationSetValue(mi, obj, data[i]);
- } else {
- throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMemberInfo"));
- }
-
- BCLDebug.Trace("SER", "[PopulateObjectMembers]\tType:", obj.GetType(), "\tMember:",
- members[i].Name, " with member type: ", ((FieldInfo)members[i]).FieldType);
- }
- //Console.WriteLine("X");
- }
-
- BCLDebug.Trace("SER", "[PopulateObjectMembers]Leave.");
-
- return obj;
- }
-
- // Extracts the data from obj. members is the array of members which we wish to
- // extract (must be FieldInfos or PropertyInfos). For each supplied member, extract the matching value and
- // return it in a Object[] of the same size.
- //
- public static Object[] GetObjectData(Object obj, MemberInfo[] members) {
-
- if (obj==null) {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (members==null) {
- throw new ArgumentNullException(nameof(members));
- }
- Contract.EndContractBlock();
-
- int numberOfMembers = members.Length;
-
- Object[] data = new Object[numberOfMembers];
- MemberInfo mi;
-
- for (int i=0; i<numberOfMembers; i++) {
- mi=members[i];
-
- if (mi==null) {
- throw new ArgumentNullException(nameof(members), Environment.GetResourceString("ArgumentNull_NullMember", i));
- }
-
- if (mi.MemberType==MemberTypes.Field) {
- Debug.Assert(mi is RuntimeFieldInfo || mi is SerializationFieldInfo,
- "[FormatterServices.GetObjectData]mi is RuntimeFieldInfo || mi is SerializationFieldInfo.");
-
- RtFieldInfo rfi = mi as RtFieldInfo;
- if (rfi != null) {
- rfi.CheckConsistency(obj);
- data[i] = rfi.UnsafeGetValue(obj);
- } else {
- data[i] = ((SerializationFieldInfo)mi).InternalGetValue(obj);
- }
- } else {
- throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMemberInfo"));
- }
- }
-
- return data;
- }
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public static ISerializationSurrogate GetSurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
- {
- if (innerSurrogate == null)
- throw new ArgumentNullException(nameof(innerSurrogate));
- Contract.EndContractBlock();
- return new SurrogateForCyclicalReference(innerSurrogate);
- }
-
- /*=============================GetTypeFromAssembly==============================
- **Action:
- **Returns:
- **Arguments:
- **Exceptions:
- ==============================================================================*/
- public static Type GetTypeFromAssembly(Assembly assem, String name) {
- if (assem==null)
- throw new ArgumentNullException(nameof(assem));
- Contract.EndContractBlock();
- return assem.GetType(name, false, false);
- }
/*============================LoadAssemblyFromString============================
**Action: Loads an assembly from a given string. The current assembly loading story
@@ -460,99 +73,6 @@ namespace System.Runtime.Serialization {
Assembly found = Assembly.Load(assemblyName);
return found;
}
-
- internal static Assembly LoadAssemblyFromStringNoThrow(String assemblyName) {
- try {
- return LoadAssemblyFromString(assemblyName);
- }
- catch (Exception e){
- BCLDebug.Trace("SER", "[LoadAssemblyFromString]", e.ToString());
- }
- return null;
- }
-
- internal static string GetClrAssemblyName(Type type, out bool hasTypeForwardedFrom) {
- if ((object)type == null) {
- throw new ArgumentNullException(nameof(type));
- }
-
- object[] typeAttributes = type.GetCustomAttributes(typeof(TypeForwardedFromAttribute), false);
- if (typeAttributes != null && typeAttributes.Length > 0) {
- hasTypeForwardedFrom = true;
- TypeForwardedFromAttribute typeForwardedFromAttribute = (TypeForwardedFromAttribute)typeAttributes[0];
- return typeForwardedFromAttribute.AssemblyFullName;
- }
- else {
- hasTypeForwardedFrom = false;
- return type.Assembly.FullName;
- }
- }
-
- internal static string GetClrTypeFullName(Type type) {
- if (type.IsArray) {
- return GetClrTypeFullNameForArray(type);
- }
- else {
- return GetClrTypeFullNameForNonArrayTypes(type);
- }
- }
-
- static string GetClrTypeFullNameForArray(Type type) {
- int rank = type.GetArrayRank();
- if (rank == 1)
- {
- return String.Format(CultureInfo.InvariantCulture, "{0}{1}", GetClrTypeFullName(type.GetElementType()), "[]");
- }
- else
- {
- StringBuilder builder = new StringBuilder(GetClrTypeFullName(type.GetElementType())).Append("[");
- for (int commaIndex = 1; commaIndex < rank; commaIndex++)
- {
- builder.Append(",");
- }
- builder.Append("]");
- return builder.ToString();
- }
- }
-
- static string GetClrTypeFullNameForNonArrayTypes(Type type) {
- if (!type.IsGenericType) {
- return type.FullName;
- }
-
- Type[] genericArguments = type.GetGenericArguments();
- StringBuilder builder = new StringBuilder(type.GetGenericTypeDefinition().FullName).Append("[");
- bool hasTypeForwardedFrom;
-
- foreach (Type genericArgument in genericArguments) {
- builder.Append("[").Append(GetClrTypeFullName(genericArgument)).Append(", ");
- builder.Append(GetClrAssemblyName(genericArgument, out hasTypeForwardedFrom)).Append("],");
- }
-
- //remove the last comma and close typename for generic with a close bracket
- return builder.Remove(builder.Length - 1, 1).Append("]").ToString();
- }
- }
-
- internal sealed class SurrogateForCyclicalReference : ISerializationSurrogate
- {
- ISerializationSurrogate innerSurrogate;
- internal SurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
- {
- if (innerSurrogate == null)
- throw new ArgumentNullException(nameof(innerSurrogate));
- this.innerSurrogate = innerSurrogate;
- }
-
- public void GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
- {
- innerSurrogate.GetObjectData(obj, info, context);
- }
-
- public Object SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
- {
- return innerSurrogate.SetObjectData(obj, info, context, selector);
- }
}
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs b/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs
index e2497e5d34..2911a4016e 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.Serialization {
using System;
// Interface does not need to be marked with the serializable attribute
- [System.Runtime.InteropServices.ComVisible(true)]
public interface IDeserializationCallback {
void OnDeserialization(Object sender);
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/IFormatter.cs b/src/mscorlib/src/System/Runtime/Serialization/IFormatter.cs
deleted file mode 100644
index 8d91d95acf..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/IFormatter.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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.
-
-/*============================================================
-**
-** Interface: IFormatter;
-**
-**
-** Purpose: The interface for all formatters.
-**
-**
-===========================================================*/
-namespace System.Runtime.Serialization {
- using System.Runtime.Remoting;
- using System;
- using System.IO;
-
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface IFormatter {
- Object Deserialize(Stream serializationStream);
-
- void Serialize(Stream serializationStream, Object graph);
-
-
- ISurrogateSelector SurrogateSelector {
- get;
- set;
- }
-
- SerializationBinder Binder {
- get;
- set;
- }
-
- StreamingContext Context {
- get;
- set;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs b/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs
index 182cc93412..0be0db9acd 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs
@@ -17,7 +17,6 @@ namespace System.Runtime.Serialization {
using System;
[CLSCompliant(false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public interface IFormatterConverter {
Object Convert(Object value, Type type);
Object Convert(Object value, TypeCode typeCode);
diff --git a/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs b/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs
index 42662a10f6..ef5ee6ade0 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs
@@ -18,9 +18,7 @@
namespace System.Runtime.Serialization {
using System;
- using System.Security.Permissions;
// Interface does not need to be marked with the serializable attribute
-[System.Runtime.InteropServices.ComVisible(true)]
public interface IObjectReference {
Object GetRealObject(StreamingContext context);
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs b/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs
index fc283d41f1..816aa0484b 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs
@@ -16,11 +16,9 @@
namespace System.Runtime.Serialization {
using System.Runtime.Remoting;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System;
using System.Reflection;
- [System.Runtime.InteropServices.ComVisible(true)]
public interface ISerializable {
void GetObjectData(SerializationInfo info, StreamingContext context);
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/ISerializationSurrogate.cs b/src/mscorlib/src/System/Runtime/Serialization/ISerializationSurrogate.cs
deleted file mode 100644
index 226bbdcc75..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/ISerializationSurrogate.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.
-
-/*============================================================
-**
-** Interface: ISurrogate
-**
-**
-** Purpose: The interface implemented by an object which
-** supports surrogates.
-**
-**
-===========================================================*/
-namespace System.Runtime.Serialization {
- using System.Runtime.Remoting;
- using System.Runtime.Serialization;
- using System.Security.Permissions;
- using System;
- using System.Reflection;
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ISerializationSurrogate {
- // Interface does not need to be marked with the serializable attribute
- // Returns a SerializationInfo completely populated with all of the data needed to reinstantiate the
- // the object at the other end of serialization.
- //
- void GetObjectData(Object obj, SerializationInfo info, StreamingContext context);
-
- // Reinflate the object using all of the information in data. The information in
- // members is used to find the particular field or property which needs to be set.
- //
- Object SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/ISurrogateSelector.cs b/src/mscorlib/src/System/Runtime/Serialization/ISurrogateSelector.cs
deleted file mode 100644
index 87b7845894..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/ISurrogateSelector.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.
-
-/*============================================================
-**
-** Interface: ISurrogateSelector
-**
-**
-** Purpose: A user-supplied class for doing the type to surrogate
-** mapping.
-**
-**
-===========================================================*/
-namespace System.Runtime.Serialization {
-
- using System.Runtime.Remoting;
- using System.Security.Permissions;
- using System;
-[System.Runtime.InteropServices.ComVisible(true)]
- public interface ISurrogateSelector {
- // Interface does not need to be marked with the serializable attribute
- // Specifies the next ISurrogateSelector to be examined for surrogates if the current
- // instance doesn't have a surrogate for the given type and assembly in the given context.
- void ChainSelector(ISurrogateSelector selector);
-
- // Returns the appropriate surrogate for the given type in the given context.
- ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector);
-
-
- // Return the next surrogate in the chain. Returns null if no more exist.
- ISurrogateSelector GetNextSelector();
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/MemberHolder.cs b/src/mscorlib/src/System/Runtime/Serialization/MemberHolder.cs
deleted file mode 100644
index 1303e40c27..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/MemberHolder.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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.
-
-/*============================================================
-**
-**
-**
-** Purpose: This is a lightweight class designed to hold the members
-** and StreamingContext for a particular class.
-**
-**
-============================================================*/
-namespace System.Runtime.Serialization {
-
- using System.Runtime.Remoting;
- using System;
- using System.Reflection;
- [Serializable]
- internal class MemberHolder {
-// disable csharp compiler warning #0414: field assigned unused value
-#pragma warning disable 0414
- internal MemberInfo[] members = null;
-#pragma warning restore 0414
- internal Type memberType;
- internal StreamingContext context;
-
- internal MemberHolder(Type type, StreamingContext ctx) {
- memberType = type;
- context = ctx;
- }
-
- public override int GetHashCode() {
- return memberType.GetHashCode();
- }
-
- public override bool Equals(Object obj) {
- if (!(obj is MemberHolder)) {
- return false;
- }
-
- MemberHolder temp = (MemberHolder)obj;
-
- if (Object.ReferenceEquals(temp.memberType, memberType) && temp.context.State == context.State) {
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs b/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs
index 585d367605..260e873bc7 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// 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;
@@ -211,10 +211,7 @@ namespace System.Runtime.Serialization
private StreamingContext m_streamingContext;
private List<object> m_serializedStates = new List<object>();
- internal SafeSerializationEventArgs(StreamingContext streamingContext)
- {
- m_streamingContext = streamingContext;
- }
+ internal SafeSerializationEventArgs() {}
public void AddSerializedState(ISafeSerializationData serializedState)
{
@@ -226,11 +223,6 @@ namespace System.Runtime.Serialization
m_serializedStates.Add(serializedState);
}
- internal IList<object> SerializedStates
- {
- get { return m_serializedStates; }
- }
-
public StreamingContext StreamingContext
{
get { return m_streamingContext; }
@@ -245,202 +237,4 @@ namespace System.Runtime.Serialization
// this object.
void CompleteDeserialization(object deserialized);
}
-#if FEATURE_SERIALIZATION
- // Helper class to implement safe serialization. Concrete ISerializable types which want to allow
- // transparent subclasses code to participate in serialization should contain an instance of
- // SafeSerializationManager and wire up to it as described in code:#SafeSerialization.
- [Serializable]
- internal sealed class SafeSerializationManager : IObjectReference, ISerializable
- {
- // Saved states to store in the serialization stream. This is typed as object rather than
- // ISafeSerializationData because ISafeSerializationData can't be marked serializable.
- private IList<object> m_serializedStates;
-
- // This is the SerializationInfo that is used when the SafeSerializationManager type has replaced
- // itself as the target of serialziation. It is not used directly by the safe serialization code,
- // but just held onto so that the real object being deserialzed can use it later.
- private SerializationInfo m_savedSerializationInfo;
-
- // Real object that we've deserialized - this is stored when we complete construction and calling
- // the deserialization .ctors on it and is used when we need to notify the stored safe
- // deserialization data that they should populate the object with their fields.
- private object m_realObject;
-
- // Real type that should be deserialized
- private RuntimeType m_realType;
-
- // Event fired when we need to collect state to serialize into the parent object
- internal event EventHandler<SafeSerializationEventArgs> SerializeObjectState;
-
- // Name that is used to store the real type being deserialized in the main SerializationInfo
- private const string RealTypeSerializationName = "CLR_SafeSerializationManager_RealType";
-
- internal SafeSerializationManager()
- {
- }
-
- private SafeSerializationManager(SerializationInfo info, StreamingContext context)
- {
- // We need to determine if we're being called to really deserialize a SafeSerializationManager,
- // or if we're being called because we've intercepted the deserialization callback for the real
- // object being deserialized. We use the presence of the RealTypeSerializationName field in the
- // serialization info to indicate that this is the interception callback and we just need to
- // safe the info. If that field is not present, then we should be in a real deserialization
- // construction.
- RuntimeType realType = info.GetValueNoThrow(RealTypeSerializationName, typeof(RuntimeType)) as RuntimeType;
-
- if (realType == null)
- {
- m_serializedStates = info.GetValue("m_serializedStates", typeof(List<object>)) as List<object>;
- }
- else
- {
- m_realType = realType;
- m_savedSerializationInfo = info;
- }
- }
-
- // Determine if the serialization manager is in an active state - that is if any code is hooked up
- // to use it for serialization
- internal bool IsActive
- {
- get { return SerializeObjectState != null; }
- }
-
- // CompleteSerialization is called by the base ISerializable in its GetObjectData method. It is
- // responsible for gathering up the serialized object state of any delegates that wish to add their
- // own state to the serialized object.
- internal void CompleteSerialization(object serializedObject,
- SerializationInfo info,
- StreamingContext context)
- {
- Contract.Requires(serializedObject != null);
- Contract.Requires(info != null);
- Contract.Requires(typeof(ISerializable).IsAssignableFrom(serializedObject.GetType()));
- Contract.Requires(serializedObject.GetType().IsAssignableFrom(info.ObjectType));
-
- // Clear out any stale state
- m_serializedStates = null;
-
- // We only want to kick in our special serialization sauce if someone wants to participate in
- // it, otherwise if we have no delegates registered there's no reason for us to get in the way
- // of the regular serialization machinery.
- EventHandler<SafeSerializationEventArgs> serializeObjectStateEvent = SerializeObjectState;
- if (serializeObjectStateEvent != null)
- {
- // Get any extra data to add to our serialization state now
- SafeSerializationEventArgs eventArgs = new SafeSerializationEventArgs(context);
- serializeObjectStateEvent(serializedObject, eventArgs);
- m_serializedStates = eventArgs.SerializedStates;
-
- // Replace the type to be deserialized by the standard serialization code paths with
- // ourselves, which allows us to control the deserialization process.
- info.AddValue(RealTypeSerializationName, serializedObject.GetType(), typeof(RuntimeType));
- info.SetType(typeof(SafeSerializationManager));
- }
- }
-
- // CompleteDeserialization is called by the base ISerializable object's OnDeserialized handler to
- // finish the deserialization of the object by notifying the saved states that they should
- // re-populate their portions of the deserialized object.
- internal void CompleteDeserialization(object deserializedObject)
- {
- Contract.Requires(deserializedObject != null);
-
- if (m_serializedStates != null)
- {
- foreach (ISafeSerializationData serializedState in m_serializedStates)
- {
- serializedState.CompleteDeserialization(deserializedObject);
- }
- }
- }
-
- void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue("m_serializedStates", m_serializedStates, typeof(List<IDeserializationCallback>));
- }
-
- // GetRealObject intercepts the deserialization process in order to allow deserializing part of the
- // object's inheritance heirarchy using standard ISerializable constructors, and the remaining
- // portion using the saved serialization states.
- object IObjectReference.GetRealObject(StreamingContext context)
- {
- // If we've already deserialized the real object, use that rather than deserializing it again
- if (m_realObject != null)
- {
- return m_realObject;
- }
-
- // If we don't have a real type to deserialize, then this is really a SafeSerializationManager
- // and we don't need to rebuild the object that we're standing in for.
- if (m_realType == null)
- {
- return this;
- }
-
- // Look for the last type in GetRealType's inheritance hierarchy which implements a critical
- // deserialization constructor. This will be the object that we use as the deserialization
- // construction type to initialize via standard ISerializable semantics
-
- // First build up the chain starting at the type below Object and working to the real type we
- // serialized.
- Stack inheritanceChain = new Stack();
- RuntimeType currentType = m_realType;
- do
- {
- inheritanceChain.Push(currentType);
- currentType = currentType.BaseType as RuntimeType;
- }
- while (currentType != typeof(object));
-
- // Now look for the first type that does not implement the ISerializable .ctor. When we find
- // that, previousType will point at the last type that did implement the .ctor. We require that
- // the .ctor we invoke also be non-transparent
- RuntimeConstructorInfo serializationCtor = null;
- RuntimeType previousType = null;
- do
- {
- previousType = currentType;
- currentType = inheritanceChain.Pop() as RuntimeType;
- serializationCtor = currentType.GetSerializationCtor();
- }
- while (serializationCtor != null && serializationCtor.IsSecurityCritical);
-
- // previousType is the last type that did implement the deserialization .ctor before the first
- // type that did not, so we'll grab it's .ctor to use for deserialization.
- BCLDebug.Assert(previousType != null, "We should have at least one inheritance from the base type");
- serializationCtor = ObjectManager.GetConstructor(previousType);
-
- // Allocate an instance of the final type and run the selected .ctor on that instance to get the
- // standard ISerializable initialization done.
- object deserialized = FormatterServices.GetUninitializedObject(m_realType);
- serializationCtor.SerializationInvoke(deserialized, m_savedSerializationInfo, context);
- m_savedSerializationInfo = null;
- m_realType = null;
-
- // Save away the real object that was deserialized so that we can fill it in later, and return
- // it back as the object that should result from the final deserialization.
- m_realObject = deserialized;
- return deserialized;
- }
-
- [OnDeserialized]
- private void OnDeserialized(StreamingContext context)
- {
- // We only need to complete deserialization if we were hooking the deserialization process. If
- // we have not deserialized an object in the GetRealObject call, then there's nothing more for
- // us to do here.
- if (m_realObject != null)
- {
- // Fire the real object's OnDeserialized method if they registered one. Since we replaced
- // ourselves as the target of the deserialization, OnDeserialized on the target won't
- // automatically get triggered unless we do it manually.
- SerializationEvents cache = SerializationEventsCache.GetSerializationEventsForType(m_realObject.GetType());
- cache.InvokeOnDeserialized(m_realObject, context);
- m_realObject = null;
- }
- }
- }
-#endif
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs
index 27c5751cc6..38abffa66e 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs
@@ -17,7 +17,6 @@ namespace System.Runtime.Serialization
using System.Reflection;
[AttributeUsage(AttributeTargets.Field, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OptionalFieldAttribute : Attribute
{
int versionAdded = 1;
@@ -38,25 +37,21 @@ namespace System.Runtime.Serialization
}
[AttributeUsage(AttributeTargets.Method, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OnSerializingAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OnSerializedAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OnDeserializingAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OnDeserializedAttribute : Attribute
{
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationBinder.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationBinder.cs
deleted file mode 100644
index 7457991008..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationBinder.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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.
-
-/*============================================================
-**
-** Interface: SerializationBinder
-**
-**
-** Purpose: The base class of serialization binders.
-**
-**
-===========================================================*/
-namespace System.Runtime.Serialization {
- using System;
-
- [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
- public abstract class SerializationBinder {
-
- public virtual void BindToName(Type serializedType, out String assemblyName, out String typeName)
- {
- assemblyName = null;
- typeName = null;
- }
-
- public abstract Type BindToType(String assemblyName, String typeName);
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs
index b88ccfd706..e9cb79b7af 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs
@@ -17,7 +17,6 @@ namespace System.Runtime.Serialization {
using System;
using System.Runtime.Serialization;
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public class SerializationException : SystemException {
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationFieldInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationFieldInfo.cs
deleted file mode 100644
index 82536ce3b4..0000000000
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationFieldInfo.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// 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.
-
-/*============================================================
-**
-**
-**
-** Purpose: Provides a methods of representing imaginary fields
-** which are unique to serialization. In this case, what we're
-** representing is the private members of parent classes. We
-** aggregate the RuntimeFieldInfo associated with this member
-** and return a managled form of the name. The name that we
-** return is .parentname.fieldname
-**
-**
-============================================================*/
-
-namespace System.Runtime.Serialization {
-
- using System;
- using System.Reflection;
- using System.Globalization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Threading;
-
- internal sealed class SerializationFieldInfo : FieldInfo {
-
- internal const String FakeNameSeparatorString = "+";
-
- private RuntimeFieldInfo m_field;
- private String m_serializationName;
-
- public override Module Module { get { return m_field.Module; } }
- public override int MetadataToken { get { return m_field.MetadataToken; } }
-
- internal SerializationFieldInfo(RuntimeFieldInfo field, String namePrefix) {
- Debug.Assert(field!=null, "[SerializationFieldInfo.ctor]field!=null");
- Debug.Assert(namePrefix!=null, "[SerializationFieldInfo.ctor]namePrefix!=null");
-
- m_field = field;
- m_serializationName = String.Concat(namePrefix, FakeNameSeparatorString, m_field.Name);
- }
-
- //
- // MemberInfo methods
- //
- public override String Name {
- get {
- return m_serializationName;
- }
- }
-
- public override Type DeclaringType {
- get {
- return m_field.DeclaringType;
- }
- }
-
- public override Type ReflectedType {
- get {
- return m_field.ReflectedType;
- }
- }
-
- public override Object[] GetCustomAttributes(bool inherit) {
- return m_field.GetCustomAttributes(inherit);
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit) {
- return m_field.GetCustomAttributes(attributeType, inherit);
- }
-
- public override bool IsDefined(Type attributeType, bool inherit) {
- return m_field.IsDefined(attributeType, inherit);
- }
-
- //
- // FieldInfo methods
- //
- public override Type FieldType {
- get {
- return m_field.FieldType;
- }
- }
-
- public override Object GetValue(Object obj) {
- return m_field.GetValue(obj);
- }
-
- internal Object InternalGetValue(Object obj) {
- RtFieldInfo field = m_field as RtFieldInfo;
- if (field != null)
- {
- field.CheckConsistency(obj);
- return field.UnsafeGetValue(obj);
- }
- else
- return m_field.GetValue(obj);
- }
-
- public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) {
- m_field.SetValue(obj, value, invokeAttr, binder, culture);
- }
-
- internal void InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) {
- RtFieldInfo field = m_field as RtFieldInfo;
- if (field != null)
- {
- field.CheckConsistency(obj);
- field.UnsafeSetValue(obj, value, invokeAttr, binder, culture);
- }
- else
- m_field.SetValue(obj, value, invokeAttr, binder, culture);
- }
-
- internal RuntimeFieldInfo FieldInfo {
- get {
- return m_field;
- }
- }
-
- public override RuntimeFieldHandle FieldHandle {
- get {
- return m_field.FieldHandle;
- }
- }
-
- public override FieldAttributes Attributes {
- get {
- return m_field.Attributes;
- }
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
index 55909c85fd..45521f2397 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
@@ -24,7 +24,6 @@ namespace System.Runtime.Serialization
using System.Security;
using System.Runtime.CompilerServices;
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class SerializationInfo
{
private const int defaultSize = 4;
@@ -146,49 +145,10 @@ namespace System.Runtime.Serialization
}
}
- private static bool Compare(byte[] a, byte[] b)
- {
- // if either or both assemblies do not have public key token, we should demand, hence, returning false will force a demand
- if (a == null || b == null || a.Length == 0 || b.Length == 0 || a.Length != b.Length)
- {
- return false;
- }
- else
- {
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] != b[i]) return false;
- }
-
- return true;
- }
- }
-
internal static void DemandForUnsafeAssemblyNameAssignments(string originalAssemblyName, string newAssemblyName)
{
}
- internal static bool IsAssemblyNameAssignmentSafe(string originalAssemblyName, string newAssemblyName)
- {
- if (originalAssemblyName == newAssemblyName)
- {
- return true;
- }
-
- AssemblyName originalAssembly = new AssemblyName(originalAssemblyName);
- AssemblyName newAssembly = new AssemblyName(newAssemblyName);
-
- // mscorlib will get loaded by the runtime regardless of its string casing or its public key token,
- // so setting the assembly name to mscorlib must always be protected by a demand
- if (string.Equals(newAssembly.Name, s_mscorlibAssemblySimpleName, StringComparison.OrdinalIgnoreCase) ||
- string.Equals(newAssembly.Name, s_mscorlibFileName, StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
-
- return Compare(originalAssembly.GetPublicKeyToken(), newAssembly.GetPublicKeyToken());
- }
-
public int MemberCount
{
get
@@ -467,7 +427,6 @@ namespace System.Runtime.Serialization
return m_data[index];
}
- [System.Runtime.InteropServices.ComVisible(true)]
private Object GetElementNoThrow(String name, out Type foundType)
{
int index = FindElement(name);
@@ -518,7 +477,6 @@ namespace System.Runtime.Serialization
return m_converter.Convert(value, type);
}
- [System.Runtime.InteropServices.ComVisible(true)]
internal Object GetValueNoThrow(String name, Type type)
{
Type foundType;
@@ -741,22 +699,5 @@ namespace System.Runtime.Serialization
return m_converter.ToString(value);
}
- internal string[] MemberNames
- {
- get
- {
- return m_members;
- }
-
- }
-
- internal object[] MemberValues
- {
- get
- {
- return m_data;
- }
- }
-
}
}
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs
index 32c65492e1..0858dfc19f 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs
@@ -21,7 +21,6 @@ namespace System.Runtime.Serialization {
//
// The tuple returned by SerializationInfoEnumerator.Current.
//
-[System.Runtime.InteropServices.ComVisible(true)]
public struct SerializationEntry {
private Type m_type;
private Object m_value;
@@ -57,7 +56,6 @@ namespace System.Runtime.Serialization {
// This does not snapshot the values, it just keeps pointers to the
// member variables of the SerializationInfo that created it.
//
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SerializationInfoEnumerator : IEnumerator {
String[] m_members;
Object[] m_data;
diff --git a/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs b/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs
index ef4a096a51..c01a3edc4f 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs
@@ -16,7 +16,6 @@ namespace System.Runtime.Serialization {
using System.Runtime.Remoting;
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public struct StreamingContext {
internal Object m_additionalContext;
internal StreamingContextStates m_state;
@@ -59,7 +58,6 @@ namespace System.Runtime.Serialization {
// **********************************************************
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum StreamingContextStates {
CrossProcess=0x01,
CrossMachine=0x02,
diff --git a/src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs b/src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs
index 6bf8f8cf45..3410f020be 100644
--- a/src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs
+++ b/src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs
@@ -7,7 +7,7 @@ using System.Runtime.CompilerServices;
namespace System.Runtime.Versioning
{
- public static class CompatibilitySwitch
+ internal static class CompatibilitySwitch
{
/* This class contains 3 sets of api:
* 1. internal apis : These apis are supposed to be used by mscorlib.dll and other assemblies which use the <runtime> section in config
@@ -19,38 +19,14 @@ namespace System.Runtime.Versioning
* 3. specialized apis: These apis are defined in order to retrieve a specific value defined in CLR Config. That value can have specific look-up rules
* for the order and location of the config sources used.
*
- * These apis are for internal use only for FX assmeblies. It has not been decided if they can be used by OOB components due to EULA restrictions
+ * These apis are for internal use only for FX assemblies. It has not been decided if they can be used by OOB components due to EULA restrictions
*/
- public static bool IsEnabled(string compatibilitySwitchName)
- {
- return IsEnabledInternalCall(compatibilitySwitchName, true);
- }
-
- public static string GetValue(string compatibilitySwitchName)
- {
- // This is used by AppContext.TryGetSwitch to check switch overrides in the Windows Quirk DB
- // If this method is updated to check other locations than the DB, please ensure compat with
- // the AppContext class.
- return GetValueInternalCall(compatibilitySwitchName, true);
- }
-
- internal static bool IsEnabledInternal(string compatibilitySwitchName)
- {
- return IsEnabledInternalCall(compatibilitySwitchName, false);
- }
-
internal static string GetValueInternal(string compatibilitySwitchName)
{
return GetValueInternalCall(compatibilitySwitchName, false);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern string GetAppContextOverridesInternalCall();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern bool IsEnabledInternalCall(string compatibilitySwitchName, bool onlyDB);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
private static extern string GetValueInternalCall(string compatibilitySwitchName, bool onlyDB);
}
}
diff --git a/src/mscorlib/src/System/Runtime/Versioning/TargetFrameworkId.cs b/src/mscorlib/src/System/Runtime/Versioning/TargetFrameworkId.cs
deleted file mode 100644
index 0a5e668a92..0000000000
--- a/src/mscorlib/src/System/Runtime/Versioning/TargetFrameworkId.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.
-
-/*============================================================
-**
-** Purpose: Describe the target framework of the application or AppDomain.
-**
-===========================================================*/
-using System;
-using System.Runtime.CompilerServices;
-
-namespace System.Runtime.Versioning
-{
- // What type of .NET Framework was this application compiled against?
- [FriendAccessAllowed]
- internal enum TargetFrameworkId
- {
- NotYetChecked = 0,
- Unrecognized = 1, // Unknown type, such as a new SKU (like watches or cars)
- Unspecified = 2, // The TargetFrameworkAttribute was created in v4.0. And apps compiled outside VS will not have this attribute.
- NetFramework = 3, // Desktop - Client or Server or ServerCore.
- Portable = 4, // Portable Library v1 Note: We do not expect people to build executables against portable libraries!
- NetCore = 5, // .NET Core = Windows 8 Immersive and Portable Library v2+
- Silverlight = 6, // Silverlight but not the Phone
- Phone = 7, // Windows Phone 7 or higher
- }
-}