Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs (C#)

Code before:
                ByRefLikeGenerics or
                UnmanagedSignatureCallingConvention or
                DefaultImplementationsOfInterfaces or
                VirtualStaticsInInterfaces or
                NumericIntPtr => true,

                nameof(IsDynamicCodeSupported) => IsDynamicCodeSupported,
                nameof(IsDynamicCodeCompiled) => IsDynamicCodeCompiled,
                nameof(IsMultithreadingSupported) => IsMultithreadingSupported,
                _ => false,
            };
        }


        /// <summary>
        /// Gets a value that indicates whether the runtime supports multithreading, including
        /// creating threads and using blocking synchronization primitives. This property
        /// returns <see langword="false"/> on platforms or configurations where multithreading
        /// is not supported or is disabled, such as single-threaded browser environments and WASI.
        /// </summary>
        [UnsupportedOSPlatformGuard("browser")]
        [UnsupportedOSPlatformGuard("wasi")]
        [FeatureSwitchDefinition("System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported")]
        public static bool IsMultithreadingSupported { get; }
#if TARGET_BROWSER
            = AppContext.TryGetSwitch("System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported", out bool isMultithreadingSupported) ? isMultithreadingSupported : false;
#elif TARGET_WASI
            = false;
#else
            = true;
#endif

#if FEATURE_SINGLE_THREADED
        [DoesNotReturn]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            throw new PlatformNotSupportedException();
        }
#else // FEATURE_SINGLE_THREADED
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
#if FEATURE_WASM_MANAGED_THREADS
            System.Threading.Thread.AssureBlockingPossible();
#endif // FEATURE_WASM_MANAGED_THREADS
        }
#endif // FEATURE_SINGLE_THREADED
    }
}


Review comment (suggestion):
Does it really make sense to read this from AppContext in the current setup? There are number of FEATURE_SINGLE_THREADED ifdefs in the unmanaged runtime, so you need a special build with multithreading enabled.

Code after:
                ByRefFields or
                ByRefLikeGenerics or
                UnmanagedSignatureCallingConvention or
                DefaultImplementationsOfInterfaces or
                VirtualStaticsInInterfaces or
                NumericIntPtr => true,

                nameof(IsDynamicCodeSupported) => IsDynamicCodeSupported,
                nameof(IsDynamicCodeCompiled) => IsDynamicCodeCompiled,
                nameof(IsMultithreadingSupported) => IsMultithreadingSupported,
                _ => false,
            };
        }

        /// <summary>
        /// Gets a value that indicates whether the runtime supports multithreading, including
        /// creating threads and using blocking synchronization primitives. This property
        /// returns <see langword="false"/> on platforms or configurations where multithreading
        /// is not supported or is disabled, such as single-threaded browser environments and WASI.
        /// </summary>
        [UnsupportedOSPlatformGuard("browser")]
        [UnsupportedOSPlatformGuard("wasi")]
        [FeatureSwitchDefinition("System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported")]
        public static bool IsMultithreadingSupported
#if FEATURE_SINGLE_THREADED
            => false;
#else
            => true;
#endif

#if FEATURE_SINGLE_THREADED
        [DoesNotReturn]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            throw new PlatformNotSupportedException();
        }
#elif FEATURE_WASM_MANAGED_THREADS
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            System.Threading.Thread.AssureBlockingPossible();
        }
#else
        [Conditional("unnecessary")]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
        }
#endif
    }
}