private static bool GetTrimBuffers() { // Environment uses ArrayPool, so we have to hit the API directly. #if !CORECLR // P/Invokes are different for CoreCLR/RT- for RT we'll not allow // enabling/disabling for now. return(true); #else return(CLRConfig.GetBoolValueWithFallbacks("System.Buffers.ArrayPool.TrimShared", "DOTNET_SYSTEM_BUFFERS_ARRAYPOOL_TRIMSHARED", defaultValue: true)); #endif }
private static bool CheckEnableAutoreleasePool() { const string feature = "System.Threading.Thread.EnableAutoreleasePool"; #if !CORECLR return AppContextConfigHelper.GetBooleanConfig(feature, false); #else bool isEnabled = CLRConfig.GetBoolValue(feature, out bool isSet); if (!isSet) return false; return isEnabled; #endif }
// GetSwitchValue calls CLRConfig first to detect if the switch is defined in the config file. // if the switch is defined we just use the value of this switch. otherwise, we'll try to get the switch // value from the environment variable if it is defined. private static bool GetSwitchValue(string switchName, string envVariable) { bool ret = CLRConfig.GetBoolValue(switchName, out bool exist); if (!exist) { string?switchValue = Environment.GetEnvironmentVariable(envVariable); if (switchValue != null) { ret = bool.IsTrueStringIgnoreCase(switchValue) || switchValue.Equals("1"); } } return(ret); }
private static bool GetGlobalizationInvariantMode() { bool invariantEnabled = CLRConfig.GetBoolValue(c_InvariantModeConfigSwitch); if (!invariantEnabled) { if (Interop.GlobalizationInterop.LoadICU() == 0) { string message = "Couldn't find a valid ICU package installed on the system. " + "Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support."; Environment.FailFast(message); } } return(invariantEnabled); }
// GetInvariantSwitchValue calls CLRConfig first to detect if the switch is defined in the config file. // if the switch is defined we just use the value of this switch. otherwise, we'll try to get the switch // value from the environment variable if it is defined. internal static bool GetInvariantSwitchValue() { bool ret = CLRConfig.GetBoolValue("System.Globalization.Invariant", out bool exist); if (!exist) { // Linux doesn't support environment variable names include dots string?switchValue = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); if (switchValue != null) { ret = bool.IsTrueStringIgnoreCase(switchValue) || switchValue.Equals("1"); } } return(ret); }
private static bool CheckEnableAutoreleasePool() { const string feature = "System.Threading.Thread.EnableAutoreleasePool"; #if CORECLR // In coreclr_initialize, we call ICLRRuntimeHost4->Start() which, among other things, // starts a finalizer thread for Objective-C's NSAutoreleasePool interop on macOS. // Although AppContext.Setup() is done during CreateAppDomainWithManager() call which // is made in coreclr_initialize right after the host has started, there is a chance of // race between the call to CreateAppDomainWithManager in coreclr_initialize and the // finalizer thread starting, that will call into the changed managed code. // // Therefore, we are using CLR configuration via QCall here, instead of AppContext. return(CLRConfig.GetBoolValue(feature, out bool isSet) && isSet); #else return(AppContextConfigHelper.GetBooleanConfig(feature, false)); #endif }
private static bool GetGlobalizationInvariantMode() { return(CLRConfig.GetBoolValue(c_InvariantModeConfigSwitch)); }
private static bool ShouldFailFastOnUnobservedException() { return(CLRConfig.CheckThrowUnobservedTaskExceptions()); }