private string GetTypeToShow(string typeName) { if (_useBuiltInNames && TypeNameFormatter.TryReplaceWithBuiltInName(ref typeName, true)) { return(typeName); } if (_showShortName) { typeName = TypeNameFormatter.GetShortName(typeName); } if (typeName == string.Empty) { return(TypeReference.NoneElement); } if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null) { _serializedTypeRef.TryUpdatingTypeUsingGUID(); if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null) { return(typeName + MissingSuffix); } } return(typeName); }
private string GetTypeToShow(string typeName) { if (_useBuiltInNames) { string builtInName = typeName.ReplaceWithBuiltInName(); if (builtInName != typeName) { return(builtInName); } } if (_showShortName) { typeName = TypeNameFormatter.GetShortName(typeName); } if (typeName == string.Empty) { return(TypeReference.NoneElement); } if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null) { return(typeName + MissingSuffix); } return(typeName); }
public DocumentationEntry(string typeName, string propertyName, Type propertyType, string content) { this.typeName = typeName; this.propertyName = propertyName; this.propertyTypeName = TypeNameFormatter.FormatTypeForDefaultLanguage(propertyType, false); this.content = content; }
public TypeItem(Type type, string fullTypeName, Grouping grouping) { Assert.IsNotNull(fullTypeName); FullTypeName = fullTypeName; Type = type; Path = TypeNameFormatter.Format(Type, FullTypeName, grouping); }
public static string GetTypeName(this ITypeReference type, NameFormattingOptions options) { TypeNameFormatter formatter = new TypeNameFormatter(); string name = formatter.GetTypeName(type, options); return(name); }
private bool AreTypesEquivalent(Type unmatchedType, TypeReference actiproType) { IDomType domType = actiproType.Resolve(this.codeProject.ProjectResolver); if (!unmatchedType.IsGenericType) { return(actiproType.GenericTypeArguments.Count == 0 && domType != null && unmatchedType.FullName == domType.FullName); } string b = TypeNameFormatter.FormatGenericTypeName(unmatchedType, true); if (!string.Equals(domType != null ? domType.FullName.Substring(0, domType.FullName.IndexOf('`')) : (string)null, b, StringComparison.Ordinal)) { return(false); } List <TypeReference> list1 = Enumerable.ToList <TypeReference>(Enumerable.OfType <TypeReference>((IEnumerable)actiproType.GenericTypeArguments)); List <Type> list2 = new List <Type>((IEnumerable <Type>)unmatchedType.GetGenericArguments()); if (list1.Count != list2.Count) { return(false); } for (int index = 0; index < list2.Count; ++index) { if (!this.AreTypesEquivalent(list2[index], list1[index])) { return(false); } } return(true); }
public override string CreateMethod(string indent, Type returnType, string methodName, IEnumerable <IParameterDeclaration> parameters, out int bodyInsertionOffset) { string str1 = indent + "Private " + "Sub " + methodName + "("; bool flag = true; foreach (IParameterDeclaration parameterDeclaration in parameters) { if (flag) { flag = false; } else { str1 += ", "; } str1 = str1 + "ByVal " + parameterDeclaration.Name + " as " + TypeNameFormatter.FormatTypeForVisualBasic(parameterDeclaration.ParameterType, true); } string str2 = str1 + ")"; if (returnType != typeof(void)) { str2 = str2 + " As " + TypeNameFormatter.FormatTypeForVisualBasic(returnType, true); } string str3 = str2 + "\r\n" + indent + "\t"; bodyInsertionOffset = str3.Length; return(str3 + "'" + StringTable.EventHandlerTodoText + "\r\n" + indent + "End Sub"); }
protected internal virtual string FormatMethodSignature(MethodBase method) { var pooled = PooledStringBuilder.GetInstance(); var builder = pooled.Builder; var declaringType = method.DeclaringType; var options = new CommonTypeNameFormatterOptions( arrayBoundRadix: NumberRadixDecimal, showNamespaces: true ); builder.Append(TypeNameFormatter.FormatTypeName(declaringType, options)); builder.Append('.'); builder.Append(method.Name); if (method.IsGenericMethod) { builder.Append( TypeNameFormatter.FormatTypeArguments(method.GetGenericArguments(), options) ); } builder.Append('('); bool first = true; foreach (var parameter in method.GetParameters()) { if (first) { first = false; } else { builder.Append(", "); } if (parameter.ParameterType.IsByRef) { builder.Append(FormatRefKind(parameter)); builder.Append(' '); builder.Append( TypeNameFormatter.FormatTypeName( parameter.ParameterType.GetElementType(), options ) ); } else { builder.Append( TypeNameFormatter.FormatTypeName(parameter.ParameterType, options) ); } } builder.Append(')'); return(pooled.ToStringAndFree()); }
public static string GetTypeName(this ITypeReference type, bool includeNamespace = true) { TypeNameFormatter formatter = new TypeNameFormatter(); NameFormattingOptions options = NameFormattingOptions.OmitTypeArguments | NameFormattingOptions.UseReflectionStyleForNestedTypeNames; if (!includeNamespace) { options |= NameFormattingOptions.OmitContainingNamespace; } string name = formatter.GetTypeName(type, options); return(name); }
public static string FormatTypeName(Type type) { if (type == (Type)null) { return(string.Empty); } Type nullableType = PlatformTypeHelper.GetNullableType(type); string shortName = TypeNameFormatter.GetShortName(TypeNameFormatter.FormatTypeForDefaultLanguage(nullableType, true)); if (!(nullableType != (Type)null)) { return(shortName); } return(shortName + "?"); }
public override string CreateMethod(string indent, Type returnType, string methodName, IEnumerable <IParameterDeclaration> parameters, out int bodyInsertionOffset) { string str1 = indent + "private " + TypeNameFormatter.FormatTypeForCSharp(returnType, true) + " " + methodName + "("; bool flag = true; foreach (IParameterDeclaration parameter in parameters) { if (flag) { flag = false; } else { str1 += ", "; } str1 += this.FormatParameter(parameter); } string str2 = str1 + ")\r\n" + indent + "{\r\n" + indent + "\t"; bodyInsertionOffset = str2.Length; return(str2 + "// " + StringTable.EventHandlerTodoText + "\r\n" + indent + "}"); }
private SortedSet <TypeItem> GetFilteredTypes() { var typeRelatedAssemblies = TypeCollector.GetAssembliesTypeHasAccessTo(_declaringType); if (_attribute.IncludeAdditionalAssemblies != null) { IncludeAdditionalAssemblies(typeRelatedAssemblies); } var filteredTypes = TypeCollector.GetFilteredTypesFromAssemblies( typeRelatedAssemblies, _attribute); bool replaceBuiltInNames = _attribute.UseBuiltInNames && typeRelatedAssemblies .Any(assembly => assembly.GetName().Name == "mscorlib"); var sortedTypes = new SortedSet <TypeItem>(new TypeItemComparer()); for (int i = 0; i < filteredTypes.Count; i++) { var type = filteredTypes[i]; string fullTypeName = type.FullName; if (fullTypeName == null) { continue; } if (replaceBuiltInNames) { TypeNameFormatter.TryReplaceWithBuiltInName(ref fullTypeName); } sortedTypes.Add(new TypeItem(type, fullTypeName, _attribute.Grouping)); } return(sortedTypes); }
private string FormatMethodName(MethodDesc method, TypeNameFormatter typeNameFormatter) { StringBuilder output = new StringBuilder(); if (!method.Signature.ReturnType.IsVoid) { output.Append(typeNameFormatter.FormatName(method.Signature.ReturnType)); output.Append(" "); } output.Append(typeNameFormatter.FormatName(method.OwningType)); output.Append("::"); output.Append(method.Name); output.Append("("); for (int paramIndex = 0; paramIndex < method.Signature.Length; paramIndex++) { if (paramIndex != 0) { output.Append(", "); } output.Append(typeNameFormatter.FormatName(method.Signature[paramIndex])); } output.Append(")"); return(output.ToString()); }
public TypeItem(Type type, Grouping grouping) { FullTypeName = type.FullName ?? string.Empty; Type = type; Path = TypeNameFormatter.Format(Type, FullTypeName, grouping); }
private string FormatParameter(IParameterDeclaration parameter) { return(TypeNameFormatter.FormatTypeForCSharp(parameter.ParameterType, true) + " " + parameter.Name); }
private ModelSigFormatter(TypeNameFormatter formatter) : base(formatter) { _formatter = formatter; }
/// <summary> /// Allocates an object with a collection of methods that format type member signatures as strings. The methods are virtual and reference each other. /// By default, types are formatting according to C# conventions. However, by overriding one or more of the /// methods, the formatting can be customized for other languages. /// </summary> /// <param name="typeNameFormatter">The type name formatter object to use for formatting the type references that occur in the signatures.</param> public SignatureFormatter(TypeNameFormatter typeNameFormatter) { _typeNameFormatter = typeNameFormatter; }
/// <summary> /// Allocates an object with a collection of methods that format type member signatures as strings. The methods are virtual and reference each other. /// By default, types are formatting according to C# conventions. However, by overriding one or more of the /// methods, the formatting can be customized for other languages. /// </summary> public SignatureFormatter() { _typeNameFormatter = new TypeNameFormatter(); }
public VBSignatureFormatter(TypeNameFormatter typeNameFormatter) : base(typeNameFormatter) { }
private string CreateEventHandlerTypeName(Type eventHandlerType) { return(TypeNameFormatter.FormatTypeForCSharp(eventHandlerType, true)); }