Skip to content

feat(namespace): update namespace declarations in source files#19

Merged
CalvinAllen merged 1 commit into
mainfrom
feat/namespace/update-source-files
Dec 20, 2025
Merged

feat(namespace): update namespace declarations in source files#19
CalvinAllen merged 1 commit into
mainfrom
feat/namespace/update-source-files

Conversation

@CalvinAllen

Copy link
Copy Markdown
Contributor

Summary

Add functionality to update namespace declarations in all .cs files within the project when renaming.

Changes Made

  • New: Services/SourceFileService.cs - Utility class for source file namespace updates
    • UpdateNamespacesInProject() - Scans all .cs files in project directory
    • UpdateNamespacesInFile() - Updates namespaces in a single file
    • Handles block-scoped namespaces: namespace OldName { }
    • Handles file-scoped namespaces: namespace OldName;
    • Handles nested namespaces: namespace OldName.SubNamespace
    • Preserves file encoding (detects BOM for UTF-8, UTF-16, UTF-32)
  • Modified: RenamifyProjectCommand.cs - Calls SourceFileService after updating project file
  • Modified: .csproj - Added new file reference

Test Plan

  • Build and debug the extension
  • Create a test project with various namespace styles:
    • Block-scoped: namespace MyProject { }
    • File-scoped: namespace MyProject;
    • Nested: namespace MyProject.Models { }
  • Rename the project
  • Verify all namespace declarations are updated
  • Verify nested namespaces preserve their suffix (e.g., NewName.Models)
  • Verify file encoding is preserved

Closes #8

- Add SourceFileService to handle .cs file namespace updates
- Replace block-scoped namespaces: namespace OldName { }
- Replace file-scoped namespaces: namespace OldName;
- Handle nested namespaces: namespace OldName.Sub
- Preserve file encoding (UTF-8, UTF-16, etc.)
- Scan all .cs files in project directory recursively

Closes #8
@CalvinAllen CalvinAllen merged commit 881b14e into main Dec 20, 2025
1 check passed
@CalvinAllen CalvinAllen deleted the feat/namespace/update-source-files branch December 20, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

feat(namespace): update namespace declarations in source files

1 participant