Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeConversion v2.0.1 throwing errors when converting from C# to Powershell #5

Open
chrisdma opened this issue Nov 21, 2022 · 1 comment

Comments

@chrisdma
Copy link

chrisdma commented Nov 21, 2022

Hello, I am trying to convert a ~100 line C# snippet to Powershell so that I don't have to use Add-Type to call the code however CodeConversion is erroring out. Below is the error I get:

   at CodeConverter.PowerShell.PowerShellCodeWriter.VisitObjectCreation(ObjectCreation node) in C:\src\code-conversion\src\PowerShell\PowerShellCodeWriter.cs:line 217
   at CodeConverter.Common.ObjectCreation.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 681
   at CodeConverter.PowerShell.PowerShellCodeWriter.VisitVariableDeclarator(VariableDeclarator node) in C:\src\code-conversion\src\PowerShell\PowerShellCodeWriter.cs:line 377
   at CodeConverter.PowerShell.PowerShellCodeWriter.VisitVariableDeclaration(VariableDeclaration node) in C:\src\code-conversion\src\PowerShell\PowerShellCodeWriter.cs:line 366
   at CodeConverter.Common.VariableDeclaration.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 1029
   at CodeConverter.Common.CStyleCodeWriter.VisitBlock(Block node) in C:\src\code-conversion\src\Common\CStyleCodeWriter.cs:line 83
   at CodeConverter.Common.Block.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 241
   at CodeConverter.PowerShell.PowerShellCodeWriter.VisitMethodDeclaration(MethodDeclaration node) in C:\src\code-conversion\src\PowerShell\PowerShellCodeWriter.cs:line 198
   at CodeConverter.Common.MethodDeclaration.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 637
   at CodeConverter.Common.NodeVisitor.VisitClassDeclaration(ClassDeclaration node) in C:\src\code-conversion\src\Common\NodeVisitor.cs:line 95
   at CodeConverter.Common.ClassDeclaration.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 341
   at CodeConverter.Common.CStyleCodeWriter.VisitBlock(Block node) in C:\src\code-conversion\src\Common\CStyleCodeWriter.cs:line 83
   at CodeConverter.Common.Block.Accept(NodeVisitor visitor) in C:\src\code-conversion\src\Common\Ast.cs:line 241
   at CodeConverter.Common.CodeWriter.Write(Node ast) in C:\src\code-conversion\src\Common\CodeWriter.cs:line 33
   at CodeConverter.Converter.Convert(String code, Language from, Language to) in C:\src\code-conversion\src\Converter.cs:line 67
   at CodeConverter.Converter.Convert(String code, Language to) in C:\src\code-conversion\src\Converter.cs:line 46
   at CodeConversion.Program.<>c.<Main>b__0_0(Options o) in C:\src\code-conversion\src\Program.cs:line 52
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at CodeConversion.Program.Main(String[] args) in C:\src\code-conversion\src\Program.cs:line 23

And here is a link to the gist of the C# code so that I don't have a 100 line code block in the issue:

https://gist.githubusercontent.com/chrisdma/2ab5e03edc8b1f656922e7c2e5753808/raw/b9c9fd09f824736354df426d4660bdbca7b1c7c9/GetCredential.cs

Thanks for any assistance you can provide!

Chris

@chrisdma
Copy link
Author

I think this is relative to using System.Management.Automation since that's only available with certain .NET frameworks and when its not you have to manually reference the DLL? Not sure how to apply that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant