Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -2,18 +2,20 @@ using System;
using System.Globalization;
using System.Runtime.CompilerServices;
#if FEATURE_WIN_DB_APPCOMPAT
namespace System.Runtime.Versioning
{
public static class CompatibilitySwitch
{
/* This class contains two sets of api:
/* This class contains 3 sets of api:
* 1. internal apis : These apis are supposed to be used by mscorlib.dll and other assemblies which use the <runtime> section in config
* These apis query for the value of quirk not only in windows quirk DB but also in runtime section of config files,
* registry and environment vars.
* 2. public apis : These apis are supposed to be used by FX assemblies which do not read the runtime section of config files and have
* have their own section in config files or do not use configs at all.
*
* 3. specialized apis: These apis are defined in order to retrieve a specific value defined in CLR Config. That value can have specific look-up rules
* for the order and location of the config sources used.
*
* These apis are for internal use only for FX assmeblies. It has not been decided if they can be used by OOB components due to EULA restrictions
*/
[System.Security.SecurityCritical]
@@ -25,6 +27,9 @@ namespace System.Runtime.Versioning
[System.Security.SecurityCritical]
public static string GetValue(string compatibilitySwitchName)
{
// This is used by AppContext.TryGetSwitch to check switch overrides in the Windows Quirk DB
// If this method is updated to check other locations than the DB, please ensure compat with
// the AppContext class.
return GetValueInternalCall(compatibilitySwitchName, true);
}
@@ -40,12 +45,14 @@ namespace System.Runtime.Versioning
return GetValueInternalCall(compatibilitySwitchName, false);
}
[System.Security.SecurityCritical]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern string GetAppContextOverridesInternalCall();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool IsEnabledInternalCall(string compatibilitySwitchName, bool onlyDB);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string GetValueInternalCall(string compatibilitySwitchName, bool onlyDB);
}
}
#endif

View File

@@ -0,0 +1,34 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: NonVersionableAttribute
**
**
** The [NonVersionable] attribute is applied to indicate that the implementation
** of a particular member or layout of a struct cannot be changed for given platform in incompatible way.
** This allows cross-module inlining of methods and data structures whose implementation
** is never changed in ReadyToRun native images. Any changes to such members or types would be
** breaking changes for ReadyToRun.
**
===========================================================*/
using System;
using System.Diagnostics;
namespace System.Runtime.Versioning {
// This Conditional is here to strip the annotations for targets where ReadyToRun is not supported.
// If this attribute is ever made public, this Conditional should be removed.
[Conditional("FEATURE_READYTORUN")]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor,
AllowMultiple = false, Inherited = false)]
sealed class NonVersionableAttribute : Attribute {
public NonVersionableAttribute()
{
}
}
}

View File

@@ -67,9 +67,9 @@ namespace System.Runtime.Versioning
// .NET Framework 3.5
// Silverlight 3
// Silverlight 4
// .NET Framework 4
// Expected additions:
// .NET Framework 4.5 <-> Silverlight 5 <-> Phone 7.1
// .NET Framework 4 Phone 8.0
// .NET Framework 4.5 Phone 8.1
// .NET Framework 4.5.1 Phone 8.1
//
// (Note: Windows Phone 7.0 was built using the .NET Compact Framework, which forked around v1 or v1.1)
//
@@ -145,25 +145,8 @@ namespace System.Runtime.Versioning
// Version number is major * 10000 + minor * 100 + build (ie, 4.5.1.0 would be version 40501).
private static int s_AppWasBuiltForVersion;
readonly static BinaryCompatibilityMap s_map;
readonly static BinaryCompatibilityMap s_map = new BinaryCompatibilityMap();
// Consider initializing the field directly instead of declaring a .cctor. There is a perf
// tradeoff to either choice. The tradeoff is some startup perf if you compile code
// that references this type, vs. a bit of a hit every time you use one of these methods
// because we must verify that the .cctor ran. For now, we'll make this class slower
// to use, but you can write code with quirks in it that only triggers iff you need legacy
// behavior (ie, if you need to not throw an exception, see if you need to throw it first
// via normal logic then check the compatibility flag).
// Initialize the s_map field right before it's going to be used, not the moment we
// JITs code that contains a call to this class. For this reason, explicitly create a
// .cctor instead of letting the compiler generate one with different initialization
// semantics.
static BinaryCompatibility()
{
s_map = new BinaryCompatibilityMap();
}
// For parsing a target Framework moniker, from the FrameworkName class
private const char c_componentSeparator = ',';
private const char c_keyValueSeparator = '=';
@@ -180,6 +163,7 @@ namespace System.Runtime.Versioning
// A bit for each property
internal bool TargetsAtLeast_Phone_V7_1;
internal bool TargetsAtLeast_Phone_V8_0;
internal bool TargetsAtLeast_Phone_V8_1;
internal bool TargetsAtLeast_Desktop_V4_5;
internal bool TargetsAtLeast_Desktop_V4_5_1;
internal bool TargetsAtLeast_Desktop_V4_5_2;
@@ -234,10 +218,15 @@ namespace System.Runtime.Versioning
case TargetFrameworkId.Phone:
if (buildAgainstVersion >= 80000)
{
// This is for Apollo apps. For Apollo apps we don't want to enable any of the 4.5 or 4.5.1 quirks
TargetsAtLeast_Phone_V8_0 = true;
// @
//TargetsAtLeast_Desktop_V4_5 = true;
}
if (buildAgainstVersion >= 80100)
{
// For WindowsPhone 8.1 and SL 8.1 scenarios we want to enable both 4.5 and 4.5.1 quirks.
TargetsAtLeast_Desktop_V4_5 = true;
TargetsAtLeast_Desktop_V4_5_1 = true;
}
if (buildAgainstVersion >= 710)
@@ -301,6 +290,24 @@ namespace System.Runtime.Versioning
targetFramework = TargetFrameworkId.NetCore;
break;
case "WindowsPhone":
if (targetFrameworkVersion >= 80100)
{
// A TFM of the form WindowsPhone,Version=v8.1 corresponds to SL 8.1 scenario
// and gets the same quirks as WindowsPhoneApp\v8.1 store apps.
targetFramework = TargetFrameworkId.Phone;
}
else
{
// There is no TFM for Apollo or below and hence we assign the targetFramework to Unspecified.
targetFramework = TargetFrameworkId.Unspecified;
}
break;
case "WindowsPhoneApp":
targetFramework = TargetFrameworkId.Phone;
break;
case "Silverlight":
targetFramework = TargetFrameworkId.Silverlight;
// Windows Phone 7 is Silverlight,Version=v4.0,Profile=WindowsPhone
@@ -443,15 +450,69 @@ namespace System.Runtime.Versioning
}
}
#if FEATURE_CORECLR
/// <summary>
/// This method checks for CompatibilitySwitches for SL8.1 scenarios.
/// PS - This is used only for SL 8.1
/// </summary>
[System.Security.SecuritySafeCritical]
private static bool IsAppUnderSL81CompatMode()
{
Contract.Assert(s_AppWasBuiltForFramework == TargetFrameworkId.NotYetChecked);
if (CompatibilitySwitches.IsAppSilverlight81)
{
// This is an SL8.1 scenario and hence it gets the same quirks as WPBlue+ settings.
s_AppWasBuiltForFramework = TargetFrameworkId.Phone;
s_AppWasBuiltForVersion = 80100;
return true;
}
return false;
}
#endif //FEATURE_CORECLR
[System.Security.SecuritySafeCritical]
private static void ReadTargetFrameworkId()
{
#if FEATURE_CORECLR
if (IsAppUnderSL81CompatMode())
{
// Since the SL does not have any Main() the reading of the TFM will not work and as a workaround we use the CompatibilitySwitch.IsAppSilverlight81
// to identify if the given app targets SL 8.1 and accordingly give it the value TargetFrameworkId.Phone;80100
// PS - This also means that the CompatMode set by AppDomain m_compatFlags with AppDomainCompatMode.APPDOMAINCOMPAT_APP_SL81
// will override any other mechanism like TFM, RegistryKey, env variable or config file settings. Since this option
// is only used by SL8.1 scenario's I don't think this is an issue and is rather desirable.
return;
}
#endif //FEATURE_CORECLR
String targetFrameworkName = AppDomain.CurrentDomain.GetTargetFrameworkName();
var overrideValue = System.Runtime.Versioning.CompatibilitySwitch.GetValueInternal("TargetFrameworkMoniker");
if (!string.IsNullOrEmpty(overrideValue))
{
targetFrameworkName = overrideValue;
}
// Write to a local then to _targetFramework, after writing the version number.
TargetFrameworkId fxId;
int fxVersion = 0;
if (targetFrameworkName == null)
fxId = TargetFrameworkId.Unspecified;
{
#if FEATURE_CORECLR
// if we don't have a value for targetFrameworkName we need to figure out if we should give the newest behavior or not.
if (CompatibilitySwitches.UseLatestBehaviorWhenTFMNotSpecified)
{
fxId = TargetFrameworkId.NetFramework;
fxVersion = 50000; // We are going to default to the latest value for version that we have in our code.
}
else
#endif
fxId = TargetFrameworkId.Unspecified;
}
else if (!ParseTargetFrameworkMonikerIntoEnum(targetFrameworkName, out fxId, out fxVersion))
fxId = TargetFrameworkId.Unrecognized;