[Mono-bugs] [Bug 698598] New: Use of extern keyword without DllImport generates error CS0626

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jun 7 13:42:06 EDT 2011



           Summary: Use of extern keyword without DllImport generates
                    error CS0626
    Classification: Mono
           Product: Mono: Compilers
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: msafar at novell.com
        ReportedBy: rodrigo.jordao at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
Trident/4.0; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727; .NET CLR
3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729;
NET4.0C; .NET4.0E)

When I use the extern keyword in a method I get error CS0626. The compiler
forces the use of this attribute, which, when used, also forces the method to
be static.

The MS C# compiler produces a warning for the same issue (CS0626).

It's conceivable that the compiled code runs in a runtime environment that
provides different ways for an external method to be injected, that doesn't
rely on DllImport or on the method being static.

Reproducible: Always

Steps to Reproduce:
Step 1. Save this code in file extern.cs:

public class Example {
  public extern void M();
  public static void Main() {}

Step 2. Run the compiler on it:

gmcs extern.cs

Actual Results:  
The code generates this error and fails compilation:

extern.cs(2,22): error CS0626: `Example.M()' is marked as an external but has
 DllImport attribute. Consider adding a DllImport attribute to specify the
nal implementation
Compilation failed: 1 error(s), 0 warnings

Expected Results:  
Compilation should be successful, and generate a warning instead of an error.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list