Merge pull request #3809 from lateralusX/jlorenss/win-api-family-support-cleanup
[mono.git] / mcs / class / corlib / System / Environment.cs
index 4bd15db01a2c535a10bb7e634bca7c9d8ce52fd6..c8b87782310327f36d1ffe0fbca382f0431c1987 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 152;
+               private const int mono_corlib_version = 163;
 #pragma warning restore 169
 
                [ComVisible (true)]
@@ -322,7 +322,7 @@ namespace System {
                                return trace.ToString ();
                        }
                }
-#if !MOBILE
+
                /// <summary>
                /// Get a fully qualified path to the system directory
                /// </summary>
@@ -331,7 +331,7 @@ namespace System {
                                return GetFolderPath (SpecialFolder.System);
                        }
                }
-#endif
+
                /// <summary>
                /// Get the number of milliseconds that have elapsed since the system was booted
                /// </summary>
@@ -472,7 +472,15 @@ namespace System {
                public extern static string[] GetCommandLineArgs ();
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               internal extern static string internalGetEnvironmentVariable (string variable);
+               internal extern static string internalGetEnvironmentVariable_native (IntPtr variable);
+
+               internal static string internalGetEnvironmentVariable (string variable) {
+                       if (variable == null)
+                               return null;
+                       using (var h = Mono.RuntimeMarshal.MarshalString (variable)) {
+                               return internalGetEnvironmentVariable_native (h.Value);
+                       }
+               }
 
                /// <summary>
                /// Return a string containing the value of the environment
@@ -862,6 +870,22 @@ namespace System {
                        }
                }
 #else
+               public static string GetEnvironmentVariable (string variable, EnvironmentVariableTarget target)
+               {
+                       if (target == EnvironmentVariableTarget.Process)
+                               return GetEnvironmentVariable (variable);
+
+                       return null;
+               }
+
+               public static IDictionary GetEnvironmentVariables (EnvironmentVariableTarget target)
+               {
+                       if (target == EnvironmentVariableTarget.Process)
+                               return GetEnvironmentVariables ();
+
+                       return (IDictionary)new Hashtable ();
+               }
+
                public static void SetEnvironmentVariable (string variable, string value)
                {
                        if (variable == null)
@@ -875,6 +899,14 @@ namespace System {
 
                        InternalSetEnvironmentVariable (variable, value);
                }
+
+               public static void SetEnvironmentVariable (string variable, string value, EnvironmentVariableTarget target)
+               {
+                       if (target == EnvironmentVariableTarget.Process)
+                               SetEnvironmentVariable (variable, value);
+
+                       // other targets ignored
+               }
 #endif
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal static extern void InternalSetEnvironmentVariable (string variable, string value);
@@ -893,7 +925,9 @@ namespace System {
                [SecurityCritical]
                public static void FailFast (string message, Exception exception)
                {
-                       throw new NotImplementedException ();
+#pragma warning disable 618
+                       throw new ExecutionEngineException (message, exception);
+#pragma warning restore
                }
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -962,6 +996,14 @@ namespace System {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern static int GetPageSize ();
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern private static string get_bundled_machine_config ();
+
+               internal static string GetBundledMachineConfig ()
+               {
+                       return get_bundled_machine_config ();
+               }
+
                static internal bool IsUnix {
                        get {
                                int platform = (int) Environment.Platform;
@@ -998,6 +1040,15 @@ namespace System {
                        // Do not include a trailing newline for backwards compatibility
                        return st.ToString( System.Diagnostics.StackTrace.TraceFormat.Normal );
                }
+
+               // Copied from referencesource Environment
+               internal static bool IsWinRTSupported
+               {
+                       get
+                       {
+                               return true;
+                       }
+               }
        }
 }