1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Apache License, Version 2.0, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Apache License, Version 2.0.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
16 using System.Security;
19 namespace Microsoft.Scripting {
22 /// This class holds onto internal debugging options used in this assembly.
23 /// These options can be set via environment variables DLR_{option-name}.
24 /// Boolean options map "true" to true and other values to false.
26 /// These options are for internal debugging only, and should not be
27 /// exposed through any public APIs.
29 internal static class DebugOptions {
31 private static bool ReadOption(string name) {
35 string envVar = ReadString(name);
36 return envVar != null && envVar.ToLowerInvariant() == "true";
40 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "name")]
41 private static bool ReadDebugOption(string name) {
43 return ReadOption(name);
49 private static string ReadString(string name) {
52 return Environment.GetEnvironmentVariable("DLR_" + name);
53 } catch (SecurityException) {
61 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "name")]
62 private static string ReadDebugString(string name) {
64 return ReadString(name);
70 private readonly static bool _trackPerformance = ReadDebugOption("TrackPerformance");
72 internal static bool TrackPerformance {
73 get { return _trackPerformance; }