void TypeToString(IDecompilerOutput output, ConvertTypeOptions options, ITypeDefOrRef?type, IHasCustomAttribute?typeAttributes = null) { if (type is null) { return; } var envProvider = new ILSpyEnvironmentProvider(); var converter = new CSharpToVBConverterVisitor(type.Module, envProvider); var astType = AstBuilder.ConvertType(type, new StringBuilder(), typeAttributes, options); if (type.TryGetByRefSig() is not null) { output.Write("ByRef", BoxedTextColor.Keyword); output.Write(" ", BoxedTextColor.Text); if (astType is ICSharpCode.NRefactory.CSharp.ComposedType && ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank > 0) { ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank--; } } var vbAstType = astType.AcceptVisitor(converter, null); var settings = GetDecompilerSettings(); var ctx = new DecompilerContext(settings.SettingsVersion, type.Module, MetadataTextColorProvider); vbAstType.AcceptVisitor(new OutputVisitor(new VBTextOutputFormatter(output, ctx), CreateVBFormattingOptions(settings)), null); }
protected override void WriteResult(TextWriter writer, IEnumerable<AstNode> ast, DecompilerContext context) { var converter = new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider()); var visitor = new OutputVisitor( new VBTextOutputFormatter(new CustomizableIndentPlainTextOutput(writer) { IndentationString = " " }), new VBFormattingOptions() ); foreach (var node in ast) { node.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); var converted = node.AcceptVisitor(converter, null); converted.AcceptVisitor(visitor, null); } }
protected override void WriteResult(TextWriter writer, AstBuilder ast) { ast.RunTransformations(); var converter = new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider()); var visitor = new OutputVisitor( new VBTextOutputFormatter(new CustomizableIndentPlainTextOutput(writer) { IndentationString = " " }), new VBFormattingOptions() ); var converted = ast.SyntaxTree.AcceptVisitor(converter, null); converted.AcceptVisitor(visitor, null); }
string TypeToString(ConvertTypeOptions options, TypeReference type, ICustomAttributeProvider typeAttributes = null) { var envProvider = new ILSpyEnvironmentProvider(); var converter = new CSharpToVBConverterVisitor(envProvider); var astType = AstBuilder.ConvertType(type, typeAttributes, options); StringWriter w = new StringWriter(); if (type.IsByReference) { w.Write("ByRef "); if (astType is NRefactory.CSharp.ComposedType && ((NRefactory.CSharp.ComposedType)astType).PointerRank > 0) ((NRefactory.CSharp.ComposedType)astType).PointerRank--; } var vbAstType = astType.AcceptVisitor(converter, null); vbAstType.AcceptVisitor(new OutputVisitor(w, new VBFormattingOptions()), null); return w.ToString(); }
void TypeToString(IDecompilerOutput output, ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null) { var envProvider = new ILSpyEnvironmentProvider(); var converter = new CSharpToVBConverterVisitor(type.Module, envProvider); var astType = AstBuilder.ConvertType(type, new StringBuilder(), typeAttributes, options); if (type.TryGetByRefSig() != null) { output.Write("ByRef", BoxedTextColor.Keyword); output.Write(" ", BoxedTextColor.Text); if (astType is ICSharpCode.NRefactory.CSharp.ComposedType && ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank > 0) { ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank--; } } var vbAstType = astType.AcceptVisitor(converter, null); vbAstType.AcceptVisitor(new OutputVisitor(new VBTextOutputFormatter(output), new VBFormattingOptions()), null); }
protected override void WriteResult(TextWriter writer, IEnumerable <AstNode> ast, DecompilerContext context) { var converter = new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider()); var visitor = new OutputVisitor( new VBTextOutputFormatter(new CustomizableIndentPlainTextOutput(writer) { IndentationString = " " }), new VBFormattingOptions() ); foreach (var node in ast) { node.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); var converted = node.AcceptVisitor(converter, null); converted.AcceptVisitor(visitor, null); } }
string TypeToString(ConvertTypeOptions options, TypeReference type, ICustomAttributeProvider typeAttributes = null) { var envProvider = new ILSpyEnvironmentProvider(); var converter = new CSharpToVBConverterVisitor(envProvider); var astType = AstBuilder.ConvertType(type, typeAttributes, options); StringWriter w = new StringWriter(); if (type.IsByReference) { w.Write("ByRef "); if (astType is NRefactory.CSharp.ComposedType && ((NRefactory.CSharp.ComposedType)astType).PointerRank > 0) ((NRefactory.CSharp.ComposedType)astType).PointerRank--; } var vbAstType = astType.AcceptVisitor(converter, null); vbAstType.AcceptVisitor(new OutputVisitor(w, new VBFormattingOptions()), null); return w.ToString(); }
void TypeToString(ITextOutput output, ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null) { var envProvider = new ILSpyEnvironmentProvider(); var converter = new CSharpToVBConverterVisitor(envProvider); var astType = AstBuilder.ConvertType(type, typeAttributes, options); if (type.TryGetByRefSig() != null) { output.Write("ByRef", TextTokenType.Keyword); output.WriteSpace(); if (astType is NRefactory.CSharp.ComposedType && ((NRefactory.CSharp.ComposedType)astType).PointerRank > 0) ((NRefactory.CSharp.ComposedType)astType).PointerRank--; } var vbAstType = astType.AcceptVisitor(converter, null); vbAstType.AcceptVisitor(new OutputVisitor(new VBTextOutputFormatter(output), new VBFormattingOptions()), null); }