Skip to content
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

Move the 'application/validation/resolution' portion of rename OOP. #43592

Merged
merged 25 commits into from
Apr 25, 2020

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Apr 23, 2020

Followup to #43554 and #43573. Those should go in first before reviewing.

Rename is composed of two parts. The first finds the all the places to rename (and only needs to run once). The second checks for conflicts at all those locations whenever the user updates the name (so it may run many times). This PR moves the second part of this out of process.

This also moved encapsulate-field OOP.

This can be reviewed one commit at a time.

@CyrusNajmabadi
Copy link
Member Author

@dpoeschl @ryzngard This is ready for review.

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

Done with pass. Some cleanup work that can be done after if needed.


private TestParameters GetRemoteHostOptions(TestHost host)
{
return new TestParameters(options: Option(RemoteHostOptions.RemoteHostTest, host != TestHost.InProcess));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Why do we use a != instead of == TestHost.OutOfProcess here? Just a little harder to parse the negative when reading

Copy link
Member Author

Choose a reason for hiding this comment

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

good question. The basic reason (copied from elsewhere) is that this means if we add more out-of-proc options (which happens in some case) then all of them will run OOP since they're not the .InProcess value.

@@ -43,8 +44,7 @@ public async Task<IInlineRenameReplacementInfo> GetReplacementsAsync(string repl
var conflicts = await _renameLocationSet.ResolveConflictsAsync(
_renameInfo.GetFinalSymbolName(replacementText), nonConflictSymbols: null, cancellationToken: cancellationToken).ConfigureAwait(false);

if (conflicts.ErrorMessage != null)
throw new ArgumentException(conflicts.ErrorMessage);
Contract.ThrowIfTrue(conflicts.ErrorMessage != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add Contract.ThrowIfNotNull?

Copy link
Member Author

Choose a reason for hiding this comment

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

i thought about it.. but it didn't really seem important/common enough to warrant it :)


internal static class RemoteUtilities
{
public static async Task<DocumentTextChanges> GetDocumentTextChangesAsync(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these unique to remote work?

Copy link
Member Author

Choose a reason for hiding this comment

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

because normally we can just pass around solutions when in the same process. But for remote/oop we want to be able to say "here's the solution result of this operation" and we do that by passing along hte text changes necessary to convert the original solutoin to the same one that the OOP side see.s

return builder.ToImmutable();
}

public static async Task<Solution> UpdateSolutionAsync(
Copy link
Contributor

Choose a reason for hiding this comment

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

When would you use this over something like UpdateSolutionIfPossible from the remote workspace? http://sourceroslyn.io/#Microsoft.CodeAnalysis.Remote.Workspaces/Services/RemoteWorkspace.cs,115

Copy link
Member Author

Choose a reason for hiding this comment

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

so, UpdateSolutionIfPossible is for updating the Remote workspaces's .CurrentSolution to match what is on the host side.

In the case here we don't want to actually update any workspaces. this is just allowing certain operations (which result in a new solutoin snapshot) to be able to do that in an OOP context.

public DocumentId[] DocumentIds;
public SerializableRelatedLocation[] RelatedLocations;
public ImmutableArray<(DocumentId, ImmutableArray<TextChange>)> DocumentTextChanges;
public (DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>)[] DocumentToModifiedSpansMap;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there no serializable map type we can use? What's the benefit of array of tuples here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there no serializable map type we can use?

There is not unfortunately. That's because this all goes through JSON. And json can only represent maps using strings (and DocIds are not rountrippable to a simple string). So this is effectively just serializing out all the key/values to tuples since that is something that can go through json.

…eFieldService.cs

Co-Authored-By: Andrew Hall <ryzngard@live.com>
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@CyrusNajmabadi CyrusNajmabadi merged commit 7e1880d into dotnet:master Apr 25, 2020
@ghost ghost added this to the Next milestone Apr 25, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the renameOOP6 branch April 25, 2020 05:12
@sharwell sharwell modified the milestones: Next, temp, 16.7.P1 Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants