David,

Your way of wording it is more precise, yes.  What matters for using default arguments in C# is the version of the compiler, not the version of the runtime.

For the purpose of a feature like this, we could just make a note in the documentation such as “%compactdefaultargs only works with C# compilers that support version 4.0 of the language, such as Visual Studio 2010 or later.” The existence of the feature would not break your SWIG wrappers under VS2008, as long as you don’t try to enable %compactdefaultargs.

As it stands, the feature is implemented for nobody on C#, so adding it for most people on C# seems like a win.

~James


From: David Piepgrass <david.piepgrass@trapezegroup.com>
Date: Monday, May 12, 2014 at 11:54 AM
To: James Athey <james@apx-labs.com>, swig-devel <swig-devel@lists.sourceforge.net>
Subject: RE: %compactdefaultargs and C#

Visual Studio 2010 uses C# 4.0. Perhaps what you meant to say was “even if you’re targeting a version of .NET older than 4.0, you can still use C# 4.0 or higher in VS2010”. The C# version and the .NET Framework version are independent and are numbered separately.

 

Because MS dropped support for Windows CE in VS 2010, my workplace is stuck on VS 2008: C# 3.0 and C++03.

 

From: James Athey [mailto:james@apx-labs.com]
Sent: Monday, May 12, 2014 9:01 AM
To: swig-devel
Subject: [Swig-devel] %compactdefaultargs and C#

 

A question for anyone familiar with the implementation of %compactdefaultargs - if I wanted to add support for %compactdefaultargs to C#, how difficult would it be?

 

The documentation currently states that %compactdefaultargs "does not work for the statically typed languages, such as C# and Java, which don't have optional arguments in the language.” As it turns out, C# DOES support default arguments.  The CLR has supported default arguments from the beginning, and C# as a language has supported it explicitly since C# 4.0.  Even if you’re targeting a previous version of C#, as long as you’re using Visual Studio 2010 or later to compile the code (or a recent version of Mono), default arguments will compile in any version of C#.

 

~James

DISCLAIMER: This email may contain confidential and/or privileged information and any rights to confidentiality and/or privilege have not been waived. Please notify us immediately if you have received this message in error.