code - Tomato Soup https://www.wholetomato.com/blog Visual Assist Team Blog Wed, 28 Aug 2024 05:32:22 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.5 https://i0.wp.com/www.wholetomato.com/blog/wp-content/uploads/2020/05/cropped-wt-logo.jpg?fit=32%2C32&ssl=1 code - Tomato Soup https://www.wholetomato.com/blog 32 32 227787260 Installing Virtual Machines to use Visual Studio on Mac https://www.wholetomato.com/blog/2024/08/27/installing-virtual-machines-to-use-visual-studio-on-mac/ https://www.wholetomato.com/blog/2024/08/27/installing-virtual-machines-to-use-visual-studio-on-mac/#respond Tue, 27 Aug 2024 14:58:10 +0000 https://www.wholetomato.com/blog/?p=3868 There are many options for IDEs for developers who are working on a Mac; however, there may still be use cases and instances where the available options are insufficient. For example some projects and client...

The post Installing Virtual Machines to use Visual Studio on Mac first appeared on Tomato Soup.

]]>
There are many options for IDEs for developers who are working on a Mac; however, there may still be use cases and instances where the available options are insufficient. For example some projects and client requirements may dictate the use of Microsoft’s Visual Studio (VS)—which is predominantly designed for the Windows OS.

As a workaround for, what most Mac users have done (and is one of Microsoft’s recommendations) is to install a Virtual Machine on ARM Macs to emulate a Windows environment and use Visual Studio from there.

This guide will walk you through the entire process of installing and using Visual Studio on a Mac, with a special mention of a handy productivity plugin you can add to make its performance closer to a natively-installed app.

The Different Visual Studios on Mac

Before you dive right in, here’s something to consider before you install: there are similarly named versions of Visual Studio—and you need to know which one you are looking for.

The first one is the native app “Visual Studio 2022 for Mac” (VS 2022 Mac). The naming scheme is how Visual Studio Code is to Visual Studio—they’re two completely different products that confusingly share a similar name.

The native Visual Studio for Mac is largely based on Xamarin, another cross-platform framework for building native mobile apps on iOS, Android, and Windows. It is primarily used for C# or .NET development. Consequently, Visual Studio for Mac is also used primarily for C# development. 

VS 2022 Mac has been discontinued in favor of “Visual Studio Code” (VSC) for Mac. You can use Microsoft’s VSC with the new C# Dev Kit and related extensions in lieu of VS 2022 Mac. The caveat is that VSC may not be enough for C++ developers, or for C# developers who rely on VS’s frameworks and libraries for their app or program development needs.

Fortunately, if you’re opting for VSC on Mac, it may be good to know that there is less discrepancy between the Windows and Mac versions of VSC—just a few keystroke and shortcut differences. 

To summarize, here are the Visual Studios that you can use on Mac:

  • Visual Studio 2022 for Mac — the Xamarin-like native app
  • Visual Studio Code Mac — the VS text editor but on mac. Almost the same as Windows version
  • Visual Studio Code Windows — the VS text editor
  • Visual Studio Windows — the native Windows version (in our case, installed on a virtual machine)

Of course users can also opt to use alternative IDEs. In this blog, however, we will be teaching you how to install the second option—a virtual machine on your Apple-silicon Mac and installing Visual Studio, the complete Windows version, (VS for Windows on a VM) thereafter.

 

Why you may need Visual Studio for Windows on Mac

The primary reasons to use Visual Studio for Windows on a Mac are the following:

  • Maintain compatibility with Windows-based projects
  • Rely on certain features that are Windows version of Visual Studio-specific
  • developing .NET applications
  • working with Azure
  • or integrating specific third-party tools that are Visual Studio-specific
  • You use a Mac!

Other considerations may be based on developer preferences such as those who like Visual Studio for tasks like debugging complex applications, managing large solutions, or using specialized extensions that are only available on the Windows version.

For game developers using Unity, Xamarin developers building cross-platform mobile apps, or .NET developers focusing on backend and cloud development, using a VM allows you to retain access to the full suite of Visual Studio’s tools. This includes robust debugging features, integrated version control with Git, and comprehensive support for a variety of programming languages and frameworks.

Prerequisites for Installation

Visual Studio 2022 has official requirements which you can read here. However, we can summarize for some advice:

  • It runs on both Intel and ARM computers
  • You will need to install either the Intel or the ARM version of Windows. You can’t run the Intel version of Windows on an ARM Mac, not even in a VM. The ARM version of Windows runs Intel apps just fine, even including using a debugger, in our experience.
  • Dedicate lots of RAM and multiple cores to your VM. We recommend a minimum of 4GB of your host Mac’s RAM goes to the virtual machine. In general, the beefier a machine is in terms of RAM and cores, the more VMs you can run at once.
  • While you can use an old Intel Mac, the Apple Silicon ones are very performant and we strongly recommend using an M-series ARM Mac. Any of them. They’re all good.

If you’ve never used a virtual machine for development before, you might be worried about performance – after all, it’s not running directly on the hardware, right? In practice, this is not an issue. Modern CPUs have inbuilt support for running virtual machines and your VM is not emulated; it runs code directly on the CPU just like the host operating system does.

The biggest mistake people make is not giving a VM enough RAM or dedicated CPU cores. Run on a powerful machine and configure the VM to a couple of cores minimum, and at least 4GB of RAM minimum. If you do heavy computation on the VM (building large projects, etc) increase that. Make sure you have a host machine powerful enough that if you allocate, say, half its resources to the VM then both have enough resources to run. A Macbook Air has 8 cores, so you can allocate 2 to 4 to the VM; if you have 16GB of RAM, you can allocate 4GB to the VM and leave macOS 12GB. This kind of setup works well.

Before diving into the installation process, ensure your Mac meets the following requirements. To summarize, however, any recent computer will meet them in terms of performance—the more important components to consider are available RAM and disk space

Hardware Recommendations:

  • Processor: Modern M-series (Apple Silicon) or Intel processors are more than capable of handling Visual Studio within a VM.
  • RAM: Minimum of 4 GB (16 GB recommended for typical professional solutions).
  • Hard Disk Space: Minimum of 850 MB up to 210 GB of available space, depending on the features installed (20-50 GB of free space is typical). Installing Windows and Visual Studio on a solid-state drive (SSD) is recommended for increased performance.

By following the recommended setup, you’ll meet or exceed the necessary hardware requirements, making your development experience seamless even within a virtualized environment.

Step-by-Step Installation Guide

In this guide, we’ll walk you through installing Visual Studio on your Mac using a virtual machine. Since Visual Studio is no longer natively supported on macOS, setting up a virtual machine (VM) is the best approach to ensure you have access to the full range of Visual Studio features. Below, we’ll outline the steps using Parallels Desktop, a popular VM software for Mac.

Step 1: Choosing Your Virtual Machine Software

Before installing Visual Studio, you need to set up a virtual machine that runs Windows on your Mac. Here are some of the top options currently available:

  • Parallels Desktop: Known for its seamless integration with macOS, Parallels is user-friendly and optimized for running Windows on Apple Silicon (M1/M2) and Intel-based Macs.
  • VMware Fusion: A robust alternative to Parallels, VMware Fusion offers advanced features and supports a wide range of operating systems.
  • VirtualBox: An open-source option that is free to use, though it may require more manual configuration and might not offer the same level of performance as Parallels or VMware Fusion.

For this guide, we’ll focus on Parallels Desktop. This is the officially supported way Microsoft offers to run Windows on a modern ARM Mac.

Step 2: Installing Parallels Desktop

  1. Download Parallels Desktop:
    • Visit the Parallels Desktop website.
    • Click on the “Try Now” or “Buy Now” button, depending on whether you want a trial or full version.
    • The installer file will start downloading.
  2. Install Parallels Desktop:
    • Open the downloaded .dmg file.
    • Drag the Parallels Desktop icon to the Applications folder.
    • Open the Applications folder and double-click the Parallels Desktop icon to launch it.
    • Follow the on-screen instructions to complete the installation. You may need to grant permissions and sign in with a Parallels account.
  3. Set Up a New Windows Virtual Machine.

    • When you first launch Parallels Desktop, it will prompt you to set up a new VM.
    • Choose to install Windows from an ISO image file or from an existing Windows installation disk
    • Parallels may also offer the option to download and install Windows directly, streamlining the process

    • Follow the prompts to complete the Windows installation. This process may take some time as Windows sets up.
  • installing windows on a virtual machine
install confirmation for visual studio on virtual machines

If you’ve done everything correctly, you will get to this confirmation screen.

Step 3: Downloading Visual Studio for Windows

Now that you have Windows running on your Mac via Parallels, you can proceed with installing Visual Studio.

  1. Download Visual Studio:
    • Within your Windows VM, open a web browser and visit the Visual Studio download page.
    • Choose the edition of Visual Studio you want to install (Community, Professional, or Enterprise).
    • Click the “Download” button to start downloading the installer.

      Note: This is open on a browser window inside the VM.

       

  2. Install Visual Studio:
    • Once the download is complete, open the installer file.
    • Follow the on-screen instructions to select your workload preferences (e.g., C++ desktop development, .NET desktop development, ASP.NET and web development, game development with Unity).
    • Click “Install” to begin the installation. This process may take some time, depending on the selected workloads and your internet speed.
    • After installation, launch Visual Studio from the Start menu within your Windows VM.

      visual studio on a mac

Step 4: Setting Up Your First Project

  1. Once Visual Studio is installed, open it and select “New Project.”
  2. Choose the type of project you want to create (e.g., Console App, Web App, Mobile App).
  3. Follow the prompts to configure your project, including setting the project name and location.
  4. Click “Create” to generate your new project.
    Visual Studio open on a virtual machine

Using Visual Studio for Windows on Mac: Navigating the Interface and optimizing the Virtual Machine

When running Visual Studio on a virtual machine (VM) on your Mac, there are some key differences and considerations to keep in mind to ensure a smooth development experience:

Keyboard Shortcuts

Running Visual Studio in a VM can result in some keyboard shortcuts behaving differently than they would on a native Windows PC. This is due to differences in how macOS and Windows handle certain key combinations. Here are a few tips:

  • Cmd vs. Ctrl Mapping: Parallels lets you map macOS shortcuts to their Windows equivalents, enabling the use of familiar macOS commands like Cmd+C for copy and Cmd+V for paste in your Windows VM. This can be configured under Devices & Sound > Keyboard by enabling the “Use macOS shortcuts” option.
  • Function Keys in Parallels: Adjust the behavior of function keys (F1-F12) in Parallels to operate as standard function keys for Visual Studio commands. Access these settings via Parallels Desktop > Preferences > Shortcuts or under Devices & Sound > Keyboard for your VM.
  • Customize Mac System Settings: Alternatively, modify your Mac’s System Preferences > Keyboard by checking “Use F1, F2, etc. keys as standard function keys.” This avoids needing to press the Fn key when using function keys in Visual Studio within a Parallels VM.
  • Customizing Shortcuts in Visual Studio: If certain shortcuts aren’t functioning as expected within the VM, customize your keyboard shortcuts directly in Visual Studio under Tools > Options > Environment > Keyboard.
  • Windows Apps on the Mac Taskbar: Parallels can display Windows apps on the Mac taskbar. If you prefer a cleaner interface, disable this feature in Parallels settings to avoid taskbar clutter.
  • Folder Sharing in Parallels: Parallels shares many folders between your Mac and the VM by default. For increased privacy or security, customize sharing options to limit access to specific folders, such as only sharing your Downloads or a dedicated project folder.
  • System Resource Allocation: Optimize CPU, RAM, and disk space allocation for your VM based on your workload. Proper allocation ensures both your Mac and the VM perform smoothly during demanding tasks like code compilation.

Display and Resolution

When running a VM, Parallels offers different display modes to suit your workflow:

  • Fullscreen Mode: Parallels can run your VM in fullscreen, integrating it seamlessly into your Mac’s desktop environment. You can use macOS Spaces to switch between your VM and other macOS apps effortlessly.
  • Windowed Mode: If you prefer to keep your VM contained, Windowed mode lets you run Windows inside a resizable window on your desktop. This can be useful for quickly accessing other macOS applications without losing sight of your VM.
  • Coherence Mode: This mode allows Windows applications to appear alongside macOS apps on your desktop, blending the two environments. While it looks impressive, it can sometimes cause graphical glitches. In my experience, it’s a neat marketing feature, but not always practical for everyday use. However, some users find it very effective for their needs, so it’s worth experimenting with if you’re curious.

Parallels generally sets up Windows with the correct DPI settings automatically, so display resolution issues are rare. Adjusting these settings usually requires deliberate changes, making it easy to maintain a crisp and consistent interface across your VM and macOS.

Enhancing the Experience with Visual Assist

Developing on a VM can present unique challenges, but with the right setup and a few tweaks, you can create a development environment that’s nearly as effective as working on a native Windows machine. By paying attention to how keyboard shortcuts behave, optimizing performance settings, and ensuring good network connectivity, you can make the most out of Visual Studio in a virtualized environment on your Mac.

Visual Assist, renowned for its powerful productivity features, is now fully supported on ARM devices, including Macs with Apple Silicon (M1, M2, etc). Here’s how to install it:

  1. Initiate the Virtual Machine environment. Launch whatever VM you installed.
  2. Open Visual Studio on your Mac: Launch the Visual Studio application to begin the installation process.
  3. Navigate to Extensions > Manage Extensions: In the top menu, click on “Extensions,” then select “Manage Extensions” from the dropdown. This will open the Extensions Manager window.
  4. Search for “Visual Assist” and click “Install”: In the Extensions Manager, use the search bar to find “Visual Assist.” Once located, click the “Install” button next to the extension. You can also download it straight from the VS marketplace. The installation process will begin automatically.
    Visual assist ARM support
  5. Restart Visual Studio to enable the extension: After installation, restart Visual Studio to activate Visual Assist. Once restarted, you will have access to all the powerful features Visual Assist offers.

Benefits of Visual Assist on ARM Devices

With Visual Assist enabled on ARM devices, Mac users can experience a significant boost in productivity and code quality. Here are some of the key benefits:

  • Full ARM support. Visual Assist added ARM support which includes Mac silicon-based devices. For those using VMs, this is one of the best workarounds to getting a better VS experience.
  • Enhanced Code Navigation: Quickly jump to definitions, references, and symbols within your codebase. This feature allows you to navigate complex projects with ease, reducing the time spent searching for specific code elements and improving overall efficiency.
  • Refactoring Tools: Easily refactor code with powerful tools like Rename, Encapsulate Field, and Extract Method. These tools help maintain clean and organized code by automating common refactoring tasks, making it easier to implement changes and ensure code consistency.
  • Code Assistance: Improved IntelliSense with better suggestions and real-time error checking. Visual Assist enhances IntelliSense by providing more accurate and context-aware code completions, helping you write code faster and with fewer errors. Real-time error checking also helps you catch and fix issues as you code, reducing the likelihood of bugs in your final product.
  • Performance Optimization: Visual Assist is optimized for ARM architecture, ensuring smooth and efficient performance on M1 and M2 Macs. This optimization takes full advantage of the advanced capabilities of Apple Silicon, providing a responsive and lag-free development experience even for large and complex projects.
  • Advanced Code Analysis: Visual Assist includes advanced code analysis tools that help you understand and improve your codebase. These tools identify potential issues, suggest improvements, and provide insights into code complexity and maintainability, enabling you to write high-quality code.
  • Customizable Shortcuts and Commands: Tailor your development environment to your workflow by customizing shortcuts and commands. Visual Assist allows you to configure key bindings and commands to suit your preferences, making it easier to access frequently used features and streamline your coding process.
  • Seamless Integration with Visual Studio: Visual Assist integrates seamlessly with Visual Studio for Mac, providing a cohesive and unified development experience. The extension works alongside other Visual Studio tools and features, enhancing the overall functionality of the IDE without disrupting your workflow.

By leveraging the capabilities of Visual Assist on ARM devices, you can significantly enhance your coding experience on Mac. Whether you’re working on small projects or large-scale applications, Visual Assist provides the tools and features you need to be more productive and write better code.

Conclusion

Congratulations! You have successfully installed Visual Studio on a virtual machine. You should now be able to develop as you would normally on a native Windows device. Tech is always changing and we can assume that with advances in both hardware and software, we will be able to utilize more performance with less in the future—but for now, enjoy your new virtual machine, fit with a fresh install of Visual Studio! Happy coding.

The post Installing Virtual Machines to use Visual Studio on Mac first appeared on Tomato Soup.

]]>
https://www.wholetomato.com/blog/2024/08/27/installing-virtual-machines-to-use-visual-studio-on-mac/feed/ 0 3868
Visual Assist 2024.1 release post https://www.wholetomato.com/blog/2024/01/31/visual-assist-2024-1-release-post/ https://www.wholetomato.com/blog/2024/01/31/visual-assist-2024-1-release-post/#respond Wed, 31 Jan 2024 09:32:52 +0000 https://www.wholetomato.com/blog/?p=3725 The first release of the year is here with Visual Assist 2024.1. This update is headlined by the overhaul of our parser, which significantly reduces users’ initial startup times for projects. Also in this release:...

The post Visual Assist 2024.1 release post first appeared on Tomato Soup.

]]>
The first release of the year is here with Visual Assist 2024.1. This update is headlined by the overhaul of our parser, which significantly reduces users’ initial startup times for projects. Also in this release: key behavioral fixes for a few or VA’s navigation features, a UI update for the ubiquitous dropdown toolbar, and a plethora of bug fixes and QoL improvements.

Download the release now and get the benefits of VA 2024.1.

Significantly faster initial startup time

va initial parse startup speed update

Initial parse time is defined by how long it takes Visual Assist and Visual Studio to become fully active, starting from the moment a new file is loaded up for the first until it fully completes its initial parse (i.e. all features loaded and functional.)

Startup times just got extremely buffed in the first release of Visual Assist this year. The initial project parsing that Visual Assist executes when opening projects for the first time has now been significantly reduced. An example Unreal Engine project, when opened for the first time, used to take 15 minutes; it now takes just under two minutes instead! This is a huge improvement, and you will see this reflected in all projects that are opened and parsed.

More testing is underway to provide a better and more accurate performance number, but the developer team has found excellent results in their tests so far. Reports show a trend of having significantly reduced parse time for a sizable Unreal Engine project—with results averaging up to fifteen times faster initialization.

Update on Initial Parsing Time: More Testing Results

More testing results for Visual Assist’s updated parser are in! Here are the results:

Initial parsing time is defined as the point where the Visual Assist starts parsing up to the end where it completes it. This project used the latest Visual Studio 2022 version as of Feb 10 (VS 2022 17.8.6) on the Lyra sample game project provided by Epic Games. Two performance benchmarks on two different devices were done using the same methodology. 

Device 1  (High-end Desktop PC)

Run 1 Run 2 Run 3 Average
Visual Assist 2024.1 0:01:13 0:01:05 0:01:06 0:01:08
Visual Assist 2023.6 0:11:55 0:11:57 0:12:42 0:12:11

Device 2 (Gaming-class laptop)

Run 1 Run 2 Run 3 Average
Visual Assist 2024.1 0:02:12 0:02:17 0:02:10 0:02:13
Visual Assist 2023.6 0:29:37 0:28:52 0:30:09 0:29:33

Both test runs show very exciting results for the overhauled VA 2024.1 parser over its immediate predecessor VA 2023.6.

The test showed an average 1075% faster parse time using a high-end desktop PC; and 1333.08% faster parse using a powerful albeit relatively less performant gaming laptop. That’s 11 and 13 times faster, respectively. 

There is variance in the advantages gained between the two devices, with a significant performance edge on the less powerful laptop. We suspect the gains could be much larger on low and mid-end computers or laptops.

Curious to see how VA 2024.1 performs on your platform? Download a free trial of Visual Assist and try it for yourself now.

Navigate directly to a class constructor definition from an explicit constructor call

This neat addition to VA’s find reference and go to reference features allows users to find and navigate to a class’s constructor definition from a call to that constructor. 

Highlight or click over a constructor and use the shortcut Alt + G to navigate instantly to the default constructor.

Improved and expanded header selection when using Add Include

This release greatly improves VA’s Add Include detection and expands the number of actual includes supported. 

If you have not used this feature extensively VA can automatically add includes directives for you if it detects you are using an undeclared feature or type from a known library such as STL or even your own code elsewhere. Specifically, this update adds many new types baked into C++ such as std::stringstream and std::once_flag.

In essence, using Add include should automatically insert the correct include under many more circumstances.

Code completion dropdown toolbar now displayed by default 

The coding completion toolbar will now be turned on by default and will be displayed more frequently. This new quality of life change brings a visual UI as you write code. VA tries to predict your intended actions so the options shown will always be contextual apart from being accurate.

Furthermore, when you type code, the code completion UI will be shown by default regardless if you are hovering your cursor over the current portion of the code.

code completion toolbar visual assist

The code completion toolbar is displayed as you type code.

For very large projects and long source code, you can use the filter options (highlighted in the screenshot above) to select which options are shown in the new toolbar.

Bug fixes and improvements

For this release, we have severak fixes—both from examining recent features and user reports. The most notable of these improvements include functional visual changes to a plethora of features and better parser recognition of Unreal code.

  • Fixed visual issues with completion dropdown toolbar
  • Fixed issue where trial activation dialog could display an error and prevent activation
  • Fixed issue with new “Magic Numbers” detecting Code Inspection where it was highlighting only a portion of the constant
  • Fixed issue where logging could overflow and cause a crash when enabled alongside very large solutions
  • Fixed issue where preprocessor directives in shader files were sometimes colored as methods
  • Fixed issue where Unreal Engine Create***Subobject symbols were not recognized by our parser
  • Fixed issue where changing the signature of an Unreal Engine method which requires a *_Validate thunk would result in rewriting the return of the *_Validate thunk to void.
  • Fixed issue where typing a dot the start of the word in a few of our dialogs would result in no hits being displayed

Many thank to those who submitted their suggestions and error reports. Please continue reporting problems you may find along the way. To report bugs, you can send us a message or start a thread on the user forum.
You can also check our download page to update to the latest release manually. Happy coding!

The post Visual Assist 2024.1 release post first appeared on Tomato Soup.

]]>
https://www.wholetomato.com/blog/2024/01/31/visual-assist-2024-1-release-post/feed/ 0 3725
Visual Assist 2023.6 release post https://www.wholetomato.com/blog/2023/11/28/va-2023-6-release/ https://www.wholetomato.com/blog/2023/11/28/va-2023-6-release/#respond Tue, 28 Nov 2023 06:58:29 +0000 https://blog.wholetomato.com/?p=3637 Visual Assist 2023.6 is here and is available to download! This release is filled to the brim with new functionality that improves upon your staple VA features and a new, convenient way to share source...

The post Visual Assist 2023.6 release post first appeared on Tomato Soup.

]]>
Visual Assist 2023.6 is here and is available to download! This release is filled to the brim with new functionality that improves upon your staple VA features and a new, convenient way to share source code with colleagues.

We also have a new code checker, support for two new C++ language features, and small but useful improvements to VA’s behavior. Read on further to get the complete details of the changes and improvements in this release, or download the release right away.

Share source code via email, GitHub, and more.

Starting from VA 2023.6, users can now highlight sections of code from the editor and open the Quick Actions and Refactoring (Shift + Alt + Q) menu, or right-click on the code and select the “Share with team member” option to instantly send code to other developers.

Select and share sections of code by highlighting it and using the Quick Actions
menu (Shift + Alt + Q).

Choose where and how you want to share your code. This new feature can work in conjunction with GitHub Gist and GitLab’s snippets feature, where you can instantly share and upload parts of your source code. You can also send your source code via email for more general-use purposes. 

Improvements to VA’s navigation features

This release provides a number of improvements and additional functionality to VA’s bread and butter navigation features, such as open file in solution and find symbol in solution.

  • Fuzzy search and uppercase search for opening files and searching symbols
    Fuzzy search is a technique used in searches and information retrieval to find approximate matches for a given query, accommodating variations like typos and misspellings. It employs string distance metrics to measure the similarity between strings.

    Visual Assist’s open file in solution and find symbol in solution will now employ this algorithm, so you can expect more results with fewer, less accurate search queries.

    Furthermore, besides fuzzy searching for inexact matches, VA will also match capital letters. If you have a class named MyClassName, searching for “mcn” would find it. It works similarly if you have a global variable named myGlobalVariable and type “mgv”. It is smart enough to count the lowercase “my” as if it were MyGlobalVariable leading to expected results.

    Enable fuzzy search and see smarter search results using approximate string matching.

     

     

  • Select all items in open file in solution (Ctrl + A)
    You can now select and highlight multiple files and open them simultaneously when using open file in solution. The usual shortcut Ctrl + A works.

    Select and open all files with the new select all shortcut.

Improved support for Braced Initialization Lists / Uniform initialization (C++ 11)

2023.6 also improves support for braced initialization of lists and/or uniform initialization. Brace initialization lists and uniform initialization provide a more consistent and flexible way to initialize objects in C++. 

These features  improve code readability and reduce the chances of certain types of errors. Visual Assist’s parser will recognize these lists and highlight and suggest auto corrections within them.

Improved support for constexpr, consteval and constinit  (C++ 20)

These features are related to compile-time evaluation and initialization. They have specific use cases and are used to enforce certain behaviors at compile time. If you haven’t been using these, here’s a quick breakdown:

  • constexpr used to indicate that a function or variable can be evaluated at compile time.
  • consteval a stricter version, ensuring that the function or expression is only evaluated at compile time and cannot be evaluated at runtime.
  • constinit is used to indicate that a variable must be initialized at compile time and, once initialized, its value cannot be changed during the program’s lifetime.

When using these features, Visual Assist will recognize what you are trying to accomplish such as refactoring commands mainly. Refactorings such as Create From Usage will now properly handle these keywords.

New code inspection for detecting “magic-numbers”

This new Clang-based code inspection checks for instances of magic numbers—or numeric literals that are used without any definition—that are advised against by many coding guidelines for readability sake.

Enable code inspections by navigating to Extensions ->> VAssistX ->> Code Inspection ->> Enable code inspections.  This specific code inspection is disabled by default because some users may be intentionally using it and are not interested in “fixing” it.

Then you can either click on detected issues underlined in blue, use the Quick Refactoring Menu (Shift + Alt + Q) while on the highlighted issue, to allow VA to do it for you. In this case, there is no automatic fix so it will prompt you to define a variable with that number as its value and use the variable instead. 

Protip: VA can help do that for you with the introduce variable feature. If you highlight the number, then use the Quick Actions menu and select Introduce Variable it will ask you for a name and pull the number out into a variable for you.

You can read more about the readability-magic-numbers code checker on Clang’s documentation

New move class feature

You can now move entire classes into different files with the new move class feature included in 2023.6. 

For example, if you have a class named MyClass, with its declaration in MyClass.h and its definition in MyClass.cpp, you can move the entire class into a new pair of files, MyClassNew.h and MyClassNew.cpp. 

This is useful if you have a header and source file pair (.h and .cpp) that contain multiple classes and you want to break that up into multiple files.

Bug fixes and improvements

For this release, we have a couple of fixes based on user requests. The most notable of these improvements include a fix for file exclusion instructions using .json configs similar to a previous release, a parser improvement for Unreal Engine 5, and improved auto-detect logic for Unity.

  • Fixed multiple issues with file exclusion logic when reading from “.vscode\settings.json” configs.  
  • Our parser now better understands Unreal Engine 5.0 (specifically that build) types, such as FVector.
  • Fixed Create from Usage behavior when used inside const inline methods. 
  • Fixed coloring of [[fallthrough]] marked enum items. 
  • Attempted to fix rare temporary hang when debugging C# Unity projects.
  • Code Inspections options dialog now displays much more quickly. 
  • Improved Unity engine auto detect logic to reduce false positives.

Thanks to those who submitted their feedback and bug reports. Please continue sending them our way. Send us a message or start a thread on the user forums for bug reports or suggestions.

You can also check our download page to manually update to the latest release. Happy coding!

 

 

The post Visual Assist 2023.6 release post first appeared on Tomato Soup.

]]>
https://www.wholetomato.com/blog/2023/11/28/va-2023-6-release/feed/ 0 3637
Ensuring Code Quality: Why Every C++ Developer Needs Unit Tests https://www.wholetomato.com/blog/2023/10/31/ensuring-code-quality-why-every-c-developer-needs-unit-tests/ https://www.wholetomato.com/blog/2023/10/31/ensuring-code-quality-why-every-c-developer-needs-unit-tests/#respond Tue, 31 Oct 2023 23:09:59 +0000 https://blog.wholetomato.com/?p=3469 Modern programming languages evolve and are continuously refined even further with each new update. During these incremental stages of development, components such as compilers, IDEs, libraries, their units, their components, and tools undergo changes. Furthermore,...

The post Ensuring Code Quality: Why Every C++ Developer Needs Unit Tests first appeared on Tomato Soup.

]]>

Modern programming languages evolve and are continuously refined even further with each new update. During these incremental stages of development, components such as compilers, IDEs, libraries, their units, their components, and tools undergo changes.

Furthermore, there are also rapid changes in operating systems and hardware systems. This means that if you are developing applications professionally, you must test your units or components at the beginning of your main application development to make sure it is compatible with the newly released versions. 

C++ is a very powerful and modern programming language but to keep up with ever changing industry demands, standard language practices and conventions constantly change. Thus, C++ applications need be to be regularly maintained by software developers and engineers.

All these require rapid unit testing to ensure that company and tech requirements are met using better memory management and improved runtime performance of the main application. Let’s learn more about unit testing and how it’s used to maintain source code.

Why do developers need to test C++ Code?

Developers need to test C++ code for various crucial reasons. First and foremost, testing is a fundamental means of detecting and addressing bugs, errors, and issues within the codebase. By running tests, developers can catch problems early in the development process, saving time and resources. Additionally, testing ensures that the software behaves as expected and meets its requirements and specifications. 

It also plays a pivotal role in regression prevention, safeguarding existing functionality as code evolves. Moreover, tests serve as documentation, providing examples of code usage and clarifying its intended behavior, making it easier for developers to understand and work with the code. Testing encourages good coding practices, promoting modularity and maintainability. It facilitates collaboration by allowing multiple developers to work on a project with confidence. 

But more importantly, performance is another aspect that can be tested and memory and CPU usage are really important in C and C++ programming—it’s one of its main strengths. Ensuring the safety of your product and minimizing memory usage is crucial for achieving reliability and usefulness, as it also impacts the performance of your application during runtime. Increased CPU usage can lead to slower operations, making your app lag behind those of your competitors. This will result in higher energy consumption and higher battery usage in mobile applications that are not liked by users. 

However, this performance comes at a cost. C++ is considered to be a little harder than other programming languages because you need to have a solid grasp of how to manage and use memory. Furthermore, C++ can be extended with headers of libraries, units, and components giving it even more complexity. Consequently, diagnosing problems and tracking issues in C++-based applications require more skill and know-how. Launching a version of an application without testing can lead to unwanted outcomes such as the dreaded blue/black windows screen. Failure to properly test code can also lead to random performance drops, higher CPU usage, and unoptimized energy consumption.

For example, using multi-threading development skills on the CPU, GPU, and memory operations is important in programming, but it can give rise to problems in synchronization of multi-threaded operations and accessing data for reading and writing. Thus, multi-threading functions/methods or classes/libraries should be rigorously tested before general availability. In C++, testing multithreaded and parallel-programming application codes requires more professional skills than testing traditional C++ code.

Nowadays most of these problems can be monitored by tools baked into operating systems, which means it is easier to detect issues on runtime. Thus, there should be minimal reasons to publish and use untested applications. C++ developers should test their codes and other codes embedded into the main code.

What is unit testing and why do I need to use it?

Unit testing is a technique for developing and  experimenting with software applications that focuses on individual units or components of a main software application. This process seeks to validate whether each unit or component meets the project requirements.

Generally, unit testing is applied in the early stages of the development process before any of the code is released as an alpha or beta release. Every unit or component needs to be updated based on the requirements  of the operating systems or with the coding  standards and conventions of a language.

Generally, tests do not require technical developer skills, but in some tests, there may be more precise work that can lead to better informative results.  These tests involve computational, multi-tasking applications such as AI applications or other computational engineering applications. These applications are mostly based on C/C++ codes or  are using languages that are related to C++ modules or libs, such as Python, Delphi, etc.

Unit testing is also applied to test different versions of units or components of a software system. Sometimes new versions of units may not fit your requirements or may cause problems during the runtime of your applications. Here are some of the problems:

  • lower performance issues
  • higher memory or CPU usage issues
  • graphical issues
  • crash issues (rare)
  • Random freezes on runtime. 

If there are problems in your main applications, it may be hard to define which unit or component causing this kind of issue. This is why unit testing is important in the early stages of development. Thus, the developer or the dev team determines whether these tested units and/or components are suitable for use or not.

Here are few bad excuses example for not doing unit tests and some tips on how to possibly address them:

Testing our software is too difficult!

  •  try to redesign or refactor
  • try to decouple
  • try TDD which helps ensure a cleaner design

We can’t test now. We are too pressed for time.

  • Technical debt accrues and bugs are more time consuming in the long run
  • prioritize, but make sure you test the most relevant partsHere are few bad excuses example for not doing unit tests and some tips on how to possibly address them.

Unit testing may be applied manually for some specific unit or components or they can be automated for general purposes to test some parts of units. These tests are applied on run-time when the code is changed to ensure that the new code does not break existing functionality.

Unit tests are generally small codes that have a unit or component and are applied to validate possible units of code. This code may be using a function or a method of a class or library. These are tested in isolation from the main software system. Thus, developers may test these units to identify possible problems and they may find a way to fix these problems in the early stage of the development process. This improves the overall quality of the main software application and reduces bugs, and issues in the main software, and reduces the time required for later testing.

Executing basic unit testing

How can I do better unit testing and code maintenance in C++?

When you do unit tests there are many C++ features to help maintain your code. Here are some features included in the Visual Assist C++ productivity plugin that can be used in application development, when testing a unit, or using a unit in the main application:

Visual Assist is one of the definitive plugins that conceptualized and shaped most of the current features you see now in Visual Studio. And to this day it continues to develop user-centric design for maximum productivity and usability.

 

 

 

 

 

 

The post Ensuring Code Quality: Why Every C++ Developer Needs Unit Tests first appeared on Tomato Soup.

]]>
https://www.wholetomato.com/blog/2023/10/31/ensuring-code-quality-why-every-c-developer-needs-unit-tests/feed/ 0 3469