Visual Studio 2019 for Mac version 8.7 is now available

Jon Galloway

Jon

Visual Studio 2019 for Mac version 8.7 is available today and includes support for gRPC / OpenAPI client generation and improved unit testing integration. Additionally, it includes several improvements for Xamarin developers, including Xamarin.Forms 4.8 Support. This release also includes initial support for macOS Big Sur, with the exception of Xamarin support. macOS Big Sur support for Xamarin is expected in one of the first servicing releases for Visual Studio for Mac 8.7.

Are you ready for the latest version of Visual Studio 2019 for Mac? If so, version 8.7 is available for you to download today! With this release, we’ve continued to polish the existing experience, paying close attention to many of the problem areas mentioned by our users.

gRPC and OpenAPI Client Generation

Visual Studio for Mac now includes support for generating an API client from an OpenAPI or gRPC service. This allows you to generate the client from a local file or URL, manage service references, and regenerate the client code if the service changes.

To add a new reference to an OpenAPI or gRPC service, right-click on the Connected Services node in the Solution pad and select Open Service Gallery.

Visual Studio for Mac screenshot showing the new Connected Services node in the Solution Pad

Once you’ve opened the Connected Services Gallery, you have the option to add either an OpenAPI or gRPC reference.

Screenshot showing the Connected Services Gallery in Visual Studio for Mac

Clicking on either of the options will launch a prompt allowing you to enter the service reference, either by file path or URL.

You can also select whether to generate the following client class types when generating a gRPC client:

  • Client
  • Server
  • Client and Server
  • Messages Only (used to generate strongly typed classes based on message properties, with no generated server or client code)

When generating an OpenAPI client, you can specify the namespace and additional options which are passed through to the code generator. Code generation is based on the dotnet-grpc and dotnet-openapi command-line tools.

After generating a service reference, you can view and modify it in the Connected Services Gallery as shown below.

Screenshot showing an added gRPC service in the Connected Services Gallery

For more information on using a generated OpenAPI client, see the Getting Started with NSwag tutorial.

For more information on using a generated gRPC client, see the Create a gRPC client and server in ASP.NET Core tutorial.

Right-Click to Run Unit Tests

When editing a C# class that contains unit tests, a developer can run tests using the “Run Test(s)” item in a context menu by right clicking in the file, the body of a test class, or the body of a test method. The context menu for the editor has been updated to include Run/Debug Test options:

Screenshot of Visual Studio for Mac showing the Run Tests and Debug Tests options in the code editor context menu

These new commands can be run using the following keyboard shortcuts (in the Visual Studio for Mac key bindings):

  • Run Test(s): ⌘T
  • Debug Test(s): ⌘⌥T

The Run command will run tests based on the rules below, in the “Rules for determining which tests to run” section. Running a test is the same as selecting it in the Unit Test pad and running that test.

The Debug command will run tests the same as described above but will also attach the debugger when running the tests. You can customize these key bindings in the Visual Studio for Mac preferences (Visual Studio > Preferences > Environment > Key Bindings) as explained in the documentation.

Rules for determining which tests to run

The Run/Debug Test(s) commands will run one or more tests, based on the following rules.

  • Run all tests in a file by right-clicking in the body of a file with test methods, and choose Run Tests.
  • Run a single test by right-clicking in a test method, or on the method signature, and choose Run Test.
  • Run all tests in a single class by right clicking in the body of a class definition, or the method signature, and choose Run Tests.

As an example, using the code below…

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GardenTracker.Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
        }

        [TestMethod]
        public void TestMethod2()
        {
            Assert.IsTrue(true);
        }
    }

    [TestClass]
    public class UnitTest2
    {
        [TestMethod]
        public void TestMethod3()
        {
            Assert.IsTrue(true);
        }
    }
}

Here’s what happens when you right-click in different places:

  • When you right-click inside a test method (e.g. inside TestMethod1()), just that test is executed.
  • When you right-click inside a test class but not in a specific test method (e.g. directly on the UnitTest1 class), all tests in that class are executed.
  • When you right-click outside of a class, all tests in that file are executed.

Right-click in the solution pad to run tests

From the solution pad, a .cs file can be right-clicked and Run/Debug Tests commands used to run or debug all the tests in the file.

Screenshot showing the Run Tests and Debug Tests options when right-clicking on a test class in the Solution Pad

Configuring Keybindings

Screenshot showing Key Bindings configuration in Visual Studio for Mac

When customizing the keyboard shortcuts for the new test commands, the description field reads as follows:

CommandDescription
Debug Test(s)Debug tests based on where your cursor is in the code editor.
Run Test(s)Run tests based on where your cursor is in the code editor.

 

Smarter integration with Unity

This release includes more Unity-specific diagnostics to help you catch problematic code sooner. We’ve added these new diagnostics which also include suggested code fixes that you can apply automatically:

  • Detect incorrect method signature with InitializeOnLoadMethod or RuntimeInitializeOnLoadMethod attribute.
  • Using Invoke, InvokeRepeating, StartCoroutine or StopCoroutine with a first argument being a string literal is not type safe.
  • SetPixels invocation is slow.

If you have an idea for how Visual Studio for Mac can provide even better diagnostic best practices and suggestions for Unity projects, visit our open source project on GitHub and make a suggestion.

Xamarin Forms 4.8

This release of Visual Studio for Mac includes additional support for Xamarin Forms 4.8. This update to Xamarin.Forms is primarily focused on stabilizing current features, moving experimental features to stable, and delivering Gradient Brush support.

Here’s a quick walkthrough showing how you can try out the new Gradient Brush:

  1. First, update the Xamarin.Forms NuGet packages in your solution to version 4.8.
  2. Brushes are an experimental preview. First add the flag to your App.xaml.cs at the top of the constructor:
    Device.SetFlags(new string[]{ "Brush_Experimental" });
  3. You can now apply a GradientBrush using the new Background property of any Page, Layout, or View:
<StackLayout Orientation="Vertical" Padding="30,24,30,24" Spacing="10">
    <StackLayout.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="#59CEFF" Offset="0.0" />
            <GradientStop Color="#FB6EEE" Offset="1.0" />
        </LinearGradientBrush>
    </StackLayout.Background>
</StackLayout>

Visual Studio for Mac screenshot showing the Xamarin Forms 4.8 Gradient Brush editing experience

Quick Actions and Refactorings

Visual Studio for Mac 8.7 introduces several useful new actions to Quick Actions and Refactorings:

  • Generate comparison operators for types that implement IComparable
  • Generate IEquatable operators when generating .Equals for structs
  • Create and initialize properties or fields for all unused constructor parameters
  • IntelliSense completion in DateTime and TimeSpan string literals
  • Warning and code fix when a suppression operator is present but has no effect
  • Generate properties when generating a constructor in a type

While these are all handy, I especially like the IntelliSense completions for DateTime and TimeSpan string literals:

Screenshot of Visual Studio for Mac showing IntelliSense completion for DateTime literals

Keep sending us your feedback!

We’ve been working hard to address issues our users encounter in Visual Studio for Mac in their average day. As part of our efforts on improving the overall experience, we’ve released a handful of new changes that address some of the top reported issues, with highest priority given to unhealthy (crashing and hanging) sessions. Your bug reports are very important to us as we continue to improve the product – please keep those suggestions and problem reports coming!

Update to the latest today

We hope you enjoy Visual Studio 2019 for Mac 8.7 as much as we enjoyed working on it. To update to this version, you can download the installer from the Visual Studio for Mac website or use the in-product updater to update an existing installation.

If you have any feedback on this, or any version of Visual Studio for Mac, please leave it in the comments below this post or reach out to us on Twitter at @VisualStudioMac. If you run into any issues while using Visual Studio for Mac, you can use Report a Problem to notify the team. In addition to reports on issues in the product, we’d also appreciate hearing from you on what’s important to you via feature suggestions on the Visual Studio Developer Community website.

3 comments

Leave a comment