Skip to content

Commit 681d1f1

Browse files
Start from the end of file since the compilation can now lose track when renaming a symbol before another rename
1 parent 27d2810 commit 681d1f1

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

CodeConverter/Common/SymbolRenamer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public static string GetName(ISymbol m) {
2424
return m.Name;
2525
}
2626

27-
public static async Task<Project> PerformRenamesAsync(Project project, IReadOnlyCollection<(ISymbol Original, string NewName)> symbolsWithNewNames)
27+
public static async Task<Project> PerformRenamesAsync(Project project, IEnumerable<(ISymbol Original, string NewName)> symbolsWithNewNames)
2828
{
2929
var solution = project.Solution;
30-
foreach (var (originalSymbol, newName) in symbolsWithNewNames) {
30+
foreach (var (originalSymbol, newName) in symbolsWithNewNames.OrderByDescending(s => s.Original.DeclaringSyntaxReferences.Select(x => x.Span.End).Max())) {
3131
project = solution.GetProject(project.Id);
3232
var compilation = await project.GetCompilationAsync();
3333
ISymbol currentDeclaration = SymbolFinder.FindSimilarSymbols(originalSymbol, compilation).FirstOrDefault();

CodeConverter/VB/ClashingMemberRenamer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static IEnumerable<IEnumerable<ISymbol>> GetLocalSymbolSets(INamespaceOrT
3737
}
3838

3939
private static IEnumerable<(ISymbol Original, string NewName)> GetUniqueNamesForSymbolSet(IEnumerable<ISymbol> symbols) {
40-
var membersByCaseInsensitiveName = symbols.ToLookup(SymbolRenamer.GetName, m => m, StringComparer.OrdinalIgnoreCase);
40+
var membersByCaseInsensitiveName = symbols.ToLookup(SymbolRenamer.GetName, StringComparer.OrdinalIgnoreCase);
4141
var names = new HashSet<string>(membersByCaseInsensitiveName.Select(ms => ms.Key),
4242
StringComparer.OrdinalIgnoreCase);
4343
var symbolsWithNewNames = membersByCaseInsensitiveName.Where(ms => ms.Count() > 1)

Tests/VB/MemberTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,17 +765,14 @@ Private testField As Integer
765765
766766
Public Property Test As Integer
767767
Get
768-
Dim TEST = 0
769-
Return testField + TEST
768+
Dim lTEST = 0
769+
Return testField + lTEST
770770
End Get
771771
Set(ByVal value As Integer)
772772
testField = value
773773
End Set
774774
End Property
775-
End Class
776-
777-
1 target compilation errors:
778-
BC30290: Local variable cannot have the same name as the function containing it.");
775+
End Class");
779776
}
780777

781778
[Fact]

Tests/VB/SpecialConversionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ Public Custom Event Test As EventHandler
588588
End AddHandler
589589
RemoveHandler(ByVal value As EventHandler)
590590
Dim lTeSt1 As Object = 5
591-
Dim lTesT As Integer = CInt(o)
591+
Dim lTesT = CInt(o)
592592
testField = [Delegate].Remove(testField, value)
593593
End RemoveHandler
594594
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)

0 commit comments

Comments
 (0)