XamarinCommunityToolkit: [Bug] VS2019 Syntax/Code Highlighting for Custom Types (since v1.3.2)

Description

Since upgrading our NuGet packages over the years all our team member have the same issue: Sometimes our Visual Studio Code/Syntax highlighting isn’t working. I’ve finally managed to reproduce this and track down what causes this: The NuGet package Xamarin.CommunityToolkit.

If I create a completely new (console) application everything works fine. I add a custom type and see that type highlighted (green for me) when I instantiate a variable/property with that type. See the image, in this case a custom enum (which is defined in CustomEnum.cs next to Program.cs). image

But, as seen in the next image, as soon as I add NuGet package Xamarin.CommunityToolkit, the “CustomEnum” isn’t green anymore. image

If I remove the NuGet package, it works again.

Please note that “sometimes” it works for a short time. Then, all custom types have colour. But this colour is gone after “some” time, especially when scrolling.

This is just an example. We noticed this behaviour in our real Xamarin.Forms 5.0 application with Xamarin.CommunityToolkit and many other NuGet packages used. But, this is only the case for Xamarin.CommunityToolkit (if I remove all other packages, it still is not green and if I only remove Xamarin.CommunityToolkit it works).

I can not reproduce this in VS2022 but we need to be able to use VS2019. I’ve tested different versions:

  • 1.3.0 -> It works, enum type is green.
  • 1.3.1 -> It works, enum type is green.
  • 1.3.2 -> It doesn’t work, enum type is white (wrong).
  • 2.0.0 -> It doesn’t work, enum type is white (wrong).

Systems used:

  • BAD: Windows 10 20H2, Visual Studio 2019 16.11.10, No Extensions enabled
  • OK: Windows 10 20H2, Visual Studio 2022 17.1.0 Preview 3.0, No Extensions enabled

Steps to Reproduce

  1. Create a new (console, .NET5) application.
  2. Add a custom enum (CustomEnum).
  3. Add a property to the Program class that has the type of the added custom enum (CustomEnum).
  4. Add NuGetPackage Xamarin.CommunityToolkit v2.0.0.

Expected Behavior

The code/syntax highlighting must be correct for the type of the added property in Pogram.cs. It should be “green” (for dark mode, depending on colour settings).

Actual Behavior

The code/syntax highlighting isn’t correct for the type of the added property in Program.cs. It’s white/default coloured (for dark mode, depending on colour settings).

Basic Information

  • Version with issue: 1.3.2, 2.0.0
  • Last known good version: 1.3.1
  • IDE: Visual Studio 2019 16.11.10
  • Platform Target Frameworks: (None, Design-Time only)
  • Nuget Packages: Xamarin.CommunityToolkit
  • Affected Devices: Windows (Design-Time only)

Workaround

Only use Xamarin.CommunityToolkit <= v1.3.1 or use Visual Studio 2022.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 18 (6 by maintainers)

Most upvoted comments

It seems that it might be related to installing this toolkit package through the NuGet Package manager and having the preview version of MAUI installed, as that was my setup.

I’m in the process of getting a new SSD installed on my machine, and once I get Visual Studio re-installed, I will check the project I’m working with to see if the issue is still present.

Youi are right, I though I had broken some configuration when syntax highlighting worked differently between two of my projects. Downgrading XCT to 1.3.1 helped. Thank you!