Bug 26569 - "using System.Math;" C# 6 syntax no longer works
Summary: "using System.Math;" C# 6 syntax no longer works
Status: RESOLVED FEATURE
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-01-29 15:01 UTC by Sandy Armstrong [MSFT]
Modified: 2015-02-10 04:13 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Sandy Armstrong [MSFT] 2015-01-29 15:01:27 UTC
Steps:

1) Include a C# 6 style using statement like `using System.Math;` in your source
2) Compile


Expected results:

Compilation succeeds. You can then use `Min` (for example) without having to prefix `Math.`. This works in Mono 3.12.


Actual results:

error CS0138: A `using' directive can only be applied to namespaces but `System.Math' denotes a type. Consider using a `using static' instead


I'm using mono master (bc13a8125e5efe020eafe42560302ff4f42f5557).
Comment 1 Marek Safar 2015-01-30 10:47:30 UTC
The spec has changed, Correct syntax is "using static Foo;"
Comment 2 Sandy Armstrong [MSFT] 2015-01-30 10:59:53 UTC
Mea culpa. I'll go actually learn C# 6 now...
Comment 3 Sandy Armstrong [MSFT] 2015-01-30 11:03:37 UTC
FWIW, `using static System.Math;` is not working in the REPL in master:

csharp> using System.Math;
(1,2): error CS0138: A `using' directive can only be applied to namespaces but `System.Math' denotes a type. Consider using a `using static' instead
/Users/sandy/mono-prefix/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
csharp> using static System.Math;
(1,7): error CS1525: Unexpected symbol `static', expecting `('
Comment 4 Marek Safar 2015-02-10 04:13:37 UTC
REPL issues is fixed in master