Creating Types with Generate from Usage
One great feature in the code editor that Visual Studio 2015 inherits from its predecessors is the ability to generate on-the-fly objects that do not exist yet. This feature is known as Generate from Usage, and now it is integrated within light bulbs and quick actions, described in Chapter 6, “Errors, Exceptions, and Code Refactoring.” To understand how it works, create a new Console application named GenerateFromUsage and, within the Main
method, type the following code:
Sub Main() Dim p As New PersonEnd Sub
Because the Person
class has not been implemented, the Visual Basic compiler throws an exception, but if you enable the light bulb, it will suggest possible solutions, as shown in Figure 17.11 ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.