Skip to content

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jun 13, 2025

Fixes #34707

@@ -58,7 +54,4 @@ public CSharpSyncNamespaceCodeRefactoringProvider()

return null;
}

protected override string EscapeIdentifier(string identifier)
=> identifier.EscapeIdentifier();
Copy link
Member Author

Choose a reason for hiding this comment

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

unused.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review June 13, 2025 21:50
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner June 13, 2025 21:50
@@ -2169,7 +2235,7 @@ namespace {{defaultNamespace}}
{
public static class Extensions
{
public static bool Foo(this string s) => true;
public static bool Foo(this String s) => true;
Copy link
Member Author

Choose a reason for hiding this comment

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

desirable change in behavior. we were unnecessarily changing this here, despite it having nothing to do with the namespaces being changed.

@CyrusNajmabadi CyrusNajmabadi requested a review from JoeRobich June 13, 2025 22:00
public CSharpChangeNamespaceService()
{
}
public override AbstractReducer NameReducer { get; } = new CSharpNameReducer();
Copy link
Member Author

Choose a reason for hiding this comment

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

general idea is htat we go find the locations of interest, and only simplify them with the language's name simplifier (not all the other simplifiers).

@@ -501,15 +503,6 @@ private static SyntaxNode CreateImport(SyntaxGenerator syntaxGenerator, string n
return (solutionWithFixedReferences, refLocationGroups.SelectAsArray(g => g.Key));
}

private readonly struct LocationForAffectedSymbol(ReferenceLocation location, bool isReferenceToExtensionMethod)
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to its own file.

name = parentName;

return name.Parent is TCrefSyntax ? name.Parent : name;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

crux of the change. we only go fixup names that were using one of hte namespace names in either the old namespace name, or the new namespace name.

/// declaration in global namespace and there's no namespace declaration in this document.
/// (3) otherwise, null.
/// </returns>
protected abstract Task<SyntaxNode?> TryGetApplicableInvocationNodeAsync(Document document, TextSpan span, CancellationToken cancellationToken);
Copy link
Member Author

Choose a reason for hiding this comment

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

moved up from bottom.

/// </returns>
protected abstract Task<SyntaxNode?> TryGetApplicableInvocationNodeAsync(Document document, TextSpan span, CancellationToken cancellationToken);

protected abstract string EscapeIdentifier(string identifier);
Copy link
Member Author

Choose a reason for hiding this comment

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

removed.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge June 13, 2025 22:02
@CyrusNajmabadi CyrusNajmabadi merged commit 6ae6778 into dotnet:main Jun 13, 2025
24 of 25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the syncNamespace branch June 13, 2025 22:59
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 13, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
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.

Sync namespace to folder reformats the entire document
3 participants