diff --git a/src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb b/src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb index b83fbc572ea950fb67be6c82e41a04ca2b293047..9bac38c62068f4e76407b0085d7fd22574c8c41f 100644 --- a/src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb +++ b/src/EditorFeatures/Test2/Rename/RenameEngineTests.CSharpConflicts.vb @@ -3344,5 +3344,72 @@ class {|conflict:C$$|} { } result.AssertLabeledSpansAre("conflict", renameTo, RelatedLocationType.UnresolvedConflict) End Using End Sub + + + + + Public Sub DeclarationConflictInFileWithoutReferences_SameProject() + Using result = RenameEngineResult.Create( + + + +class Program +{ + internal void [|A$$|]() { } + internal void {|conflict:B|}() { } +} + + +class Program2 +{ + void M() + { + Program p = null; + p.{|conflict:A|}(); + p.{|conflict:B|}(); + } +} + + + , renameTo:="B") + + result.AssertLabeledSpansAre("conflict", "B", RelatedLocationType.UnresolvedConflict) + End Using + End Sub + + + + + Public Sub DeclarationConflictInFileWithoutReferences_DifferentProjects() + Using result = RenameEngineResult.Create( + + + +public class Program +{ + public void [|A$$|]() { } + public void {|conflict:B|}() { } +} + + + + CSAssembly1 + +class Program2 +{ + void M() + { + Program p = null; + p.{|conflict:A|}(); + p.{|conflict:B|}(); + } +} + + + , renameTo:="B") + + result.AssertLabeledSpansAre("conflict", "B", RelatedLocationType.UnresolvedConflict) + End Using + End Sub End Class End Namespace diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index 6d78a8ce423fa5378928a7130453a16fea0ad12e..7809c891462878813a0c4e3ffca139742f676336 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -170,6 +170,14 @@ public async Task ResolveConflictsAsync() // Note that we need to get the conflictLocations here since we're going to remove some locations below if phase == 2 documentIdsThatGetsAnnotatedAndRenamed = new HashSet(_conflictLocations.Select(l => l.DocumentId)); + // Include the declaration document if we are processing its project to + // ensure declaration conflicts are calculated correctly when the + // declaration document does not contain any references. + if (documentsByProject.Key == _documentIdOfRenameSymbolDeclaration.ProjectId) + { + documentIdsThatGetsAnnotatedAndRenamed.Add(_documentIdOfRenameSymbolDeclaration); + } + if (phase == 2) { // After phase 2, if there are still conflicts then remove the conflict locations from being expanded