Merge pull request #498 from Unroll-Me/master
[mono.git] / mcs / class / corlib / System / Environment.cs
index c5fa5bfc9f4f0d2878d72608874c20f655ad0233..3f8878b0439bb5d04ba580ba6551da9fe9371d71 100644 (file)
@@ -39,6 +39,7 @@ using System.Security;
 using System.Security.Permissions;
 using System.Text;
 using System.Runtime.InteropServices;
+using System.Threading;
 
 namespace System {
 
@@ -55,7 +56,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 96;
+               private const int mono_corlib_version = 108;
 #pragma warning restore 169
 
                [ComVisible (true)]
@@ -168,6 +169,14 @@ namespace System {
                                Directory.SetCurrentDirectory (value);
                        }
                }
+               
+#if NET_4_5
+               public static int CurrentManagedThreadId {
+                       get {
+                               return Thread.CurrentThread.ManagedThreadId;
+                       }
+               }
+#endif
 
                /// <summary>
                /// Gets or sets the exit code of this process
@@ -357,6 +366,7 @@ namespace System {
                                // If value not found, add %FOO to stream,
                                //  and use the closing % for the next iteration.
                                // If value found, expand it in place of %FOO%
+                               int realOldOff2 = off2;
                                if (value == null) {
                                        result.Append ('%');
                                        result.Append (var);
@@ -380,7 +390,7 @@ namespace System {
                                // If value not found in current iteration, but a % was found for next iteration,
                                //  use text from current closing % to the next %.
                                else
-                                       textLen = off1 - oldOff2;
+                                       textLen = off1 - realOldOff2;
                                if(off1 >= oldOff2 || off1 == -1)
                                        result.Append (name, oldOff2+1, textLen);
                        } while (off2 > -1 && off2 < len);
@@ -651,7 +661,13 @@ namespace System {
                                        return Path.Combine (home, "Library", "Caches");
                                else
                                        return String.Empty;
-                               
+
+#if NET_4_0
+                               // #2873
+                       case SpecialFolder.UserProfile:
+                               return home;
+#endif
+
                        case SpecialFolder.Programs:
                        case SpecialFolder.SendTo:
                        case SpecialFolder.StartMenu:
@@ -669,7 +685,6 @@ namespace System {
                        case SpecialFolder.CommonDesktopDirectory:
                        case SpecialFolder.PrinterShortcuts:
                        case SpecialFolder.Windows:
-                       case SpecialFolder.UserProfile:
                        case SpecialFolder.SystemX86:
                        case SpecialFolder.ProgramFilesX86:
                        case SpecialFolder.CommonProgramFilesX86:
@@ -896,6 +911,11 @@ namespace System {
                                return (platform == 4 || platform == 128 || platform == 6);
                        }
                }
+               static internal bool IsMacOS {
+                       get {
+                               return Environment.Platform == PlatformID.MacOSX;
+                       }
+               }
        }
 }