Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -13,8 +13,9 @@ namespace System.Runtime.CompilerServices
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
internal sealed class TypeDependencyAttribute: Attribute
{
#pragma warning disable 414
private string typeName;
#pragma warning restore
public TypeDependencyAttribute (string typeName)
{

View File

@@ -32,11 +32,15 @@ namespace System.Runtime.ExceptionServices {
{
// Private members that will hold the relevant details.
private Exception m_Exception;
#if !MONO
private string m_remoteStackTrace;
#endif
private object m_stackTrace;
#if !MONO
private object m_dynamicMethods;
private UIntPtr m_IPForWatsonBuckets;
private Object m_WatsonBuckets;
#endif
private ExceptionDispatchInfo(Exception exception)
{
@@ -66,6 +70,7 @@ namespace System.Runtime.ExceptionServices {
#endif
}
#if !MONO
internal UIntPtr IPForWatsonBuckets
{
get
@@ -81,6 +86,7 @@ namespace System.Runtime.ExceptionServices {
return m_WatsonBuckets;
}
}
#endif
internal object BinaryStackTraceArray
{
@@ -90,6 +96,7 @@ namespace System.Runtime.ExceptionServices {
}
}
#if !MONO
internal object DynamicMethodArray
{
get
@@ -105,6 +112,7 @@ namespace System.Runtime.ExceptionServices {
return m_remoteStackTrace;
}
}
#endif
// This static method is used to create an instance of ExceptionDispatchInfo for
// the specified exception object and save all the required details that maybe

View File

@@ -522,6 +522,9 @@ namespace System.Runtime.InteropServices{
[System.Runtime.InteropServices.ComVisible(false)]
HString = 0x2f, // Windows Runtime HSTRING
[System.Runtime.InteropServices.ComVisible(false)]
LPUTF8Str = 0x30, // UTF8 string
}
#if !MONO

View File

@@ -110,7 +110,7 @@ namespace System.Runtime.InteropServices {
return null;
#endif
String dir = GetRuntimeDirectoryImpl();
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand();
#endif
return dir;
@@ -143,7 +143,7 @@ namespace System.Runtime.InteropServices {
String path = sb.ToString();
#endif
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
// Do security check
new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand();
#endif

View File

@@ -1278,11 +1278,13 @@ namespace System.Runtime.InteropServices.WindowsRuntime
if (type == null)
throw new ArgumentNullException("type");
#if FEATURE_COMINTEROP || MONO_COM
if (type.IsWindowsRuntimeObject && type.IsImport)
{
return (IActivationFactory)Marshal.GetNativeActivationFactory(type);
}
else
#endif
{
#if FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION
return GetManagedActivationFactory(type);

View File

@@ -639,15 +639,23 @@ namespace System.Runtime.Serialization.Formatters.Binary{
internal sealed class BinaryMethodCall
{
#if FEATURE_REMOTING
String uri;
#endif
String methodName;
String typeName;
#if FEATURE_REMOTING
Type[] instArgs;
#endif
Object[] args;
#if FEATURE_REMOTING
Object methodSignature;
#endif
Object callContext;
#if FEATURE_REMOTING
String scallContext;
Object properties;
#endif
Type[] argTypes;
bool bArgsPrimitive = true;
MessageEnum messageEnum;
@@ -657,14 +665,22 @@ namespace System.Runtime.Serialization.Formatters.Binary{
// if not the args are written out as a separate array
internal Object[] WriteArray(String uri, String methodName, String typeName, Type[] instArgs, Object[] args, Object methodSignature, Object callContext, Object[] properties)
{
#if FEATURE_REMOTING
this.uri = uri;
#endif
this.methodName = methodName;
this.typeName = typeName;
#if FEATURE_REMOTING
this.instArgs = instArgs;
#endif
this.args = args;
#if FEATURE_REMOTING
this.methodSignature = methodSignature;
#endif
this.callContext = callContext;
#if FEATURE_REMOTING
this.properties = properties;
#endif
int arraySize = 0;
if (args == null || args.Length == 0)
@@ -878,8 +894,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
{
if (callContext is String)
BinaryUtil.NVTraceI("callContext", (String)callContext);
#if FEATURE_REMOTING
else
BinaryUtil.NVTraceI("callContext", scallContext);
#endif
}
if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
@@ -900,10 +918,14 @@ namespace System.Runtime.Serialization.Formatters.Binary{
{
Object returnValue;
Object[] args;
#if FEATURE_REMOTING
Exception exception;
#endif
Object callContext;
#if FEATURE_REMOTING
String scallContext;
Object properties;
#endif
Type[] argTypes;
bool bArgsPrimitive = true;
MessageEnum messageEnum;
@@ -928,9 +950,13 @@ namespace System.Runtime.Serialization.Formatters.Binary{
this.returnValue = returnValue;
this.args = args;
#if FEATURE_REMOTING
this.exception = exception;
#endif
this.callContext = callContext;
#if FEATURE_REMOTING
this.properties = properties;
#endif
int arraySize = 0;
if (args == null || args.Length == 0)
@@ -1159,8 +1185,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
{
if (callContext is String)
BinaryUtil.NVTraceI("callContext", (String)callContext);
#if FEATURE_REMOTING
else
BinaryUtil.NVTraceI("callContext", scallContext);
#endif
}
if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))

View File

@@ -319,7 +319,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
}
internal BinaryObjectString binaryObjectString;
#if !MONO
internal BinaryCrossAppDomainString binaryCrossAppDomainString;
#endif
internal void WriteObjectString(int objectId, String value)
{
@@ -397,7 +399,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
private void WriteArrayAsBytes(Array array, int typeLength)
{
InternalWriteItemNull();
#if !MONO
int byteLength = array.Length*typeLength;
#endif
int arrayOffset = 0;
if (byteBuffer == null)
byteBuffer = new byte[chunkSize];
@@ -689,7 +693,9 @@ if (!BitConverter.IsLittleEndian) {
internal BinaryAssembly binaryAssembly;
#if !MONO
internal BinaryCrossAppDomainAssembly crossAppDomainAssembly;
#endif
internal void WriteAssembly(Type type, String assemblyString, int assemId, bool isNew)
{

View File

@@ -15,7 +15,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
[Serializable]
internal sealed class BinaryMethodCallMessage
{
#pragma warning disable 414
Object[] _inargs = null;
#pragma warning restore
String _methodName = null;
String _typeName = null;
Object _methodSignature = null;
@@ -100,7 +102,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
[Serializable]
internal class BinaryMethodReturnMessage
{
#pragma warning disable 414
Object[] _outargs = null;
#pragma warning restore
Exception _exception = null;
Object _returnValue = null;

View File

@@ -50,7 +50,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
internal Object m_topObject;
internal Header[] headers;
internal HeaderHandler handler;
#pragma warning disable 649
internal SerObjectInfoInit serObjectInfoInit;
#pragma warning restore
internal IFormatterConverter m_formatterConverter;
// Stack of Object ParseRecords
@@ -71,7 +73,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
private BinaryMethodReturn binaryMethodReturn;
private bool bIsCrossAppDomain;
#endif
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
private static FileIOPermission sfileIOPermission = new FileIOPermission(PermissionState.Unrestricted);
#endif
private SerStack ValueFixupStack
@@ -669,7 +671,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
{
SerTrace.Log( this, "ParseArray Entry");
#if !MONO
long genId = pr.PRobjectId;
#endif
if (pr.PRarrayTypeEnum == InternalArrayTypeE.Base64)
{
@@ -1055,9 +1059,11 @@ namespace System.Runtime.Serialization.Formatters.Binary {
ParseRecord objectPr = (ParseRecord)stack.Peek();
#if !MONO
String objName = null;
if (objectPr != null)
objName = objectPr.PRname;
#endif
#if _DEBUG
SerTrace.Log( this, "ParseMember ",objectPr.PRobjectId," ",pr.PRname);
@@ -1362,7 +1368,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
if (bSimpleAssembly)
{
try {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
sfileIOPermission.Assert();
#endif
try {
@@ -1373,7 +1379,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
#endif // FEATURE_FUSION
}
finally {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
@@ -1390,14 +1396,14 @@ namespace System.Runtime.Serialization.Formatters.Binary {
else {
try
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
sfileIOPermission.Assert();
#endif
try {
assm = Assembly.Load(assemblyName);
}
finally {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
@@ -1512,7 +1518,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
if ( !FormatterServices.UnsafeTypeForwardersIsEnabled() && sourceAssembly != destAssembly )
{
// we have a type forward to attribute !
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
// we can try to see if the dest assembly has less permissionSet
if (!destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
#endif
@@ -1523,14 +1529,16 @@ namespace System.Runtime.Serialization.Formatters.Binary {
TypeInformation typeInfo = BinaryFormatter.GetTypeInformation(resolvedType);
if (typeInfo.HasTypeForwardedFrom)
{
#pragma warning disable 219
Assembly typeFowardedFromAssembly = null;
#pragma warning restore
try
{
// if this Assembly.Load failed, we still want to throw security exception
typeFowardedFromAssembly = Assembly.Load(typeInfo.AssemblyString);
}
catch { }
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
if (typeFowardedFromAssembly != sourceAssembly)
{
// throw security exception
@@ -1540,7 +1548,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
}
else
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
// throw security exception
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
#endif

View File

@@ -354,8 +354,8 @@ namespace System.Runtime.Serialization.Formatters.Binary
{
for (int i=0; i<Count(); i++)
{
#if _DEBUG
Object obj = objects[i];
#if _DEBUG
SerTrace.Log(this, "Stack Dump ",stackId," "+((obj is ITrace)?((ITrace)obj).Trace():""));
#endif
}

View File

@@ -44,7 +44,9 @@ namespace System.Runtime.Serialization {
internal long m_fixupCount;
internal ISurrogateSelector m_selector;
internal StreamingContext m_context;
#if !FEATURE_PAL
bool m_isCrossAppDomain;
#endif
[System.Security.SecuritySafeCritical] // auto-generated
public ObjectManager(ISurrogateSelector selector, StreamingContext context) : this(selector, context, true, false) {
@@ -60,7 +62,9 @@ namespace System.Runtime.Serialization {
m_objects = new ObjectHolder[DefaultInitialSize];
m_selector = selector;
m_context = context;
#if !FEATURE_PAL
m_isCrossAppDomain = isCrossAppDomain;
#endif
}
@@ -341,7 +345,9 @@ namespace System.Runtime.Serialization {
int[] arrayIndex = null;
ValueTypeFixupInfo currFixup=null;
Object fixupObj=holder.ObjectValue;
#if false
ObjectHolder originalHolder = holder;
#endif
Contract.Assert(holder!=null, "[TypedReferenceBuilder.ctor]holder!=null");
Contract.Assert(holder.RequiresValueTypeFixup, "[TypedReferenceBuilder.ctor]holder.RequiresValueTypeFixup");

View File

@@ -36,7 +36,9 @@ using System.Diagnostics.Contracts;
// Traverse the hierarchy to find all methods with the particular attribute
while (baseType != null && baseType != typeof(Object))
{
#if !MONO
RuntimeType rt = (RuntimeType)baseType;
#endif
// Get all methods which are declared on this type, instance and public or nonpublic
MethodInfo[] mis = baseType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
#if _DEBUG
@@ -97,7 +99,9 @@ using System.Diagnostics.Contracts;
// Invoke all OnSerializingMethods
if (m_OnSerializingMethods != null)
{
#if !MONO
Object[] p = new Object[] {context};
#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnSerializingMethods)
{
@@ -116,7 +120,9 @@ using System.Diagnostics.Contracts;
// Invoke all OnDeserializingMethods
if (m_OnDeserializingMethods != null)
{
#if !MONO
Object[] p = new Object[] {context};
#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnDeserializingMethods)
{
@@ -135,7 +141,9 @@ using System.Diagnostics.Contracts;
// Invoke all OnDeserializingMethods
if (m_OnDeserializedMethods != null)
{
#if !MONO
Object[] p = new Object[] {context};
#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnDeserializedMethods)
{