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.
Have been using MD on Windows for the past 6 months, which uses csc.
Compiling the same source code under Linux keeps throwing up bogus CS0219 warnings for assignments that have side effects, where csc does not.
This bug appears to have been reported (it's on old mailing lists on the net) but doesn't seem to be an open bug here.
var links = obj.Links;
where Links is a property of obj that is lazily initialised, will cause that property to be initialised, even if the local variable links is never used. There does not appear to be any simple and clean way to cause this behaviour without an assignment. (You can't just leave out the assignment.)
Following old discussions of this, the CS0219 warning should only be issued where the assignment is to something that the compiler knows has no side effects (e.g. assigning a constant). If the assignment has side effects, it is valid and should not be warned about.
I know it's possible to ignore the warning or turn off this warning or drop the warning level down to avoid it (or, even worse, build a whole lot of code to trigger the lazy initialisation of the property), but it would be better to simply make dmcs compatible with csc.
john@john-laptop:~$ dmcs --version
Mono C# compiler version 184.108.40.206
Fixed in master.
Thank you, sir!