diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-03-22 15:32:43 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-03-22 15:32:43 -0700 |
commit | 21cbca6a3165ac9f3e2a3c1753ac6ee023aa9443 (patch) | |
tree | 50be984a9a4c9932e536f029c849878230e6192d | |
parent | cfe34e6d0ed068caab9c4ee370549e86db4ee2bd (diff) | |
parent | 3e537a4fbc5480280c990b51bd61e7a0c12df860 (diff) | |
download | coreclr-21cbca6a3165ac9f3e2a3c1753ac6ee023aa9443.tar.gz coreclr-21cbca6a3165ac9f3e2a3c1753ac6ee023aa9443.tar.bz2 coreclr-21cbca6a3165ac9f3e2a3c1753ac6ee023aa9443.zip |
Merge pull request #3863 from jkotas/legacynetcf-2
Delete legacy netcf compat support (part 2)
42 files changed, 83 insertions, 1451 deletions
diff --git a/src/binder/CMakeLists.txt b/src/binder/CMakeLists.txt index 7180623f00..84b35b9cbc 100644 --- a/src/binder/CMakeLists.txt +++ b/src/binder/CMakeLists.txt @@ -18,7 +18,6 @@ set(BINDER_COMMON_SOURCES debuglog.cpp bindinglog.cpp cdebuglog.cpp - compatibility.cpp textualidentityparser.cpp assemblyidentitycache.cpp coreclrbindercommon.cpp diff --git a/src/binder/assemblybinder.cpp b/src/binder/assemblybinder.cpp index a4ad3c1798..55d0147b07 100644 --- a/src/binder/assemblybinder.cpp +++ b/src/binder/assemblybinder.cpp @@ -23,7 +23,6 @@ #ifdef FEATURE_VERSIONING_LOG #include "bindinglog.hpp" #endif // FEATURE_VERSIONING_LOG -#include "compatibility.hpp" #include "utils.hpp" #include "variables.hpp" #include "stringarraylist.h" @@ -47,10 +46,6 @@ BOOL IsCompilationProcess(); -#ifdef FEATURE_LEGACYNETCF -extern BOOL RuntimeIsLegacyNetCF(DWORD adid); -#endif - #if defined(FEATURE_HOST_ASSEMBLY_RESOLVER) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) #include "clrprivbindercoreclr.h" #include "clrprivbinderassemblyloadcontext.h" @@ -92,11 +87,6 @@ namespace BINDER_SPACE AssemblyVersion *pRequestedVersion = pRequestedName->GetVersion(); AssemblyVersion *pFoundVersion = pFoundName->GetVersion(); - bool fWindowsPhone7 = false; -#ifdef FEATURE_LEGACYNETCF - fWindowsPhone7 = RuntimeIsLegacyNetCF(pApplicationContext->GetAppDomainId()) == TRUE; -#endif - // // If the AssemblyRef has no version, we can treat it as requesting the most accommodating version (0.0.0.0). In // that case, skip version checking and allow the bind. @@ -105,41 +95,31 @@ namespace BINDER_SPACE { return hr; } - // - // Windows Phone 7 Quirk: + // This if condition is paired with the one above that checks for pRequestedName + // not having an assembly version. If we didn't exit in the above if condition, + // and satisfy this one's requirements, we're in a situation where the assembly + // Ref has a version, but the Def doesn't, which cannot succeed a bind // - // NetCF does not respect version numbers when binding unsigned assemblies. If you ask - // for a version you can get any version back, including an unversioned assembly. - // - if (!fWindowsPhone7 || pRequestedName->IsStronglyNamed()) + _ASSERTE(pRequestedName->HaveAssemblyVersion()); + if (!pFoundName->HaveAssemblyVersion()) { - // - // This if condition is paired with the one above that checks for pRequestedName - // not having an assembly version. If we didn't exit in the above if condition, - // and satisfy this one's requirements, we're in a situation where the assembly - // Ref has a version, but the Def doesn't, which cannot succeed a bind - // - _ASSERTE(pRequestedName->HaveAssemblyVersion()); - if (!pFoundName->HaveAssemblyVersion()) - { - hr = FUSION_E_APP_DOMAIN_LOCKED; - } - else if (pRequestedVersion->IsEqualFeatureVersion(pFoundVersion)) - { - // Now service version matters - if (pRequestedVersion->IsLargerServiceVersion(pFoundVersion)) - { - hr = FUSION_E_APP_DOMAIN_LOCKED; - } - } - else if (pRequestedVersion->IsLargerFeatureVersion(pFoundVersion)) + hr = FUSION_E_APP_DOMAIN_LOCKED; + } + else if (pRequestedVersion->IsEqualFeatureVersion(pFoundVersion)) + { + // Now service version matters + if (pRequestedVersion->IsLargerServiceVersion(pFoundVersion)) { hr = FUSION_E_APP_DOMAIN_LOCKED; } } - + else if (pRequestedVersion->IsLargerFeatureVersion(pFoundVersion)) + { + hr = FUSION_E_APP_DOMAIN_LOCKED; + } + if (pApplicationContext->IsTpaListProvided() && hr == FUSION_E_APP_DOMAIN_LOCKED) { // For our new binding models, use a more descriptive error code than APP_DOMAIN_LOCKED for bind @@ -929,15 +909,10 @@ namespace BINDER_SPACE HRESULT hr = S_OK; BINDER_LOG_ENTER(W("AssemblyBinder::BindByName")); PathString assemblyDisplayName; - ReleaseHolder<AssemblyName> pRetargetedAssemblyName; - BOOL fIsRetargeted = FALSE; - - // Apply retargeting - IF_FAIL_GO(Compatibility::Retarget(pAssemblyName, &pRetargetedAssemblyName, &fIsRetargeted)); // Look for already cached binding failure (ignore PA, every PA will lock the context) - pRetargetedAssemblyName->GetDisplayName(assemblyDisplayName, - AssemblyName::INCLUDE_VERSION); + pAssemblyName->GetDisplayName(assemblyDisplayName, + AssemblyName::INCLUDE_VERSION); hr = pApplicationContext->GetFailureCache()->Lookup(assemblyDisplayName); if (FAILED(hr)) @@ -953,18 +928,18 @@ namespace BINDER_SPACE else if (hr == S_FALSE) { // workaround: Special case for byte arrays. Rerun the bind to create binding log. - pRetargetedAssemblyName->SetIsDefinition(TRUE); + pAssemblyName->SetIsDefinition(TRUE); hr = S_OK; } - if (!Assembly::IsValidArchitecture(pRetargetedAssemblyName->GetArchitecture())) + if (!Assembly::IsValidArchitecture(pAssemblyName->GetArchitecture())) { // Assembly reference contains wrong architecture IF_FAIL_GO(FUSION_E_INVALID_NAME); } IF_FAIL_GO(BindLocked(pApplicationContext, - pRetargetedAssemblyName, + pAssemblyName, dwBindFlags, excludeAppPaths, pBindResult)); @@ -1014,8 +989,6 @@ namespace BINDER_SPACE BINDER_LOG_ENTER(W("AssemblyBinder::BindWhereRef")); ReleaseHolder<Assembly> pAssembly; - ReleaseHolder<AssemblyName> pRetargetedAssemblyName; - BOOL fIsRetargeted = FALSE; BindResult lockedBindResult; // Look for already cached binding failure @@ -1045,12 +1018,10 @@ namespace BINDER_SPACE AssemblyName *pAssemblyName; pAssemblyName = pAssembly->GetAssemblyName(); - IF_FAIL_GO(Compatibility::Retarget(pAssemblyName, &pRetargetedAssemblyName, &fIsRetargeted)); - if (!fNgenExplicitBind) { IF_FAIL_GO(BindLockedOrService(pApplicationContext, - pRetargetedAssemblyName, + pAssemblyName, excludeAppPaths, &lockedBindResult)); if (lockedBindResult.HaveResult()) @@ -1058,21 +1029,6 @@ namespace BINDER_SPACE pBindResult->SetResult(&lockedBindResult); GO_WITH_HRESULT(S_OK); } - - else if (fIsRetargeted) - { - // We did not find retargeted assembly. - // Check that assembly we have does match (must have retargetable property set). - ReleaseHolder<AssemblyName> pClonedAssemblyName; - - IF_FAIL_GO(pRetargetedAssemblyName->Clone(&pClonedAssemblyName)); - pClonedAssemblyName->SetIsRetargetable(TRUE); - - if (!pClonedAssemblyName->Equals(pAssemblyName, AssemblyName::INCLUDE_VERSION)) - { - IF_FAIL_GO(FUSION_E_REF_DEF_MISMATCH); - } - } } hr = S_OK; @@ -1241,17 +1197,8 @@ namespace BINDER_SPACE { DWORD dwIncludeFlags = AssemblyName::INCLUDE_DEFAULT; - bool fWindowsPhone7 = false; -#ifdef FEATURE_LEGACYNETCF - fWindowsPhone7 = RuntimeIsLegacyNetCF(pApplicationContext->GetAppDomainId()) == TRUE; -#endif - - if (!tpaListAssembly || (fWindowsPhone7 && tpaListAssembly)) + if (!tpaListAssembly) { - // - // On Windows Phone 7, exclude culture comparisons when requesting an uncultured - // assembly for app compat reasons (there are main app assemblies with spurious cultures) - // SString &culture = pRequestedAssemblyName->GetCulture(); if (culture.IsEmpty() || culture.EqualsCaseInsensitive(g_BinderVariables->cultureNeutral)) { diff --git a/src/binder/binder.targets b/src/binder/binder.targets index fc214c9ecb..01b35e2315 100644 --- a/src/binder/binder.targets +++ b/src/binder/binder.targets @@ -40,7 +40,6 @@ <CppCompile Include="..\DebugLog.cpp" /> <CppCompile Include="..\BindingLog.cpp" /> <CppCompile Include="..\CDebugLog.cpp" /> - <CppCompile Include="..\Compatibility.cpp" /> <CppCompile Include="..\TextualIdentityParser.cpp" /> <CppCompile Include="..\AssemblyIdentityCache.cpp" /> <CppCompile Include="..\CLRPrivBinderAssemblyLoadContext.cpp" Condition="'$(FeatureHostAssemblyResolver)' == 'true'"/> diff --git a/src/binder/compatibility.cpp b/src/binder/compatibility.cpp deleted file mode 100644 index ca376b63c8..0000000000 --- a/src/binder/compatibility.cpp +++ /dev/null @@ -1,255 +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. -// ============================================================ -// -// Compatibility.cpp -// - - -// -// Implements the V2 Compatibility class -// -// ============================================================ - -#include "compatibility.hpp" -#include "assemblyname.hpp" -#include "utils.hpp" -#include "ndpversion.h" - -#define ECMAKeyToken W("B77A5C561934E089") // The ECMA key used by some framework assemblies: mscorlib, system, etc. -#define FXKeyToken W("b03f5f7f11d50a3a") // The FX key used by other framework assemblies: System.Web, System.Drawing, etc. -#define CoreClrKeyToken W("7CEC85D7BEA7798E") // The silverlight platform key used by CoreClr framework assemblies: mscorlib, system, etc -#define SilverlightKeyToken W("31bf3856ad364e35") - -#define NETCF_PUBLIC_KEY_TOKEN_3 W("969db8053d3322ac") - -#ifdef FEATURE_LEGACYNETCF -extern BOOL RuntimeIsLegacyNetCF(DWORD adid); -#endif - -namespace BINDER_SPACE -{ - typedef struct - { - LPCWSTR pwzSimpleName; - LPCWSTR pwzPublicKeyToken; - LPCWSTR pwzVersion; - // Newline - LPCWSTR pwzNewSimpleName; - LPCWSTR pwzNewPublicKeyToken; - LPCWSTR pwzNewVersion; -#ifdef FEATURE_LEGACYNETCF - BOOL fMangoOnly; -#endif - } RetargetConfig; - - namespace - { - // Hard-coded retargeting table from legacy Fusion - - static RetargetConfig arRetargetConfig[] = - { - // Example entry - // {W("System.Data.SqlServerCe"), SQL_MOBILE_PUBLIC_KEY_TOKEN, W("3.0.3600.0"), - // NULL, SQL_PUBLIC_KEY_TOKEN, VER_SQL_ASSEMBLYVERSION_STR_L} - {W("Microsoft.CSharp"), SilverlightKeyToken, W("1.0.0.0-99.0.0.0"), - NULL, FXKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , FALSE -#endif - }, - {W("System.Xml"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - ,TRUE -#endif - }, - {W("System"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - }, - {W("Microsoft.VisualBasic"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - }, - {W("System.Core"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - }, - {W("System.Runtime.Serialization"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - }, - {W("System.ServiceModel"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - }, - {W("System.ServiceModel.Web"), NETCF_PUBLIC_KEY_TOKEN_3, W("1.0.0.0-99.0.0.0"), - NULL, CoreClrKeyToken, VER_ASSEMBLYVERSION_STR_L -#ifdef FEATURE_LEGACYNETCF - , TRUE -#endif - } - }; - - - BOOL IsMatchingString(/* in */ SString &sValue, - /* in */ LPCWSTR pwzValue) - { - SString value(SString::Literal, pwzValue); - - return EqualsCaseInsensitive(sValue, value); - } - - BOOL IsMatchingVersion(/* in */ AssemblyVersion *pAssemblyVersion, - /* in */ LPCWSTR pwzAssemblyVersion) - { - SmallStackSString assemblyVersionStr(pwzAssemblyVersion); - assemblyVersionStr.Normalize(); - SString::CIterator pos = assemblyVersionStr.Begin(); - - if (assemblyVersionStr.Find(pos, W('-'))) - { - SmallStackSString beginVersionStr(assemblyVersionStr, - assemblyVersionStr.Begin(), - pos++); - SmallStackSString endVersionStr(assemblyVersionStr, pos, assemblyVersionStr.End()); - - BINDER_LOG_STRING(W("begin"), beginVersionStr); - BINDER_LOG_STRING(W("end"), endVersionStr); - - AssemblyVersion beginVersion; - AssemblyVersion endVersion; - BOOL fIsValidBeginVersion = beginVersion.SetVersion(beginVersionStr.GetUnicode()); - BOOL fIsValidEndVersion = endVersion.SetVersion(endVersionStr.GetUnicode()); - _ASSERTE(fIsValidBeginVersion && fIsValidEndVersion); - - return (pAssemblyVersion->IsLargerOrEqual(&beginVersion) && - pAssemblyVersion->IsSmallerOrEqual(&endVersion)); - } - else - { - AssemblyVersion assemblyVersion; - BOOL fIsValidVersion = assemblyVersion.SetVersion(pwzAssemblyVersion); - _ASSERTE(fIsValidVersion); - - return pAssemblyVersion->Equals(&assemblyVersion); - } - } - }; - - - /* static */ - HRESULT Compatibility::Retarget(AssemblyName *pAssemblyName, - AssemblyName **ppRetargetedAssemblyName, - BOOL *pfIsRetargeted) - { - HRESULT hr = S_OK; - BINDER_LOG_ENTER(W("Compatibility::Retarget")); - - IF_FALSE_GO(pAssemblyName != NULL); - IF_FALSE_GO(ppRetargetedAssemblyName != NULL); - - BINDER_LOG_ASSEMBLY_NAME(W("source"), pAssemblyName); - - if (pfIsRetargeted) - { - *pfIsRetargeted = FALSE; - } -#ifdef FEATURE_CORESYSTEM - // Apply retargeting only for strong-named culture neutral assemblies - if (pAssemblyName->IsStronglyNamed() && - pAssemblyName->GetDeNormalizedCulture().IsEmpty()) - { - ReleaseHolder<AssemblyName> pRetargetedAssemblyName; - SString &simpleName = pAssemblyName->GetSimpleName(); - AssemblyVersion *pAssemblyVersion = pAssemblyName->GetVersion(); - SString publicKeyToken; - - TextualIdentityParser::BlobToHex(pAssemblyName->GetPublicKeyTokenBLOB(), - publicKeyToken); - - // Perform linear search for matching assembly. Legacy Fusion also does that - for (unsigned int i = 0; i < LENGTH_OF(arRetargetConfig); i++) - { -#ifdef FEATURE_LEGACYNETCF - if (!RuntimeIsLegacyNetCF(0) && arRetargetConfig[i].fMangoOnly == TRUE) - continue; -#endif - if (IsMatchingString(simpleName, arRetargetConfig[i].pwzSimpleName) && - IsMatchingVersion(pAssemblyVersion, arRetargetConfig[i].pwzVersion) && - IsMatchingString(publicKeyToken, arRetargetConfig[i].pwzPublicKeyToken)) - { - AssemblyVersion newAssemblyVersion; - IF_FALSE_GO(newAssemblyVersion.SetVersion(arRetargetConfig[i].pwzNewVersion)); - - SAFE_NEW(pRetargetedAssemblyName, AssemblyName); - - if (arRetargetConfig[i].pwzNewSimpleName != NULL) - { - pRetargetedAssemblyName-> - GetSimpleName().Set(arRetargetConfig[i].pwzNewSimpleName); - } - else - { - pRetargetedAssemblyName->GetSimpleName().Set(simpleName); - } - pRetargetedAssemblyName->SetVersion(&newAssemblyVersion); - - SBuffer newPublicKeyTokenBlob; - SmallStackSString newPublicKeyToken(arRetargetConfig[i].pwzNewPublicKeyToken); - TextualIdentityParser::HexToBlob(newPublicKeyToken, - FALSE /* fValidateHex */, - TRUE /* fIsToken */, - newPublicKeyTokenBlob); - - pRetargetedAssemblyName->GetPublicKeyTokenBLOB().Set(newPublicKeyTokenBlob); - - BINDER_LOG_ASSEMBLY_NAME(W("retargeted"), pRetargetedAssemblyName); - - *ppRetargetedAssemblyName = pRetargetedAssemblyName.Extract(); - - if (pfIsRetargeted) - { - *pfIsRetargeted = TRUE; - } - - GO_WITH_HRESULT(S_OK); - } - } - - // Create a clone without retargetable flag - if (pAssemblyName->GetIsRetargetable()) - { - IF_FAIL_GO(pAssemblyName->Clone(&pRetargetedAssemblyName)); - pRetargetedAssemblyName->SetIsRetargetable(FALSE); - *ppRetargetedAssemblyName = pRetargetedAssemblyName.Extract(); - } else - { - pAssemblyName->AddRef(); - *ppRetargetedAssemblyName = pAssemblyName; - } - } - else -#endif // FEATURE_CORESYSTEM - { - pAssemblyName->AddRef(); - *ppRetargetedAssemblyName = pAssemblyName; - } - - Exit: - BINDER_LOG_LEAVE_HR(W("Compatibility::Retarget"), hr); - return hr; - } -}; diff --git a/src/binder/inc/compatibility.hpp b/src/binder/inc/compatibility.hpp deleted file mode 100644 index 80ee20657b..0000000000 --- a/src/binder/inc/compatibility.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// ============================================================ -// -// Compatibility.hpp -// - - -// -// Defines the V2 Compatibility class -// -// ============================================================ - -#ifndef __BINDER__COMPATIBLITY_HPP__ -#define __BINDER__COMPATIBLITY_HPP__ - -#include "bindertypes.hpp" - -namespace BINDER_SPACE -{ - class Compatibility - { - public: - static HRESULT Retarget(/* in */ AssemblyName *pAssemblyName, - /* out */ AssemblyName **ppRetargetedAssemblyName, - /* out */ BOOL *pFIsRetargeted); - }; -}; - -#endif diff --git a/src/mscorlib/mscorlib.shared.sources.props b/src/mscorlib/mscorlib.shared.sources.props index 4713826ffd..3761d6e4dd 100644 --- a/src/mscorlib/mscorlib.shared.sources.props +++ b/src/mscorlib/mscorlib.shared.sources.props @@ -402,7 +402,6 @@ <SystemSources Include="$(BclSourcesRoot)\System\ParseNumbers.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\PlatformID.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\PlatformNotSupportedException.cs" /> - <SystemSources Include="$(BclSourcesRoot)\System\Platforms.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\Progress.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\Random.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\RankException.cs" /> @@ -415,7 +414,6 @@ <SystemSources Include="$(BclSourcesRoot)\System\SharedStatics.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\Single.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\StubHelpers.cs" /> - <SystemSources Include="$(BclSourcesRoot)\System\SupportedPlatformsAttribute.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\ThreadAttributes.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\TimeoutException.cs" /> <SystemSources Include="$(BclSourcesRoot)\System\TimeSpan.cs" /> @@ -1026,9 +1024,9 @@ <ItemGroup> <XmlSources Include="$(BclSourcesRoot)\System\Security\SecurityElement.cs" /> <XmlSources Include="$(BclSourcesRoot)\System\Security\XMLSyntaxException.cs" /> - <XmlSources Condition="'$(FeatureCasPolicy)' == 'true' or '$(FeatureLegacyNetCFCrypto)' == 'true'" Include="$(BclSourcesRoot)\System\Security\SecurityDocument.cs" /> - <XmlSources Condition="'$(FeatureCasPolicy)' == 'true' or '$(FeatureLegacyNetCFCrypto)' == 'true'" Include="$(BclSourcesRoot)\System\Security\Util\Parser.cs" /> - <XmlSources Condition="'$(FeatureCasPolicy)' == 'true' or '$(FeatureLegacyNetCFCrypto)' == 'true'" Include="$(BclSourcesRoot)\System\Security\Util\Tokenizer.cs" /> + <XmlSources Condition="'$(FeatureCasPolicy)' == 'true'" Include="$(BclSourcesRoot)\System\Security\SecurityDocument.cs" /> + <XmlSources Condition="'$(FeatureCasPolicy)' == 'true'" Include="$(BclSourcesRoot)\System\Security\Util\Parser.cs" /> + <XmlSources Condition="'$(FeatureCasPolicy)' == 'true'" Include="$(BclSourcesRoot)\System\Security\Util\Tokenizer.cs" /> </ItemGroup> <ItemGroup> <Win32Sources Include="$(BclSourcesRoot)\Microsoft\Win32\UnsafeNativeMethods.cs" /> @@ -1127,7 +1125,6 @@ <GenericsSources Include="$(BclSourcesRoot)\System\Collections\Concurrent\Partitioner.cs" /> <GenericsSources Include="$(BclSourcesRoot)\System\Collections\Concurrent\OrderablePartitioner.cs" /> <GenericsSources Include="$(BclSourcesRoot)\System\Collections\Concurrent\PartitionerStatic.cs" /> - <GenericsSources Condition="'$(FeatureLegacyNetCF)'=='true'" Include="$(BclSourcesRoot)\System\Collections\Generic\MangoArraySortHelper.cs" /> </ItemGroup> <ItemGroup> <SafehandleSources Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeFileHandle.cs" /> diff --git a/src/mscorlib/src/System/Activator.cs b/src/mscorlib/src/System/Activator.cs index 682eb81d36..8a8465a6a1 100644 --- a/src/mscorlib/src/System/Activator.cs +++ b/src/mscorlib/src/System/Activator.cs @@ -205,20 +205,6 @@ namespace System { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; // Skip the CreateInstanceCheckThis call to avoid perf cost and to maintain compatibility with V2 (throwing the same exceptions). -#if FEATURE_CORECLR - // In SL2/3 CreateInstance<T> doesn't do any security checks. This would mean that Assembly B can create instances of an internal - // type in Assembly A upon A's request: - // TypeInAssemblyA.DoWork() { AssemblyB.Create<InternalTypeInAssemblyA>();} - // TypeInAssemblyB.Create<T>() {return new T();} - // This violates type safety but we saw multiple user apps that have put a dependency on it. So for compatibility we allow this if - // the SL app was built against SL2/3. - // Note that in SL2/3 it is possible for app code to instantiate public transparent types with public critical default constructors. - // Fortunately we don't have such types in out platform assemblies. - if (CompatibilitySwitches.IsAppEarlierThanSilverlight4 || - CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - return (T)rt.CreateInstanceSlow(true /*publicOnly*/, true /*skipCheckThis*/, false /*fillCache*/, ref stackMark); - else -#endif // FEATURE_CORECLR return (T)rt.CreateInstanceDefaultCtor(true /*publicOnly*/, true /*skipCheckThis*/, true /*fillCache*/, ref stackMark); } diff --git a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs index e53fe20ad9..a7bdf99f63 100644 --- a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs +++ b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs @@ -26,19 +26,6 @@ namespace System /// </summary> private static void ParseTargetFrameworkName(out string identifier, out string profile, out int version) { -#if FEATURE_CORECLR - if (CompatibilitySwitches.IsAppSilverlight81) - { - // Since Silverlight apps don't have an explicit 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 WindowsPhone;80100 - identifier = "WindowsPhone"; - version = 80100; - profile = string.Empty; - return; - } -#endif - string targetFrameworkMoniker = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName; // If we don't have a TFM then we should default to the 4.0 behavior where all quirks are turned on. diff --git a/src/mscorlib/src/System/Collections/Generic/MangoArraySortHelper.cs b/src/mscorlib/src/System/Collections/Generic/MangoArraySortHelper.cs deleted file mode 100644 index 942ebebe54..0000000000 --- a/src/mscorlib/src/System/Collections/Generic/MangoArraySortHelper.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** -** -** Purpose: class to sort arrays -** -** -===========================================================*/ -namespace System.Collections.Generic { - - using System; - using System.Globalization; - using System.Runtime.CompilerServices; - - internal class MangoArraySortHelper<T> - - { - static MangoArraySortHelper<T> defaultArraySortHelper; - - public static MangoArraySortHelper<T> Default - { - get { - MangoArraySortHelper<T> sorter = defaultArraySortHelper; - if( sorter != null) { - return sorter; - } - return CreateArraySortHelper(); - } - } - - [System.Security.SecuritySafeCritical] // auto-generated - private static MangoArraySortHelper<T> CreateArraySortHelper() { - if (typeof(IComparable<T>).IsAssignableFrom(typeof(T))) { - defaultArraySortHelper = (MangoArraySortHelper<T>)RuntimeTypeHandle.Allocate(typeof(MangoGenericArraySortHelper<string>).TypeHandle.Instantiate(new Type[] { typeof(T) })); - } - else { - defaultArraySortHelper = new MangoArraySortHelper<T>(); - } - return defaultArraySortHelper; - } - - public void Sort(T[] items, int index, int length, IComparer<T> comparer) { - Sort<Object>(items, (object[])null, index, length, comparer); - } - - public virtual void Sort<TValue>(T[] keys, TValue[] values, int index, int length, IComparer<T> comparer) { - BCLDebug.Assert(keys != null, "Check the arguments in the caller!"); - BCLDebug.Assert( index >= 0 && length >= 0 && (keys.Length - index >= length), "Check the arguments in the caller!"); - - if( comparer == null || comparer == Comparer<T>.Default ) { - comparer = Comparer<T>.Default; - } - - QuickSort(keys, values, index, index + (length - 1), comparer); - } - - private void QuickSort<TValue>(T[] keys, TValue[] values, int left, int right, IComparer<T> comparer) { - do { - int i = left; - int j = right; - T x = keys[i + ((j - i) >> 1)]; - do { - // Add a try block here to detect IComparers (or their - // underlying IComparables, etc) that are bogus. - try { - while (comparer.Compare(keys[i], x) < 0) i++; - while (comparer.Compare(x, keys[j]) < 0) j--; - } - catch (IndexOutOfRangeException) { - throw new ArgumentException(null, "keys"); - } - catch (Exception) { - throw new InvalidOperationException(); - } - BCLDebug.Assert(i>=left && j<=right, "(i>=left && j<=right) Sort failed - Is your IComparer bogus?"); - if (i > j) break; - if (i < j) { - T key = keys[i]; - keys[i] = keys[j]; - keys[j] = key; - if (values != null) { - TValue value = values[i]; - values[i] = values[j]; - values[j] = value; - } - } - i++; - j--; - } while (i <= j); - if (j - left <= right - i) { - if (left < j) QuickSort(keys, values, left, j, comparer); - left = i; - } - else { - if (i < right) QuickSort(keys, values, i, right, comparer); - right = j; - } - } while (left < right); - } - - public virtual int BinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer) { - BCLDebug.Assert(array != null, "Check the arguments in the caller!"); - BCLDebug.Assert( index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!"); - - if (comparer == null) { - comparer = System.Collections.Generic.Comparer<T>.Default; - } - - int lo = index; - int hi = index + length - 1; - while (lo <= hi) { - int i = lo + ((hi -lo) >> 1); - int order; - try { - order = comparer.Compare(array[i], value); - } - catch (Exception) { - throw new InvalidOperationException(); - } - - if (order == 0) return i; - if (order < 0) { - lo = i + 1; - } - else { - hi = i - 1; - } - } - - return ~lo; - } - } - - - internal class MangoGenericArraySortHelper<T>: MangoArraySortHelper<T> where T: IComparable<T> { - // Do not add a constructor to this class because MangoArraySortHelper<T>.CreateSortHelper will not execute it - - public override int BinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer) { - BCLDebug.Assert(array != null, "Check the arguments in the caller!"); - BCLDebug.Assert( index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!"); - - if( comparer == null || comparer == Comparer<T>.Default ) { - return BinarySearch(array, index, length, value); - } - else { - return base.BinarySearch(array, index, length, value, comparer); - } - } - - public override void Sort<TValue>(T[] keys, TValue[] values, int index, int length, IComparer<T> comparer) { - BCLDebug.Assert(keys != null, "Check the arguments in the caller!"); - BCLDebug.Assert( index >= 0 && length >= 0 && (keys.Length - index >= length), "Check the arguments in the caller!"); - - if( comparer == null || comparer == Comparer<T>.Default ) { - // call the fatser version of QuickSort if the user doesn't provide a comparer - QuickSort(keys, values, index, index + length -1); - } - else { - base.Sort(keys, values, index, length, comparer); - } - } - - // This function is called when the user doesn't specify any comparer. - // Since T is constrained here, we can call IComparable<T>.CompareTo here. - // We can avoid boxing for value type and casting for reference types. - private int BinarySearch(T[] array, int index, int length, T value) { - int lo = index; - int hi = index + length - 1; - while (lo <= hi) { - int i = lo + ((hi -lo) >> 1); - int order; - try { - if( array[i] == null) { - order = (value == null) ? 0 : -1; - } - else { - order = array[i].CompareTo(value); - } - } - catch (Exception) { - throw new InvalidOperationException(); - } - - if (order == 0) return i; - if (order < 0) { - lo = i + 1; - } - else { - hi = i - 1; - } - } - - return ~lo; - } - - private void QuickSort<TValue>(T[] keys, TValue[] values, int left, int right) { - // The code in this function looks very similar to QuickSort in MangoArraySortHelper<T> class. - // The difference is that T is constrainted to IComparable<T> here. - // So the IL code will be different. This function is faster than the one in MangoArraySortHelper<T>. - do { - int i = left; - int j = right; - T x = keys[i + ((j - i) >> 1)]; - do { - // Add a try block here to detect IComparers (or their - // underlying IComparables, etc) that are bogus. - try { - if(x == null) { - // if x null, the loop to find two elements to be switched can be reduced. - while (keys[j] != null) j--; - } - else { - while(x.CompareTo(keys[i]) > 0) i++; - while(x.CompareTo(keys[j]) < 0) j--; - } - } - catch (IndexOutOfRangeException) { - throw new ArgumentException(null, "keys"); - } - catch (Exception) { - throw new InvalidOperationException(); - } - BCLDebug.Assert(i>=left && j<=right, "(i>=left && j<=right) Sort failed - Is your IComparer bogus?"); - if (i > j) break; - if (i < j) { - T key = keys[i]; - keys[i] = keys[j]; - keys[j] = key; - if (values != null) { - TValue value = values[i]; - values[i] = values[j]; - values[j] = value; - } - } - i++; - j--; - } while (i <= j); - if (j - left <= right - i) { - if (left < j) QuickSort(keys, values, left, j); - left = i; - } - else { - if (i < right) QuickSort(keys, values, i, right); - right = j; - } - } while (left < right); - } - } -} diff --git a/src/mscorlib/src/System/CompatibilitySwitches.cs b/src/mscorlib/src/System/CompatibilitySwitches.cs index f55d4d1c6a..52961ba322 100644 --- a/src/mscorlib/src/System/CompatibilitySwitches.cs +++ b/src/mscorlib/src/System/CompatibilitySwitches.cs @@ -13,13 +13,7 @@ namespace System { private static bool s_AreSwitchesSet; -#if FEATURE_LEGACYNETCF - private static bool s_isAppEarlierThanWindowsPhone8; - private static bool s_isAppEarlierThanWindowsPhoneMango; -#endif //FEATURE_LEGACYNETCF - #if FEATURE_CORECLR - private static bool s_isAppSilverlight81; // The app targets SL8.1 version private static bool s_useLatestBehaviorWhenTFMNotSpecified; // Which behavior to use when the TFM is not specified. #endif //FEATURE_CORECLR @@ -46,17 +40,9 @@ namespace System internal static void InitializeSwitches() { #if FEATURE_CORECLR - s_isAppSilverlight81 = IsCompatibilitySwitchSet("WindowsPhone_5.1.0.0"); s_useLatestBehaviorWhenTFMNotSpecified = IsCompatibilitySwitchSet("UseLatestBehaviorWhenTFMNotSpecified"); #endif //FEATURE_CORECLR -#if FEATURE_LEGACYNETCF - s_isAppEarlierThanWindowsPhoneMango = IsCompatibilitySwitchSet("WindowsPhone_3.7.0.0"); - s_isAppEarlierThanWindowsPhone8 = s_isAppEarlierThanWindowsPhoneMango || - IsCompatibilitySwitchSet("WindowsPhone_3.8.0.0"); - -#endif //FEATURE_LEGACYNETCF - #if !FEATURE_CORECLR s_isNetFx40TimeSpanLegacyFormatMode = IsCompatibilitySwitchSet("NetFx40_TimeSpanLegacyFormatMode"); s_isNetFx40LegacySecurityPolicy = IsCompatibilitySwitchSet("NetFx40_LegacySecurityPolicy"); @@ -66,28 +52,8 @@ namespace System s_AreSwitchesSet = true; } - public static bool IsAppEarlierThanSilverlight4 - { - get - { - return false; - } - } - #if FEATURE_CORECLR /// <summary> - /// This property returns whether the app is hosted under SL 8.1 version - /// </summary> - internal static bool IsAppSilverlight81 - { - get - { - // PS - Do not use this property for adding quirks. Please use the exposed properties of BinaryCompatiblity class instead. - return s_isAppSilverlight81; - } - } - - /// <summary> /// This property returns whether to give the latest behavior when the TFM is missing /// </summary> internal static bool UseLatestBehaviorWhenTFMNotSpecified @@ -99,30 +65,6 @@ namespace System } #endif //FEATURE_CORECLR - public static bool IsAppEarlierThanWindowsPhone8 - { - get - { -#if FEATURE_LEGACYNETCF - return s_isAppEarlierThanWindowsPhone8; -#else - return false; -#endif //FEATURE_LEGACYNETCF - } - } - - public static bool IsAppEarlierThanWindowsPhoneMango - { - get - { -#if FEATURE_LEGACYNETCF - return s_isAppEarlierThanWindowsPhoneMango; -#else - return false; -#endif //FEATURE_LEGACYNETCF - } - } - public static bool IsNetFx40TimeSpanLegacyFormatMode { get diff --git a/src/mscorlib/src/System/Enum.cs b/src/mscorlib/src/System/Enum.cs index b0e3bf8f07..598719e44d 100644 --- a/src/mscorlib/src/System/Enum.cs +++ b/src/mscorlib/src/System/Enum.cs @@ -551,14 +551,6 @@ namespace System // Delegate rest of error checking to the other functions TypeCode typeCode = Convert.GetTypeCode(value); - // NetCF doesn't support char and boolean conversion - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && - ((typeCode == TypeCode.Boolean) || (typeCode == TypeCode.Char))) - { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), "value"); - } - - switch (typeCode) { case TypeCode.Int32 : diff --git a/src/mscorlib/src/System/GC.cs b/src/mscorlib/src/System/GC.cs index 5f8f09f620..d5c9c59eb6 100644 --- a/src/mscorlib/src/System/GC.cs +++ b/src/mscorlib/src/System/GC.cs @@ -159,20 +159,13 @@ namespace System { // Returns the generation that obj is currently in. // -#if FEATURE_LEGACYNETCF - [System.Security.SecurityCritical] -#else [System.Security.SecuritySafeCritical] // auto-generated -#endif [MethodImplAttribute(MethodImplOptions.InternalCall)] public static extern int GetGeneration(Object obj); // Forces a collection of all generations from 0 through Generation. // -#if FEATURE_LEGACYNETCF - [System.Security.SecurityCritical] // auto-generated -#endif public static void Collect(int generation) { Collect(generation, GCCollectionMode.Default); } diff --git a/src/mscorlib/src/System/Globalization/CultureData.cs b/src/mscorlib/src/System/Globalization/CultureData.cs index a15025c390..8316f4617e 100644 --- a/src/mscorlib/src/System/Globalization/CultureData.cs +++ b/src/mscorlib/src/System/Globalization/CultureData.cs @@ -513,23 +513,6 @@ namespace System.Globalization return CultureData.Invariant; } - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - // WinCE named some locales differently than Windows. - if (cultureName.Equals("iw", StringComparison.OrdinalIgnoreCase)) - { - cultureName = "he"; - } - else if (cultureName.Equals("tl", StringComparison.OrdinalIgnoreCase)) - { - cultureName = "fil"; - } - else if (cultureName.Equals("english", StringComparison.OrdinalIgnoreCase)) - { - cultureName = "en"; - } - } - // Try the hash table first String hashName = AnsiToLower(useUserOverride ? cultureName : cultureName + '*'); Dictionary<String, CultureData> tempHashTable = s_cachedCultures; diff --git a/src/mscorlib/src/System/IO/File.cs b/src/mscorlib/src/System/IO/File.cs index 34d5cc147f..cfcb469bc3 100644 --- a/src/mscorlib/src/System/IO/File.cs +++ b/src/mscorlib/src/System/IO/File.cs @@ -227,21 +227,6 @@ namespace System.IO { if (path == null) throw new ArgumentNullException("path"); Contract.EndContractBlock(); - -#if FEATURE_LEGACYNETCF - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); - if(callingAssembly != null && !callingAssembly.IsProfileAssembly) { - string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName; - string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName; - throw new MethodAccessException(String.Format( - CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithCaller"), - caller, - callee)); - } - } -#endif // FEATURE_LEGACYNETCF InternalDelete(path, true); } @@ -341,20 +326,6 @@ namespace System.IO { [System.Security.SecuritySafeCritical] public static bool Exists(String path) { -#if FEATURE_LEGACYNETCF - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); - if(callingAssembly != null && !callingAssembly.IsProfileAssembly) { - string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName; - string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName; - throw new MethodAccessException(String.Format( - CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithCaller"), - caller, - callee)); - } - } -#endif // FEATURE_LEGACYNETCF return InternalExistsHelper(path, true); } @@ -655,25 +626,8 @@ namespace System.IO { } #endif -#if FEATURE_LEGACYNETCF - [System.Security.SecuritySafeCritical] -#endif // FEATURE_LEGACYNETCF public static FileStream OpenRead(String path) { -#if FEATURE_LEGACYNETCF - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); - if(callingAssembly != null && !callingAssembly.IsProfileAssembly) { - string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName; - string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName; - throw new MethodAccessException(String.Format( - CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithCaller"), - caller, - callee)); - } - } -#endif // FEATURE_LEGACYNETCF - return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); } diff --git a/src/mscorlib/src/System/IO/FileLoadException.cs b/src/mscorlib/src/System/IO/FileLoadException.cs index 3c6e7744df..60e5ff0e05 100644 --- a/src/mscorlib/src/System/IO/FileLoadException.cs +++ b/src/mscorlib/src/System/IO/FileLoadException.cs @@ -78,21 +78,6 @@ namespace System.IO { get { return _fileName; } } -#if FEATURE_LEGACYNETCF - // override Data property to populate FileLoadException with Hresult - public override System.Collections.IDictionary Data { - [System.Security.SecuritySafeCritical] - get { - var _data = base.Data; - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && !_data.Contains("HResult")) - { - _data.Add("HResult", HResult); - } - return _data; - } - } -#endif //FEATURE_LEGACYNETCF - public override String ToString() { String s = GetType().FullName + ": " + Message; diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs index c52daa4b8a..999a2add82 100644 --- a/src/mscorlib/src/System/IO/Stream.cs +++ b/src/mscorlib/src/System/IO/Stream.cs @@ -304,13 +304,6 @@ namespace System.IO { #if !NEW_EXPERIMENTAL_ASYNC_IO return BlockingBeginRead(buffer, offset, count, callback, state); #else - - // Mango did not do Async IO. - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - return BlockingBeginRead(buffer, offset, count, callback, state); - } - // To avoid a race with a stream's position pointer & generating race conditions // with internal buffer indexes in our own streams that // don't natively support async IO operations when there are multiple @@ -377,12 +370,6 @@ namespace System.IO { #if !NEW_EXPERIMENTAL_ASYNC_IO return BlockingEndRead(asyncResult); #else - // Mango did not do async IO. - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - return BlockingEndRead(asyncResult); - } - var readTask = _activeReadWriteTask; if (readTask == null) @@ -473,13 +460,6 @@ namespace System.IO { #if !NEW_EXPERIMENTAL_ASYNC_IO return BlockingBeginWrite(buffer, offset, count, callback, state); #else - - // Mango did not do Async IO. - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - return BlockingBeginWrite(buffer, offset, count, callback, state); - } - // To avoid a race condition with a stream's position pointer & generating conditions // with internal buffer indexes in our own streams that // don't natively support async IO operations when there are multiple @@ -589,15 +569,7 @@ namespace System.IO { #if !NEW_EXPERIMENTAL_ASYNC_IO BlockingEndWrite(asyncResult); -#else - - // Mango did not do Async IO. - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - BlockingEndWrite(asyncResult); - return; - } - +#else var writeTask = _activeReadWriteTask; if (writeTask == null) { diff --git a/src/mscorlib/src/System/IO/StreamReader.cs b/src/mscorlib/src/System/IO/StreamReader.cs index 671ec202a0..d42bbd044b 100644 --- a/src/mscorlib/src/System/IO/StreamReader.cs +++ b/src/mscorlib/src/System/IO/StreamReader.cs @@ -52,13 +52,6 @@ namespace System.IO { get { -#if FEATURE_LEGACYNETCF - // Quirk for Mango app compatibility - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - return 4096; - } -#endif // FEATURE_LEGACYNETCF return 1024; } } @@ -178,26 +171,9 @@ namespace System.IO Init(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen); } -#if FEATURE_LEGACYNETCF - [System.Security.SecuritySafeCritical] -#endif // FEATURE_LEGACYNETCF public StreamReader(String path) : this(path, true) { -#if FEATURE_LEGACYNETCF - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); - if(callingAssembly != null && !callingAssembly.IsProfileAssembly) { - string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName; - string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName; - throw new MethodAccessException(String.Format( - System.Globalization.CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithCaller"), - caller, - callee)); - } - } -#endif // FEATURE_LEGACYNETCF - } + } public StreamReader(String path, bool detectEncodingFromByteOrderMarks) : this(path, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultBufferSize) { diff --git a/src/mscorlib/src/System/IO/StreamWriter.cs b/src/mscorlib/src/System/IO/StreamWriter.cs index 7269efc007..9fd7ad5428 100644 --- a/src/mscorlib/src/System/IO/StreamWriter.cs +++ b/src/mscorlib/src/System/IO/StreamWriter.cs @@ -276,7 +276,7 @@ namespace System.IO __Error.WriterClosed(); // Perf boost for Flush on non-dirty writers. - if (charPos==0 && ((!flushStream && !flushEncoder) || CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)) + if (charPos==0 && (!flushStream && !flushEncoder)) return; if (!haveWrittenPreamble) { diff --git a/src/mscorlib/src/System/ObjectDisposedException.cs b/src/mscorlib/src/System/ObjectDisposedException.cs index c900eb293e..fdad0f8d52 100644 --- a/src/mscorlib/src/System/ObjectDisposedException.cs +++ b/src/mscorlib/src/System/ObjectDisposedException.cs @@ -52,7 +52,7 @@ namespace System { public String ObjectName { get { - if ((objectName == null) && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) + if (objectName == null) { return String.Empty; } diff --git a/src/mscorlib/src/System/OperatingSystem.cs b/src/mscorlib/src/System/OperatingSystem.cs index 67f7c9debb..6955310acf 100644 --- a/src/mscorlib/src/System/OperatingSystem.cs +++ b/src/mscorlib/src/System/OperatingSystem.cs @@ -35,11 +35,7 @@ namespace System { } internal OperatingSystem(PlatformID platform, Version version, string servicePack) { -#if !FEATURE_LEGACYNETCF if( platform < PlatformID.Win32S || platform > PlatformID.MacOSX) { -#else // FEATURE_LEGACYNETCF - if( platform < PlatformID.Win32S || platform > PlatformID.NokiaS60) { -#endif // FEATURE_LEGACYNETCF throw new ArgumentException( Environment.GetResourceString("Arg_EnumIllegalVal", (int)platform), "platform"); @@ -139,11 +135,9 @@ namespace System { case PlatformID.WinCE: os = "Microsoft Windows CE "; break; -#if !FEATURE_LEGACYNETCF case PlatformID.MacOSX: os = "Mac OS X "; break; -#endif default: os = "<unknown> "; break; diff --git a/src/mscorlib/src/System/PlatformID.cs b/src/mscorlib/src/System/PlatformID.cs index 89f9ca1376..57941996ee 100644 --- a/src/mscorlib/src/System/PlatformID.cs +++ b/src/mscorlib/src/System/PlatformID.cs @@ -22,11 +22,7 @@ namespace System { WinCE = 3, Unix = 4, Xbox = 5, -#if !FEATURE_LEGACYNETCF MacOSX = 6 -#else // FEATURE_LEGACYNETCF - NokiaS60 = 6 -#endif // FEATURE_LEGACYNETCF } } diff --git a/src/mscorlib/src/System/Platforms.cs b/src/mscorlib/src/System/Platforms.cs deleted file mode 100644 index 2d83b86e45..0000000000 --- a/src/mscorlib/src/System/Platforms.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** -** -** Purpose: Defines flags for supported platforms for use -** with the PlatformsSupportedAttribute -** -** -===========================================================*/ -#if FEATURE_CORECLR -namespace System -{ - -[Serializable] - [Flags] - public enum Platforms - { - Win32S = 1 << PlatformID.Win32S, - Win32Windows = 1 << PlatformID.Win32Windows, - Win32NT = 1 << PlatformID.Win32NT, - WinCE = 1 << PlatformID.WinCE, - Unix = 1 << PlatformID.Unix, - Xbox = 1 << PlatformID.Xbox, -#if !FEATURE_LEGACYNETCF - MacOSX = 1 << PlatformID.MacOSX, -#else // FEATURE_LEGACYNETCF - NokiaS60 = 1 << PlatformID.NokiaS60, -#endif // FEATURE_LEGACYNETCF - - All = Win32S | Win32Windows | Win32NT | WinCE | Unix | Xbox -#if !FEATURE_LEGACYNETCF -| MacOSX -#else // FEATURE_LEGACYNETCF -| NokiaS60 -#endif // FEATURE_LEGACYNETCF - } - -} -#endif // FEATURE_CORECLR diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/Assembly.cs index e0c7460905..b05fb42953 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.cs @@ -125,21 +125,6 @@ namespace System.Reflection #if FEATURE_WINDOWSPHONE throw new NotSupportedException(Environment.GetResourceString("NotSupported_WindowsPhone", "Assembly.LoadFrom")); #else -#if FEATURE_LEGACYNETCF - if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); - if(callingAssembly != null && !callingAssembly.IsProfileAssembly) { - string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName; - string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName; - throw new MethodAccessException(String.Format( - CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithCaller"), - caller, - callee)); - } - } -#endif // FEATURE_LEGACYNETCF - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RuntimeAssembly.InternalLoadFrom( @@ -870,7 +855,7 @@ namespace System.Reflection throw new NotImplementedException(); } -#if FEATURE_LEGACYNETCF +#if FEATURE_CORECLR internal virtual bool IsProfileAssembly { [System.Security.SecurityCritical] @@ -879,7 +864,7 @@ namespace System.Reflection throw new NotImplementedException(); } } -#endif // FEATURE_LEGACYNETCF +#endif // FEATURE_CORECLR public virtual IList<CustomAttributeData> GetCustomAttributesData() { @@ -2547,7 +2532,7 @@ namespace System.Reflection newGrant = granted; newDenied = denied; } -#if FEATURE_LEGACYNETCF +#if FEATURE_CORECLR [System.Security.SecurityCritical] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] @@ -2563,7 +2548,7 @@ namespace System.Reflection return GetIsProfileAssembly(GetNativeHandle()); } } -#endif // FEATURE_LEGACYNETCF +#endif // FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] @@ -2877,17 +2862,6 @@ namespace System.Reflection if (retAssembly == this || (retAssembly == null && throwOnFileNotFound)) { -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - if (retAssembly == this) - { - if (throwOnFileNotFound) - throw new FileNotFoundException(); - return null; - } - } -#endif throw new FileNotFoundException(String.Format(culture, Environment.GetResourceString("IO.FileNotFound_FileName"), an.Name)); } diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs index a271f76d59..f1d58ba44a 100644 --- a/src/mscorlib/src/System/Reflection/AssemblyName.cs +++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs @@ -283,11 +283,7 @@ namespace System.Reflection { { [System.Security.SecuritySafeCritical] // auto-generated get { - String name = nToString(); - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && string.IsNullOrEmpty(name)) - return base.ToString(); - - return name; + return nToString(); } } diff --git a/src/mscorlib/src/System/Reflection/Associates.cs b/src/mscorlib/src/System/Reflection/Associates.cs index 01c3c82c53..8b34e77b63 100644 --- a/src/mscorlib/src/System/Reflection/Associates.cs +++ b/src/mscorlib/src/System/Reflection/Associates.cs @@ -75,13 +75,8 @@ namespace System.Reflection // the reflected type, the private methods should not be exposed. Note that this implies that the // identity of a property includes it's reflected type. - // NetCF actually includes private methods from parent classes in Reflection results - // We will mimic that in Mango Compat mode. - if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) - return null; - } + if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) + return null; // Note this is the first time the property was encountered walking from the most derived class // towards the base class. It would seem to follow that any associated methods would not diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.cs b/src/mscorlib/src/System/Reflection/FieldInfo.cs index fca3c25470..eb35ef6baa 100644 --- a/src/mscorlib/src/System/Reflection/FieldInfo.cs +++ b/src/mscorlib/src/System/Reflection/FieldInfo.cs @@ -314,10 +314,7 @@ namespace System.Reflection #region Object Overrides public unsafe override String ToString() { - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - return FieldType.ToString() + " " + Name; - else - return FieldType.FormatTypeName() + " " + Name; + return FieldType.FormatTypeName() + " " + Name; } #endregion diff --git a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs b/src/mscorlib/src/System/Reflection/ParameterAttributes.cs index 74bb82dc19..12f8145ddd 100644 --- a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs +++ b/src/mscorlib/src/System/Reflection/ParameterAttributes.cs @@ -22,9 +22,7 @@ namespace System.Reflection { None = 0x0000, // no flag is specified In = 0x0001, // Param is [In] Out = 0x0002, // Param is [Out] -#if FEATURE_USE_LCID || FEATURE_LEGACYNETCF Lcid = 0x0004, // Param is [lcid] -#endif Retval = 0x0008, // Param is [Retval] Optional = 0x0010, // Param is optional diff --git a/src/mscorlib/src/System/Reflection/PropertyInfo.cs b/src/mscorlib/src/System/Reflection/PropertyInfo.cs index 0e4fa1e517..30e375c0d8 100644 --- a/src/mscorlib/src/System/Reflection/PropertyInfo.cs +++ b/src/mscorlib/src/System/Reflection/PropertyInfo.cs @@ -295,53 +295,11 @@ namespace System.Reflection Contract.Requires(this != target); Contract.Requires(this.ReflectedType == target.ReflectedType); - -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - return Signature.CompareSigForAppCompat(this.Signature, this.m_declaringType, - target.Signature, target.m_declaringType); -#endif return Signature.CompareSig(this.Signature, target.Signature); } internal BindingFlags BindingFlags { get { return m_bindingFlags; } } #endregion -#if FEATURE_LEGACYNETCF - // BEGIN helper methods for Dev11 466969 quirk - internal bool HasMatchingAccessibility(RuntimePropertyInfo target) - { - Contract.Assert(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8); - bool match = true; - - if (!IsMatchingAccessibility(this.GetGetMethod(true), target.GetGetMethod(true))) - { - match = false; - } - else if (!IsMatchingAccessibility(this.GetSetMethod(true), target.GetSetMethod(true))) - { - match = false; - } - - return match; - } - - private bool IsMatchingAccessibility(MethodInfo lhsInfo, MethodInfo rhsInfo) - { - if (lhsInfo != null && rhsInfo != null) - { - return lhsInfo.IsPublic == rhsInfo.IsPublic; - } - else - { - // don't be tempted to return false here! we only want to introduce - // the quirk behavior when we know that the accessibility is different. - // in all other cases return true so the code works as before. - return true; - } - } - // END helper methods for Dev11 466969 quirk -#endif - #region Object Overrides public override String ToString() { diff --git a/src/mscorlib/src/System/Resources/ResourceFallbackManager.cs b/src/mscorlib/src/System/Resources/ResourceFallbackManager.cs index 724e2ce7a5..def7836e05 100644 --- a/src/mscorlib/src/System/Resources/ResourceFallbackManager.cs +++ b/src/mscorlib/src/System/Resources/ResourceFallbackManager.cs @@ -93,40 +93,31 @@ namespace System.Resources // Added but disabled from desktop in .NET 4.0, stayed disabled in .NET 4.5 #if FEATURE_CORECLR -#if FEATURE_LEGACYNETCF - if(!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) + // 2. user preferred cultures, omitting starting culture if tried already + // Compat note: For console apps, this API will return cultures like Arabic + // or Hebrew that are displayed right-to-left. These don't work with today's + // CMD.exe. Since not all apps can short-circuit RTL languages to look at + // US English resources, we're exposing an appcompat flag for this, to make the + // osFallbackArray an empty array, mimicing our V2 behavior. Apps should instead + // be using CultureInfo.GetConsoleFallbackUICulture, and then test whether that + // culture's code page can be displayed on the console, and if not, they should + // set their culture to their neutral resources language. + // Note: the app compat switch will omit the OS Preferred fallback culture. + // Compat note 2: This feature breaks certain apps dependent on fallback to neutral + // resources. See extensive note in GetResourceFallbackArray. + CultureInfo[] osFallbackArray = LoadPreferredCultures(); + if (osFallbackArray != null) { -#endif // FEATURE_LEGACYNETCF - - // 2. user preferred cultures, omitting starting culture if tried already - // Compat note: For console apps, this API will return cultures like Arabic - // or Hebrew that are displayed right-to-left. These don't work with today's - // CMD.exe. Since not all apps can short-circuit RTL languages to look at - // US English resources, we're exposing an appcompat flag for this, to make the - // osFallbackArray an empty array, mimicing our V2 behavior. Apps should instead - // be using CultureInfo.GetConsoleFallbackUICulture, and then test whether that - // culture's code page can be displayed on the console, and if not, they should - // set their culture to their neutral resources language. - // Note: the app compat switch will omit the OS Preferred fallback culture. - // Compat note 2: This feature breaks certain apps dependent on fallback to neutral - // resources. See extensive note in GetResourceFallbackArray. - CultureInfo[] osFallbackArray = LoadPreferredCultures(); - if (osFallbackArray != null) + foreach (CultureInfo ci in osFallbackArray) { - foreach (CultureInfo ci in osFallbackArray) + // only have to check starting culture and immediate parent for now. + // in Dev10, revisit this policy. + if (m_startingCulture.Name != ci.Name && m_startingCulture.Parent.Name != ci.Name) { - // only have to check starting culture and immediate parent for now. - // in Dev10, revisit this policy. - if (m_startingCulture.Name != ci.Name && m_startingCulture.Parent.Name != ci.Name) - { - yield return ci; - } + yield return ci; } } -#if FEATURE_LEGACYNETCF } -#endif // FEATURE_LEGACYNETCF - #endif // FEATURE_CORECLR // 3. invariant diff --git a/src/mscorlib/src/System/RtType.cs b/src/mscorlib/src/System/RtType.cs index 8478dcdcc4..2da3211f0f 100644 --- a/src/mscorlib/src/System/RtType.cs +++ b/src/mscorlib/src/System/RtType.cs @@ -116,17 +116,6 @@ namespace System Contract.Requires(index < Count); return (_items != null) ? _items[index] : _item; } -#if FEATURE_LEGACYNETCF - // added for Dev11 466969 quirk - set - { - Contract.Requires(index < Count); - if (_items != null) - _items[index] = value; - else - _item = value; - } -#endif } public T[] ToArray() @@ -276,10 +265,6 @@ namespace System // reallocating the list every time a new entry is added. private T[] m_allMembers; private bool m_cacheComplete; -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - private List<RuntimePropertyInfo> m_ambiguousProperties; -#endif // This is the strong reference back to the cache private RuntimeTypeCache m_runtimeTypeCache; @@ -296,29 +281,6 @@ namespace System #endif m_runtimeTypeCache = runtimeTypeCache; } - -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - internal IReadOnlyList<RuntimePropertyInfo> AmbiguousProperties { get { return m_ambiguousProperties; } } - - private void InitializeAndUpdateAmbiguousPropertiesList(RuntimePropertyInfo parent, RuntimePropertyInfo child) - { - Contract.Assert(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8); - - if (m_ambiguousProperties == null) - { - List<RuntimePropertyInfo> newList = new List<RuntimePropertyInfo>(); - Interlocked.CompareExchange(ref m_ambiguousProperties, newList, null); - } - - lock (m_ambiguousProperties) - { - // record the parent type in case it needs to be pruned later. - Contract.Assert(child.DeclaringType.IsSubclassOf(parent.DeclaringType)); - m_ambiguousProperties.Add(parent); - } - } -#endif [System.Security.SecuritySafeCritical] // auto-generated internal MethodBase AddMethod(RuntimeType declaringType, RuntimeMethodHandleInternal method, CacheType cacheType) @@ -729,14 +691,10 @@ namespace System bool isInherited = declaringType != ReflectedType; - // NetCF actually includes private methods from parent classes in Reflection results - // We will mimic that in Mango Compat mode. - if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - bool isPrivate = methodAccess == MethodAttributes.Private; - if (isInherited && isPrivate && !isVirtual) - continue; - } + bool isPrivate = methodAccess == MethodAttributes.Private; + if (isInherited && isPrivate && !isVirtual) + continue; + #endregion #region Continue if this is a virtual and is already overridden @@ -1464,18 +1422,8 @@ namespace System { if (propertyInfo.EqualsSig(cache[j])) { -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && !propertyInfo.HasMatchingAccessibility(cache[j])) - { - InitializeAndUpdateAmbiguousPropertiesList(propertyInfo, cache[j]); - } - else -#endif - { - cache = null; - break; - } + cache = null; + break; } } @@ -1492,18 +1440,8 @@ namespace System { if (propertyInfo.EqualsSig(list[j])) { -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && !propertyInfo.HasMatchingAccessibility(list[j])) - { - InitializeAndUpdateAmbiguousPropertiesList(propertyInfo, list[j]); - } - else -#endif - { - duplicate = true; - break; - } + duplicate = true; + break; } } @@ -1612,25 +1550,6 @@ namespace System return existingCache.GetMemberList(listType, name, cacheType); } -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - private T[] GetMemberList<T>(ref MemberInfoCache<T> m_cache, MemberListType listType, string name, CacheType cacheType, out IReadOnlyList<RuntimePropertyInfo> ambiguousProperties) - where T : MemberInfo - { - Contract.Assert(cacheType == CacheType.Property); - - MemberInfoCache<T> existingCache = GetMemberCache<T>(ref m_cache); - T[] results = existingCache.GetMemberList(listType, name, cacheType); - - // must access property after GetMemberList() has been called - ambiguousProperties = existingCache.AmbiguousProperties; - - // we should only have an ambiguous properties list in Mango-compat mode - Contract.Assert(ambiguousProperties == null || CompatibilitySwitches.IsAppEarlierThanWindowsPhone8); - return results; - } -#endif - private MemberInfoCache<T> GetMemberCache<T>(ref MemberInfoCache<T> m_cache) where T : MemberInfo { @@ -1874,14 +1793,6 @@ namespace System return GetMemberList<RuntimePropertyInfo>(ref m_propertyInfoCache, listType, name, CacheType.Property); } -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - internal RuntimePropertyInfo[] GetPropertyList(MemberListType listType, string name, out IReadOnlyList<RuntimePropertyInfo> ambiguousProperties) - { - return GetMemberList<RuntimePropertyInfo>(ref m_propertyInfoCache, listType, name, CacheType.Property, out ambiguousProperties); - } -#endif - internal RuntimeEventInfo[] GetEventList(MemberListType listType, string name) { return GetMemberList<RuntimeEventInfo>(ref m_eventInfoCache, listType, name, CacheType.Event); @@ -1964,11 +1875,6 @@ namespace System throw new ArgumentNullException("typeName"); Contract.EndContractBlock(); -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && typeName.Length == 0) - throw new TypeLoadException(Environment.GetResourceString("Arg_TypeLoadNullStr")); -#endif - return RuntimeTypeHandle.GetTypeByName( typeName, throwOnError, ignoreCase, reflectionOnly, ref stackMark, false); } @@ -2846,13 +2752,7 @@ namespace System MemberListType listType; RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType); -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - IReadOnlyList<RuntimePropertyInfo> ambiguousProperties = null; - RuntimePropertyInfo[] cache = Cache.GetPropertyList(listType, name, out ambiguousProperties); -#else RuntimePropertyInfo[] cache = Cache.GetPropertyList(listType, name); -#endif bindingAttr ^= BindingFlags.DeclaredOnly; @@ -2868,93 +2768,9 @@ namespace System } } -#if FEATURE_LEGACYNETCF - // Dev11 466969 quirk - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && - candidates.Count > 1 && - ambiguousProperties != null && - ambiguousProperties.Count > 0) - { - return PruneAmbiguousProperties(candidates, ambiguousProperties); - } -#endif - return candidates; } -#if FEATURE_LEGACYNETCF - private ListBuilder<PropertyInfo> PruneAmbiguousProperties(ListBuilder<PropertyInfo> candidates, IReadOnlyList<RuntimePropertyInfo> ambiguousProperties) - { - Contract.Assert(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8); - Contract.Assert(candidates.Count > 1); - Contract.Assert(ambiguousProperties != null && ambiguousProperties.Count > 0); - - ListBuilder<PropertyInfo> newCandidates = candidates; - - // Dev11 466969 quirk - // NetCF reflection will differentiate properties by sig and by accessibility. - // Consider the following: - // - // class FooBase - // { - // public int Prop { get; set; } - // } - // - // class FooDerived : FooBase - // { - // private int Prop { get; set; } - // } - // - // In Mango one can reflect on FooDerived for property "Prop" with *Public* - // binding flags and get an answer. On desktop CLR/CoreCLR you get back null - // since FooBase.Prop is considered a duplicate and thus removed from the - // list of candidate properties. To make this distinction the method - // RuntimePropertyInfo.HasMatchingAccessibility() was added. - // - // There is a wrinkle here though, when reflecting on FooDerived for - // property "Prop" with Public and NonPublic binding flags the answer - // will always be the most-derived type, so FooDerived in this example. - // The purpose of PruneAmbiguousProperties() is to apply this invariant. - // - - int countRemoved = 0; - - lock (ambiguousProperties) - { - for (int outerIndex = 0; outerIndex < ambiguousProperties.Count; ++outerIndex) - { - for (int innerIndex = 0; innerIndex < candidates.Count; ++innerIndex) - { - if (candidates[innerIndex] != null && - candidates[innerIndex] == ambiguousProperties[outerIndex]) - { - candidates[innerIndex] = null; - ++countRemoved; - } - } - } - } - - // should have only gone down this code path because we knew - // that at least one ambiguous property needed to be pruned. - Contract.Assert(countRemoved > 0); - - if (countRemoved > 0) - { - newCandidates = new ListBuilder<PropertyInfo>(candidates.Count - countRemoved); - for (int index = 0; index < candidates.Count; ++index) - { - if (candidates[index] != null) - newCandidates.Add(candidates[index]); - } - - Contract.Assert(newCandidates.Count == (candidates.Count - countRemoved)); - } - - return newCandidates; - } -#endif - private ListBuilder<EventInfo> GetEventCandidates(String name, BindingFlags bindingAttr, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; @@ -4087,12 +3903,6 @@ namespace System return (Array.BinarySearch(ulValues, ulValue) >= 0); } - else if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - // if at this point the value type is not an integer type, then its type doesn't match the enum type - // NetCF used to throw an argument exception in this case - throw new ArgumentException(Environment.GetResourceString("Arg_EnumUnderlyingTypeAndObjectMustBeSameType", valueType.ToString(), GetEnumUnderlyingType())); - } else { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); diff --git a/src/mscorlib/src/System/Runtime/Versioning/BinaryCompatibility.cs b/src/mscorlib/src/System/Runtime/Versioning/BinaryCompatibility.cs index 99a84e26dd..99e30b5488 100644 --- a/src/mscorlib/src/System/Runtime/Versioning/BinaryCompatibility.cs +++ b/src/mscorlib/src/System/Runtime/Versioning/BinaryCompatibility.cs @@ -445,45 +445,9 @@ 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"); diff --git a/src/mscorlib/src/System/RuntimeHandles.cs b/src/mscorlib/src/System/RuntimeHandles.cs index 12c65960ec..b751985323 100644 --- a/src/mscorlib/src/System/RuntimeHandles.cs +++ b/src/mscorlib/src/System/RuntimeHandles.cs @@ -127,9 +127,7 @@ namespace System public IntPtr Value { -#if !FEATURE_LEGACYNETCF [SecurityCritical] -#endif get { return m_type != null ? m_type.m_handle : IntPtr.Zero; @@ -675,19 +673,9 @@ namespace System [System.Security.SecuritySafeCritical] // auto-generated internal RuntimeType MakeByRef() { -#if FEATURE_LEGACYNETCF - try { -#endif - RuntimeType type = null; - MakeByRef(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type)); - return type; -#if FEATURE_LEGACYNETCF - } catch(Exception) { - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - return null; - throw; - } -#endif + RuntimeType type = null; + MakeByRef(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type)); + return type; } [System.Security.SecurityCritical] // auto-generated @@ -1006,11 +994,7 @@ namespace System public IntPtr Value { -#if FEATURE_LEGACYNETCF - [SecuritySafeCritical] -#else [SecurityCritical] -#endif get { return m_value != null ? m_value.Value.Value : IntPtr.Zero; @@ -1516,11 +1500,7 @@ namespace System public IntPtr Value { -#if FEATURE_LEGACYNETCF - [SecuritySafeCritical] -#else [SecurityCritical] -#endif get { return m_ptr != null ? m_ptr.Value.Value : IntPtr.Zero; @@ -2086,12 +2066,6 @@ namespace System [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern bool CompareSig(Signature sig1, Signature sig2); -#if FEATURE_LEGACYNETCF - [System.Security.SecuritySafeCritical] - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern bool CompareSigForAppCompat(Signature left, RuntimeType typeLeft, Signature right, RuntimeType typeRight); -#endif - [System.Security.SecuritySafeCritical] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern Type[] GetCustomModifiers(int position, bool required); diff --git a/src/mscorlib/src/System/Security/Permissions/PermissionAttributes.cs b/src/mscorlib/src/System/Security/Permissions/PermissionAttributes.cs index 271b74bd13..ec6ad6e39a 100644 --- a/src/mscorlib/src/System/Security/Permissions/PermissionAttributes.cs +++ b/src/mscorlib/src/System/Security/Permissions/PermissionAttributes.cs @@ -77,12 +77,8 @@ namespace System.Security.Permissions internal SecurityAction m_action; /// <internalonly/> internal bool m_unrestricted; -#if FEATURE_LEGACYNETCF - public -#else - protected -#endif - SecurityAttribute( SecurityAction action ) + + protected SecurityAttribute( SecurityAction action ) { m_action = action; } @@ -122,12 +118,7 @@ namespace System.Security.Permissions #endif public abstract class CodeAccessSecurityAttribute : SecurityAttribute { -#if FEATURE_LEGACYNETCF - public -#else - protected -#endif - CodeAccessSecurityAttribute( SecurityAction action ) + protected CodeAccessSecurityAttribute( SecurityAction action ) : base( action ) { } diff --git a/src/mscorlib/src/System/SharedStatics.cs b/src/mscorlib/src/System/SharedStatics.cs index f7d531d1a9..ec63a0ec25 100644 --- a/src/mscorlib/src/System/SharedStatics.cs +++ b/src/mscorlib/src/System/SharedStatics.cs @@ -20,7 +20,7 @@ namespace System { using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Diagnostics.Contracts; -#if FEATURE_CAS_POLICY || FEATURE_LEGACYNETCFCRYPTO +#if FEATURE_CAS_POLICY using StringMaker = System.Security.Util.Tokenizer.StringMaker; #endif // FEATURE_CAS_POLICY @@ -67,7 +67,7 @@ namespace System { } } -#if FEATURE_CAS_POLICY || FEATURE_LEGACYNETCFCRYPTO +#if FEATURE_CAS_POLICY private StringMaker _maker; [System.Security.SecuritySafeCritical] // auto-generated static public StringMaker GetSharedStringMaker() diff --git a/src/mscorlib/src/System/SupportedPlatformsAttribute.cs b/src/mscorlib/src/System/SupportedPlatformsAttribute.cs deleted file mode 100644 index af3cd3bebc..0000000000 --- a/src/mscorlib/src/System/SupportedPlatformsAttribute.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** -** -** Purpose: Annotates items as existing only on certain -** platforms. -** -** -===========================================================*/ -#if FEATURE_CORECLR -using System.Diagnostics.Contracts; - -namespace System -{ - [Serializable] - [AttributeUsage(AttributeTargets.All, Inherited=true)] - public sealed class SupportedPlatformsAttribute : Attribute - { - internal Platforms m_platforms = Platforms.All; - - internal static SupportedPlatformsAttribute Default = new SupportedPlatformsAttribute(Platforms.All); - - public SupportedPlatformsAttribute(Platforms platforms) - { - if ((platforms & ~Platforms.All) != 0) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "platforms"); - Contract.EndContractBlock(); - m_platforms = platforms; - } - - public Platforms Platforms - { - get { return m_platforms; } - } - } - -} -#endif // FEATURE_CORECLR diff --git a/src/mscorlib/src/System/Text/StringBuilder.cs b/src/mscorlib/src/System/Text/StringBuilder.cs index e5d0fcdab0..809b51585a 100644 --- a/src/mscorlib/src/System/Text/StringBuilder.cs +++ b/src/mscorlib/src/System/Text/StringBuilder.cs @@ -590,12 +590,6 @@ namespace System.Text { Contract.Ensures(Contract.Result<StringBuilder>() != null); Contract.EndContractBlock(); - // in NetCF arguments pretty much don't matter as long as count is 0 - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (charCount == 0)) - { - return this; - } - if (value == null) { if (startIndex == 0 && charCount == 0) { return this; @@ -686,12 +680,6 @@ namespace System.Text { } Contract.Ensures(Contract.Result<StringBuilder>() != null); - // in NetCF arguments pretty much don't matter as long as count is 0 - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (count == 0)){ - return this; - } - - //If the value being added is null, eat the null //and return. if (value == null) { diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs index b656b6bc01..36a2ff8562 100644 --- a/src/mscorlib/src/System/Threading/Mutex.cs +++ b/src/mscorlib/src/System/Threading/Mutex.cs @@ -102,29 +102,10 @@ namespace System.Threading CreateMutexWithGuaranteedCleanup(initiallyOwned, name, out createdNew, secAttrs); } -#if FEATURE_LEGACYNETCF - static string WinCEObjectNameQuirk(string name) - { - if (name == null) - return null; - - // WinCE allowed backslashes in kernel object names, but WinNT does not allow them. - // Replace all backslashes with a rare unicode character if we are in NetCF compat mode. - // Mutex was the only named kernel object exposed to phone apps, so we do not have - // to apply this quirk in other places. - return name.Replace('\\', '\u2044'); - } -#endif - [System.Security.SecurityCritical] // auto-generated_required [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal void CreateMutexWithGuaranteedCleanup(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs) { -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - name = WinCEObjectNameQuirk(name); -#endif - RuntimeHelpers.CleanupCode cleanupCode = new RuntimeHelpers.CleanupCode(MutexCleanupCode); MutexCleanupInfo cleanupInfo = new MutexCleanupInfo(null, false); MutexTryCodeHelper tryCodeHelper = new MutexTryCodeHelper(initiallyOwned, cleanupInfo, name, secAttrs, this); @@ -243,18 +224,7 @@ namespace System.Threading } } - // For the .NET Compact Framework this constructor was security safe critical. - // For Windows Phone version 8 (Apollo), all apps will run as fully trusted, - // meaning the CLR is not considered a trust boundary. This API could be marked security critical. - // However for Windows Phone version 7.1 applications, they will still be run - // as partially trusted applications, with our security transparency model enforced. - // So we have this peculiar #ifdef that should be enabled only for .NET CF backwards - // compatibility. -#if FEATURE_LEGACYNETCF - [System.Security.SecuritySafeCritical] // auto-generated_required -#else [System.Security.SecurityCritical] // auto-generated_required -#endif //FEATURE_LEGACYNETCF [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public Mutex(bool initiallyOwned, String name) : this(initiallyOwned, name, out dummyBool) { } @@ -355,11 +325,6 @@ namespace System.Threading result = null; -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - name = WinCEObjectNameQuirk(name); -#endif - // To allow users to view & edit the ACL's, call OpenMutex // with parameters to allow us to view & edit the ACL. This will // fail if we don't have permission to view or edit the ACL's. diff --git a/src/mscorlib/src/System/Threading/SynchronizationContext.cs b/src/mscorlib/src/System/Threading/SynchronizationContext.cs index 3dfa5cc716..f690e8c938 100644 --- a/src/mscorlib/src/System/Threading/SynchronizationContext.cs +++ b/src/mscorlib/src/System/Threading/SynchronizationContext.cs @@ -171,10 +171,6 @@ namespace System.Threading [ThreadStatic] private static SynchronizationContext s_threadStaticContext; - // - // Maintain legacy NetCF Behavior where setting the value for one thread impacts all threads. - // - private static SynchronizationContext s_appDomainStaticContext; [System.Security.SecurityCritical] public static void SetSynchronizationContext(SynchronizationContext syncContext) @@ -185,25 +181,14 @@ namespace System.Threading [System.Security.SecurityCritical] public static void SetThreadStaticContext(SynchronizationContext syncContext) { - // - // If this is a pre-Mango Windows Phone app, we need to set the SC for *all* threads to match the old NetCF behavior. - // - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhoneMango) - s_appDomainStaticContext = syncContext; - else - s_threadStaticContext = syncContext; + s_threadStaticContext = syncContext; } public static SynchronizationContext Current { get { - SynchronizationContext context = null; - - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhoneMango) - context = s_appDomainStaticContext; - else - context = s_threadStaticContext; + SynchronizationContext context = s_threadStaticContext; #if FEATURE_APPX if (context == null && Environment.IsWinRTSupported) diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs index d204f8b64b..e1cdd30081 100644 --- a/src/mscorlib/src/System/ThrowHelper.cs +++ b/src/mscorlib/src/System/ThrowHelper.cs @@ -81,14 +81,8 @@ namespace System { } internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) { - - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - // Dev11 474369 quirk: Mango had an empty message string: - throw new ArgumentOutOfRangeException(GetArgumentName(argument), String.Empty); - } else { - throw new ArgumentOutOfRangeException(GetArgumentName(argument), - Environment.GetResourceString(GetResourceName(resource))); - } + throw new ArgumentOutOfRangeException(GetArgumentName(argument), + Environment.GetResourceString(GetResourceName(resource))); } internal static void ThrowInvalidOperationException(ExceptionResource resource) { @@ -100,7 +94,7 @@ namespace System { } internal static void ThrowSecurityException(ExceptionResource resource) { - throw new System.Security.SecurityException(Environment.GetResourceString(GetResourceName(resource))); + throw new System.Security.SecurityException(Environment.GetResourceString(GetResourceName(resource))); } internal static void ThrowNotSupportedException(ExceptionResource resource) { diff --git a/src/mscorlib/src/System/TimeSpan.cs b/src/mscorlib/src/System/TimeSpan.cs index 332721a47c..c9cfc084f3 100644 --- a/src/mscorlib/src/System/TimeSpan.cs +++ b/src/mscorlib/src/System/TimeSpan.cs @@ -424,7 +424,7 @@ namespace System { return true; return CompatibilitySwitches.IsNetFx40TimeSpanLegacyFormatMode; #else - return CompatibilitySwitches.IsAppEarlierThanSilverlight4; + return false; #endif // !FEATURE_CORECLR } diff --git a/src/mscorlib/src/System/Type.cs b/src/mscorlib/src/System/Type.cs index c6215d24c9..0e0544ccf5 100644 --- a/src/mscorlib/src/System/Type.cs +++ b/src/mscorlib/src/System/Type.cs @@ -1511,12 +1511,6 @@ namespace System { Array values = GetEnumRawConstantValues(); return (BinarySearch(values, value) >= 0); } - else if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - { - // if at this point the value type is not an integer type, then its type doesn't match the enum type - // NetCF used to throw an argument exception in this case - throw new ArgumentException(Environment.GetResourceString("Arg_EnumUnderlyingTypeAndObjectMustBeSameType", valueType.ToString(), GetEnumUnderlyingType())); - } else { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); diff --git a/src/mscorlib/src/System/Version.cs b/src/mscorlib/src/System/Version.cs index 6454fa2f3b..f3520b81a2 100644 --- a/src/mscorlib/src/System/Version.cs +++ b/src/mscorlib/src/System/Version.cs @@ -92,10 +92,6 @@ namespace System { _Revision = v.Revision; } -#if FEATURE_LEGACYNETCF - //required for Mango AppCompat - [System.Runtime.CompilerServices.FriendAccessAllowed] -#endif public Version() { _Major = 0; @@ -140,29 +136,13 @@ namespace System { { if (version == null) { -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - throw new ArgumentOutOfRangeException(); - } else { -#endif - return 1; -#if FEATURE_LEGACYNETCF - } -#endif + return 1; } Version v = version as Version; if (v == null) { -#if FEATURE_LEGACYNETCF - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { - throw new InvalidCastException(Environment.GetResourceString("Arg_MustBeVersion")); - } else { -#endif - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeVersion")); -#if FEATURE_LEGACYNETCF - } -#endif + throw new ArgumentException(Environment.GetResourceString("Arg_MustBeVersion")); } if (this._Major != v._Major) |