This post will give you an overview of some of the new and exciting features in Oxygene 5.2 for .NET (also known as Embarcadero Prism XE3) and for Java.
Fix-It, Reloaded. With Oxygene 5, we introduced Fix-It, a revolutionary new IDE-integrated compiler feature that lets the compiler help you fix errors and work more productively. With the all-new Oxygene 5.2, we're taking Fix-It to the next level, with three major new features:
In addition to giving you the ability to fix individual errors or warnings with a single click, 5.2 introduces a new "Fix Them All" button in the Fix-It panel that lets you fix all occurrences of a given problem throughout your project. This is especially helpful if you wrote new code and made the same mistake several times, or — most prominently — if you just turned on "Warn on Case Mismatch" and find your project has literally dozens or hundreds of mismatched identifiers. With a single click, Oxygene 5.2 will go thru your project and fix all of them at once.
But that's not all. We're also introducing a new "Automatically Fix these problems" feature that, for a select number of issues, lets you instruct the compiler to just go ahead and automatically adjust your code to apply the necessary fixes. Once again, this is helpful mostly for smaller but frequently made mistakes, such as missing "var" (as shown below) or a mistyped identifier case. If you enable this option (on a per-message basis, and off by default), the IDE will just automatically take care of correcting these issues for you after the compile finishes. It goes without saying that "Automatically Fix" will only ever be applied to issues that have a single and obvious fix.
The gray marker with the red checkmark indicates where issues have been fixed for you. It will disappear with the next build.
So that's two areas where Fix-It has gotten better and saves you even more time — by letting you fix lots of issues at once, and by automatically fixing trivial issues for you. But we wanted to go one step further.
When we introduced Fix-It last year, we also talked about how the compiler has gotten smarter and tried to "compile on" after errors, if it can discern what your intention was, and can omit extra error messages. For example, you can write:
and the compiler will complain about not knowing "Strnig", but will assume you meant "String" and compile on — not warning you about ToLower(), because it knows that method exists on "String".
So the compiler recognized your mistake and internally corrected it. Wouldn't it be nice if it could just let you run the project too? We've introduced a new project option that allows you to do just that: "Treat Fixable Errors as Warnings". Enabling this option does just what its name implies: If you made a mistake, but the compiler knows what you meant, it will let you successfully build and run your app!
Of course you will still get an error/warning message, and you're encouraged to fix the mistake in your next iteration — but at least you could see your code run without losing the precious 60 seconds to see the compiler fail, have to go back to fix the typo, and press "Start" a second time. We find this is especially useful when you're in a quick "debug/change/test/debug-again" cycle, where having to deal with silly typos can really slow you down.
Gendarme Code Analysis. One of our goals with Oxygene is to help you write better code. Oxygene 5.2 provides deep IDE integration for Gendarme Code Analysis for .NET and Mono projects right inside Visual Studio and your code editor.
Once you enable Code Analysis in your project options, Oxygene will run an additional analysis step over your application on build and provide a wide range of flow analyses, enhanced warnings and detection of "Code Smells" for you.
Code Analysis can warn you about code duplication, non-conformance with style guidelines, bad coding practices and many many other potential problems.
Code Analysis warnings integrate with our "Inline Error" system, showing up as blue warnings right inside your code editor. They can provide Fix-Its, and if you ever want to ignore a particular warning, you can easily ignore it — either for a particular code location or for the entire project — with a single click in the Fix-It Panel.
Language Native Tuples. Oxygene 5.2 also extends the Oxygene language with support for native tuple types for both .NET and Java. Tuples are a new core type in the language, like arrays or sequences, and are designed to hold a set of specific typed objects.
Tuples make it easy to pass around groups of values (for example a String and an Integer), store them in arrays or collections, even return multiple values from function calls.
You can define a tuple variable such as:
var t: tuple of (String, Int32, Boolean);
and you can access individual members of the tuple using the strongly typed [] indexer:
var s := t[0];
var i := t[1];
where each index is strongly typed, i.e. the compiler knows that t[1] is an Int32 type. You can also declare tuple literals using the new () syntax:
t := ('Holla', 23, false);
and even assign tuples back to individual values:
var s: String;
var i: Int32;
(s, i) := MyTupleMethod();
Tuples are available in both editions of Oxygene and on .NET, they are assignment-compatible with the generic Tuple<> class for tuples with 1 to 7 values (and with nested Tuple<>s for tuples with 8 or more values).
Language Enhancements for Java. Oxygene 5.2 for Java gains support for several core Pascal language features that traditionally are not supported on the Java runtime. These include "records" (a.k.a stack-based objects), "var"/"out" parameters and our excellent "future" types. All three of these features now seamlessly "just work", as they always have in Oxygene for .NET.
More Readable Numerical Constants. Sometimes it’s the little things that count, but if you work with large numerical constants a lot, you will be happy to hear that you can now use spaces inside constants to group digits into sets of three or four to make them more readable, such as:
c = 299 792 458;
max32 = $ffff ffff;
Visual Studio 2012. Oxygene 5.2 officially supports the release version of Visual Studio 2012, Microsoft's new flagship IDE. Visual Studio 2012 is now the default and recommended IDE, and for users who do not have a copy of Visual Studio 2012 yet, Oxygene will offer to install the brand new Visual Studio 2012 Shell.
Along with the new IDE, Oxygene gains a range of new capabilities enabled by Visual Studio 2012, such as the new "Preview Tabs" in the editor when selecting files in Solution Explorer, color-coded IDE status when coding, building debugging, and — most importantly — support for creating true Metro applications for Windows 8 and for Windows RT-based ARM tablets such as the upcoming Microsoft Surface, in Visual Studio 2012 Professional or Higher.
Of course Oxygene 5.2 will continue to work in Visual Studio 2010 as well, and will integrate with both IDEs on the same system, if so desired.