New tests.
[mono.git] / mcs / class / corlib / System.Security.Policy / Evidence.cs
index 0fb40c23457e4634adf4711de11750fd88c20946..5d932f5259d0fec1b475152154acaa88b9129246 100644 (file)
@@ -39,15 +39,15 @@ using System.Runtime.InteropServices;
 using System.Security.Permissions;
 using System.Security.Cryptography.X509Certificates;
 
+#if !MOONLIGHT
 using Mono.Security.Authenticode;
+#endif
 
 namespace System.Security.Policy {
 
        [Serializable]
-       [MonoTODO ("Fix serialization compatibility with MS.NET")]
-#if NET_2_0
+       [MonoTODO ("Serialization format not compatible with .NET")]
        [ComVisible (true)]
-#endif
        public sealed class Evidence : ICollection, IEnumerable {
        
                private bool _locked;
@@ -65,6 +65,9 @@ namespace System.Security.Policy {
                                Merge (evidence);       
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public Evidence (object[] hostEvidence, object[] assemblyEvidence)
                {
                        if (null != hostEvidence)
@@ -77,6 +80,9 @@ namespace System.Security.Policy {
                // Public Properties
                //
        
+#if NET_4_0
+               [Obsolete]
+#endif
                public int Count {
                        get {
                                int count = 0;
@@ -93,12 +99,7 @@ namespace System.Security.Policy {
                }
                
                public bool IsSynchronized {
-#if NET_2_0
                        get { return false; }
-#else
-                       // LAMESPEC: Always TRUE (not FALSE)
-                       get { return true; }
-#endif
                }
 
                public bool Locked {
@@ -133,12 +134,18 @@ namespace System.Security.Policy {
                // Public Methods
                //
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public void AddAssembly (object id) 
                {
                        AssemblyEvidenceList.Add (id);
                        _hashCode = 0;
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public void AddHost (object id) 
                {
                        if (_locked && SecurityManager.SecurityEnabled) {
@@ -148,7 +155,6 @@ namespace System.Security.Policy {
                        _hashCode = 0;
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public void Clear ()
                {
@@ -158,8 +164,10 @@ namespace System.Security.Policy {
                                assemblyEvidenceList.Clear ();
                        _hashCode = 0;
                }
-#endif
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public void CopyTo (Array array, int index) 
                {
                        int hc = 0;
@@ -172,7 +180,6 @@ namespace System.Security.Policy {
                                assemblyEvidenceList.CopyTo (array, index + hc);
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override bool Equals (object obj)
                {
@@ -212,8 +219,10 @@ namespace System.Security.Policy {
                        
                        return true;
                }
-#endif
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public IEnumerator GetEnumerator () 
                {
                        IEnumerator he = null;
@@ -221,7 +230,7 @@ namespace System.Security.Policy {
                                he = hostEvidenceList.GetEnumerator ();
                        IEnumerator ae = null;
                        if (assemblyEvidenceList != null)
-                               assemblyEvidenceList.GetEnumerator ();
+                               ae = assemblyEvidenceList.GetEnumerator ();
                        return new EvidenceEnumerator (he, ae);
                }
 
@@ -230,7 +239,6 @@ namespace System.Security.Policy {
                        return AssemblyEvidenceList.GetEnumerator ();
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override int GetHashCode ()
                {
@@ -247,7 +255,6 @@ namespace System.Security.Policy {
                        }
                        return _hashCode;
                }
-#endif
 
                public IEnumerator GetHostEnumerator () 
                {
@@ -269,7 +276,6 @@ namespace System.Security.Policy {
                        }
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public void RemoveType (Type t)
                {
@@ -286,13 +292,17 @@ namespace System.Security.Policy {
                                }
                        }
                }
-#endif
 
                // Use an icall to avoid multiple file i/o to detect the 
                // "possible" presence of an Authenticode signature
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                static extern bool IsAuthenticodePresent (Assembly a);
-
+#if NET_2_1
+               static internal Evidence GetDefaultHostEvidence (Assembly a)
+               {
+                       return new Evidence ();
+               }
+#else
                // this avoid us to build all evidences from the runtime
                // (i.e. multiple unmanaged->managed calls) and also allows
                // to delay their creation until (if) needed
@@ -332,7 +342,6 @@ namespace System.Security.Policy {
                                        }
                                }
                        }
-#if NET_2_0
                        // assemblies loaded from the GAC also get a Gac evidence (new in Fx 2.0)
                        if (a.GlobalAssemblyCache) {
                                e.AddHost (new GacInstalled ());
@@ -346,10 +355,12 @@ namespace System.Security.Policy {
                                        e = dommgr.HostSecurityManager.ProvideAssemblyEvidence (a, e);
                                }
                        }
-#endif
+
                        return e;
                }
-       
+
+#endif // NET_2_1
+
                private class EvidenceEnumerator : IEnumerator {
                        
                        private IEnumerator currentEnum, hostEnum, assemblyEnum;