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/ConditionalWeakTable.cs38
-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/MethodImplAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/GcSettings.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/COMException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs128
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/PInvokeMap.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/PInvokeMarshal.cs24
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/VariantWrapper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs40
-rw-r--r--src/mscorlib/src/System/Runtime/RuntimeImports.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs1
42 files changed, 149 insertions, 179 deletions
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
index f32cc2b510..6c6f6ee472 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
@@ -651,16 +651,10 @@ namespace System.Runtime.CompilerServices
int bucket = hashCode & (_buckets.Length - 1);
for (int entriesIndex = Volatile.Read(ref _buckets[bucket]); entriesIndex != -1; entriesIndex = _entries[entriesIndex].Next)
{
- if (_entries[entriesIndex].HashCode == hashCode)
+ if (_entries[entriesIndex].HashCode == hashCode && _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out value) == key)
{
- object primary, secondary;
- _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out primary, out secondary);
- if (primary == key)
- {
- GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
- value = secondary;
- return entriesIndex;
- }
+ GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
+ return entriesIndex;
}
}
@@ -677,7 +671,7 @@ namespace System.Runtime.CompilerServices
if (index < _entries.Length)
{
object oKey, oValue;
- _entries[index].depHnd.GetPrimaryAndSecondary(out oKey, out oValue);
+ oKey = _entries[index].depHnd.GetPrimaryAndSecondary(out oValue);
GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
if (oKey != null)
@@ -921,8 +915,8 @@ namespace System.Runtime.CompilerServices
{
for (int entriesIndex = _buckets[bucket]; entriesIndex != -1; entriesIndex = _entries[entriesIndex].Next)
{
- object primary = null, secondary = null;
- _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out primary, out secondary);
+ object primary, secondary;
+ primary = _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out secondary);
// Now that we've secured a strong reference to the secondary, must check the primary again
// to ensure it didn't expire (otherwise, we open a race where TryGetValue misreports an
@@ -951,7 +945,7 @@ namespace System.Runtime.CompilerServices
}
object thisKey, thisValue;
- _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out thisKey, out thisValue);
+ thisKey = _entries[entriesIndex].depHnd.GetPrimaryAndSecondary(out thisValue);
if (Equals(thisKey, key))
{
GC.KeepAlive(this); // ensure we don't get finalized while accessing DependentHandles.
@@ -1069,10 +1063,8 @@ namespace System.Runtime.CompilerServices
#region Constructors
public DependentHandle(object primary, object secondary)
{
- IntPtr handle = (IntPtr)0;
- nInitialize(primary, secondary, out handle);
// no need to check for null result: nInitialize expected to throw OOM.
- _handle = handle;
+ _handle = nInitialize(primary, secondary);
}
#endregion
@@ -1084,14 +1076,12 @@ namespace System.Runtime.CompilerServices
// primary.
public object GetPrimary()
{
- object primary;
- nGetPrimary(_handle, out primary);
- return primary;
+ return nGetPrimary(_handle);
}
- public void GetPrimaryAndSecondary(out object primary, out object secondary)
+ public object GetPrimaryAndSecondary(out object secondary)
{
- nGetPrimaryAndSecondary(_handle, out primary, out secondary);
+ return nGetPrimaryAndSecondary(_handle, out secondary);
}
public void SetPrimary(object primary)
@@ -1121,13 +1111,13 @@ namespace System.Runtime.CompilerServices
#region Private Members
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void nInitialize(object primary, object secondary, out IntPtr dependentHandle);
+ private static extern IntPtr nInitialize(object primary, object secondary);
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void nGetPrimary(IntPtr dependentHandle, out object primary);
+ private static extern object nGetPrimary(IntPtr dependentHandle);
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void nGetPrimaryAndSecondary(IntPtr dependentHandle, out object primary, out object secondary);
+ private static extern object nGetPrimaryAndSecondary(IntPtr dependentHandle, out object secondary);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void nSetPrimary(IntPtr dependentHandle, object primary);
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
index 8f4c79cd94..7393bb2bcd 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/CustomConstantAttribute.cs
@@ -7,7 +7,6 @@ using System.Collections.Generic;
namespace System.Runtime.CompilerServices
{
- [Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
public abstract class CustomConstantAttribute : Attribute
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
index 7aca42b627..5155d0085d 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
@@ -7,7 +7,6 @@ using System.Diagnostics.Contracts;
namespace System.Runtime.CompilerServices
{
- [Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
public sealed class DateTimeConstantAttribute : CustomConstantAttribute
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
index 0e2b6f8418..f5fd5a21a3 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
@@ -12,7 +12,6 @@ using System.Collections.Generic;
namespace System.Runtime.CompilerServices
{
- [Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
public sealed class DecimalConstantAttribute : Attribute
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs
index b24018cf78..3c19ee8863 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
// certain method properties.
// Custom attribute to specify additional method properties.
- [Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
sealed public class MethodImplAttribute : Attribute
{
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
index c050000169..df52f301e4 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs
@@ -13,12 +13,10 @@
using System;
using System.Runtime.Serialization;
-using System.Runtime.Remoting;
using System.Diagnostics.Contracts;
namespace System.Runtime.CompilerServices
{
- [Serializable]
public sealed class RuntimeWrappedException : Exception
{
private RuntimeWrappedException(Object thrownObject)
@@ -37,19 +35,7 @@ namespace System.Runtime.CompilerServices
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
base.GetObjectData(info, context);
- info.AddValue("WrappedException", m_wrappedException, typeof(Object));
- }
-
- internal RuntimeWrappedException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- m_wrappedException = info.GetValue("WrappedException", typeof(Object));
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/GcSettings.cs b/src/mscorlib/src/System/Runtime/GcSettings.cs
index 993a24f986..ecb28e6034 100644
--- a/src/mscorlib/src/System/Runtime/GcSettings.cs
+++ b/src/mscorlib/src/System/Runtime/GcSettings.cs
@@ -13,14 +13,12 @@ namespace System.Runtime
// These settings are the same format as in clr\src\vm\gcpriv.h
// make sure you change that file if you change this file!
- [Serializable]
public enum GCLargeObjectHeapCompactionMode
{
Default = 1,
CompactOnce = 2
}
- [Serializable]
public enum GCLatencyMode
{
Batch = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs b/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
index c4beb024b1..e009db277f 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
@@ -9,7 +9,6 @@ using System.Runtime.Versioning;
namespace System.Runtime.InteropServices
{
- [Serializable]
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 ccba51e840..668358995b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs
@@ -46,7 +46,6 @@ namespace System.Runtime.InteropServices
public int Value { get { return _val; } }
}
- [Serializable]
public enum ComInterfaceType
{
InterfaceIsDual = 0,
@@ -84,7 +83,6 @@ namespace System.Runtime.InteropServices
public Type Value { get { return _val; } }
}
- [Serializable]
public enum ClassInterfaceType
{
None = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
index 77c38139cd..586b03b366 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs
@@ -17,7 +17,6 @@ using System.Security;
namespace System.Runtime.InteropServices
{
- [Serializable]
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 889a74f6bc..8ee10ed349 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs
@@ -22,7 +22,6 @@ namespace System.Runtime.InteropServices
{
// Exception for COM Interop errors where we don't recognize the HResult.
//
- [Serializable]
public class COMException : ExternalException
{
public COMException()
@@ -51,6 +50,7 @@ namespace System.Runtime.InteropServices
protected COMException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
public override String ToString()
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs
index 8198d9fd18..fe69f619fe 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs
@@ -99,7 +99,6 @@
// code:ComEventsMethod.Invoke
using System;
-using System.Runtime.Remoting;
namespace System.Runtime.InteropServices
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
index ea99781975..2de01465d3 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComMemberType.cs
@@ -9,7 +9,6 @@ using System;
namespace System.Runtime.InteropServices
{
- [Serializable]
public enum ComMemberType
{
Method = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs
index 967746f379..ae403d138c 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs
@@ -15,7 +15,6 @@ using System;
namespace System.Runtime.InteropServices.ComTypes
{
- [Serializable]
public enum DESCKIND
{
DESCKIND_NONE = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs
index 1857fdbb35..4cd102f76e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs
@@ -15,7 +15,6 @@ using System;
namespace System.Runtime.InteropServices.ComTypes
{
- [Serializable]
public enum TYPEKIND
{
TKIND_ENUM = 0,
@@ -29,7 +28,6 @@ namespace System.Runtime.InteropServices.ComTypes
TKIND_MAX = TKIND_UNION + 1
}
- [Serializable]
[Flags()]
public enum TYPEFLAGS : short
{
@@ -50,7 +48,6 @@ namespace System.Runtime.InteropServices.ComTypes
TYPEFLAG_FPROXY = 0x4000
}
- [Serializable]
[Flags()]
public enum IMPLTYPEFLAGS
{
@@ -106,7 +103,6 @@ namespace System.Runtime.InteropServices.ComTypes
public Int16 wFuncFlags; //WORD wFuncFlags;
}
- [Serializable]
[Flags()]
public enum IDLFLAG : short
{
@@ -125,7 +121,6 @@ namespace System.Runtime.InteropServices.ComTypes
public IDLFLAG wIDLFlags;
}
- [Serializable]
[Flags()]
public enum PARAMFLAG : short
{
@@ -173,7 +168,6 @@ namespace System.Runtime.InteropServices.ComTypes
public DESCUNION desc;
}
- [Serializable]
public enum VARKIND : int
{
VAR_PERINSTANCE = 0x0,
@@ -231,7 +225,6 @@ namespace System.Runtime.InteropServices.ComTypes
public Int32 scode;
}
- [Serializable]
public enum FUNCKIND : int
{
FUNC_VIRTUAL = 0,
@@ -241,7 +234,6 @@ namespace System.Runtime.InteropServices.ComTypes
FUNC_DISPATCH = 4
}
- [Serializable]
[Flags]
public enum INVOKEKIND : int
{
@@ -251,7 +243,6 @@ namespace System.Runtime.InteropServices.ComTypes
INVOKE_PROPERTYPUTREF = 0x8
}
- [Serializable]
public enum CALLCONV : int
{
CC_CDECL = 1,
@@ -266,7 +257,6 @@ namespace System.Runtime.InteropServices.ComTypes
CC_MAX = 9
}
- [Serializable]
[Flags()]
public enum FUNCFLAGS : short
{
@@ -285,7 +275,6 @@ namespace System.Runtime.InteropServices.ComTypes
FUNCFLAG_FIMMEDIATEBIND = 0x1000
}
- [Serializable]
[Flags()]
public enum VARFLAGS : short
{
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs
index 3ed6e42d08..05a9e3f176 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs
@@ -15,7 +15,6 @@ using System;
namespace System.Runtime.InteropServices.ComTypes
{
- [Serializable]
public enum SYSKIND
{
SYS_WIN16 = 0,
@@ -24,7 +23,6 @@ namespace System.Runtime.InteropServices.ComTypes
SYS_WIN64 = SYS_MAC + 1
}
- [Serializable]
[Flags()]
public enum LIBFLAGS : short
{
@@ -35,7 +33,6 @@ namespace System.Runtime.InteropServices.ComTypes
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- [Serializable]
public struct TYPELIBATTR
{
public Guid guid;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
index 4b436825e8..590925aafe 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Runtime.InteropServices
{
- [Serializable]
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 87ec4ed15e..5fb78c56ad 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs
@@ -17,7 +17,6 @@ using System.Security;
namespace System.Runtime.InteropServices
{
- [Serializable]
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 73be2c5777..34237d539a 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Runtime.InteropServices
{
- [Serializable]
public sealed class ErrorWrapper
{
public ErrorWrapper(int errorCode)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
index dcb9e24258..2ee81a9f5c 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
@@ -18,7 +18,6 @@ namespace System.Runtime.InteropServices
// 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]
public enum GCHandleType
{
Weak = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs b/src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs
index 4f4b10bbf0..f0aa35e7dd 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]
public enum CustomQueryInterfaceResult
{
Handled = 0,
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
index 2fae2b6e52..bf89df94bb 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs
@@ -17,7 +17,6 @@ using System.Runtime.Serialization;
namespace System.Runtime.InteropServices
{
- [Serializable]
public class InvalidComObjectException : SystemException
{
public InvalidComObjectException()
@@ -40,6 +39,7 @@ namespace System.Runtime.InteropServices
protected InvalidComObjectException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
index 5154a028ad..412853920e 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs
@@ -16,7 +16,6 @@ using System.Runtime.Serialization;
namespace System.Runtime.InteropServices
{
- [Serializable]
public class InvalidOleVariantTypeException : SystemException
{
public InvalidOleVariantTypeException()
@@ -39,6 +38,7 @@ namespace System.Runtime.InteropServices
protected InvalidOleVariantTypeException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
index 6fb631121b..03750bcb8b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
@@ -15,13 +15,13 @@
namespace System.Runtime.InteropServices
{
using System;
+ using System.Runtime;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Security;
using System.Text;
using System.Threading;
- using System.Runtime.Remoting;
using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.ConstrainedExecution;
@@ -31,8 +31,8 @@ namespace System.Runtime.InteropServices
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices.ComTypes;
+ using System.StubHelpers;
- [Serializable]
public enum CustomQueryInterfaceMode
{
Ignore = 0,
@@ -406,9 +406,9 @@ namespace System.Runtime.InteropServices
//====================================================================
// Read from memory
//====================================================================
- public static byte ReadByte([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs)
+ public static byte ReadByte(Object ptr, int ofs)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadByte(nativeHome, offset));
}
public static unsafe byte ReadByte(IntPtr ptr, int ofs)
@@ -430,9 +430,9 @@ namespace System.Runtime.InteropServices
return ReadByte(ptr, 0);
}
- public static short ReadInt16([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs)
+ public static short ReadInt16(Object ptr, int ofs)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt16(nativeHome, offset));
}
public static unsafe short ReadInt16(IntPtr ptr, int ofs)
@@ -467,9 +467,9 @@ namespace System.Runtime.InteropServices
return ReadInt16(ptr, 0);
}
- public static int ReadInt32([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs)
+ public static int ReadInt32(object ptr, int ofs)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt32(nativeHome, offset));
}
public static unsafe int ReadInt32(IntPtr ptr, int ofs)
@@ -506,7 +506,7 @@ namespace System.Runtime.InteropServices
return ReadInt32(ptr, 0);
}
- public static IntPtr ReadIntPtr([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs)
+ public static IntPtr ReadIntPtr(Object ptr, int ofs)
{
#if BIT64
return (IntPtr)ReadInt64(ptr, ofs);
@@ -535,7 +535,7 @@ namespace System.Runtime.InteropServices
public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt64(nativeHome, offset));
}
public static unsafe long ReadInt64(IntPtr ptr, int ofs)
@@ -576,6 +576,41 @@ namespace System.Runtime.InteropServices
return ReadInt64(ptr, 0);
}
+ //====================================================================
+ // Read value from marshaled object (marshaled using AsAny)
+ // It's quite slow and can return back dangling pointers
+ // It's only there for backcompact
+ // I don't think we should spend time optimizing it
+ // People should really call the IntPtr overload instead
+ //====================================================================
+ private static unsafe T ReadValueSlow<T>(object ptr, int ofs, Func<IntPtr, int, T> readValueHelper)
+ {
+ // We AV on desktop if passing NULL. So this is technically a breaking change but is an improvement
+ if (ptr == null)
+ throw new ArgumentNullException(nameof(ptr));
+
+ int dwFlags =
+ (int)AsAnyMarshaler.AsAnyFlags.In |
+ (int)AsAnyMarshaler.AsAnyFlags.IsAnsi |
+ (int)AsAnyMarshaler.AsAnyFlags.IsBestFit;
+
+ MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState();
+ AsAnyMarshaler marshaler = new AsAnyMarshaler(new IntPtr(&nativeArrayMarshalerState));
+
+ IntPtr pNativeHome = IntPtr.Zero;
+
+ try
+ {
+ pNativeHome = marshaler.ConvertToNative(ptr, dwFlags);
+ return readValueHelper(pNativeHome, ofs);
+ }
+ finally
+ {
+ marshaler.ClearNative(pNativeHome);
+ }
+ }
+
+
//====================================================================
// Write to memory
@@ -594,9 +629,9 @@ namespace System.Runtime.InteropServices
}
}
- public static void WriteByte([MarshalAs(UnmanagedType.AsAny), In, Out] Object ptr, int ofs, byte val)
+ public static void WriteByte(Object ptr, int ofs, byte val)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, byte value) => Marshal.WriteByte(nativeHome, offset, value));
}
public static void WriteByte(IntPtr ptr, byte val)
@@ -629,9 +664,9 @@ namespace System.Runtime.InteropServices
}
}
- public static void WriteInt16([MarshalAs(UnmanagedType.AsAny), In, Out] Object ptr, int ofs, short val)
+ public static void WriteInt16(Object ptr, int ofs, short val)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, short value) => Marshal.WriteInt16(nativeHome, offset, value));
}
public static void WriteInt16(IntPtr ptr, short val)
@@ -681,9 +716,9 @@ namespace System.Runtime.InteropServices
}
}
- public static void WriteInt32([MarshalAs(UnmanagedType.AsAny), In, Out] Object ptr, int ofs, int val)
+ public static void WriteInt32(Object ptr, int ofs, int val)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, int value) => Marshal.WriteInt32(nativeHome, offset, value));
}
public static void WriteInt32(IntPtr ptr, int val)
@@ -700,7 +735,7 @@ namespace System.Runtime.InteropServices
#endif
}
- public static void WriteIntPtr([MarshalAs(UnmanagedType.AsAny), In, Out] Object ptr, int ofs, IntPtr val)
+ public static void WriteIntPtr(Object ptr, int ofs, IntPtr val)
{
#if BIT64
WriteInt64(ptr, ofs, (long)val);
@@ -749,9 +784,9 @@ namespace System.Runtime.InteropServices
}
}
- public static void WriteInt64([MarshalAs(UnmanagedType.AsAny), In, Out] Object ptr, int ofs, long val)
+ public static void WriteInt64(Object ptr, int ofs, long val)
{
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10442
+ WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, long value) => Marshal.WriteInt64(nativeHome, offset, value));
}
public static void WriteInt64(IntPtr ptr, long val)
@@ -759,6 +794,41 @@ namespace System.Runtime.InteropServices
WriteInt64(ptr, 0, val);
}
+ //====================================================================
+ // Write value into marshaled object (marshaled using AsAny) and
+ // propagate the value back
+ // It's quite slow and is only there for backcompact
+ // I don't think we should spend time optimizing it
+ // People should really call the IntPtr overload instead
+ //====================================================================
+ private static unsafe void WriteValueSlow<T>(object ptr, int ofs, T val, Action<IntPtr, int, T> writeValueHelper)
+ {
+ // We AV on desktop if passing NULL. So this is technically a breaking change but is an improvement
+ if (ptr == null)
+ throw new ArgumentNullException(nameof(ptr));
+
+ int dwFlags =
+ (int)AsAnyMarshaler.AsAnyFlags.In |
+ (int)AsAnyMarshaler.AsAnyFlags.Out |
+ (int)AsAnyMarshaler.AsAnyFlags.IsAnsi |
+ (int)AsAnyMarshaler.AsAnyFlags.IsBestFit;
+
+ MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState();
+ AsAnyMarshaler marshaler = new AsAnyMarshaler(new IntPtr(&nativeArrayMarshalerState));
+
+ IntPtr pNativeHome = IntPtr.Zero;
+
+ try
+ {
+ pNativeHome = marshaler.ConvertToNative(ptr, dwFlags);
+ writeValueHelper(pNativeHome, ofs, val);
+ marshaler.ConvertToManaged(ptr, pNativeHome);
+ }
+ finally
+ {
+ marshaler.ClearNative(pNativeHome);
+ }
+ }
//====================================================================
// GetLastWin32Error
@@ -1772,11 +1842,7 @@ namespace System.Runtime.InteropServices
}
Contract.EndContractBlock();
-#if FEATURE_COMINTEROP
return s.MarshalToBSTR();
-#else
- throw new PlatformNotSupportedException(); // https://github.com/dotnet/coreclr/issues/10443
-#endif
}
public static IntPtr SecureStringToCoTaskMemAnsi(SecureString s)
@@ -1800,30 +1866,28 @@ namespace System.Runtime.InteropServices
return s.MarshalToString(globalAlloc: false, unicode: true);
}
-
-#if FEATURE_COMINTEROP
+
public static void ZeroFreeBSTR(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.SysStringLen(s) * 2));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)(Win32Native.SysStringLen(s) * 2));
FreeBSTR(s);
}
-#endif
public static void ZeroFreeCoTaskMemAnsi(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s)));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s)));
FreeCoTaskMem(s);
}
public static void ZeroFreeCoTaskMemUnicode(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2));
FreeCoTaskMem(s);
}
unsafe public static void ZeroFreeCoTaskMemUTF8(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)System.StubHelpers.StubHelpers.strlen((sbyte*)s));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)System.StubHelpers.StubHelpers.strlen((sbyte*)s));
FreeCoTaskMem(s);
}
@@ -1851,13 +1915,13 @@ namespace System.Runtime.InteropServices
public static void ZeroFreeGlobalAllocAnsi(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s)));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s)));
FreeHGlobal(s);
}
public static void ZeroFreeGlobalAllocUnicode(IntPtr s)
{
- Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2));
+ RuntimeImports.RhZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2));
FreeHGlobal(s);
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
index 6fe7574e26..75b291af30 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs
@@ -17,7 +17,6 @@ using System.Runtime.Serialization;
namespace System.Runtime.InteropServices
{
- [Serializable]
public class MarshalDirectiveException : SystemException
{
public MarshalDirectiveException()
@@ -40,6 +39,7 @@ namespace System.Runtime.InteropServices
protected MarshalDirectiveException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs b/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
index 7b7c5efb90..c79af8b459 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
@@ -171,11 +171,6 @@ namespace System.Runtime.InteropServices
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
}
-
- public static void ZeroFreeBSTR(System.IntPtr s)
- {
- throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
- }
}
public class DispatchWrapper
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMap.cs
index ed289fd14b..33f1b5f09c 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMap.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMap.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Runtime.InteropServices
{
// This Enum matchs the CorPinvokeMap defined in CorHdr.h
- [Serializable]
internal enum PInvokeMap
{
NoMangle = 0x0001, // Pinvoke is to use the member name as specified.
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMarshal.cs
new file mode 100644
index 0000000000..9eb60bdce7
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/InteropServices/PInvokeMarshal.cs
@@ -0,0 +1,24 @@
+// 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 Microsoft.Win32;
+
+namespace System.Runtime.InteropServices
+{
+ internal static class PInvokeMarshal
+ {
+ public static IntPtr AllocBSTR(int length)
+ {
+ IntPtr bstr = Win32Native.SysAllocStringLen(null, length);
+ if (bstr == IntPtr.Zero)
+ throw new OutOfMemoryException();
+ return bstr;
+ }
+
+ public static void FreeBSTR(IntPtr ptr)
+ {
+ Win32Native.SysFreeString(ptr);
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
index 5595fadc43..d61e79757c 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SEHException.cs
@@ -19,7 +19,6 @@ namespace System.Runtime.InteropServices
{
// Exception for Structured Exception Handler exceptions.
//
- [Serializable]
public class SEHException : ExternalException
{
public SEHException()
@@ -42,6 +41,7 @@ namespace System.Runtime.InteropServices
protected SEHException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
// Exceptions can be resumable, meaning a filtered exception
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
index f39f1f3a41..9df858f0b1 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs
@@ -16,7 +16,6 @@ using System.Runtime.Serialization;
namespace System.Runtime.InteropServices
{
- [Serializable]
public class SafeArrayRankMismatchException : SystemException
{
public SafeArrayRankMismatchException()
@@ -39,6 +38,7 @@ namespace System.Runtime.InteropServices
protected SafeArrayRankMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
index 2283263422..4b03691e82 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs
@@ -17,7 +17,6 @@ using System.Runtime.Serialization;
namespace System.Runtime.InteropServices
{
- [Serializable]
public class SafeArrayTypeMismatchException : SystemException
{
public SafeArrayTypeMismatchException()
@@ -40,6 +39,7 @@ namespace System.Runtime.InteropServices
protected SafeArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
{
+ throw new PlatformNotSupportedException();
}
}
}
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
index c758ae1b4f..de06cbf1a8 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/UnknownWrapper.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Runtime.InteropServices
{
- [Serializable]
public sealed class UnknownWrapper
{
public UnknownWrapper(Object obj)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/VariantWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/VariantWrapper.cs
index 50689e08f8..455f0759fe 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/VariantWrapper.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/VariantWrapper.cs
@@ -16,8 +16,6 @@ using System;
namespace System.Runtime.InteropServices
{
- [Serializable]
-
public sealed class VariantWrapper
{
public VariantWrapper(Object obj)
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
index 4549a407e0..0ed0bb3f7b 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs
@@ -21,7 +21,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
/// </summary>
/// <typeparam name="TKey">Type of objects that act as keys.</typeparam>
/// <typeparam name="TValue">Type of objects that act as entries / values.</typeparam>
- [Serializable]
[DebuggerDisplay("Count = {Count}")]
internal sealed class ConstantSplittableMap<TKey, TValue> : IMapView<TKey, TValue>
{
@@ -169,7 +168,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
#region IKeyValuePair Enumerator
- [Serializable]
internal struct IKeyValuePairEnumerator : IEnumerator<IKeyValuePair<TKey, TValue>>
{
private KeyValuePair<TKey, TValue>[] _array;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs
index 2a34aba717..f2434ce91d 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs
@@ -9,7 +9,6 @@ using System.Diagnostics;
namespace System.Runtime.InteropServices.WindowsRuntime
{
- [Serializable]
[DebuggerDisplay("Count = {Count}")]
internal sealed class DictionaryKeyCollection<TKey, TValue> : ICollection<TKey>
{
@@ -83,7 +82,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
} // public class DictionaryKeyCollection<TKey, TValue>
- [Serializable]
internal sealed class DictionaryKeyEnumerator<TKey, TValue> : IEnumerator<TKey>
{
private readonly IDictionary<TKey, TValue> dictionary;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
index 083b0ffcb1..6be0ddd9f0 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs
@@ -13,7 +13,6 @@ using System.Runtime.InteropServices.WindowsRuntime;
namespace System.Runtime.InteropServices.WindowsRuntime
{
- [Serializable]
[DebuggerDisplay("Count = {Count}")]
internal sealed class DictionaryValueCollection<TKey, TValue> : ICollection<TValue>
{
@@ -91,7 +90,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
} // public class DictionaryValueCollection<TKey, TValue>
- [Serializable]
internal sealed class DictionaryValueEnumerator<TKey, TValue> : IEnumerator<TValue>
{
private readonly IDictionary<TKey, TValue> dictionary;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
index e06364dcae..0900012338 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs
@@ -123,7 +123,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
}
// Note: One day we may make these return IReadOnlyCollection<T>
- [Serializable]
[DebuggerDisplay("Count = {Count}")]
internal sealed class ReadOnlyDictionaryKeyCollection<TKey, TValue> : IEnumerable<TKey>
{
@@ -178,7 +177,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
} // public class ReadOnlyDictionaryKeyCollection<TKey, TValue>
- [Serializable]
internal sealed class ReadOnlyDictionaryKeyEnumerator<TKey, TValue> : IEnumerator<TKey>
{
private readonly IReadOnlyDictionary<TKey, TValue> dictionary;
@@ -220,7 +218,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
} // class ReadOnlyDictionaryKeyEnumerator<TKey, TValue>
- [Serializable]
[DebuggerDisplay("Count = {Count}")]
internal sealed class ReadOnlyDictionaryValueCollection<TKey, TValue> : IEnumerable<TValue>
{
@@ -279,7 +276,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime
} // public class ReadOnlyDictionaryValueCollection<TKey, TValue>
- [Serializable]
internal sealed class ReadOnlyDictionaryValueEnumerator<TKey, TValue> : IEnumerator<TValue>
{
private readonly IReadOnlyDictionary<TKey, TValue> dictionary;
diff --git a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
index de8137f1ec..a7bf871a39 100644
--- a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
+++ b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs
@@ -71,15 +71,9 @@ namespace System.Runtime.Loader
[SuppressUnmanagedCodeSecurity]
private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, string ilPath, string niPath, ObjectHandleOnStack retAssembly);
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void GetLoadedAssembliesInternal(ObjectHandleOnStack assemblies);
-
public static Assembly[] GetLoadedAssemblies()
{
- Assembly[] assemblies = null;
- GetLoadedAssembliesInternal(JitHelpers.GetObjectHandleOnStack(ref assemblies));
- return assemblies;
+ return AppDomain.CurrentDomain.GetAssemblies(false);
}
// These are helpers that can be used by AssemblyLoadContext derivations.
diff --git a/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs b/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs
deleted file mode 100644
index e76882d6df..0000000000
--- a/src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.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.
-
-/*============================================================
-**
-**
-**
-** ObjectHandle wraps object references. A Handle allows a
-** marshal by value object to be returned through an
-** indirection allowing the caller to control when the
-** object is loaded into their domain.
-**
-**
-===========================================================*/
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Remoting
-{
- public class ObjectHandle
- {
- private Object WrappedObject;
-
- private ObjectHandle()
- {
- }
-
- internal ObjectHandle(Object o)
- {
- WrappedObject = o;
- }
-
- internal Object Unwrap()
- {
- return WrappedObject;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Runtime/RuntimeImports.cs b/src/mscorlib/src/System/Runtime/RuntimeImports.cs
index 16d41d3951..ed0c556575 100644
--- a/src/mscorlib/src/System/Runtime/RuntimeImports.cs
+++ b/src/mscorlib/src/System/Runtime/RuntimeImports.cs
@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
#if BIT64
using nuint = System.UInt64;
#else
- using nuint = System.UInt32;
+using nuint = System.UInt32;
#endif
namespace System.Runtime
@@ -26,8 +26,13 @@ namespace System.Runtime
}
}
+ internal unsafe static void RhZeroMemory(IntPtr p, UIntPtr byteLength)
+ {
+ RhZeroMemory((void*)p, (nuint)byteLength);
+ }
+
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- extern private unsafe static void RhZeroMemory(byte* b, nuint byteLength);
+ extern private unsafe static void RhZeroMemory(void* b, nuint byteLength);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern unsafe static void RhBulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount);
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
index 18139324a3..b49b372b4b 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs
@@ -17,7 +17,6 @@ using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Security;
-using System.Runtime.Remoting;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
index 7fc3ce27d9..8fb54c79a7 100644
--- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
+++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs
@@ -15,7 +15,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Runtime.Remoting;
using System.Globalization;
using System.Diagnostics;
using System.Diagnostics.Contracts;