-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrequested edits applied to source code when importing existing files #72579
Comments
Based on feedback from the customer, my best guess here is Code Cleanup on Save might be getting applied automatically to files added to a project with Add → Add Existing Item. |
I'm unable to repro locally even with Code Cleanup on Save turned on. |
Hello, |
@sujayvsarma can you supply a repro case? |
@CyrusNajmabadi (Hi again!) Repro steps:
You will notice that the imported instance of Class1.cs is now "changed". The original instance of the file remains untouched. Code that is typically changed in such a way:
will become:
will become:
and so on...
The bug we are talking about will cause this to become:
Until now, in the cases we have come across, the meaning and intent of the statement(s) have not been modified by such changes (which would result in functional bugs). However, it is not inconceivable to wonder if that might happen, in some specific un-approved circumstances and nobody finds about it unless something really bad happens in Prod. |
Closing out. Fixed with #76019 |
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
When adding existing source code files from outside the current solution/project, Visual Studio applies unrequested changes/edits to the imported (new copy) source code. Currently, seems to impact
.cs
files, unsure if other file types are impacted.Examples of such changes/edits include:
if
statements,inline conditions
For example:
if ((a == b) && (! foo()))
will becomeif (a == b && !foo())
Code that is sub-indented (eg: parameters in a signature or function call, object construction, etc) will be re-indented.
While the changes do not cause any bugs or changes in functionality as far as I can tell and it seems to be applying some default "code stylesheet", this is not a "welcome" feature/bug! And it needs to be fixed.
I am setting a severity of 2 to this because this destroys:
(a) Code readability and maintainability
(b) Coding standards at our end
The problem has been around for a while. I am filing this only now because I just had to go through a 1000+ line .cs file to fix the changes!!!
Original Comments
Feedback Bot on 2/18/2024, 00:51 AM:
(private comment, text removed)
Sam Harwell [MSFT] on 2/20/2024, 04:12 PM:
(private comment, text removed)
Sujay V. Sarma on 3/2/2024, 02:36 AM:
(private comment, text removed)
Feedback Bot on 2/27/2024, 11:48 PM:
(private comment, text removed)
Sujay V. Sarma on 3/16/2024, 01:10 AM:
(private comment, text removed)
Feedback Bot on 3/18/2024, 09:06 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: