C# editor changing font size on some variables

Anonymous
2024-11-12T14:18:17.2133333+00:00

Hi

Microsoft Visual Studio Community 2022

Version 17.12.0 Preview 5.0

VisualStudio.17.Preview/17.12.0-pre.5.0+35424.110

Microsoft .NET Framework

Version 4.8.09032

I have several occurrences of a strange thing in the VS code Editor, C# Project.

The editor is changing the font sizes of some variables in my code, I believe it happens after accepting one or another of the pop up error correction suggestions. These items which have been changed, in the editor, are no longer selectable - any mouse click on them is just ignored. Not ALL accepted error corrections are like this.

Please see short video at HERE. In the video, all I doo is to attempt to select any part of the List<string> in the editor and then paste into an empty line below - as can be seen, it is neither selectable, and is ignored on the Copy attempt.

https://1drv.ms/v/s!AgEpHyV3DNo7g5tjIQ80m3t71AfeBA?e=IuzVuO

Any one shed light on this?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,101 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiale Xue - MSFT 47,581 Reputation points Microsoft Vendor
    2024-11-13T02:04:06.4466667+00:00

    Hi @Anonymous , Welcome to Microsoft Q&A,

    Updated:

    Maybe during programming, it will suggest you change the type declaration to var and give a message about it.

    You can use a #pragma to circumvent these warnings.


    You seem to have misunderstood the type you want to copy, it is the type of your variable that VS automatically infers.

    It is just a reminder for you, it is not selectable.

    If you don't like it, you can disable it in the settings.

    When you use the var keyword in your code (such as var myVariable = 10;), Visual Studio will automatically infer the type of myVariable to be int.

    1. Go to Tools > Options.
    2. Under Text Editor > C# > Code Style > General, you can find the relevant options for using var.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.