generate namespace for new file

This commit is contained in:
Matt Parker
2025-10-20 19:55:28 +10:00
parent 6fa0049f62
commit e114e2c524
4 changed files with 23 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
using SharpIDE.Application.Features.SolutionDiscovery;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.FileWatching;
@@ -25,10 +26,11 @@ public class IdeFileOperationsService(SharpIdeSolutionModificationService sharpI
// await _sharpIdeSolutionModificationService.RemoveFile(file);
// }
public async Task CreateCsFile(SharpIdeFolder parentFolder, string newFileName, string @namespace)
public async Task CreateCsFile(SharpIdeFolder parentFolder, string newFileName)
{
var newFilePath = Path.Combine(parentFolder.Path, newFileName);
var className = Path.GetFileNameWithoutExtension(newFileName);
var @namespace = NewFileTemplates.ComputeNamespace(parentFolder);
var fileText = NewFileTemplates.CsharpClass(className, @namespace);
await File.WriteAllTextAsync(newFilePath, fileText);
await _sharpIdeSolutionModificationService.CreateFile(parentFolder, newFileName, fileText);