dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.71k stars 3.98k forks source link

C# Code Style setting "Qualify field access with 'this'" still not remembered / being reset #49473

Open vsfeedback opened 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] This issue plays for a long time now and has been posted by multiple people, but it is still not fixed in 16.8. Continuesly all of these posts get closed as duplicates and no real action seems to have been taken so far.

Please Microsoft solve it, because it leads to also incorrect .editorconfig exports, so that the settings are also not usable as a nice template for new exports.

I have added a recording of actions hopfully that these provide more info.

Main problem is after changing any other settings here, I also have to check this first setting over again.

Thank you very much.


Original Comments

Feedback Bot on 11/13/2020, 09:56 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

sharwell commented 3 years ago

Steps to reproduce

  1. Open Tools → Options...
  2. Navigate to Text Editor → C# → Code Style → General
  3. Set the severity of Qualify field access with 'this' to Suggestion
  4. Click OK
  5. Open Tools → Options...
  6. Click OK
  7. Open Tools → Options...

Expected behavior

The setting from step (3) is maintained.

Actual behavior

The setting has been reset to Refactoring Only.

Additional notes

The bug does not occur after step 5. It only occurs after the dialog is opened a second time.

mmarinchenko commented 2 years ago

I've just installed VS 2022 and this bug is still there... It is also reproduced on the [Visual]Basic page, not only on the C# one.

sjb-sjb commented 2 years ago

Still there in VS 2022 v 17.1.1. Seems like the kind of thing that should be pretty easy to fix !!

CyrusNajmabadi commented 2 years ago

@sjb-sjb this is in the backlog, so we're prioritizing more critical issues ahead of it.

Seems like the kind of thing that should be pretty easy to fix !!

We'd definitely take a community pr to fix this if you were interested!

sjb-sjb commented 2 years ago

If you can tell me approximately which piece of code to take a look at then I’ll take a look.

CyrusNajmabadi commented 2 years ago

I can see that this is where we retrieve the option to populate the UI wth: https://github.com/dotnet/roslyn/blob/28745474ba00975c11c86d98e80d35cc69c03ac1/src/VisualStudio/Core/Def/EditorConfigSettings/DataProvider/CodeStyle/CommonCodeStyleSettingsProvider.cs#L56

So maybe somewhere around there? Thanks!

sjb-sjb commented 2 years ago

I browse around a bit but didn’t see anything obvious. To me it feels more like a failure to write out the correct value than a problem reading it in. However I couldn’t find where the values are written to file. If you have any tips on that I would be interested.

mmarinchenko commented 9 months ago

Some additional info about the repro steps.

1. When the qualification options are changed for the first time, we can generate .editorconfig with them right from the options page. And we will see that changed severity has been successfully generated:

dotnet_style_qualification_for_field = false:suggestion

2. Then we can click "OK" button, close Visual Studio and check the .vssettings file in text editor. We will see that changed severity has been successfully persisted:

<PropertyValue name="Style_QualifyFieldAccess">&lt;CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Info" /&gt;</PropertyValue>

3. Now, if we launch Visual Studio and open the options page again, we will find that persisted severity has been successfully initialized. Everything looks good, but if we generate .editorconfig, we will see that severity has gone:

dotnet_style_qualification_for_field = false

Even before we closed the options page.