-// CS0234: The type or namespace name `Linq' does not exist in the namespace `System'. Are you missing an assembly reference?
-// Line: 3
+// CS0234: The type or namespace name `Linq' does not exist in the namespace `System'. Are you missing `System.Core' assembly reference?
+// Line: 5
// Compiler options: -noconfig
using System.Linq;
-// CS0246: The type or namespace name `Nonexistant' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `Nonexistant' could not be found. Are you missing an assembly reference?
// Line: 5
using System;
-// CS0246: The type or namespace name `aa' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `aa' could not be found. Are you missing an assembly reference?
// Line: 6
public class Test
-// CS0246: The type or namespace name `RNGCryptoServiceProvider' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `RNGCryptoServiceProvider' could not be found. Are you missing `System.Security.Cryptography' using directive?
// Line: 13
using System;
-// CS0246: The type or namespace name `class' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `class' could not be found. Are you missing an assembly reference?
// Line: 9
using System;
-// CS0246: The type or namespace name `Uri' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `Uri' could not be found. Are you missing `System' using directive?
// Line: 7
-// This bug actual checks that the compiler doesn't crash
-
public interface IFoo
{
string Heh { get; } // significant to cause the error.
-// CS0246: The type or namespace name `InvalidTypeBlah' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `InvalidTypeBlah' could not be found. Are you missing an assembly reference?
// Line: 17
//
-// CS0246: The type or namespace name `B' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `B' could not be found. Are you missing an assembly reference?
// Line: 4
class A : B
-// CS0246: The type or namespace name `Foo' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `Foo' could not be found. Are you missing an assembly reference?
// Line: 4
using Foo;
-// CS0246: The type or namespace name `dynamic' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `dynamic' could not be found. Are you missing an assembly reference?
// Line: 9
// Compiler options: -langversion:ISO-2
-// CS0246: The type or namespace name `aGgt' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `aGgt' could not be found. Are you missing an assembly reference?
// Line: 13
using System;
-// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing an assembly reference?
// Line: 5
interface A {
event ErrorType Test;
-}
\ No newline at end of file
+}
-// CS0246: The type or namespace name `C' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `C' could not be found. Are you missing an assembly reference?
// Line: 5
using C = Cks.Runtime.Data;
-// CS0246: The type or namespace name `IBase' could not be found. Are you missing a using directive or an assembly reference?
-// Line: 155555
+// CS0246: The type or namespace name `IBase' could not be found. Are you missing `Foo' using directive?
+// Line: 15
namespace Foo {
public interface IBase {
-// CS0246: The type or namespace name `var' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `var' could not be found. Are you missing an assembly reference?
// Line: 8
class C
-// CS0246: The type or namespace name `var' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `var' could not be found. Are you missing an assembly reference?
// Line: 8
-// CS0246: The type or namespace name `TypeMe' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `TypeMe' could not be found. Are you missing an assembly reference?
// Line: 12
class C
-// CS0246: The type or namespace name `X' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `X' could not be found. Are you missing an assembly reference?
// Line: 4
class A<T> where T : X
-// CS0246: The type or namespace name `M' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `M' could not be found. Are you missing an assembly reference?
// Line: 11
interface I<T>
-// CS0246: The type or namespace name `NotExist' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `NotExist' could not be found. Are you missing an assembly reference?
// Line: 6
class X
-// CS0246: The type or namespace name `B' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `B' could not be found. Are you missing an assembly reference?
// Line: 4
class A : C<B>
-// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing an assembly reference?
// Line: 5
interface A {
ErrorType Method();
-}
\ No newline at end of file
+}
-// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `ErrorType' could not be found. Are you missing an assembly reference?
// Line: 4
-public delegate ErrorType Delegate ();
\ No newline at end of file
+public delegate ErrorType Delegate ();
-// CS0246: The type or namespace name `AAAA' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `AAAA' could not be found. Are you missing an assembly reference?
// Line: 7
using System;
-// CS0246: The type or namespace name `XmlDocument' could not be found. Are you missing a using directive or an assembly reference?
-// Line: 7
-// This is bug 55770
+// CS0246: The type or namespace name `XmlDocument' could not be found. Are you missing `System.Xml' using directive?
+// Line: 6
using System;
using System.Xml;
public static void Main ()
{
}
-}
\ No newline at end of file
+}
-// CS0246: The type or namespace name `foo' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `foo' could not be found. Are you missing an assembly reference?
// Line: 5
struct bar {
-// CS0246: The type or namespace name `Reflection' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `Reflection' could not be found. Are you missing an assembly reference?
// Line: 7
using System;
-// CS0246: The type or namespace name `B' could not be found. Are you missing a using directive or an assembly reference?
+// CS0246: The type or namespace name `B' could not be found. Are you missing an assembly reference?
// Line: 4
interface A : B {
}
-// CS0400: The type or namespace name `N' could not be found in the global namespace (are you missing an assembly reference?)
+// CS0400: The type or namespace name `N' could not be found in the global namespace. Are you missing an assembly reference?
// Line: 8
class C
{
global::N n = null;
}
-}
\ No newline at end of file
+}
}
}
+ var report = ctx.Module.Compiler.Report;
+
var retval = ctx.LookupNamespaceOrType (Name, Arity, LookupMode.IgnoreAccessibility, loc);
if (retval != null) {
- ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (retval.Type);
+ report.SymbolRelatedToPreviousError (retval.Type);
ErrorIsInaccesible (ctx, retval.GetSignatureForError (), loc);
return;
}
return;
}
- NamespaceContainer.Error_NamespaceNotFound (loc, Name, ctx.Module.Compiler.Report);
+ var ns_candidates = ctx.Module.GlobalRootNamespace.FindTypeNamespaces (ctx, Name, Arity);
+ if (ns_candidates != null) {
+ string usings = string.Join ("' or `", ns_candidates);
+ report.Error (246, loc,
+ "The type or namespace name `{0}' could not be found. Are you missing `{1}' using directive?",
+ Name, usings);
+ } else {
+ report.Error (246, loc,
+ "The type or namespace name `{0}' could not be found. Are you missing an assembly reference?",
+ Name);
+ }
}
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
report.Error (1681, loc, "The global extern alias cannot be redefined");
}
+ //
+ // For better error reporting where we try to guess missing using directive
+ //
+ public List<string> FindTypeNamespaces (IMemberContext ctx, string name, int arity)
+ {
+ List<string> res = null;
+
+ foreach (var ns in all_namespaces) {
+ var type = ns.Value.LookupType (ctx, name, arity, LookupMode.Normal, Location.Null);
+ if (type != null) {
+ if (res == null)
+ res = new List<string> ();
+
+ res.Add (ns.Key);
+ }
+ }
+
+ return res;
+ }
+
public void RegisterNamespace (Namespace child)
{
if (child != this)
return;
}
+ string assembly = null;
+ string possible_name = fullname + "." + name;
+
+ // Only assembly unique name should be added
+ switch (possible_name) {
+ case "System.Drawing":
+ case "System.Web.Services":
+ case "System.Web":
+ case "System.Data":
+ case "System.Configuration":
+ case "System.Data.Services":
+ case "System.DirectoryServices":
+ case "System.Json":
+ case "System.Net.Http":
+ case "System.Numerics":
+ case "System.Runtime.Caching":
+ case "System.ServiceModel":
+ case "System.Transactions":
+ case "System.Web.Routing":
+ case "System.Xml.Linq":
+ case "System.Xml":
+ assembly = possible_name;
+ break;
+
+ case "System.Linq":
+ case "System.Linq.Expressions":
+ assembly = "System.Core";
+ break;
+
+ case "System.Windows.Forms":
+ case "System.Windows.Forms.Layout":
+ assembly = "System.Windows.Name";
+ break;
+ }
+
+ assembly = assembly == null ? "an" : "`" + assembly + "'";
+
if (this is GlobalRootNamespace) {
ctx.Module.Compiler.Report.Error (400, loc,
- "The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)",
- name);
+ "The type or namespace name `{0}' could not be found in the global namespace. Are you missing {1} assembly reference?",
+ name, assembly);
} else {
ctx.Module.Compiler.Report.Error (234, loc,
- "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?",
- name, GetSignatureForError ());
+ "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing {2} assembly reference?",
+ name, GetSignatureForError (), assembly);
}
}
return match;
}
- static void MsgtryRef (string s)
- {
- Console.WriteLine (" Try using -r:" + s);
- }
-
- static void MsgtryPkg (string s)
- {
- Console.WriteLine (" Try using -pkg:" + s);
- }
-
- public static void Error_NamespaceNotFound (Location loc, string name, Report Report)
- {
- Report.Error (246, loc, "The type or namespace name `{0}' could not be found. Are you missing a using directive or an assembly reference?",
- name);
-
- switch (name) {
- case "Gtk": case "GtkSharp":
- MsgtryPkg ("gtk-sharp-2.0");
- break;
-
- case "Gdk": case "GdkSharp":
- MsgtryPkg ("gdk-sharp-2.0");
- break;
-
- case "Glade": case "GladeSharp":
- MsgtryPkg ("glade-sharp-2.0");
- break;
-
- case "System.Drawing":
- case "System.Web.Services":
- case "System.Web":
- case "System.Data":
- case "System.Windows.Forms":
- MsgtryRef (name);
- break;
- }
- }
-
protected override void DefineNamespace ()
{
if (namespace_using_table == null)