From caf7eb718604fe00fd4ddc790fc89378c30eae98 Mon Sep 17 00:00:00 2001
From: snorrsi <snorrsi@gmail.com>
Date: Fri, 19 Apr 2024 22:04:20 +0000
Subject: [PATCH 1/2] Update ExecutionEnvironment to cache command line

---
 .../src/ExecutionEnvironment.cs               | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/source/VersionHandlerImpl/src/ExecutionEnvironment.cs b/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
index 0a69aad1..083ed8b5 100644
--- a/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
+++ b/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
@@ -25,18 +25,35 @@ namespace Google {
 /// </summary>
 internal class ExecutionEnvironment {
 
+    /// <summary>
+    /// Cached lower case CommandLine
+    /// </summary>
+    private static string Cached_Environment_CommandLine_Lower = null;
+    
+    /// <summary>
+    /// Get/Set cached lower case CommandLine
+    /// </summary>
+    public static string Environment_CommandLine_Lower {
+        get {
+            if (Cached_Environment_CommandLine_Lower != null) {
+                Cached_Environment_CommandLine_Lower = Environment.CommandLine.ToLower();
+            }
+            return Cached_Environment_CommandLine_Lower;
+        }
+    }
+    
     /// <summary>
     /// Whether the editor was started in batch mode.
     /// </summary>
     public static bool InBatchMode {
-        get { return Environment.CommandLine.ToLower().Contains("-batchmode"); }
+        get { return Environment_CommandLine_Lower.Contains("-batchmode"); }
     }
 
     /// <summary>
     /// Whether the editor was started with a method to executed.
     /// </summary>
     public static bool ExecuteMethodEnabled {
-        get { return Environment.CommandLine.ToLower().Contains("-executemethod"); }
+        get { return Environment_CommandLine_Lower.Contains("-executemethod"); }
     }
 
     /// <summary>
@@ -44,7 +61,7 @@ public static bool ExecuteMethodEnabled {
     /// </summary>
     internal static bool InteractiveMode {
         get {
-            return !(Environment.CommandLine.ToLower().Contains("-gvh_noninteractive") ||
+            return !(Environment_CommandLine_Lower.Contains("-gvh_noninteractive") ||
                      ExecutionEnvironment.InBatchMode);
         }
     }

From 2b3ef3e86e8c0134ce984972f18e00bdead53673 Mon Sep 17 00:00:00 2001
From: snorrsi <snorrsi@gmail.com>
Date: Fri, 19 Apr 2024 22:22:50 +0000
Subject: [PATCH 2/2] Update ExecutionEnvironment.cs fix cache check

---
 source/VersionHandlerImpl/src/ExecutionEnvironment.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/VersionHandlerImpl/src/ExecutionEnvironment.cs b/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
index 083ed8b5..ed642f76 100644
--- a/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
+++ b/source/VersionHandlerImpl/src/ExecutionEnvironment.cs
@@ -35,7 +35,7 @@ internal class ExecutionEnvironment {
     /// </summary>
     public static string Environment_CommandLine_Lower {
         get {
-            if (Cached_Environment_CommandLine_Lower != null) {
+            if (Cached_Environment_CommandLine_Lower == null) {
                 Cached_Environment_CommandLine_Lower = Environment.CommandLine.ToLower();
             }
             return Cached_Environment_CommandLine_Lower;