Bug 29044

Summary: "using static" not consulted for nested type
Product: [Mono] Compilers Reporter: Malcolm Rowe <malcolm.rowe+xamarin-bugzilla>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Malcolm Rowe 2015-04-13 11:24:27 UTC
In mono-4.0.0/9236ac4 and master/bd471cb, C#6-style "using static" directives do not appear to be consulted if the type is a nested type.

(Note that - for master - this is after the fix for issue 28976, which in any case only affected types in different assemblies.)

-- Constants.cs
public class Constants
{
  public class One
  {
      public override string ToString()
      {
          return "1";
      }
  }
}
-- Program.cs
using static Constants;

static class Program
{
  static void Main(string[] args)
  {
    System.Console.WriteLine(typeof(One).FullName);
    System.Console.WriteLine(new One());
  }
}
--

With master/bd471cb:

$ mcs -debug Program.cs Constants.cs
Program.cs(7,37): error CS0246: The type or namespace name `One' could not be found. Are you missing an assembly reference?
Program.cs(8,34): error CS0246: The type or namespace name `One' could not be found. Are you missing an assembly reference?
$

Replacing "One" in both cases with "Constants.One" works, and produces the expected output:
Constants+One
1
Comment 1 Marek Safar 2015-04-14 12:00:08 UTC
Fixed in master