-
Notifications
You must be signed in to change notification settings - Fork 23
Description
When attempting to convert from PowerShell to C#, I'm running this:
$Params = @{
InputFile = "$env:SystemRoot\repo\Modules\test\classes\class_Options.ps1"
OutputFile = "$env:SystemRoot\repo\Modules\test\classes\class_Options.cs"
}
Invoke-CodeConversion @ParamsThe CodeConverter outputs the below error. Curiously, the converter doesn't throw errors (i.e. it outputs to stdout instead of stderr), but I digress.
CodeConversion 1.0.0
Copyright (C) 2023 CodeConversion
ERROR(S):
Option 'OutputFile' is unknown.
Required option 'o, OutputPath' is missing.
-i, --InputFile Required. File to convert.
-o, --OutputPath Required. Output file.
--PowerShell Required. PowerShell script block to convert to C#
--CSharp Required. C# code to convert to PowerShell
--help Display this help screen.
--version Display version information.
I'm very inexperienced with .NET and C# (using this as a means to translate my PowerShell knowledge), but as best I can tell this is tracing to the Program.cs.
If I'm understanding it correctly, it's taking this line from /CodeConversion.psm1:
& $Path --InputFile $InputFile --OutputPath $OutputFilewhich passes $OutputFile into the Options class in /src/Program.cs:
[Option('o', "OutputPath", Required = true, HelpText = "Output file.", SetName = "File")]
public string OutputFile { get; set; }and somehow the $OutputFile parameter is not being passed correctly, causing a failure because the OutputPath option is required? If I'm understanding the context, the first error says the cmdlet is calling OutputFile as the option instead of OutputPath?
I'm not entirely sure if this is an actual bug or I am merely not using this correctly... But I'm also curious if I am correctly understanding the mechanics of this (testing my knowledge, if you will). Any help is appreciated.