Bug 13135 - Error "Default parameter specifiers are not permitted" is not generated by GMCS
Summary: Error "Default parameter specifiers are not permitted" is not generated by GMCS
Status: RESOLVED FEATURE
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-07-09 15:40 UTC by Andres G. Aragoneses
Modified: 2013-07-10 06:56 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 Andres G. Aragoneses 2013-07-09 15:40:32 UTC
Default parameters were implemented in C# 4.0 (.NET 4.0), so then compiling with gmcs this testcase:

namespace TestProject
{
	public static class MyClass
	{
		public static void TestWithOptionalParams (bool optional = false)
		{
		}
	}
}

Should generate the following error, which C:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe generated:

"Default parameter specifiers are not permitted"

The example of why this bug shouldn't be WONTFIXed is because of how this bug was discovered by a banshee developer: our build targets .NET 3.5, and we had already added some default-parameter code in banshee by mistake, making the Windows build fail (but having a misleading green Linux build).
Comment 1 Andres G. Aragoneses 2013-07-09 17:04:20 UTC
http://msdn.microsoft.com/en-us/library/294000kk(v=vs.80).aspx
Comment 2 Marek Safar 2013-07-10 03:18:46 UTC
gmcs is not language but profile specific. If you need to limit C# features use -langversion
Comment 3 Andres G. Aragoneses 2013-07-10 05:20:57 UTC
>If you need to limit C# features use -langversion

Fair enough... but shouldn't gmcs default to this langversion in the script? (So you can still specify a higher version of C# if you are interested.)
Comment 4 Marek Safar 2013-07-10 05:22:50 UTC
gmcs is not C# 2.0 compiler it's compiler targeting .NET 2.0 runtime.
Comment 5 Andres G. Aragoneses 2013-07-10 05:26:06 UTC
> gmcs is not C# 2.0 compiler it's compiler targeting .NET 2.0 runtime.

Right, and the .NET 2.0 runtime used to map to the 2.0 & 3.0 version of C#, not higher :)

I guess then that xbuild should be the one using -langversion 3 when dealing with a .NET2.0/.NET3.5 project...
Comment 6 Marek Safar 2013-07-10 05:31:24 UTC
Maybe but it's more project specific. I am not sure but I think VS does same when in VS2k12 you target 2.0 runtime.
Comment 7 Andres G. Aragoneses 2013-07-10 06:22:59 UTC
>Maybe but it's more project specific. I am not sure but I think VS does same
>when in VS2k12 you target 2.0 runtime.

Apparently you can set this per project via "Project Properties"->"Build"->"Advanced"->"Language Version".

Would you accept a patch that made langversion default to 3 if the sdk is set to 3.5? (Converting the feature from opt-out to opt-in.) This way, you would still be able to compile C# 4.0 via using /langversion, and it would map more closely to what C:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe does.
Comment 8 Marek Safar 2013-07-10 06:56:23 UTC
No, master gmcs is same as 4.5.1 csc targeting 2.0 runtime. If you for some reason you need to resting language version use -langversion, exactly as you would do in the latest VS