Better error message
authorMarek Safar <marek.safar@gmail.com>
Mon, 9 Jul 2012 09:19:39 +0000 (10:19 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 9 Jul 2012 14:32:30 +0000 (15:32 +0100)
mcs/errors/cs0182-16.cs [new file with mode: 0644]
mcs/errors/cs0647-12.cs
mcs/errors/cs0647-13.cs
mcs/mcs/attribute.cs

diff --git a/mcs/errors/cs0182-16.cs b/mcs/errors/cs0182-16.cs
new file mode 100644 (file)
index 0000000..73a9430
--- /dev/null
@@ -0,0 +1,11 @@
+// CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression
+// Line: 10
+
+using System.Runtime.InteropServices;
+
+class X {
+       static string dll = "some.dll";
+       
+       [DllImport (dll)]
+       extern static void Blah ();
+}
index edcdec29d9be5e794122ec285f649b2cfe889c2e..f1d8370235649976b1b0adbc92f99d2b7dbf39c6 100644 (file)
@@ -1,4 +1,4 @@
-// CS0647: Error during emitting `System.Runtime.InteropServices.DllImportAttribute' attribute. The reason is `DllName cannot be empty'
+// CS0647: Error during emitting `System.Runtime.InteropServices.DllImportAttribute' attribute. The reason is `DllName cannot be empty or null'
 // Line: 8
 
 using System.Runtime.InteropServices;
index e48c0e08d5de782cd879609b63fe0df1bb1933ad..96751a139aee7a581a783a9dc8e86c00421c2cfd 100644 (file)
@@ -1,4 +1,4 @@
-// CS0647: Error during emitting `System.Runtime.InteropServices.DllImportAttribute' attribute. The reason is `DllName cannot be empty'
+// CS0647: Error during emitting `System.Runtime.InteropServices.DllImportAttribute' attribute. The reason is `DllName cannot be empty or null'
 // Line: 8
 
 using System.Runtime.InteropServices;
index a73d7870ca032bad72a63241ed156e46f453eadc..46c0116bd18b3e60c6d89ebb463a946e99528a41 100644 (file)
@@ -1011,7 +1011,7 @@ namespace Mono.CSharp {
                                                                if (pos_args.Count == 1 && pos_args[0].Expr is Constant) {
                                                                        var value = ((Constant) pos_args[0].Expr).GetValue () as string;
                                                                        if (string.IsNullOrEmpty (value))
-                                                                               Error_AttributeEmitError ("DllName cannot be empty");
+                                                                               Error_AttributeEmitError ("DllName cannot be empty or null");
                                                                }
                                                        } else if (Type == predefined.MethodImpl && pt.BuiltinType == BuiltinTypeSpec.Type.Short &&
                                                                !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) arg_expr).GetValue ().ToString ())) {