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.
To save the JITter some time, it'd be nice if the compiler could transform Console.WriteLine ("foo".Length); into Console.WriteLine (3);. Currently, the IL produced does a ldstr followed by a callvirt to get_Length().
This cannot be done by compiler because people are running they own mscorlib with they own string implementation.
Wait, what kind of argument is that? What are the chances anyones will ever replace string.Length with an implementation that behaves differently?
I saw 2 different mscorlib(s) with custom string, novell bugzilla should still have it somewhere in backlog
I'm not disputing that there might be custom string implementations, but how likely is it that their .Length would behave differently for string constants in C# source? Is that edge case (which may never happen) really important enough to prevent this optimization?
It's as likely as this optimisation will have any effect. If you really need this optimisation it should be done at JIT/AOT level (it could be done already I didn't check) before doing this in all compilers. Just for C# you have normal C#, expressions trees, dynamic emitter + .net csc and I could continue with F# etc