Add the possibility to specify an output filename
It would be handy to specify the output filename, currently it's only possible to select the output folder. (I guess since you can have more then 1 file). But when you do have one file, it would be great if you could specify it.
This is meant for the console version and the dotnettool version.
Currently, the file names are identical to the C# namespace names (plus ".cs"). So one way of specifying the file name is to set the C# namespace name. It would be a nice feature to be able to specify the file name independently of the namespace. This could be added to the -n option, e.g.
-n XmlNamespace|a.xsd=CSNamespace|Filename.cs
I was badly in need of this feature, so implemented my own File writer to achieve it.
public class SingleFileOutputWriter : FileOutputWriter
{
public SingleFileOutputWriter(string directory, bool createIfNotExists = true)
: base(directory, createIfNotExists)
{
}
public string OutputFile { get; set; }
public override void Write(CodeNamespace cn)
{
var cu = new CodeCompileUnit();
cu.Namespaces.Add(cn);
if (string.IsNullOrWhiteSpace(OutputFile))
{
OutputFile = $"{cn.Name}.cs";
}
WriteFile(Path.Combine(OutputDirectory, OutputFile), cu);
}
}
@rashan ; Can you maybe create a PR for this?