Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
C# is (normally) an order-independent language, in that it doesn't matter what order you declare types within a file, or what order you provide files on the command-line, or what order you reference assemblies.
Created attachment 13532 [details]
Behold! A counter example appears.
Attachment #13532 [details] contains an example wherein changing the order of filenames on the command-line results in success or failure on compiler output:
> $ make works
> mcs /unsafe /t:library /out:works.dll JavaObject.cs JniObjectReference.cs JniReferenceSafeHandle.cs
> JniObjectReference.cs(7,27): warning CS0169: The private field `Java.Interop.JniObjectReference.safeHandle' is never used
> Compilation succeeded - 1 warning(s)
> $ make fails
> mcs /unsafe /t:library /out:fails.dll JniObjectReference.cs JavaObject.cs JniReferenceSafeHandle.cs
> JavaObject.cs(7,35): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type `Java.Interop.JniObjectReference'
> JniObjectReference.cs(5,16): (Location of the symbol related to previous error)
> Compilation failed: 1 error(s), 0 warnings
The difference between the two lines is the relationship between JniObjectReference.cs and JavaObject.cs: if JniObjectReference.cs comes *first*, it fails to compile. If it comes *after*, it succeeds.
Which, mind you, is extremely confusing and I think is the *opposite* of where I first saw this appear!
> $ mcs --version
> Mono C# compiler version 22.214.171.124
Actual behavior: Compiler error or no error depending on the ordering of filenames.
Expected behavior: The compiler should at least be consistent! :-)
Also, the code should fail to compile:
> CSC /unsafe JavaObject.cs JniObjectReference.cs JniReferenceSafeHandle.cs
> Microsoft (R) Visual C# Compiler version 4.0.30319.34209 for Microsoft (R) .NET Framework 4.5
> Copyright (C) Microsoft Corporation. All rights reserved.
> JavaObject.cs(7,59): error CS0208: Cannot take the address of, get the size of,
> or declare a pointer to a managed type
> JniObjectReference.cs(5,16): (Location of symbol related to previous error)
Fixed in master/6262c487d38ce3575ebe8f6425e63dfceb3adf96