protected override string GetFieldString(IField field, OutputSettings settings) { if (field == null) { return(""); } var result = new StringBuilder(); bool isEnum = field.DeclaringTypeDefinition != null && field.DeclaringTypeDefinition.Kind == TypeKind.Enum; AppendModifiers(result, settings, field); if (!settings.CompletionListFomat && settings.IncludeReturnType && !isEnum) { result.Append(GetTypeReferenceString(field.ReturnType, settings)); result.Append(settings.Markup(" ")); } if (!settings.IncludeReturnType && settings.UseFullName) { result.Append(GetTypeReferenceString(field.DeclaringTypeDefinition, settings)); result.Append(settings.Markup(".")); } result.Append(settings.EmitName(field, FilterName(Format(field.Name)))); if (settings.CompletionListFomat && settings.IncludeReturnType && !isEnum) { result.Append(settings.Markup(" : ")); result.Append(GetTypeReferenceString(field.ReturnType, settings)); } return(result.ToString()); }
protected override string GetEventString(IEvent evt, OutputSettings settings) { if (evt == null) { return(""); } var result = new StringBuilder(); AppendModifiers(result, settings, evt); if (settings.IncludeKeywords) { result.Append(settings.EmitKeyword("event")); } if (!settings.CompletionListFomat && settings.IncludeReturnType) { result.Append(GetTypeReferenceString(evt.ReturnType, settings)); result.Append(settings.Markup(" ")); } if (!settings.IncludeReturnType && settings.UseFullName) { result.Append(GetTypeReferenceString(evt.DeclaringTypeDefinition, new OutputSettings(OutputFlags.UseFullName))); result.Append(settings.Markup(".")); } AppendExplicitInterfaces(result, evt, settings); result.Append(settings.EmitName(evt, Format(FilterName(evt.Name)))); if (settings.CompletionListFomat && settings.IncludeReturnType) { result.Append(settings.Markup(" : ")); result.Append(GetTypeReferenceString(evt.ReturnType, settings)); } return(result.ToString()); }
protected override string GetParameterString(IParameterizedMember member, IParameter parameter, OutputSettings settings) { if (parameter == null) { return(""); } var result = new StringBuilder(); if (settings.IncludeParameterName) { if (settings.IncludeModifiers) { if (parameter.IsOut) { result.Append(settings.EmitKeyword("out")); } if (parameter.IsRef) { result.Append(settings.EmitKeyword("ref")); } if (parameter.IsParams) { result.Append(settings.EmitKeyword("params")); } } result.Append(GetTypeReferenceString(parameter.Type, settings)); result.Append(" "); if (settings.HighlightName) { result.Append(settings.EmitName(parameter, settings.Highlight(Format(FilterName(parameter.Name))))); } else { result.Append(settings.EmitName(parameter, Format(FilterName(parameter.Name)))); } } else { result.Append(GetTypeReferenceString(parameter.Type, settings)); } return(result.ToString()); }
protected override string GetIndexerString(IProperty property, OutputSettings settings) { if (property == null) { return(""); } var result = new StringBuilder(); AppendModifiers(result, settings, property); if (settings.IncludeReturnType) { result.Append(GetTypeReferenceString(property.ReturnType, settings)); result.Append(settings.Markup(" ")); } if (!settings.IncludeReturnType && settings.UseFullName) { result.Append(GetTypeReferenceString(property.DeclaringTypeDefinition, new OutputSettings(OutputFlags.UseFullName))); result.Append(settings.Markup(".")); } AppendExplicitInterfaces(result, property, settings); result.Append(settings.EmitName(property, Format("this"))); if (settings.IncludeParameters && property.Getter.Parameters.Count > 0) { result.Append(settings.Markup("[")); AppendParameterList(result, settings, property.Getter.Parameters); result.Append(settings.Markup("]")); } if (settings.IncludeAccessor) { result.Append(settings.Markup(" {")); if (property.CanGet) { result.Append(settings.Markup(" get;")); } if (property.CanSet) { result.Append(settings.Markup(" set;")); } result.Append(settings.Markup(" }")); } return(result.ToString()); }
protected override string GetOperatorString(IMethod method, OutputSettings settings) { return(InternalGetMethodString(method, settings, settings.EmitName(method, Format(FilterName(method.Name))), true)); }
protected override string GetDestructorString(IMethod method, OutputSettings settings) { return(InternalGetMethodString(method, settings, settings.EmitName(method, settings.Markup("~") + Format(FilterName(method.DeclaringTypeDefinition != null ? method.DeclaringTypeDefinition.Name : method.Name))), false)); }
protected override string GetMethodString(IMethod method, OutputSettings settings) { return(InternalGetMethodString(method, settings, settings.EmitName(method, Format(FilterName(method.SymbolKind == SymbolKind.Constructor || method.SymbolKind == SymbolKind.Destructor ? method.DeclaringTypeDefinition.Name : method.Name))), true)); }
protected override string GetTypeString(IType t, OutputSettings settings) { if (t.Kind == TypeKind.Unknown) { return(settings.IncludeMarkup ? settings.Markup(t.Name) : t.Name); } if (t.Kind == TypeKind.TypeParameter) { return(settings.IncludeMarkup ? settings.Markup(t.FullName) : t.FullName); } var typeWithElementType = t as TypeWithElementType; if (typeWithElementType != null) { var sb = new StringBuilder(); if (typeWithElementType is PointerType) { sb.Append(settings.Markup("*")); } AppendType(sb, typeWithElementType.ElementType, settings); if (typeWithElementType is ArrayType) { sb.Append(settings.Markup("[")); sb.Append(settings.Markup(new string (',', ((ArrayType)t).Dimensions - 1))); sb.Append(settings.Markup("]")); } return(sb.ToString()); } ITypeDefinition type = t.GetDefinition(); if (type == null) { return(""); } if (!settings.UseNETTypeNames && type.Namespace == "System" && type.TypeParameterCount == 0) { switch (type.Name) { case "Object": return("object"); case "Boolean": return("bool"); case "Char": return("char"); case "SByte": return("sbyte"); case "Byte": return("byte"); case "Int16": return("short"); case "UInt16": return("ushort"); case "Int32": return("int"); case "UInt32": return("uint"); case "Int64": return("long"); case "UInt64": return("ulong"); case "Single": return("float"); case "Double": return("double"); case "Decimal": return("decimal"); case "String": return("string"); case "Void": return("void"); } } // output anonymous type if (type.IsSynthetic && type.Name == "$Anonymous$") { return(GetTypeReferenceString(type, settings)); } var result = new StringBuilder(); var def = type; AppendModifiers(result, settings, def); if (settings.IncludeKeywords) { result.Append(GetString(def.Kind)); } if (result.Length > 0 && !result.ToString().EndsWith(" ")) { result.Append(settings.Markup(" ")); } if (type.Kind == TypeKind.Delegate && settings.ReformatDelegates && settings.IncludeReturnType) { var invoke = type.GetDelegateInvokeMethod(); result.Append(GetTypeReferenceString(invoke.ReturnType, settings)); result.Append(settings.Markup(" ")); } if (settings.UseFullName && !string.IsNullOrEmpty(type.Namespace)) { result.Append((settings.IncludeMarkup ? settings.Markup(t.Namespace) : type.Namespace) + "."); } if (settings.UseFullInnerTypeName && type.DeclaringTypeDefinition != null) { bool includeGenerics = settings.IncludeGenerics; settings.OutputFlags |= OutputFlags.IncludeGenerics; string typeString = GetTypeReferenceString(type.DeclaringTypeDefinition, settings); if (!includeGenerics) { settings.OutputFlags &= ~OutputFlags.IncludeGenerics; } result.Append(typeString); result.Append(settings.Markup(".")); } result.Append(settings.EmitName(type, settings.IncludeMarkup ? settings.Markup(t.Name) : type.Name)); if (settings.IncludeGenerics && type.TypeParameterCount > 0) { result.Append(settings.Markup("<")); for (int i = 0; i < type.TypeParameterCount; i++) { if (i > 0) { result.Append(settings.Markup(settings.HideGenericParameterNames ? "," : ", ")); } if (!settings.HideGenericParameterNames) { if (t.TypeArguments.Count > 0) { result.Append(GetTypeReferenceString(t.TypeArguments [i], settings)); } else { AppendVariance(result, type.TypeParameters [i].Variance); result.Append(NetToCSharpTypeName(type.TypeParameters [i].FullName)); } } } result.Append(settings.Markup(">")); } if (t.Kind == TypeKind.Delegate && settings.ReformatDelegates) { // var policy = GetPolicy (settings); // if (policy.BeforeMethodCallParentheses) // result.Append (settings.Markup (" ")); result.Append(settings.Markup("(")); var invoke = type.GetDelegateInvokeMethod(); if (invoke != null) { AppendParameterList(result, settings, invoke.Parameters); } result.Append(settings.Markup(")")); return(result.ToString()); } if (settings.IncludeBaseTypes && type.DirectBaseTypes.Any()) { bool first = true; foreach (var baseType in type.DirectBaseTypes) { // if (baseType.FullName == "System.Object" || baseType.FullName == "System.Enum") // continue; result.Append(settings.Markup(first ? " : " : ", ")); first = false; result.Append(GetTypeReferenceString(baseType, settings)); } } // OutputConstraints (result, settings, type.TypeParameters); return(result.ToString()); }