Merge pull request #1843 from info-lvsys/patch-1
[mono.git] / mcs / class / corlib / System.Security.Principal / WindowsImpersonationContext.cs
index 11f0be64d04e7c26d022997b5aa3e662b3076988..870c786b3418ea23fb885732a9b0429189395d4e 100644 (file)
@@ -34,12 +34,8 @@ using System.Security;
 
 namespace System.Security.Principal {
 
-#if NET_2_0
        [ComVisible (true)]
        public class WindowsImpersonationContext : IDisposable {
-#else
-       public class WindowsImpersonationContext {
-#endif
 
                private IntPtr _token;
                private bool undo;
@@ -53,7 +49,6 @@ namespace System.Security.Principal {
                        }
                        undo = false;
                }
-#if NET_2_0
                [ComVisible (false)]
                public void Dispose ()
                {
@@ -68,15 +63,12 @@ namespace System.Security.Principal {
                        if (!undo) {
                                Undo ();
                        }
-               }
-#else
-               ~WindowsImpersonationContext ()
-               {
-                       if (!undo) {
-                               Undo ();
+                       if (disposing){
+                               // If we are explicitly disposed, we can avoid finalization.
+                               GC.SuppressFinalize (this);
                        }
                }
-#endif
+
                public void Undo ()
                {
                        if (!RevertToSelf ()) {