string TypeToString(ITypeDefOrRef?type, bool includeNamespace, IHasCustomAttribute?typeAttributes = null) { var output = new StringBuilderDecompilerOutput(); TypeToString(output, type, includeNamespace, typeAttributes); return(output.ToString()); }
/// <summary> /// Checks whether a custom attribute exists /// </summary> /// <param name="provider">Custom attribute provider</param> /// <param name="namespace">Namespace of custom attribute</param> /// <param name="name">Name of custom attribute</param> /// <returns></returns> public static bool IsDefined(this IHasCustomAttribute?provider, UTF8String? @namespace, UTF8String?name) { if (provider is null || provider.CustomAttributes.Count == 0) { return(false); } foreach (var ca in provider.CustomAttributes) { if (ca.AttributeType is TypeRef tr) { if (tr.Namespace == @namespace && tr.Name == name) { return(true); } continue; } if (ca.AttributeType is TypeDef td) { if (td.Namespace == @namespace && td.Name == name) { return(true); } continue; } } return(false); }
protected override void TypeToString(IDecompilerOutput output, ITypeDefOrRef?t, bool includeNamespace, IHasCustomAttribute?attributeProvider = null) => t.WriteTo(output, includeNamespace ? ILNameSyntax.TypeName : ILNameSyntax.ShortTypeName);
public override void WriteToolTip(ITextColorWriter output, IMemberRef member, IHasCustomAttribute?typeAttributes) { if (!(member is ITypeDefOrRef) && ILDecompilerUtils.Write(TextColorWriterToDecompilerOutput.Create(output), member)) { return; } base.WriteToolTip(output, member, typeAttributes); }
public virtual void WriteToolTip(ITextColorWriter output, IMemberRef member, IHasCustomAttribute?typeAttributes) => new CSharpFormatter(output, DefaultFormatterOptions, null).WriteToolTip(member);
protected virtual void TypeToString(IDecompilerOutput output, ITypeDefOrRef?type, bool includeNamespace, IHasCustomAttribute?typeAttributes = null) { if (type is null) { return; } if (includeNamespace) { output.Write(IdentifierEscaper.Escape(type.FullName), MetadataTextColorProvider.GetColor(type)); } else { output.Write(IdentifierEscaper.Escape(type.Name), MetadataTextColorProvider.GetColor(type)); } }
public override void WriteToolTip(ITextColorWriter output, IMemberRef member, IHasCustomAttribute?typeAttributes) => new VisualBasicFormatter(output, DefaultFormatterOptions, null).WriteToolTip(member);
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 TypeToString(IDecompilerOutput output, ITypeDefOrRef?type, bool includeNamespace, IHasCustomAttribute?typeAttributes = null) { ConvertTypeOptions options = ConvertTypeOptions.IncludeTypeParameterDefinitions; if (includeNamespace) { options |= ConvertTypeOptions.IncludeNamespace; } TypeToString(output, options, type, typeAttributes); }
public void WriteToolTip(ITextColorWriter output, IMemberRef member, IHasCustomAttribute?typeAttributes) => implementation.WriteToolTip(output, member, typeAttributes);