Bug 9571 - CS1654 not reported when struct comes from referenced assembly
Summary: CS1654 not reported when struct comes from referenced assembly
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-01-15 10:59 UTC by Paul Johnson
Modified: 2014-01-15 14:46 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Paul Johnson 2013-01-15 10:59:49 UTC
Using the code in BZ #8746

This code builds fine on the Mac using Mono 2.10.9

Under VS2010, LoLCommon/Extensions.cs fails to compile (public static RectangleF Rotate (this RectangleF owner, double degAngle) - the two lines eachCorner.X and eachCorner.Y throw an error due to a problem with a foreach. I don't know if this is a Windows or Mac issue)

Not tested it targetting Mono
Comment 1 Jonathan Pryor 2014-01-14 17:24:51 UTC
This is an mcs compiler bug: CS1654 is not properly reported when the type comes from a referenced assembly:

$ cat > bxc9571.cs <<EOF
  using System;
  using System.Collections.Generic;
  using System.Drawing;
  class Test {
    public static void Main ()
      List<PointF> rectCorners = new List<PointF> ();

      foreach (PointF eachCorner in rectCorners) {
        eachCorner.X *= 2;
        eachCorner.Y *= 2;
$ mcs bxc9571.cs

Expected behavior:

> bxc9571.cs(13,5): error CS1654: Cannot modify members of 'eachCorner' because it is a 'foreach iteration variable'
> bxc9571.cs(14,5): error CS1654: Cannot modify members of 'eachCorner' because it is a 'foreach iteration variable'

Actual behavior: it compiles.
Comment 2 Jonathan Pryor 2014-01-14 17:25:31 UTC
Doh; the compile line is wrong. It should be:

$ mcs bxc9571.cs -r:System.Drawing.dll
Comment 3 Marek Safar 2014-01-15 14:46:49 UTC
Fixed in master