Merge pull request #855 from echampet/spec
authorMarek Safar <marek.safar@gmail.com>
Thu, 2 Jan 2014 17:37:47 +0000 (09:37 -0800)
committerMarek Safar <marek.safar@gmail.com>
Thu, 2 Jan 2014 17:37:47 +0000 (09:37 -0800)
Fix a small typo in mono-core.spec.in breaking the build

12 files changed:
mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs
mcs/class/WindowsBase/Test/System.ComponentModel/SortDescriptionCollectionTest.cs
mcs/class/corlib/System.Runtime.CompilerServices/AsyncTaskMethodBuilder.cs
mcs/class/corlib/System.Runtime.CompilerServices/AsyncTaskMethodBuilder_T.cs
mcs/class/corlib/System.Threading.Tasks/Task.cs
mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs
mcs/mcs/class.cs
mcs/mcs/cs-parser.jay
mcs/mcs/eval.cs
mcs/tests/test-async-22.cs
mcs/tests/test-async-56.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 2044bca07693e952cfc5973b61e19874e7c68a44..9174cfb44585a7b55e33fe75c4d6e68308981da9 100644 (file)
@@ -32,10 +32,17 @@ namespace System.ComponentModel {
 
        public class SortDescriptionCollection : Collection<SortDescription>, INotifyCollectionChanged
        {
-               public static readonly SortDescriptionCollection Empty = new SortDescriptionCollection ();
+               public static readonly SortDescriptionCollection Empty = new SortDescriptionCollection (true);
 
-               public SortDescriptionCollection ()
+               readonly bool isReadOnly;
+
+               public SortDescriptionCollection () : this (false)
+               {
+               }
+
+               SortDescriptionCollection (bool isReadOnly)
                {
+                       this.isReadOnly = isReadOnly;
                }
 
                event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged {
@@ -47,12 +54,18 @@ namespace System.ComponentModel {
 
                protected override void ClearItems ()
                {
+                       if (isReadOnly)
+                               throw new NotSupportedException ();
+
                        base.ClearItems ();
                        OnCollectionChanged (NotifyCollectionChangedAction.Reset);
                }
 
                protected override void InsertItem (int index, SortDescription item)
                {
+                       if (isReadOnly)
+                               throw new NotSupportedException ();
+
                        item.Seal ();
                        base.InsertItem (index, item);
                        OnCollectionChanged (NotifyCollectionChangedAction.Add, item, index);
@@ -60,6 +73,9 @@ namespace System.ComponentModel {
 
                protected override void RemoveItem (int index)
                {
+                       if (isReadOnly)
+                               throw new NotSupportedException ();
+
                        SortDescription sd = base [index];
                        base.RemoveItem (index);
                        OnCollectionChanged (NotifyCollectionChangedAction.Remove, sd, index);
@@ -67,6 +83,9 @@ namespace System.ComponentModel {
 
                protected override void SetItem (int index, SortDescription item)
                {
+                       if (isReadOnly)
+                               throw new NotSupportedException ();
+
                        SortDescription old = base [index];
                        item.Seal ();
                        base.SetItem (index, item);
index 9c1e3d5e6681e83862d4e397ca75f37a8a4c0bc1..cfde0f6813f518437c7a17783286a543bc6f3396 100644 (file)
@@ -152,5 +152,51 @@ namespace MonoTests.System.ComponentModel {
                        Assert.AreEqual (ListSortDirection.Descending, addedItem.Direction, "ADD_#2");
                        Assert.AreEqual (true, addedItem.IsSealed, "ADD_#3");
                }
+
+               [Test]
+               public void GetEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       CollectionAssert.IsEmpty (collection, "A1");
+               }
+
+               [Test]
+               [ExpectedException (typeof(NotSupportedException))]
+               public void AddToEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       collection.Add (new SortDescription ());
+               }
+
+               [Test]
+               public void RemoveFromEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       Assert.IsFalse (collection.Remove (new SortDescription ()), "A1");
+               }
+
+               [Test]
+               [ExpectedException (typeof(NotSupportedException))]
+               public void RemoveAtIndexFromEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       collection.RemoveAt (0);
+               }
+
+               [Test]
+               [ExpectedException (typeof(NotSupportedException))]
+               public void ClearEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       collection.Clear ();
+               }
+
+               [Test]
+               [ExpectedException (typeof(NotSupportedException))]
+               public void InsertIntoEmptyCollection ()
+               {
+                       var collection = SortDescriptionCollection.Empty;
+                       collection.Insert (0, new SortDescription ());
+               }
        }
 }
index 29578435b898fb13194a999b97c7292ed41b8453..13a7f218fee1619f18d755b09a5882b01e5e7d10 100644 (file)
@@ -69,7 +69,7 @@ namespace System.Runtime.CompilerServices
                
                public static AsyncTaskMethodBuilder Create ()
                {
-                       var task = new Task<object> (TaskActionInvoker.Empty, null, CancellationToken.None, TaskCreationOptions.None, null);
+                       var task = new Task<object> (TaskActionInvoker.Promise, null, CancellationToken.None, TaskCreationOptions.None, null);
                        task.SetupScheduler (TaskScheduler.Current);
                        return new AsyncTaskMethodBuilder (task);
                }
index 96f6dc68ab0fd9ef994ce80b91fe41a1ef40602e..71fd4b1b81fe57ee3ff498754c38899f2d0e1f72 100644 (file)
@@ -69,7 +69,7 @@ namespace System.Runtime.CompilerServices
                
                public static AsyncTaskMethodBuilder<TResult> Create ()
                {
-                       var task = new Task<TResult> (TaskActionInvoker.Empty, null, CancellationToken.None, TaskCreationOptions.None, null);
+                       var task = new Task<TResult> (TaskActionInvoker.Promise, null, CancellationToken.None, TaskCreationOptions.None, null);
                        task.SetupScheduler (TaskScheduler.Current);
                        return new AsyncTaskMethodBuilder<TResult> (task);
                }
index cf34f769c950e68be8eb749eeacf0ce90ef8c0ea..6f9cf654022b7700c35ad9a53908603606339a0f 100644 (file)
@@ -182,6 +182,9 @@ namespace System.Threading.Tasks
                        if (IsContinuation)
                                throw new InvalidOperationException ("Start may not be called on a continuation task");
 
+                       if (IsPromise)
+                               throw new InvalidOperationException ("Start may not be called on a promise-style task");
+
                        SetupScheduler (scheduler);
                        Schedule ();
                }
@@ -208,6 +211,9 @@ namespace System.Threading.Tasks
                        if (IsContinuation)
                                throw new InvalidOperationException ("RunSynchronously may not be called on a continuation task");
 
+                       if (IsPromise)
+                               throw new InvalidOperationException ("RunSynchronously may not be called on a promise-style task");
+
                        RunSynchronouslyCore (scheduler);
                }
 
@@ -1349,6 +1355,12 @@ namespace System.Threading.Tasks
                        }
                }
 
+               bool IsPromise {
+                       get {
+                               return invoker == TaskActionInvoker.Promise;
+                       }
+               }
+
                internal Task ContinuationAncestor {
                        get {
                                return contAncestor;
index 412bcf1cfaacf93e82b8884ecf2cdf87f56874ee..72a486f7a806e066243703865ad460e7b17d9404 100644 (file)
@@ -35,6 +35,7 @@ namespace System.Threading.Tasks
        abstract class TaskActionInvoker
        {
                public static readonly TaskActionInvoker Empty = new EmptyTaskActionInvoker ();
+               public static readonly TaskActionInvoker Promise = new EmptyTaskActionInvoker ();
                public static readonly TaskActionInvoker Delay = new DelayTaskInvoker ();
                
                sealed class EmptyTaskActionInvoker : TaskActionInvoker
index 0a46fd5b7ce8ae2ac0130b2a76e99c1ec00a5ccf..d450030d747ebc686eec4f757f2b8882983df7d1 100644 (file)
@@ -13,6 +13,7 @@
 //
 
 using System;
+using System.Linq;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Security;
@@ -2751,6 +2752,17 @@ namespace Mono.CSharp
                        }
                }
 
+               public override void GetCompletionStartingWith (string prefix, List<string> results)
+               {
+                       base.GetCompletionStartingWith (prefix, results);
+
+                       var bt = base_type;
+                       while (bt != null) {
+                               results.AddRange (MemberCache.GetCompletitionMembers (this, bt, prefix).Where (l => l.IsStatic).Select (l => l.Name));
+                               bt = bt.BaseType;
+                       }
+               }
+
                protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class)
                {
                        var ifaces = base.ResolveBaseTypes (out base_class);
index a64e4a86a8851e9e1a12ad6680f6c4d6c42c190e..901ce7d3f438db85375bd646dacd20a4612ed7b6 100644 (file)
@@ -2601,6 +2601,8 @@ enum_declaration
          }
          opt_enum_member_declarations
          {
+               lexer.parsing_modifiers = true;
+         
                // here will be evaluated after CLOSE_BLACE is consumed.
                if (doc_support)
                        Lexer.doc_state = XmlCommentState.Allowed;
index 26e4f5d8d90ca2e1d004e5b20c60b9259ccdd78d..3458f7499c937c8ecdf5a468035f02ec7ae1ced0 100644 (file)
@@ -370,8 +370,14 @@ namespace Mono.CSharp
                                if (parser == null){
                                        return null;
                                }
-                               
-                               Class parser_result = parser.InteractiveResult;
+
+                               Class host = parser.InteractiveResult;
+
+                               var base_class_imported = importer.ImportType (base_class);
+                               var baseclass_list = new List<FullNamedExpression> (1) {
+                                       new TypeExpression (base_class_imported, host.Location)
+                               };
+                               host.SetBaseTypes (baseclass_list);
 
 #if NET_4_0
                                var access = AssemblyBuilderAccess.RunAndCollect;
@@ -383,9 +389,11 @@ namespace Mono.CSharp
                                module.SetDeclaringAssembly (a);
 
                                // Need to setup MemberCache
-                               parser_result.CreateContainer ();
+                               host.CreateContainer ();
+                               // Need to setup base type
+                               host.DefineContainer ();
 
-                               var method = parser_result.Members[0] as Method;
+                               var method = host.Members[0] as Method;
                                BlockContext bc = new BlockContext (method, method.Block, ctx.BuiltinTypes.Void);
 
                                try {
index 3e0350012b945ee2c7bd643e1288139012fe8b19..c9824a794e22d1c803eadb0028dd5c8a42017053 100644 (file)
@@ -60,6 +60,15 @@ class C
        }
 }
 
+class D
+{
+       enum E {}
+
+       async Task M ()
+       {
+       }
+}
+
 class async
 {
        async (async arg)
diff --git a/mcs/tests/test-async-56.cs b/mcs/tests/test-async-56.cs
new file mode 100644 (file)
index 0000000..88f547e
--- /dev/null
@@ -0,0 +1,32 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+class Test
+{
+       public static int Main ()
+       {
+               Task<int> t = TestMethod ();
+
+               try {
+                       t.Start ();
+                       return 1;
+               } catch (InvalidOperationException) {
+               }
+
+               try {
+                       t.RunSynchronously ();
+                       return 2;
+               } catch (InvalidOperationException) {
+               }
+
+               Console.WriteLine ("ok");
+               return 0;
+       }
+
+       async static Task<int> TestMethod ()
+       {
+               await Task.Delay (100000);
+               return 1;
+       }
+}
\ No newline at end of file
index 7e56e3a31a72dd5c6f340f3d6cd23ae6437e2238..3ac0eaa194cbbabc8d1f3e10d619fc59a20296db 100644 (file)
         <size>13</size>\r
       </method>\r
     </type>\r
+    <type name="D">\r
+      <method name="System.Threading.Tasks.Task M()" attrs="129">\r
+        <size>33</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="D+&lt;M&gt;c__async0">\r
+      <method name="Void MoveNext()" attrs="486">\r
+        <size>31</size>\r
+      </method>\r
+      <method name="Void SetStateMachine(IAsyncStateMachine)" attrs="486">\r
+        <size>13</size>\r
+      </method>\r
+    </type>\r
   </test>\r
   <test name="test-async-23.cs">\r
     <type name="MyContext">\r
       </method>\r
     </type>\r
   </test>\r
+  <test name="test-async-56.cs">\r
+    <type name="Test">\r
+      <method name="Int32 Main()" attrs="150">\r
+        <size>70</size>\r
+      </method>\r
+      <method name="System.Threading.Tasks.Task`1[System.Int32] TestMethod()" attrs="145">\r
+        <size>33</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="Test+&lt;TestMethod&gt;c__async0">\r
+      <method name="Void MoveNext()" attrs="486">\r
+        <size>169</size>\r
+      </method>\r
+      <method name="Void SetStateMachine(IAsyncStateMachine)" attrs="486">\r
+        <size>13</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="test-cls-00.cs">\r
     <type name="CLSCLass_6">\r
       <method name="Void add_Disposed(Delegate)" attrs="2182">\r