Exemplo n.º 1
0
        void TypeToString(ITextOutput output, ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            if (type == null)
            {
                return;
            }
            AstType astType = AstBuilder.ConvertType(type, typeAttributes, options);

            if (WriteRefIfByRef(output, type.TryGetByRefSig(), typeAttributes as ParamDef))
            {
                if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
                {
                    ((ComposedType)astType).PointerRank--;
                }
            }

            var module = type.Module;

            if (module == null && type is TypeSpec && ((TypeSpec)type).TypeSig.RemovePinnedAndModifiers() is GenericSig)
            {
                var sig = (GenericSig)((TypeSpec)type).TypeSig.RemovePinnedAndModifiers();
                if (sig.OwnerType != null)
                {
                    module = sig.OwnerType.Module;
                }
                if (module == null && sig.OwnerMethod != null && sig.OwnerMethod.DeclaringType != null)
                {
                    module = sig.OwnerMethod.DeclaringType.Module;
                }
            }
            var ctx = new DecompilerContext(type.Module);

            astType.AcceptVisitor(new CSharpOutputVisitor(new TextTokenWriter(output, ctx), FormattingOptionsFactory.CreateAllman()));
        }
Exemplo n.º 2
0
        string TypeToString(ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            AstType astType = AstBuilder.ConvertType(null, null, type, typeAttributes, options);

            StringWriter w = new StringWriter();

            if (type.TryGetByRefSig() != null)
            {
                ParamDef pd = typeAttributes as ParamDef;
                if (pd != null && (!pd.IsIn && pd.IsOut))
                {
                    w.Write("out ");
                }
                else
                {
                    w.Write("ref ");
                }

                if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
                {
                    ((ComposedType)astType).PointerRank--;
                }
            }

            astType.AcceptVisitor(new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateAllman()));
            return(w.ToString());
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        string TypeToString(ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            var          envProvider = new ILSpyEnvironmentProvider();
            var          converter   = new CSharpToVBConverterVisitor(envProvider);
            var          astType     = AstBuilder.ConvertType(null, null, type, typeAttributes, options);
            StringWriter w           = new StringWriter();

            if (type.TryGetByRefSig() != null)
            {
                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());
        }
Exemplo n.º 5
0
        string TypeToString(ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            AstType astType = AstBuilder.ConvertType(null, null, type, typeAttributes, options);

            StringWriter w = new StringWriter();
            if (type.TryGetByRefSig() != null) {
                ParamDef pd = typeAttributes as ParamDef;
                if (pd != null && (!pd.IsIn && pd.IsOut))
                    w.Write("out ");
                else
                    w.Write("ref ");

                if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
                    ((ComposedType)astType).PointerRank--;
            }

            astType.AcceptVisitor(new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateAllman()));
            return w.ToString();
        }
Exemplo n.º 6
0
        void TypeToString(ITextOutput output, ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            if (type == null)
                return;
            AstType astType = AstBuilder.ConvertType(type, typeAttributes, options);

            if (WriteRefIfByRef(output, type.TryGetByRefSig(), typeAttributes as ParamDef)) {
                if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
                    ((ComposedType)astType).PointerRank--;
            }

            var module = type.Module;
            if (module == null && type is TypeSpec && ((TypeSpec)type).TypeSig.RemovePinnedAndModifiers() is GenericSig) {
                var sig = (GenericSig)((TypeSpec)type).TypeSig.RemovePinnedAndModifiers();
                if (sig.OwnerType != null)
                    module = sig.OwnerType.Module;
                if (module == null && sig.OwnerMethod != null && sig.OwnerMethod.DeclaringType != null)
                    module = sig.OwnerMethod.DeclaringType.Module;
            }
            var ctx = new DecompilerContext(type.Module);
            astType.AcceptVisitor(new CSharpOutputVisitor(new TextTokenWriter(output, ctx), FormattingOptionsFactory.CreateAllman()));
        }
Exemplo n.º 7
0
		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);
		}
Exemplo n.º 8
0
        string TypeToString(ConvertTypeOptions options, ITypeDefOrRef type, IHasCustomAttribute typeAttributes = null)
        {
            var envProvider = new ILSpyEnvironmentProvider();
            var converter = new CSharpToVBConverterVisitor(envProvider);
            var astType = AstBuilder.ConvertType(null, null, type, typeAttributes, options);
            StringWriter w = new StringWriter();

            if (type.TryGetByRefSig() != null) {
                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();
        }