Imported Upstream version 4.0.1

Former-commit-id: 757121caeaad523350be5330f0a3ecc891c70fb8
This commit is contained in:
Jo Shields
2015-04-26 19:10:23 +01:00
parent 7fce50ac98
commit c54b0bda4e
252 changed files with 16715 additions and 1176 deletions

View File

@@ -19,7 +19,7 @@ namespace System {
using System.Runtime.Remoting;
#if FEATURE_REMOTING
using System.Runtime.Remoting.Activation;
using Message = System.Runtime.Remoting.Messaging.Message;
// using Message = System.Runtime.Remoting.Messaging.Message;
#endif
using System.Security;
using CultureInfo = System.Globalization.CultureInfo;
@@ -74,10 +74,10 @@ namespace System {
if ((object)type == null)
throw new ArgumentNullException("type");
Contract.EndContractBlock();
#if !FULL_AOT_RUNTIME
if (type is System.Reflection.Emit.TypeBuilder)
throw new NotSupportedException(Environment.GetResourceString("NotSupported_CreateInstanceWithTypeBuilder"));
#endif
// If they didn't specify a lookup, then we will provide the default lookup.
if ((bindingAttr & (BindingFlags) LookupMask) == 0)
bindingAttr |= Activator.ConstructorDefault;
@@ -110,7 +110,7 @@ namespace System {
static public Object CreateInstance(Type type, params Object[] args)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && type != null)
{
FrameworkEventSource.Log.ActivatorCreateInstance(type.GetFullNameForEtw());
@@ -138,7 +138,7 @@ namespace System {
static public Object CreateInstance(Type type)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && type != null)
{
FrameworkEventSource.Log.ActivatorCreateInstance(type.GetFullNameForEtw());
@@ -157,6 +157,10 @@ namespace System {
static public ObjectHandle CreateInstance(String assemblyName,
String typeName)
{
#if MONO
if(assemblyName == null)
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return CreateInstance(assemblyName,
typeName,
@@ -177,6 +181,10 @@ namespace System {
Object[] activationAttributes)
{
#if MONO
if(assemblyName == null)
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return CreateInstance(assemblyName,
typeName,
@@ -210,7 +218,7 @@ namespace System {
static public T CreateInstance<T>()
{
RuntimeType rt = typeof(T) as RuntimeType;
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && rt != null)
{
FrameworkEventSource.Log.ActivatorCreateInstanceT(rt.GetFullNameForEtw());
@@ -280,6 +288,10 @@ namespace System {
Object[] activationAttributes,
Evidence securityInfo)
{
#if MONO
if(assemblyName == null)
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return CreateInstance(assemblyName,
typeName,
@@ -304,6 +316,10 @@ namespace System {
CultureInfo culture,
object[] activationAttributes)
{
#if MONO
if(assemblyName == null)
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return CreateInstance(assemblyName,
typeName,
@@ -335,7 +351,6 @@ namespace System {
throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
}
#endif // FEATURE_CAS_POLICY
Type type = null;
Assembly assembly = null;
if (assemblyString == null) {
@@ -611,7 +626,7 @@ namespace System {
activationAttributes,
null);
}
#if FEATURE_COMINTEROP
#if FEATURE_COMINTEROP || MONO_COM
#if FEATURE_CLICKONCE
[System.Security.SecuritySafeCritical] // auto-generated

View File

@@ -20,10 +20,101 @@ namespace System {
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_Attribute))]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Attribute : _Attribute
public abstract partial class Attribute : _Attribute
{
#region Private Statics
#if MONO
static Attribute[] InternalGetCustomAttributes (PropertyInfo element, Type type, bool inherit)
{
return (Attribute []) MonoCustomAttrs.GetCustomAttributes (element, type, inherit);
}
static Attribute[] InternalGetCustomAttributes (EventInfo element, Type type, bool inherit)
{
return (Attribute []) MonoCustomAttrs.GetCustomAttributes (element, type, inherit);
}
static Attribute[] InternalParamGetCustomAttributes (ParameterInfo parameter, Type attributeType, bool inherit)
{
if (parameter.Member.MemberType != MemberTypes.Method)
return null;
var method = (MethodInfo) parameter.Member;
var definition = method.GetBaseDefinition ();
if (method == definition)
return (Attribute []) parameter.GetCustomAttributes (typeof(Attribute), inherit);
var types = new List<Type> ();
var custom_attributes = new List<Attribute> ();
if (attributeType == null)
attributeType = typeof (Attribute);
while (true) {
var param = method.GetParametersInternal () [parameter.Position];
var param_attributes = (Attribute []) param.GetCustomAttributes (attributeType, false);
foreach (var param_attribute in param_attributes) {
var param_type = param_attribute.GetType ();
if (types.Contains (param_type))
continue;
types.Add (param_type);
custom_attributes.Add (param_attribute);
}
var base_method = method.GetBaseMethod ();
if (base_method == method)
break;
method = base_method;
}
var attributes = (Attribute []) Array.CreateInstance (attributeType, custom_attributes.Count);
custom_attributes.CopyTo (attributes, 0);
return attributes;
}
static bool InternalIsDefined (PropertyInfo element, Type attributeType, bool inherit)
{
return MonoCustomAttrs.IsDefined (element, attributeType, inherit);
}
static bool InternalIsDefined (EventInfo element, Type attributeType, bool inherit)
{
return MonoCustomAttrs.IsDefined (element, attributeType, inherit);
}
static bool InternalParamIsDefined (ParameterInfo parameter, Type attributeType, bool inherit)
{
if (parameter.IsDefined (attributeType, inherit))
return true;
if (!inherit)
return false;
var member = parameter.Member;
if (member.MemberType != MemberTypes.Method)
return false;
var method = ((MethodInfo) member).GetBaseMethod ();
while (true) {
var param = method.GetParametersInternal () [parameter.Position];
if (param.IsDefined (attributeType, false))
return true;
var base_method = method.GetBaseMethod ();
if (base_method == method)
break;
method = base_method;
}
return false;
}
#else
#region PropertyInfo
private static Attribute[] InternalGetCustomAttributes(PropertyInfo element, Type type, bool inherit)
{
@@ -414,7 +505,7 @@ namespace System {
return (Attribute[])Array.UnsafeCreateInstance(elementType, elementCount);
}
#endregion
#endif
#endregion
#region Public Statics

View File

@@ -19,7 +19,7 @@ namespace System {
using CultureInfo = System.Globalization.CultureInfo;
//Marked serializable even though it has no state.
[Serializable]
internal class DefaultBinder : Binder
internal partial class DefaultBinder : Binder
{
// This method is passed a set of methods and must choose the best
// fit. The methods all have the same number of arguments and the object
@@ -1097,7 +1097,7 @@ namespace System {
return methWithDeepestHierarchy;
}
#if !MONO
// CanConvertPrimitive
// This will determine if the source can be converted to the target type
[System.Security.SecurityCritical] // auto-generated
@@ -1112,7 +1112,7 @@ namespace System {
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static internal extern bool CanConvertPrimitiveObjectToType(Object source,RuntimeType type);
#endif
// This method will sort the vars array into the mapping order stored
// in the paramOrder array.
private static void ReorderParams(int[] paramOrder,Object[] vars)

View File

@@ -66,13 +66,17 @@ namespace System
if (getValues || getNames)
{
#if MONO
if (!GetEnumValuesAndNames (enumType, out values, out names))
Array.Sort (values, names, System.Collections.Generic.Comparer<ulong>.Default);
#else
GetEnumValuesAndNames(
enumType.GetTypeHandleInternal(),
JitHelpers.GetObjectHandleOnStack(ref values),
JitHelpers.GetObjectHandleOnStack(ref names),
getValues,
getNames);
#endif
if (getValues)
hashEntry.values = values;
@@ -283,12 +287,16 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern RuntimeType InternalGetUnderlyingType(RuntimeType enumType);
#if MONO
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool GetEnumValuesAndNames (RuntimeType enumType, out ulong[] values, out string[] names);
#else
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern void GetEnumValuesAndNames(RuntimeTypeHandle enumType, ObjectHandleOnStack values, ObjectHandleOnStack names, bool getValues, bool getNames);
#endif
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -421,7 +429,7 @@ namespace System
parseResult.SetFailure(ParseFailureKind.Argument, "Arg_MustContainEnumInfo", null);
return false;
}
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumTryParseEnum(rtType.GetFullNameForEtw(), value);
@@ -525,7 +533,7 @@ namespace System
throw new ArgumentNullException("enumType");
Contract.Ensures(Contract.Result<Type>() != null);
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumGetUnderlyingType(enumType.GetFullNameForEtw());
@@ -542,7 +550,7 @@ namespace System
throw new ArgumentNullException("enumType");
Contract.Ensures(Contract.Result<Array>() != null);
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumGetValues(enumType.GetFullNameForEtw());
@@ -569,7 +577,7 @@ namespace System
throw new ArgumentNullException("enumType");
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumGetName(enumType.GetFullNameForEtw());
@@ -586,7 +594,7 @@ namespace System
Contract.Ensures(Contract.Result<String[]>() != null);
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumGetNames(enumType.GetFullNameForEtw());
@@ -668,7 +676,7 @@ namespace System
if (enumType == null)
throw new ArgumentNullException("enumType");
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumIsDefined(enumType.GetFullNameForEtw());
@@ -696,7 +704,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginEnumFormat(rtType.GetFullNameForEtw());
@@ -726,7 +734,7 @@ namespace System
// all acceptable format string are of length 1
throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification"));
}
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndEnumFormat(rtType.GetFullNameForEtw());
@@ -771,10 +779,18 @@ namespace System
}
#endregion
#if MONO
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern object get_value ();
#endif
#region Private Methods
[System.Security.SecuritySafeCritical]
internal unsafe Object GetValue()
{
#if MONO
return get_value ();
#else
fixed (void* pValue = &JitHelpers.GetPinningHelper(this).m_data)
{
switch (InternalGetCorElementType())
@@ -812,6 +828,7 @@ namespace System
return null;
}
}
#endif
}
[System.Security.SecurityCritical] // auto-generated
@@ -822,19 +839,31 @@ namespace System
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
#if MONO
private extern int get_hashcode ();
#else
private extern CorElementType InternalGetCorElementType();
#endif
#endregion
#region Object Overrides
#if MONO
public override bool Equals (object obj)
{
return DefaultEquals (this, obj);
}
#else
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern override bool Equals(Object obj);
#endif
[System.Security.SecuritySafeCritical]
public override unsafe int GetHashCode()
{
#if MONO
return get_hashcode ();
#else
// Avoid boxing by inlining GetValue()
// return GetValue().GetHashCode();
@@ -875,6 +904,7 @@ namespace System
return 0;
}
}
#endif
}
public override String ToString()
@@ -1138,7 +1168,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1159,7 +1189,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1180,7 +1210,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1201,7 +1231,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1223,7 +1253,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1245,7 +1275,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1266,7 +1296,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());
@@ -1288,7 +1318,7 @@ namespace System
RuntimeType rtType = enumType as RuntimeType;
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EnumToObject(enumType.GetFullNameForEtw());

View File

@@ -109,6 +109,54 @@ namespace System.Globalization {
internal sbyte digit;
}
unsafe private static int EndianSwap(int value)
{
if (!BitConverter.IsLittleEndian) {
byte *ptr = (byte *) &value;
int res;
byte *buf = (byte *) &res;
int t = sizeof(int) - 1;
for (int i = 0; i < sizeof(int); i++)
buf[t-i] = ptr[i];
return(res);
} else
return(value);
}
unsafe private static uint EndianSwap(uint value)
{
if (!BitConverter.IsLittleEndian) {
byte *ptr = (byte *) &value;
uint res;
byte *buf = (byte *) &res;
uint t = sizeof(uint) - 1;
for (uint i = 0; i < sizeof(uint); i++)
buf[t-i] = ptr[i];
return(res);
} else
return(value);
}
unsafe private static ushort EndianSwap(ushort value)
{
if (!BitConverter.IsLittleEndian) {
byte *ptr = (byte *) &value;
ushort res;
byte *buf = (byte *) &res;
ushort t = sizeof(ushort) - 1;
for (ushort i = 0; i < sizeof(ushort); i++)
buf[t-i] = ptr[i];
return(res);
} else
return(value);
}
//We need to allocate the underlying table that provides us with the information that we
//use. We allocate this once in the class initializer and then we don't need to worry
@@ -125,11 +173,11 @@ namespace System.Globalization {
UnicodeDataHeader* mainHeader = (UnicodeDataHeader*)pDataTable;
// Set up the native pointer to different part of the tables.
s_pCategoryLevel1Index = (ushort*) (pDataTable + mainHeader->OffsetToCategoriesIndex);
s_pCategoriesValue = (byte*) (pDataTable + mainHeader->OffsetToCategoriesValue);
s_pNumericLevel1Index = (ushort*) (pDataTable + mainHeader->OffsetToNumbericIndex);
s_pNumericValues = (byte*) (pDataTable + mainHeader->OffsetToNumbericValue);
s_pDigitValues = (DigitValues*) (pDataTable + mainHeader->OffsetToDigitValue);
s_pCategoryLevel1Index = (ushort*) (pDataTable + EndianSwap(mainHeader->OffsetToCategoriesIndex));
s_pCategoriesValue = (byte*) (pDataTable + EndianSwap(mainHeader->OffsetToCategoriesValue));
s_pNumericLevel1Index = (ushort*) (pDataTable + EndianSwap(mainHeader->OffsetToNumbericIndex));
s_pNumericValues = (byte*) (pDataTable + EndianSwap(mainHeader->OffsetToNumbericValue));
s_pDigitValues = (DigitValues*) (pDataTable + EndianSwap(mainHeader->OffsetToDigitValue));
return true;
}
@@ -254,11 +302,11 @@ namespace System.Globalization {
internal unsafe static double InternalGetNumericValue(int ch) {
Contract.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range.");
// Get the level 2 item from the highest 12 bit (8 - 19) of ch.
ushort index = s_pNumericLevel1Index[ch >> 8];
ushort index = EndianSwap(s_pNumericLevel1Index[ch >> 8]);
// Get the level 2 WORD offset from the 4 - 7 bit of ch. This provides the base offset of the level 3 table.
// The offset is referred to an float item in m_pNumericFloatData.
// Note that & has the lower precedence than addition, so don't forget the parathesis.
index = s_pNumericLevel1Index[index + ((ch >> 4) & 0x000f)];
index = EndianSwap(s_pNumericLevel1Index[index + ((ch >> 4) & 0x000f)]);
byte* pBytePtr = (byte*)&(s_pNumericLevel1Index[index]);
// Get the result from the 0 -3 bit of ch.
#if WIN64
@@ -448,12 +496,13 @@ namespace System.Globalization {
[System.Security.SecuritySafeCritical] // auto-generated
internal unsafe static byte InternalGetCategoryValue(int ch, int offset) {
Contract.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range.");
// Get the level 2 item from the highest 12 bit (8 - 19) of ch.
ushort index = s_pCategoryLevel1Index[ch >> 8];
ushort index = EndianSwap(s_pCategoryLevel1Index[ch >> 8]);
// Get the level 2 WORD offset from the 4 - 7 bit of ch. This provides the base offset of the level 3 table.
// Note that & has the lower precedence than addition, so don't forget the parathesis.
index = s_pCategoryLevel1Index[index + ((ch >> 4) & 0x000f)];
index = EndianSwap(s_pCategoryLevel1Index[index + ((ch >> 4) & 0x000f)]);
byte* pBytePtr = (byte*)&(s_pCategoryLevel1Index[index]);
// Get the result from the 0 -3 bit of ch.
byte valueIndex = pBytePtr[(ch & 0x000f)];

View File

@@ -23,14 +23,14 @@ namespace System.Reflection
public static IEnumerable<PropertyInfo> GetRuntimeProperties(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperties(type.GetFullNameForEtw());
}
#endif
IEnumerable<PropertyInfo> properties = type.GetProperties(everything);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperties(type.GetFullNameForEtw());
@@ -41,14 +41,14 @@ namespace System.Reflection
public static IEnumerable<EventInfo> GetRuntimeEvents(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvents(type.GetFullNameForEtw());
}
#endif
IEnumerable<EventInfo> events = type.GetEvents(everything);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvents(type.GetFullNameForEtw());
@@ -60,14 +60,14 @@ namespace System.Reflection
public static IEnumerable<MethodInfo> GetRuntimeMethods(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethods(type.GetFullNameForEtw());
}
#endif
IEnumerable<MethodInfo> methods = type.GetMethods(everything);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethods(type.GetFullNameForEtw());
@@ -79,14 +79,14 @@ namespace System.Reflection
public static IEnumerable<FieldInfo> GetRuntimeFields(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeFields(type.GetFullNameForEtw());
}
#endif
IEnumerable<FieldInfo> fields = type.GetFields(everything);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeFields(type.GetFullNameForEtw());
@@ -99,7 +99,7 @@ namespace System.Reflection
public static PropertyInfo GetRuntimeProperty(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperty(type.GetFullNameForEtw(), name != null ? name : "");
@@ -107,7 +107,7 @@ namespace System.Reflection
#endif
PropertyInfo pi = type.GetProperty(name);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperty(type.GetFullNameForEtw(), pi != null ? pi.GetFullNameForEtw() : "");
@@ -119,14 +119,14 @@ namespace System.Reflection
public static EventInfo GetRuntimeEvent(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvent(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
EventInfo ei = type.GetEvent(name);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvent(type.GetFullNameForEtw(), ei != null ? ei.GetFullNameForEtw() : "");
@@ -138,14 +138,14 @@ namespace System.Reflection
public static MethodInfo GetRuntimeMethod(this Type type, string name, Type[] parameters)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethod(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
MethodInfo mi = type.GetMethod(name, parameters);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethod(type.GetFullNameForEtw(), mi != null ? mi.GetFullNameForEtw() : "");
@@ -157,14 +157,14 @@ namespace System.Reflection
public static FieldInfo GetRuntimeField(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeField(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
FieldInfo fi = type.GetField(name);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeField(type.GetFullNameForEtw(), fi != null ? fi.GetFullNameForEtw() : "");

View File

@@ -388,7 +388,7 @@ namespace System.Reflection {
}
#endif
#if FEATURE_CORECLR || !FEATURE_PAL
#if FEATURE_CORECLR || !FEATURE_PAL || MONO
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyNameAttribute : Attribute

View File

@@ -30,7 +30,7 @@ namespace System.Reflection
if(rcType==null){
return null;
}else{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.IntrospectionExtensionsGetTypeInfo(type.GetFullNameForEtw());

View File

@@ -62,7 +62,14 @@ namespace System.Reflection
throw new NotImplementedException();
}
#if MONO
public virtual extern int MetadataToken {
[System.Runtime.CompilerServices.MethodImplAttribute (System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
get;
}
#else
public virtual int MetadataToken { get { throw new InvalidOperationException(); } }
#endif
public virtual Module Module
{

View File

@@ -57,7 +57,7 @@ namespace System.Reflection
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
#pragma warning restore 618
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class MethodBase : MemberInfo, _MethodBase
public abstract partial class MethodBase : MemberInfo, _MethodBase
{
#region Static Members
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
@@ -65,18 +65,24 @@ namespace System.Reflection
if (handle.IsNullHandle())
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetMethodFromHandle();
}
#endif
#if MONO
MethodBase m = GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
if (m == null)
throw new ArgumentException ("The handle is invalid.");
#else
MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
#endif
Type declaringType = m.DeclaringType;
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && declaringType != null)
{
FrameworkEventSource.Log.EndGetMethodFromHandle(declaringType.GetFullNameForEtw(), m.GetFullNameForEtw());
@@ -97,16 +103,22 @@ namespace System.Reflection
if (handle.IsNullHandle())
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetMethodFromHandle();
}
#endif
#if MONO
MethodBase m = GetMethodFromHandleInternalType (handle.Value, declaringType.Value);
if (m == null)
throw new ArgumentException ("The handle is invalid.");
#else
MethodBase m = RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
#endif
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && declaringType != null && m != null)
{
FrameworkEventSource.Log.EndGetMethodFromHandle(declaringType.GetRuntimeType().GetFullNameForEtw(), m.GetFullNameForEtw());
@@ -116,6 +128,10 @@ namespace System.Reflection
return m;
}
#if MONO
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static MethodBase GetCurrentMethod ();
#else
[System.Security.DynamicSecurityMethod] // Specify DynamicSecurityMethod attribute to prevent inlining of the caller.
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static MethodBase GetCurrentMethod()
@@ -123,6 +139,7 @@ namespace System.Reflection
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeMethodInfo.InternalGetCurrentMethod(ref stackMark);
}
#endif
#endregion
#region Constructor
@@ -382,7 +399,7 @@ namespace System.Reflection
return parameterTypes;
}
#if !MONO
[System.Security.SecuritySafeCritical]
internal Object[] CheckArguments(Object[] parameters, Binder binder,
BindingFlags invokeAttr, CultureInfo culture, Signature sig)
@@ -409,6 +426,7 @@ namespace System.Reflection
return copyOfParameters;
}
#endif
#endregion
void _MethodBase.GetTypeInfoCount(out uint pcTInfo)

View File

@@ -44,7 +44,7 @@ namespace System.Reflection {
// Implementation attributes.
Import = 0x00001000, // Class / interface is imported
Serializable = 0x00002000, // The class is Serializable.
#if FEATURE_COMINTEROP
#if FEATURE_COMINTEROP || MONO_COM
[ComVisible(false)]
WindowsRuntime = 0x00004000, // Type is a Windows Runtime type.
#endif // FEATURE_COMINTEROP

View File

@@ -85,14 +85,14 @@ namespace System.Reflection
public virtual EventInfo GetDeclaredEvent(String name)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvent(GetFullNameForEtw(), name != null ? name : "");
}
#endif
EventInfo ei = GetEvent(name, Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvent(GetFullNameForEtw(), ei != null ? ei.GetFullNameForEtw() : "");
@@ -102,14 +102,14 @@ namespace System.Reflection
}
public virtual FieldInfo GetDeclaredField(String name)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeField(GetFullNameForEtw(), name != null ? name : "");
}
#endif
FieldInfo fi = GetField(name, Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeField(GetFullNameForEtw(), fi != null ? fi.GetFullNameForEtw() : "");
@@ -119,14 +119,14 @@ namespace System.Reflection
}
public virtual MethodInfo GetDeclaredMethod(String name)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethod(GetFullNameForEtw(), name != null ? name : "");
}
#endif
MethodInfo mi = GetMethod(name, Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethod(GetFullNameForEtw(), mi != null ? mi.GetFullNameForEtw() : "");
@@ -137,7 +137,7 @@ namespace System.Reflection
public virtual IEnumerable<MethodInfo> GetDeclaredMethods(String name)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethods(GetFullNameForEtw());
@@ -150,7 +150,7 @@ namespace System.Reflection
yield return method;
}
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethods(GetFullNameForEtw());
@@ -168,14 +168,14 @@ namespace System.Reflection
}
public virtual PropertyInfo GetDeclaredProperty(String name)
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperty(GetFullNameForEtw(), name != null ? name : "");
}
#endif
PropertyInfo pi = GetProperty(name, Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperty(GetFullNameForEtw(), pi != null ? pi.GetFullNameForEtw() : "");
@@ -194,14 +194,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeConstructors(GetFullNameForEtw());
}
#endif
IEnumerable<ConstructorInfo> constructors = GetConstructors(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeConstructors(GetFullNameForEtw());
@@ -215,14 +215,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvents(GetFullNameForEtw());
}
#endif
IEnumerable<EventInfo> events = GetEvents(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvents(GetFullNameForEtw());
@@ -236,14 +236,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeFields(GetFullNameForEtw());
}
#endif
IEnumerable<FieldInfo> fields = GetFields(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeFields(GetFullNameForEtw());
@@ -257,14 +257,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMembers(GetFullNameForEtw());
}
#endif
IEnumerable<MemberInfo> members = GetMembers(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMembers(GetFullNameForEtw());
@@ -278,14 +278,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethods(GetFullNameForEtw());
}
#endif
IEnumerable<MethodInfo> methods = GetMethods(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethods(GetFullNameForEtw());
@@ -308,14 +308,14 @@ namespace System.Reflection
{
get
{
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperties(GetFullNameForEtw());
}
#endif
IEnumerable<PropertyInfo> properties = GetProperties(Type.DeclaredOnlyLookup);
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperties(GetFullNameForEtw());

View File

@@ -255,9 +255,14 @@ namespace System.Resources {
Contract.Assert(a != null, "assembly != null");
string cultureName = null;
short fallback = 0;
#if MONO
if (GetNeutralResourcesLanguageAttribute(a, ref cultureName, ref fallback)) {
#else
if (GetNeutralResourcesLanguageAttribute(((RuntimeAssembly)a).GetNativeHandle(),
JitHelpers.GetStringHandleOnStack(ref cultureName),
out fallback)) {
#endif
if ((UltimateResourceFallbackLocation)fallback < UltimateResourceFallbackLocation.MainAssembly || (UltimateResourceFallbackLocation)fallback > UltimateResourceFallbackLocation.Satellite) {
throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallback));
}
@@ -718,11 +723,24 @@ namespace System.Resources {
throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralAsm", resName, _mediator.MainAssembly.GetSimpleName()));
}
#if MONO
static bool GetNeutralResourcesLanguageAttribute (Assembly assembly, ref string cultureName, ref short fallbackLocation)
{
var ca = assembly.GetCustomAttribute<NeutralResourcesLanguageAttribute> ();
if (ca == null)
return false;
cultureName = ca.CultureName;
fallbackLocation = (short) ca.Location;
return true;
}
#else
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[System.Security.SecurityCritical] // Our security team doesn't yet allow safe-critical P/Invoke methods.
[ResourceExposure(ResourceScope.None)]
[System.Security.SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetNeutralResourcesLanguageAttribute(RuntimeAssembly assemblyHandle, StringHandleOnStack cultureName, out short fallbackLocation);
#endif
}
}

View File

@@ -516,9 +516,10 @@ namespace System.Resources {
_neutralResourcesCulture = ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(MainAssembly, ref _fallbackLoc);
#if !FEATURE_CORECLR && !MONO // PAL doesn't support eventing, and we don't compile event providers for coreclr
#if !FEATURE_CORECLR // PAL doesn't support eventing, and we don't compile event providers for coreclr
if (_bUsingModernResourceManagement == false)
{
#if !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled()) {
CultureInfo culture = CultureInfo.InvariantCulture;
String defaultResName = GetResourceFileName(culture);
@@ -533,7 +534,7 @@ namespace System.Resources {
FrameworkEventSource.Log.ResourceManagerNeutralResourcesNotFound(BaseNameField, MainAssembly, outputResName);
}
}
#endif
#pragma warning disable 618
ResourceSets = new Hashtable(); // for backward compatibility
#pragma warning restore 618

View File

@@ -94,7 +94,7 @@ namespace System.Resources {
private const int AverageValueSize = 40;
private Dictionary<String, Object> _resourceList;
private Stream _output;
internal Stream _output;
private Dictionary<String, Object> _caseInsensitiveDups;
private Dictionary<String, PrecannedResource> _preserializedData;
private const int _DefaultBufferSize = 4096;

View File

@@ -1 +1 @@
80740fd95865cd9fb6a9642e3b5690f0d62be948
f132cbc0e367fdac450e2d7468a29528524afb99

View File

@@ -407,7 +407,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
int numArrayItems = Math.Min(chunkSize/typeLength, array.Length-arrayOffset);
int bufferUsed = numArrayItems*typeLength;
Buffer.InternalBlockCopy(array, arrayOffset*typeLength, byteBuffer, 0, bufferUsed);
#if BIGENDIAN
if (!BitConverter.IsLittleEndian) {
// we know that we are writing a primitive type, so just do a simple swap
for (int i = 0; i < bufferUsed; i += typeLength)
{
@@ -418,7 +418,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
byteBuffer[i + typeLength-1 - j] = tmp;
}
}
#endif
}
WriteBytes(byteBuffer, 0, bufferUsed);
arrayOffset += numArrayItems;
}

View File

@@ -158,12 +158,12 @@ namespace System.Runtime.Serialization.Formatters.Binary {
bIsCrossAppDomain = isCrossAppDomain;
#endif
bSimpleAssembly = (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple);
#if !MONO
if (fCheck)
{
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
}
#endif
this.handler = handler;
Contract.Assert(!bFullDeserialization, "we just set bFullDeserialization to false");
@@ -244,12 +244,12 @@ namespace System.Runtime.Serialization.Formatters.Binary {
bIsCrossAppDomain = isCrossAppDomain;
#endif
bSimpleAssembly = (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple);
#if !MONO
if (fCheck)
{
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
}
#endif
this.handler = handler;
@@ -1504,9 +1504,10 @@ namespace System.Runtime.Serialization.Formatters.Binary {
if ( !FormatterServices.UnsafeTypeForwardersIsEnabled() && sourceAssembly != destAssembly )
{
// we have a type forward to attribute !
#if !DISABLE_CAS_USE
// we can try to see if the dest assembly has less permissionSet
if (!destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
#endif
{
// let us try to see if typeforwardedfrom is there
@@ -1521,17 +1522,20 @@ namespace System.Runtime.Serialization.Formatters.Binary {
typeFowardedFromAssembly = Assembly.Load(typeInfo.AssemblyString);
}
catch { }
#if !DISABLE_CAS_USE
if (typeFowardedFromAssembly != sourceAssembly)
{
// throw security exception
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
}
#endif
}
else
{
#if !DISABLE_CAS_USE
// throw security exception
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
#endif
}
}
}

View File

@@ -85,12 +85,12 @@ namespace System.Runtime.Serialization.Formatters.Binary
Contract.EndContractBlock();
SerTrace.Log(this, "Serialize Entry 2 ", graph, ((headers == null) ? " no headers " : "headers "));
#if !MONO
if (fCheck)
{
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
}
#endif
this.serWriter = serWriter;
this.headers = inHeaders;

View File

@@ -1031,7 +1031,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
int numArrayItems = Math.Min(chunkSize/typeLength, array.Length-arrayOffset);
int bufferUsed = numArrayItems*typeLength;
ReadBytes(byteBuffer, 0, bufferUsed);
#if BIGENDIAN
if (!BitConverter.IsLittleEndian) {
// we know that we are reading a primitive type, so just do a simple swap
for (int i = 0; i < bufferUsed; i += typeLength)
{
@@ -1042,7 +1042,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
byteBuffer[i + typeLength - 1 - j] = tmp;
}
}
#endif
}
Buffer.InternalBlockCopy(byteBuffer, 0, array, arrayOffset*typeLength, bufferUsed);
arrayOffset += numArrayItems;
}

Some files were not shown because too many files have changed in this diff Show More