Skip to content

Commit cadd41f

Browse files
Copilotjkotasstephentoub
authored
Remove PlatformDetection.IsWindows7 and IsNotWindows7 properties (#122907)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jkotas <[email protected]> Co-authored-by: Jan Kotas <[email protected]> Co-authored-by: stephentoub <[email protected]>
1 parent 8d5d39a commit cadd41f

File tree

56 files changed

+90
-1226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+90
-1226
lines changed

src/coreclr/inc/ostype.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/coreclr/inc/utilcode.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,14 @@ void SplitPathInterior(
496496
_Out_opt_ LPCWSTR *pwszExt, _Out_opt_ size_t *pcchExt);
497497

498498

499-
#include "ostype.h"
499+
#ifdef HOST_64BIT
500+
inline BOOL RunningInWow64()
501+
{
502+
return FALSE;
503+
}
504+
#else
505+
BOOL RunningInWow64();
506+
#endif
500507

501508
//
502509
// Allocate free memory within the range [pMinAddr..pMaxAddr] using

src/libraries/Common/tests/System/Drawing/Helpers.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public static class Helpers
1515
public const string IsDrawingSupported = nameof(Helpers) + "." + nameof(GetIsDrawingSupported);
1616
public const string IsWindowsOrAtLeastLibgdiplus6 = nameof(Helpers) + "." + nameof(GetIsWindowsOrAtLeastLibgdiplus6);
1717
public const string RecentGdiplusIsAvailable = IsWindowsOrAtLeastLibgdiplus6;
18-
public const string GdiPlusIsAvailableNotWindows7 = nameof(Helpers) + "." + nameof(GetGdiPlusIsAvailableNotWindows7);
1918
public const string AnyInstalledPrinters = nameof(Helpers) + "." + nameof(IsAnyInstalledPrinters);
2019
public const string WindowsRS3OrEarlier = nameof(Helpers) + "." + nameof(IsWindowsRS3OrEarlier);
2120
public const string IsWindows = nameof(Helpers) + "." + nameof(GetIsWindows);
@@ -58,16 +57,6 @@ public static bool GetIsWindowsOrAtLeastLibgdiplus6()
5857

5958
public static bool IsWindowsRS3OrEarlier => !PlatformDetection.IsWindows10Version1803OrGreater;
6059

61-
public static bool GetGdiPlusIsAvailableNotWindows7()
62-
{
63-
if (PlatformDetection.IsWindows7)
64-
{
65-
return false;
66-
}
67-
68-
return GetIsDrawingSupported();
69-
}
70-
7160
public static bool IsAnyInstalledPrinters()
7261
{
7362
return PrinterSettings.InstalledPrinters.Count > 0;

src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Asynchrony.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ from contentMode in Enum.GetValues(typeof(LoopbackServer.ContentMode)).Cast<Loop
2626
[MemberData(nameof(ResponseHeadersRead_SynchronizationContextNotUsedByHandler_MemberData))]
2727
public async Task ResponseHeadersRead_SynchronizationContextNotUsedByHandler(bool responseHeadersRead, LoopbackServer.ContentMode contentMode)
2828
{
29-
if (IsWinHttpHandler && (PlatformDetection.IsWindows7 || PlatformDetection.IsWindows8x))
29+
if (IsWinHttpHandler && PlatformDetection.IsWindows8x)
3030
{ // [ActiveIssue("https://github.com/dotnet/runtime/issues/54034")]
3131
return;
3232
}

src/libraries/Common/tests/System/Net/Http/IdnaProtocolTests.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,12 @@ namespace System.Net.Http.Functional.Tests
1515

1616
public abstract class IdnaProtocolTests : HttpClientHandlerTestBase
1717
{
18-
protected abstract bool SupportsIdna { get; }
19-
2018
public IdnaProtocolTests(ITestOutputHelper output) : base(output) { }
2119

2220
[Theory]
2321
[MemberData(nameof(InternationalHostNames))]
2422
public async Task InternationalUrl_UsesIdnaEncoding_Success(string hostname)
2523
{
26-
if (!SupportsIdna)
27-
{
28-
return;
29-
}
30-
3124
Uri uri = new Uri($"http://{hostname}/");
3225

3326
await LoopbackServer.CreateServerAsync(async (server, serverUrl) =>
@@ -59,11 +52,6 @@ await LoopbackServer.CreateServerAsync(async (server, serverUrl) =>
5952
[MemberData(nameof(InternationalHostNames))]
6053
public async Task InternationalRequestHeaderValues_UsesIdnaEncoding_Success(string hostname)
6154
{
62-
if (!SupportsIdna)
63-
{
64-
return;
65-
}
66-
6755
Uri uri = new Uri($"http://{hostname}/");
6856

6957
await LoopbackServer.CreateServerAsync(async (server, serverUrl) =>
@@ -91,11 +79,6 @@ await LoopbackServer.CreateServerAsync(async (server, serverUrl) =>
9179
[MemberData(nameof(InternationalHostNames))]
9280
public async Task InternationalResponseHeaderValues_UsesIdnaDecoding_Success(string hostname)
9381
{
94-
if (!SupportsIdna)
95-
{
96-
return;
97-
}
98-
9982
Uri uri = new Uri($"http://{hostname}/");
10083

10184
await LoopbackServer.CreateServerAsync(async (server, serverUrl) =>

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/TripleDES/TripleDESCipherOneShotTests.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -848,17 +848,14 @@ public static IEnumerable<object[]> TestCases
848848
8,
849849
};
850850

851-
// 3DES CFB64 is not supported on Windows 7.
852-
if (PlatformDetection.IsNotWindows7)
851+
yield return new object[]
853852
{
854-
yield return new object[]
853+
// plaintext
854+
new byte[]
855855
{
856-
// plaintext
857-
new byte[]
858-
{
859-
0x50, 0x68, 0x12, 0xA4, 0x5F, 0x08, 0xC8, 0x89,
860-
0xB9, 0x7F, 0x59, 0x80, 0x03, 0x8B, 0x83, 0x59,
861-
},
856+
0x50, 0x68, 0x12, 0xA4, 0x5F, 0x08, 0xC8, 0x89,
857+
0xB9, 0x7F, 0x59, 0x80, 0x03, 0x8B, 0x83, 0x59,
858+
},
862859

863860
// ciphertext
864861
new byte[]
@@ -1092,7 +1089,6 @@ public static IEnumerable<object[]> TestCases
10921089
CipherMode.CFB,
10931090
64,
10941091
};
1095-
}
10961092
}
10971093
}
10981094
}

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ public static partial class PlatformDetection
2020
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
2121
public static bool IsNetFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase);
2222
public static bool HasWindowsShell => IsWindows && IsNotWindowsServerCore && IsNotWindowsNanoServer && IsNotWindowsIoTCore;
23-
public static bool IsWindows7 => IsWindows && GetWindowsVersion() == 6 && GetWindowsMinorVersion() == 1;
2423
public static bool IsWindows8x => IsWindows && GetWindowsVersion() == 6 && (GetWindowsMinorVersion() == 2 || GetWindowsMinorVersion() == 3);
25-
public static bool IsWindows8xOrLater => IsWindowsVersionOrLater(6, 2);
2624
public static bool IsWindows10OrLater => IsWindowsVersionOrLater(10, 0);
2725
public static bool IsWindowsServer2019 => IsWindows && IsNotWindowsNanoServer && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildVersion() == 17763;
2826
public static bool IsWindowsServer2022 => IsWindows && IsNotWindowsNanoServer && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildVersion() == 20348;
2927
public static bool IsWindowsServer2025 => IsWindows && IsNotWindowsNanoServer && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildVersion() == 26100;
3028
public static bool IsWindowsNanoServer => IsWindows && (IsNotWindowsIoTCore && GetWindowsInstallationType().Equals("Nano Server", StringComparison.OrdinalIgnoreCase));
3129
public static bool IsWindowsServerCore => IsWindows && GetWindowsInstallationType().Equals("Server Core", StringComparison.OrdinalIgnoreCase);
3230
public static int WindowsVersion => IsWindows ? (int)GetWindowsVersion() : -1;
33-
public static bool IsNotWindows7 => !IsWindows7;
3431
public static bool IsNotWindows8x => !IsWindows8x;
3532
public static bool IsNotWindowsNanoServer => !IsWindowsNanoServer;
3633
public static bool IsNotWindowsServerCore => !IsWindowsServerCore;
@@ -203,7 +200,7 @@ public static bool IsInAppContainer
203200
if (s_isInAppContainer != -1)
204201
return s_isInAppContainer == 1;
205202

206-
if (!IsWindows || IsWindows7)
203+
if (!IsWindows)
207204
{
208205
s_isInAppContainer = 0;
209206
return false;

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public static bool IsMetadataTokenSupported
315315
private static readonly Lazy<bool> s_supportsAlpn = new Lazy<bool>(GetAlpnSupport);
316316
private static bool GetAlpnSupport()
317317
{
318-
if (IsWindows && !IsWindows7 && !IsNetFramework)
318+
if (IsWindows && !IsNetFramework)
319319
{
320320
return true;
321321
}
@@ -359,7 +359,7 @@ private static bool GetAlpnSupport()
359359
public static bool SupportsTls12 => s_supportsTls12.Value;
360360
public static bool SupportsTls13 => s_supportsTls13.Value;
361361
public static bool SendsCAListByDefault => s_sendsCAListByDefault.Value;
362-
public static bool SupportsSendingCustomCANamesInTls => UsesAppleCrypto || IsOpenSslSupported || (PlatformDetection.IsWindows8xOrLater && SendsCAListByDefault);
362+
public static bool SupportsSendingCustomCANamesInTls => UsesAppleCrypto || IsOpenSslSupported || (PlatformDetection.IsWindows && SendsCAListByDefault);
363363
public static bool SupportsSha3 => s_supportsSha3.Value;
364364
public static bool DoesNotSupportSha3 => !s_supportsSha3.Value;
365365

@@ -597,12 +597,6 @@ private static bool GetTls11Support()
597597
{
598598
if (IsWindows)
599599
{
600-
// TLS 1.1 can work on Windows 7 but it is disabled by default.
601-
if (IsWindows7)
602-
{
603-
return GetProtocolSupportFromWindowsRegistry(SslProtocols.Tls11, defaultProtocolSupport: false, disabledByDefault: true);
604-
}
605-
606600
// It is enabled on other versions unless explicitly disabled.
607601
return GetProtocolSupportFromWindowsRegistry(SslProtocols.Tls11, defaultProtocolSupport: true) && !IsWindows10Version20348OrGreater;
608602
}
@@ -625,12 +619,6 @@ private static bool GetTls12Support()
625619
{
626620
if (IsWindows)
627621
{
628-
// TLS 1.2 can work on Windows 7 but it is disabled by default.
629-
if (IsWindows7)
630-
{
631-
return GetProtocolSupportFromWindowsRegistry(SslProtocols.Tls12, defaultProtocolSupport: false, disabledByDefault: true);
632-
}
633-
634622
// It is enabled on other versions unless explicitly disabled.
635623
return GetProtocolSupportFromWindowsRegistry(SslProtocols.Tls12, defaultProtocolSupport: true);
636624
}
@@ -709,9 +697,9 @@ private static bool GetSendsCAListByDefault()
709697
{
710698
if (IsWindows)
711699
{
712-
// Sending TrustedIssuers is conditioned on the registry. Win7 sends trusted issuer list by default,
713-
// newer Windows versions don't.
714-
object val = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL", "SendTrustedIssuerList", IsWindows7 ? 1 : 0);
700+
// Sending TrustedIssuers is conditioned on the registry.
701+
// Newer Windows versions don't send trusted issuer list by default.
702+
object val = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL", "SendTrustedIssuerList", 0);
715703
if (val is int i)
716704
{
717705
return i == 1;

src/libraries/Common/tests/Tests/System/StringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7155,7 +7155,7 @@ public static IEnumerable<object[]> UpperLowerCasing_TestData()
71557155
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR" };
71567156
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR" };
71577157
}
7158-
yield return new object[] { "\ud801\udc29", PlatformDetection.IsWindows7 ? "\ud801\udc29" : "\ud801\udc01", "en-US" };
7158+
yield return new object[] { "\ud801\udc29", "\ud801\udc01", "en-US" };
71597159
}
71607160
}
71617161

src/libraries/System.Console/src/System/ConsolePal.Windows.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ internal static class ConsolePal
2424
internal static void EnsureConsoleInitialized()
2525
{ }
2626

27-
private static bool IsWindows7()
28-
{
29-
// Version lies for all apps from the OS kick in starting with Windows 8 (6.2). They can
30-
// also be added via appcompat (by the OS or the users) so this can only be used as a hint.
31-
Version version = Environment.OSVersion.Version;
32-
return version.Major == 6 && version.Minor == 1;
33-
}
34-
3527
public static Stream OpenStandardInput() =>
3628
GetStandardFile(
3729
Interop.Kernel32.HandleTypes.STD_INPUT_HANDLE,
@@ -658,14 +650,9 @@ public static unsafe string Title
658650
throw Win32Marshal.GetExceptionForWin32Error(error, string.Empty);
659651
}
660652
}
661-
else if (result >= builder.Capacity - 1 || (IsWindows7() && result >= builder.Capacity / sizeof(char) - 1))
653+
else if (result >= builder.Capacity - 1)
662654
{
663655
// Our buffer was full. As this API truncates we need to increase our size and reattempt.
664-
// Note that Windows 7 copies count of bytes into the output buffer but returns count of chars
665-
// and as such our buffer is only "half" its actual size.
666-
//
667-
// (If we're Windows 10 with a version lie to 7 this will be inefficient so we'll want to remove
668-
// this workaround when we no longer support Windows 7)
669656
builder.EnsureCapacity(builder.Capacity * 2);
670657
continue;
671658
}

0 commit comments

Comments
 (0)