Bug 28976

Summary: "using static" not consulted for libraries
Product: [Mono] Compilers Reporter: Malcolm Rowe <malcolm.rowe+xamarin-bugzilla>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: david.siegel, 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-10 09:02:18 UTC
In mono-4.0.0, C#6-style "using static" statements do not appear to be consulted if the type is in another assembly.

-- Constants.cs
public static class Constants
  public const long One = 1;
-- Program.cs
using static Constants;

static class Program
  static void Main(string[] args)

With mono-4.0.0-branch 9236ac4, I get the following:

$ mcs Program.cs Constants.cs
$ mono Program.exe


$ mcs -target:library Constants.cs -out:Constants.dll
$ mcs Program.cs -r:Constants
Program.cs(7,30): error CS0103: The name `One' does not exist in the current context
Compilation failed: 1 error(s), 0 warnings

(monop shows that the contents of Constants.dll is as expected, and if you replace the Console.WriteLine call with "WriteLine(Constants.One)", it works as expected.)
Comment 1 Malcolm Rowe 2015-04-10 09:58:19 UTC
This also fails in master/4fc75b3.
Comment 2 Marek Safar 2015-04-13 08:20:21 UTC
Fixed in master
Comment 3 Malcolm Rowe 2015-04-13 08:59:30 UTC
Thanks for the quick fix. b526af0 applies cleanly to mono-4.0.0-branch too; it'd be great if the fix could be backported.
Comment 4 Marek Safar 2015-06-04 10:49:50 UTC
*** Bug 30755 has been marked as a duplicate of this bug. ***