Skip to content

Fix generation location when generating across files#61599

Merged
CyrusNajmabadi merged 3 commits intodotnet:mainfrom
CyrusNajmabadi:genMethodAcrossFiles
May 31, 2022
Merged

Fix generation location when generating across files#61599
CyrusNajmabadi merged 3 commits intodotnet:mainfrom
CyrusNajmabadi:genMethodAcrossFiles

Conversation

@CyrusNajmabadi
Copy link
Contributor

Fixes #61542

@ghost ghost added the Area-IDE label May 31, 2022
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review May 31, 2022 16:20
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 31, 2022 16:20
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.GenerateMethod
Imports Microsoft.CodeAnalysis.Diagnostics

Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.GenerateMethod
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted these all out into their own file since they were in a nested type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no other changes here.

// Try to strictly obey the before option by inserting immediately before the member containing the location
if (info.Context.BeforeThisLocation != null)
if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
beforeSourceTree == declarationList.FirstOrDefault()?.SyntaxTree)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are the fixes. the issue was that we were using the location the user was at in the document they started in to try to pick a location to generate into in the destination document.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any tests that show the before insertion case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. in all the "beforeThisLOcation" cases the feature is using the same syntax tree that they're currently in.

@CyrusNajmabadi CyrusNajmabadi force-pushed the genMethodAcrossFiles branch from 0ef8e3a to c01f5cc Compare May 31, 2022 16:27
@CyrusNajmabadi CyrusNajmabadi enabled auto-merge May 31, 2022 19:10
@CyrusNajmabadi CyrusNajmabadi merged commit 785315f into dotnet:main May 31, 2022
@ghost ghost added this to the Next milestone May 31, 2022
@Cosifne Cosifne modified the milestones: Next, 17.3 P2 May 31, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the genMethodAcrossFiles branch June 1, 2022 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Position of new class method which is created outside of the class via VS-proposals seems to be arbitrary

4 participants