[Mono-list] mcs won't allow implementation of interfaces withstatic methods

Jeroen Frijters jeroen@sumatra.nl
Fri, 16 Aug 2002 09:27:03 +0200


I disagree, while C# doesn't allow static interface declarations, that
doesn't mean C# should be unable to implement interfaces from other
languages that do add static methods to interfaces. There is nothing in
the C# language specification that forbids that. You don't support
static methods in interfaces, so just ignore them. Besides, the current
error message is incorrect, fixing the compiler is less effort than
fixing the error message ;-)

On the Rotor list where this was also discussed (I posted this issue
there and here), it was suggested that MS would fix the C# compiler (by
making it ignore all static methods in interfaces).

Regards,
Jeroen

> -----Original Message-----
> From: Miguel de Icaza [mailto:miguel@ximian.com] 
> Sent: Thursday, August 15, 2002 23:12
> To: Martin Baulig
> Cc: Jeroen Frijters; mono-list@ximian.com
> Subject: Re: [Mono-list] mcs won't allow implementation of 
> interfaces withstatic methods
> 
> 
> Hello,
> 
> > "Jeroen Frijters" <mono@jeroen.nu> writes:
> > 
> > > When I have a C# class that tries to implement an 
> interface (created
> > > with ILASM) that contains a static method, mcs gives an 
> error saying
> > > that I should implement the static method (which 
> obviously doesn't make
> > > sense).
> > 
> > Hi,
> > 
> > I don't understand what you're trying to do: static methods are not
> > allowed on interfaces, that'd be an error CS0106.  MCS currently
> > doesn't report that error but abort with a parsing error 
> instead since
> > its parser won't recognize `static' as a keyword if it's used on an
> > interface method.
> 
> This is being discussed as well on the .NET mailing lists (maybe this
> was posted there first, and then brought up here?).  
> Basically, C# does
> not allow static interface declarations.
> 
> So we are fine reporting an error there.
> 
> Miguel
>