11using Kysect . CommonLib . BaseTypes . Extensions ;
2- using Kysect . CommonLib . FileSystem . Extensions ;
2+ using Kysect . CommonLib . FileSystem ;
33using Kysect . PowerShellRunner . CodeGeneration . SchemaGenerating ;
44using Kysect . PowerShellRunner . CodeGeneration . UsedModelSearching ;
55using Microsoft . CodeAnalysis ;
66using Microsoft . CodeAnalysis . CSharp . Syntax ;
7+ using System . IO . Abstractions ;
78
89namespace Kysect . PowerShellRunner . CodeGeneration . SdkGenerating ;
910
@@ -12,12 +13,14 @@ public class PowerShellSchemaCodeGenerator
1213 private readonly string _outputPath ;
1314 private readonly string _namespaceName ;
1415 private readonly IPowerShellCodeGeneratorNamespaceProvider _namespaceProvider ;
16+ private readonly FileSystem _fileSystem ;
1517
1618 public PowerShellSchemaCodeGenerator ( string outputPath , string namespaceName , IPowerShellCodeGeneratorNamespaceProvider namespaceProvider )
1719 {
1820 _outputPath = outputPath ;
1921 _namespaceName = namespaceName ;
2022 _namespaceProvider = namespaceProvider ;
23+ _fileSystem = new FileSystem ( ) ;
2124 }
2225
2326 public void GenerateSdkCode ( PowerShellSchemaDto powerShellSchema )
@@ -54,7 +57,7 @@ public void GenerateSdkCode(PowerShellSchemaDto powerShellSchema)
5457
5558 private void WriteToCsFile ( string directoryPath , string typeName , MemberDeclarationSyntax declarationSyntax , string [ ] usingList )
5659 {
57- DirectoryExtensions . EnsureFileExists ( directoryPath ) ;
60+ _fileSystem . EnsureDirectoryExists ( directoryPath ) ;
5861 string fullPath = Path . Combine ( directoryPath , $ "{ typeName } .g.cs") ;
5962 string content = CodeGenerationNamespaceWrapper . Wrap ( declarationSyntax , _namespaceName , usingList ) . NormalizeWhitespace ( ) . ToString ( ) ;
6063
0 commit comments