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
Developer Community or GitHub 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.
I have a primary constructor that takes an instance of a type X, and a secondary constructor that takes an instance of type Y : X. The secondary constructor calls the primary constructor using this(x as X), which is flagged as an 'unnecessary cast' warning. However, if you remove the cast, you get a 'constructor cannot call itself' error.
I have check this issue on following builds
Mac OS X 10.7.5
Xamarin Studio: 4.2.4 (build 266)
I observed that when I build the following code, it doesn't flag any "unnecessary cast" warning.
public static void Main (string args)
Console.WriteLine ("Hello World!");
//Test objTest = new Test ("Test");
public Test(object o)
public Test(string o): this (o as object )
I also observed that, if I remove the cast, I got a "constructor cannot call itself" error.
ex : public Test(string o): this (o )
Please let me know if missing anything?