[Bug] VS2019 Syntax/Code Highlighting for Custom Types (since v1.3.2) #1815
Description
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).
But, as seen in the next image, as soon as I add NuGet package Xamarin.CommunityToolkit, the "CustomEnum" isn't green anymore.
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
- Create a new (console, .NET5) application.
- Add a custom enum (CustomEnum).
- Add a property to the Program class that has the type of the added custom enum (CustomEnum).
- 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.