Repository: dotnet/runtime
File: src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs (C#)

Code before:
            get
            {
                if (IsReleaseRuntime)
                    return 1;
                if (IsRiscV64Process)
                    return IsDebugRuntime ? 10 : 2;
                else
                    return IsDebugRuntime ? 5 : 1;
            }
        }

        public static bool IsCaseInsensitiveOS => IsWindows || IsOSX || IsMacCatalyst;
        public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;

#if NET
        public static bool FileCreateCaseSensitive => IsCaseSensitiveOS && !RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
                                                                        && !RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator");
#else
        public static bool FileCreateCaseSensitive => IsCaseSensitiveOS;
#endif

#if NET && NET11_0_OR_GREATER
        public static bool IsMultithreadingSupported => RuntimeFeature.IsMultithreadingSupported;
#else
        public static bool IsMultithreadingSupported => GetIsMultithreadingSupported(null);
        [UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "get_IsMultithreadingSupported")]
        static extern bool GetIsMultithreadingSupported([UnsafeAccessorType("System.Runtime.CompilerServices.RuntimeFeature, System.Private.CoreLib")] object? _);
#endif
        public static bool IsNotMultithreadingSupported => !IsMultithreadingSupported;
        public static bool IsWasmThreadingSupported => IsBrowser && IsMultithreadingSupported;
        public static bool IsNotWasmThreadingSupported => !IsWasmThreadingSupported;

        private static readonly Lazy<bool> s_isBinaryFormatterSupported = new Lazy<bool>(DetermineBinaryFormatterSupport);
        public static bool IsBinaryFormatterSupported => s_isBinaryFormatterSupported.Value;

        public static bool IsStartingProcessesSupported => !IsiOS && !IstvOS;

        public static bool IsLinqSpeedOptimized => !IsLinqSizeOptimized;
        public static bool IsLinqSizeOptimized => s_linqIsSizeOptimized.Value;
        private static readonly Lazy<bool> s_linqIsSizeOptimized = new Lazy<bool>(ComputeIsLinqSizeOptimized);
        private static bool ComputeIsLinqSizeOptimized()
        {
#if NET
            return (bool)typeof(Enumerable).GetMethod("get_IsSizeOptimized", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, Array.Empty<object>());
#else
            return false;
#endif
        }

        public static bool IsBrowserDomSupported => IsEnvironmentVariableTrue("IsBrowserDomSupported");
        public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || IsBrowserDomSupported;

Review comment (suggestion):
`UnsafeAccessor` is not in .NET standard. I do not think this is going to compile.

Also, this property needs to return false when we run the tests on .NET Framework.

I think this should use reflection and return false when the property does not exist.

Code after:
            get
            {
                if (IsReleaseRuntime)
                    return 1;
                if (IsRiscV64Process)
                    return IsDebugRuntime ? 10 : 2;
                else
                    return IsDebugRuntime ? 5 : 1;
            }
        }

        public static bool IsCaseInsensitiveOS => IsWindows || IsOSX || IsMacCatalyst;
        public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;

#if NET
        public static bool FileCreateCaseSensitive => IsCaseSensitiveOS && !RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
                                                                        && !RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator");
#else
        public static bool FileCreateCaseSensitive => IsCaseSensitiveOS;
#endif

#if NET11_0_OR_GREATER
        public static bool IsMultithreadingSupported => RuntimeFeature.IsMultithreadingSupported;
#else
        public static bool IsMultithreadingSupported { get; } = GetIsMultithreadingSupported();

        private static bool GetIsMultithreadingSupported()
        {
            if (!IsWasm)
                return true;

            try
            {
                Type runtimeFeatureType = typeof(System.Runtime.CompilerServices.RuntimeFeature);

                PropertyInfo isMultithreadingSupportedProperty = runtimeFeatureType.GetProperty("IsMultithreadingSupported", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                if (isMultithreadingSupportedProperty != null)
                {
                    return (bool)isMultithreadingSupportedProperty.GetValue(null);
                }
            }
            catch
            {
                // if any of the reflection calls fail, assume multithreading is not supported.
            }
            return false;
        }
#endif
        public static bool IsNotMultithreadingSupported => !IsMultithreadingSupported;
        public static bool IsWasmThreadingSupported => IsWasm && IsMultithreadingSupported;
        public static bool IsNotWasmThreadingSupported => !IsWasmThreadingSupported;