Fix CS0108 for interfaces with multiple methods of same name
[mono.git] / man / mcs.1
1 .de Sp \" Vertical space (when we can't use .PP)
2 .if t .sp .5v
3 .if n .sp
4 ..
5 .TH mcs 1 "6 January 2001"
6 .SH NAME 
7 mcs, gmcs, smcs \- Mono C# Compiler (1.0, 2.0, Moonlight)
8 .SH SYNOPSIS
9 .B mcs 
10 [option] [source-files]
11 .SH DESCRIPTION
12 mcs is the Mono C# compiler, an implementation of the ECMA-334
13 language specification.  You can pass one or more options to drive the
14 compiler, and a set of source files.  Extra options or arguments can
15 be provided in a response file.  Response files are referenced by
16 prepending the @ symbol to the response file name.
17 .PP
18 The 
19 .I mcs
20 compiler is used to compile against the 1.x profile and implements
21 C# 1.0 and parts of C# 2.0 and C# 3.0 specification which do not depend
22 on generics.
23 .PP
24 The
25 .I gmcs
26 compiler is used to compile against the 2.0 profile and implements
27 the complete C# 3.0 specification.
28 .PP
29 The
30 .I smcs
31 compiler is used to compile against the Silverlight/Moonlight profile.
32 This profile is designed to be used for creating Silverlight/Moonlight
33 applications that will run on a web browser.   The API exposed by this
34 profile is a small subset of the 3.5 API (even if it is commonly
35 referred as the 2.1 API, this API is a small subset of 2.0 with a few
36 extensions).
37 .PP
38 See the section on packages for more information.
39 .PP
40 The Mono C# compiler accepts the same command line options that the
41 Microsoft C# compiler does.  Those options can start with a slash or a
42 dash (/checked is the same as -checked).  Additionally some GNU-like
43 options are supported, those begin with "--".  All MCS-specific flags
44 which are not available in the Microsoft C# compiler are available
45 only with the GNU-style options.
46 .PP
47 C# source files must end with a ".cs" extension.  Compilation of C#
48 source code requires all the files that make up a library, module or
49 executable to be provided on the command line.  There is no support
50 for partial compilation.  To achieve the benefits of partial
51 compilation, you should compile programs into their own assemblies,
52 and later reference them with the "-r" flag.
53 .PP
54 The Mono C# compiler generates images (.exe files) that contain CIL
55 byte code that can be executed by any system that implements a Common
56 Language Infrastructure virtual machine such as the Microsoft .NET
57 runtime engine on Windows or the Mono runtime engine on Unix systems.
58 Executables are not bound to a specific CPU or operating system.
59 .PP
60 The Mono C# compiler by default only references three assemblies:
61 mscorlib.dll, System.dll and System.Xml.dll.   If you want to
62 reference extra libraries you must manually specify them using the
63 -pkg: command line option or the -r: command line option.
64 Alternatively if you want to get all of the System libraries, you can
65 use the -pkg:dotnet command line option.
66 .PP
67 .SH OPTIONS
68 .TP
69 .I \-\-about
70 Displays information about the Mono C# compiler
71 .TP
72 .I \-\-addmodule:MODULE1[,MODULE2]
73 Includes the specified modules in the resulting assembly.  Modules are
74 created by calling the compiler with the -target:module option
75 .TP
76 .I -checked, -checked+
77 Sets the default compilation mode to `checked'.  This makes all
78 the math operations checked (the default is unchecked).
79 .TP
80 .I -checked-
81 Sets the default compilation mode to `unchecked'.  This makes all
82 the math operations unchecked (this is the default).
83 .TP
84 .I -clscheck-, -clscheck+
85 Disables or enables the Common Language Specification (CLS) checks (it
86 is enabled by default). 
87 .Sp
88 The Common Language Specification (CLS) defines an interoperable
89 subset of types as well as conventions that compilers (CLS producers)
90 and developers must follow to expose code to other programming
91 languages (CLS consumers).  
92 .TP
93 .I -codepage:ID
94 Specifies the code page used to process the input files from the
95 point it is specified on.  By default files will be processed in the
96 environment-dependent native code page.  The compiler will also automatically
97 detect Unicode files that have an embedded byte mark at the beginning.   
98 .Sp
99 Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
100 .Sp
101 MCS supports a couple of shorthands: "utf8" can be used to specify utf-8 instead
102 of using the cryptic 65001 and "reset" restores the automatic handling of
103 code pages.  These shorthands are not available on the Microsoft compiler.
104 .TP
105 .I \-define:SYMLIST, -d:SYMLIST
106 Defines the symbol listed by the semi-colon separated list SYMLIST
107 SYMBOL.  This can be tested in the source code by the pre-processor,
108 or can be used by methods that have been tagged with the Conditional
109 attribute. 
110 .TP
111 .I \-debug, \-debug+
112 Generate debugging information.  To obtain stack traces with debugging
113 information, you need to invoke the mono runtime with the `--debug'
114 flag.  This debugging information is stored inside the assembly as a
115 resource.
116 .TP
117 .I \-debug-
118 Do not generate debugging information.
119 .TP
120 .I \-delaysign+
121 Only embed the strongname public key into the assembly. The actual 
122 signing must be done in a later stage using the SN tool. This is useful
123 to protect the private key during development. Note that delay signing
124 can only be done using a strongname key file (not a key container). The
125 option is equivalent to including [assembly: AssemblyDelaySign (true)] 
126 in your source code. Compiler option takes precedence over the 
127 attributes.
128 .TP
129 .I \-delaysign-
130 Default. Strongname (sign) the assembly using the strong name key file
131 (or container). The option is equivalent to including [assembly: 
132 AssemblyDelaySign (false)] in your source code. Compiler option takes
133 precedence over the attributes.
134 .TP
135 .I \-doc:FILE
136 Extracts the C#/XML documentation from the source code and stores in in
137 the given FILE.
138 .TP
139 .I \-errorreport
140 This flag is ignored by Mono's C# compiler and is present only to
141 allow MCS to be used as a CSC replacement for msbuild/xbuild.
142 .TP
143 .I \-\-fatal 
144 This is used for debugging the compiler.  This makes the error emission
145 generate an exception that can be caught by a debugger.
146 .TP
147 .I \-filealign
148 This flag is ignored by Mono's C# compiler and is present only to
149 allow MCS to be used as a CSC replacement for msbuild/xbuild.
150 .TP
151 .I \-keyfile:KEYFILE
152 Strongname (sign) the output assembly using the key pair present in 
153 the specified strong name key file (snk). A full key pair is required
154 by default (or when using delaysign-). A file containing only the
155 public key can be used with delaysign+. The option is equivalent to 
156 including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
157 Compiler option takes precedence over the attributes.
158 .TP
159 .I \-keycontainer:CONTAINER
160 Strongname (sign) the output assembly using the key pair present in 
161 the specified container. Note that delaysign+ is ignored when using 
162 key containers. The option is equivalent to including [assembly: 
163 AssemblyKeyName ("CONTAINER")] in your source code. Compiler option 
164 takes precedence over the attributes.
165 .TP
166 .I \-langversion:TEXT
167 The option specifies the version of the language to use. The feature
168 set is different in each C# version. This switch can be used to force
169 the compiler to allow only a subset of the features.
170 The possible values are:
171 .RS
172 .ne 8
173 .TP
174 .I "Default"
175 Instruct compiler to use the latest version. Equivalent is to omit the
176 switch (this currently defaults to the C# 3.0 language specification).
177 .TP
178 .I "ISO-1"
179 Restrict compiler to use only first ISO standardized features.
180 The usage of features such as generics, static classes, anonymous
181 methods will lead to error.
182 .TP
183 .I "ISO-2"
184 Restrict compiler to use only the second ISO standardized features.
185 This allows the use of generics, static classes, iterators and
186 anonymous methods for example.
187 .TP
188 .I "3"
189 Restrict the compiler to use only the features available in C# 3.0
190 (a superset of ISO-1 and ISO-2).
191 .TP
192 .I "future"
193 Enables features from upcoming versions of the language.   As of
194 May 2009 this includes support for C# 4 as released in Visual Studio 2010 beta 1.
195 .PP
196 Notice that this flag only controls the language features available to
197 the programmer, it does not control the kind of assemblies produced.
198 Programs compiled with mcs will reference the 1.1 APIs, Programs
199 compiled with gmcs reference the 2.0 APIs.
200 .ne
201 .RE
202 .TP
203 .I -lib:PATHLIST
204 Each path specified in the comma-separated list will direct the
205 compiler to look for libraries in that specified path.
206 .TP
207 .I \-L PATH
208 Directs the compiler to look for libraries in the specified path.
209 Multiple paths can be provided by using the option multiple times.
210 .TP
211 .I \-main:CLASS
212 Tells the compiler which CLASS contains the entry point. Useful when
213 you are compiling several classes with a Main method.
214 .TP
215 .I \-nostdlib, -nostdlib+
216 Use this flag if you want to compile the core library.  This makes the
217 compiler load its internal types from the assembly being compiled.
218 .TP
219 .I \-noconfig, \-noconfig+
220 Disables the default compiler configuration to be loaded.  The
221 compiler by default has references to the system assemblies. 
222 .TP
223 .I \-nowarn:WARNLIST
224 Makes the compiler ignore warnings specified in the comma-separated
225 list WARNLIST>
226 .TP
227 .I -optimize, -optimize+, -optimize-
228 Controls whether to perform optimizations on the code.   -optimize and
229 -optimize+ will turn on optimizations, -optimize- will turn it off.
230 The default in mcs is to optimize+.
231 .TP
232 .I -out:FNAME, -o FNAME
233 Names the output file to be generated.
234 .TP
235 .I \-\-parse
236 Used for benchmarking.  The compiler will only parse its input files.
237 .TP
238 .I \-pkg:package1[,packageN]
239 Reference assemblies for the given packages.
240 .Sp
241 The compiler will invoke pkg-config --libs on the set of packages
242 specified on the command line to obtain libraries and directories to
243 compile the code.
244 .Sp
245 This is typically used with third party components, like this:
246 .nf
247
248                 $ mcs -pkg:gtk-sharp demo.cs
249 .fi
250 .RS
251 .ne 8
252 .TP
253 .I \-pkg:dotnet
254 This will instruct the compiler to reference the System.* libraries
255 available on a typical dotnet framework installation, notice that this
256 does not include all of the Mono libraries, only the System.* ones.  This
257 is a convenient shortcut for those porting code.
258 .TP
259 .I \-pkg:olive
260 Use this to reference the "Olive" libraries (the 3.0 and 3.5 extended
261 libraries).
262 .TP
263 .I \-pkg:silver
264 References the assemblies for creating Moonlight/Silverlight
265 applications.  This is automatically used when using the 
266 .I smcs 
267 compiler, but it is here when developers want to use it with the
268 .I gmcs
269 compiler.
270 .TP
271 .I \-pkg:silverdesktop
272 Use this option to create Moonlight/Silverlight applications that
273 target the desktop.   This option allows developers to consume the
274 Silverlight APIs with the full 2.0 profile API available to them,
275 unlike 
276 .I smcs 
277 it gives full access to all the APIs that are part of Mono.  The only
278 downside is that applications created with silverdesktop will not run
279 on the browser.   Typically these applications will be launched
280 with the 
281 .I mopen
282 command line tool.
283 .TP
284 For more details see the PACKAGE section in this document
285 .ne
286 .RE
287 .TP
288 .I \-platform:ARCH
289 Used to specify the target platform. The possible values are: anycpu,
290 x86, x64 or itanium. As of June 2009, the Mono runtime only have support
291 to emit anycpu and x86 assemblies.
292 .TP
293 .I -resource:RESOURCE[,ID]
294 Embeds to the given resource file.  The optional ID can be used to
295 give a different name to the resource.  If not specified, the resource
296 name will be the file name.
297 .TP
298 .I -linkresource:RESOURCE[,ID]
299 Links to the specified RESOURCE.  The optional ID can be used to give
300 a name to the linked resource.
301 .TP
302 .I -r:ASSEMBLY1[,ASSEMBLY2], \-reference ASSEMBLY1[,ASSEMBLY2]
303 Reference the named assemblies.  Use this to use classes from the named
304 assembly in your program.  The assembly will be loaded from either the
305 system directory where all the assemblies live, or from the path
306 explicitly given with the -L option.
307 .Sp
308 You can also use a semicolon to separate the assemblies instead of a
309 comma. 
310 .TP
311 .I -reference:ALIAS=ASSEMBLY
312 Extern alias reference support for C#.
313 .Sp
314 If you have different assemblies that provide the same types, the
315 extern alias support allows you to provide names that your software
316 can use to tell those appart.    The types from ASSEMBLY will be
317 exposed as ALIAS, then on the C# source code, you need to do:
318 .Sp
319 .nf
320         extern alias ALIAS;
321 .fi
322 To bring it into your namespace.   For example, to cope with two
323 graphics libraries that define "Graphics.Point", one in
324 "OpenGL.dll" and one in "Postscript.dll", you would invoke the
325 compiler like this:
326 .Sp
327 .nf
328         mcs -r:Postscript=Postscript.dll -r:OpenGL=OpenGL.dll
329 .fi
330 .Sp
331 And in your source code, you would write:
332 .Sp
333 .nf
334         extern alias Postscript;
335         extern alias OpenGL;
336
337         class X {
338                 // This is a Graphics.Point from Postscrip.dll
339                 Postscript.Point p = new Postscript.Point ();
340
341                 // This is a Graphics.Point from OpenGL.dll
342                 OpenGL.Point p = new OpenGL.Point ();
343         }
344 .fi
345 .TP
346 .I \-recurse:PATTERN, --recurse PATTERN
347 Does recursive compilation using the specified pattern.  In Unix the
348 shell will perform globbing, so you might want to use it like this:
349 .PP
350 .nf
351                 $ mcs -recurse:'*.cs' 
352 .fi
353 .TP
354 .I \-sdk:VERSION
355 Used to specify the version of Base Class Library assemblies. The possible
356 values are: 2 (default), 4. The version number means which .NET version
357 should the produced assembly be compatible with.
358 .TP
359 .I \-\-shell
360 Starts up the compiler in interactive mode, providing a C# shell for
361 statements and expressions.   A shortcut is to use the
362 .I csharp
363 command directly.
364 .TP
365 .I \-\-stacktrace
366 Generates a stack trace at the time the error is reported, useful for
367 debugging the compiler.
368 .TP
369 .I \-target:KIND, \-t:KIND
370 Used to specify the desired target.  The possible values are: exe
371 (plain executable), winexe (Windows.Forms executable), library
372 (component libraries) and module (partial library).
373 .TP
374 .I \-\-timestamp
375 Another debugging flag.  Used to display the times at various points
376 in the compilation process.
377 .TP
378 .I \-unsafe, -unsafe+
379 Enables compilation of unsafe code.
380 .TP
381 .I \-v 
382 Debugging. Turns on verbose yacc parsing.
383 .TP
384 .I \-\-version
385 Shows the compiler version.
386 .TP
387 .I \-warnaserror, \-warnaserror+
388 All compilers warnings will be reported as errors.
389 .TP
390 .I \-warnaserror:W1,[Wn], -warnaserror+:W1,[Wn]
391 Treats one or more compiler warnings as errors.
392 .TP
393 .I \-warnaserror-:W1,[Wn]
394 Sets one or more compiler warnings to be always threated as warnings.
395 Becomes useful when used together with -warnaserror.
396 .TP
397 .I \-warn:LEVEL
398 Sets the warning level.  0 is the lowest warning level, and 4 is the
399 highest.  The default is 4.
400 .TP
401 .I \-win32res:FILE
402 Specifies a Win32 resource file (.res) to be bundled into the
403 resulting assembly.
404 .TP
405 .I \-win32icon:FILE
406 Attaches the icon specified in FILE on the output into the resulting
407 assembly.
408 .TP
409 .I \-\-
410 Use this to stop option parsing, and allow option-looking parameters
411 to be passed on the command line.
412 .PP
413 .SH PACKAGES AND LIBRARIES
414 When referencing an assembly, if the name of the assembly is a path,
415 the compiler will try to load the assembly specified in the path.   If
416 it does not, then the compiler will try loading the assembly from the
417 current directory, the compiler base directory and if the assembly is
418 not found in any of those places in the directories specified as
419 arguments to the -lib: command argument.
420 .PP
421 Depending on the invocation for the C# compiler (mcs, gmcs, or smcs)
422 you will get a default set of libraries and versions of those
423 libraries that are referenced.
424 .PP
425 The compiler uses the library path to locate libraries, and is able to
426 reference libraries from a particular package if that directory is
427 used.  To simplify the use of packages, the C# compiler includes the
428 -pkg: command line option that is used to load specific collections of
429 libraries. 
430 .PP 
431 Libraries visible to the compiler are stored relative to the
432 installation prefix under PREFIX/lib/mono/ called the PACKAGEBASE and the
433 defaults for mcs, gmcs and smcs are as follows:
434 .TP 
435 .I mcs
436 References the PACKAGEBASE/1.0 directory
437 .TP
438 .I gmcs
439 References the PACKAGEBASE/2.0 directory
440 .TP
441 .I smcs
442 References the PACKAGEBASE/2.1 directory
443 .PP
444 Those are the only runtime profiles that exist.  Although other
445 directories exist (like 3.0 and 3.5) those are not really runtime
446 profiles, they are merely placeholders for extra libraries that build
447 on the 2.0 foundation.
448 .PP
449 Software providers will distribute software that is installed relative
450 to the PACKAGEBASE directory.  This is integrated into the 
451 .I gacutil
452 tool that not only installs public assemblies into the Global Assembly
453 Cache (GAC) but also installs them into the PACKAGEBASE/PKG directory
454 (where PKG is the name passed to the -package flag to gacutil).
455 .PP
456 As a developer, if you want to consume the Gtk# libraries, you would
457 invoke the compiler like this:
458 .nf
459
460         $ mcs -pkg:gtk-sharp-2.0 main.cs
461
462 .fi
463 The -pkg: option instructs the compiler to fetch the definitions for
464 gtk-sharp-2.0 from pkg-config, this is equivalent to passing to the C#
465 compiler the output of:
466 .nf
467
468         $ pkg-config --libs gtk-sharp-2.0
469
470 .fi
471 Usually this merely references the libraries from PACKAGEBASE/PKG.
472 .PP
473 Although there are directory names for 3.0 and 3.5, that does not mean
474 that there are 3.0 and 3.5 compiler editions or profiles.   Those are
475 merely new libraries that must be manually referenced either with the
476 proper -pkg: invocation, or by referencing the libraries directly. 
477 .PP
478 .SH SPECIAL DEFINES
479 The 
480 .B TRACE
481 and
482 .B DEBUG
483 defines have a special meaning to the compiler.
484 .PP
485 By default calls to methods and properties in the
486 System.Diagnostics.Trace class are not generated unless the TRACE
487 symbol is defined (either through a "#define TRACE") in your source
488 code, or by using the
489 .I "--define TRACE"
490 in the command line.
491 .PP
492 By default calls to methods and properties in the
493 System.Diagnostics.Debug class are not generated unless the DEBUG
494 symbol is defined (either through a "#define DEBUG") in your source
495 code, or by using the
496 .I "--define DEBUG"
497 in the command line.
498 .PP
499 Note that the effect of defining TRACE and DEBUG is a global setting,
500 even if they are only defined in a single file.
501 .PP
502 .SH DEBUGGING SUPPORT
503 When using the "-debug" flag, MCS will generate a file with the
504 extension .mdb that contains the debugging information for the
505 generated assembly.  This file is consumed by the Mono debugger (mdb).
506 .SH ENVIRONMENT VARIABLES
507 .TP
508 .I "MCS_COLORS"
509 If this variable is set, it contains a string in the form
510 "foreground,background" that specifies which color to use to display
511 errors on some terminals.  
512 .Sp
513 The background is optional and defaults to your terminal current
514 background.   The possible colors for foreground are:
515 .B black, red, brightred, green, brightgreen, yellow, brightyellow,
516 blue, brightblue, magenta, brightmagenta, cyan, brightcyan, grey,
517 white and brightwhite.
518 .Sp
519 The possible colors for background are: black, red, green, yellow,
520 blue, magenta, cyan, grey and white.
521 .Sp 
522 For example, you could set these variable from your shell:
523 .nf
524         export MCS_COLORS
525         MCS_COLORS=errors=brightwhite,red
526 .fi
527 .Sp
528 You can disable the built-in color scheme by setting this variable to
529 "disable".
530 .SH NOTES
531 During compilation the MCS compiler defines the __MonoCS__ symbol,
532 this can be used by pre-processor instructions to compile Mono C#
533 compiler specific code.   Please note that this symbol is only to test
534 for the compiler, and is not useful to distinguish compilation or
535 deployment platforms.  
536 .SH AUTHORS
537 The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap,
538 Martin Baulig, Marek Safar and Raja Harinath.  The development was
539 funded by Ximian, Novell and Marek Safar.
540 .PP
541 .SH LICENSE
542 The Mono Compiler Suite is released under the terms of the GNU GPL or
543 the MIT X11.  Please read the accompanying `COPYING' file for details.
544 Alternative licensing for the compiler is available from Novell.
545 .PP
546 .SH SEE ALSO
547 csharp(1), mdb(1), mono(1), mopen(1), mint(1), pkg-config(1),sn(1)
548 .PP
549 .SH BUGS
550 To report bugs in the compiler, you must file them on our bug tracking
551 system, at:
552 http://www.mono-project.com/Bugs 
553 .SH MAILING LIST
554 The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
555 .SH MORE INFORMATION
556 The Mono C# compiler was developed by Novell, Inc
557 (http://www.novell.com, http) and is based on the
558 ECMA C# language standard available here:
559 http://www.ecma.ch/ecma1/STAND/ecma-334.htm
560 .PP
561 The home page for the Mono C# compiler is at http://www.mono-project.com/CSharp_Compiler