public override string GetFullName() { string refPrefix = string.Empty; switch (refKind) { case RefKind.Out: refPrefix = "out"; break; case RefKind.Ref: refPrefix = "ref"; break; default: throw new NotSupportedException(); } return(refPrefix + " " + referencedType.GetFullName()); }
public static string GetErrorReportingName(TypeSymbol type, RefKind refKind = RefKind.None) { string prefix = ""; switch (refKind) { case RefKind.Ref: prefix = "ref "; break; case RefKind.Out: prefix = "out "; break; } switch (type.GetSpecialTypeSafe()) { case SpecialType.System_Void: case SpecialType.System_SByte: case SpecialType.System_Int16: case SpecialType.System_Int32: case SpecialType.System_Int64: case SpecialType.System_Byte: case SpecialType.System_UInt16: case SpecialType.System_UInt32: case SpecialType.System_UInt64: case SpecialType.System_Single: case SpecialType.System_Double: case SpecialType.System_Decimal: case SpecialType.System_Char: case SpecialType.System_Boolean: case SpecialType.System_String: case SpecialType.System_Object: return(prefix + SemanticFacts.GetLanguageName(type.SpecialType)); case SpecialType.None: if (type != null && type.IsNullableType() && !ReferenceEquals(type, type.OriginalDefinition)) { TypeSymbol underlyingType = type.GetNullableUnderlyingType(); switch (underlyingType.GetSpecialTypeSafe()) { case SpecialType.System_Boolean: case SpecialType.System_SByte: case SpecialType.System_Int16: case SpecialType.System_Int32: case SpecialType.System_Int64: case SpecialType.System_Byte: case SpecialType.System_UInt16: case SpecialType.System_UInt32: case SpecialType.System_UInt64: case SpecialType.System_Single: case SpecialType.System_Double: case SpecialType.System_Decimal: case SpecialType.System_Char: return(prefix + SemanticFacts.GetLanguageName(underlyingType.SpecialType) + "?"); } return(prefix + GetErrorReportingName(underlyingType) + "?"); } break; } var dynamicType = type as DynamicTypeSymbol; if (dynamicType != null) { return(prefix + "dynamic"); } var arrayType = type as ArrayTypeSymbol; if (arrayType != null) { string suffix = ""; while (true) { var elementType = arrayType.ElementType; suffix += GetSuffix(arrayType.Rank); arrayType = elementType as ArrayTypeSymbol; if (arrayType == null) { return(prefix + GetErrorReportingName(elementType) + suffix); } } } var pointerType = type as PointerTypeSymbol; if (pointerType != null) { return(prefix + GetErrorReportingName(pointerType.BaseType) + "*"); } var namedType = type as NamedTypeSymbol; if (namedType != null) { string result = ""; if (namedType.ContainingType != null) { result = GetErrorReportingName(namedType.ContainingType) + "."; } else if (namedType.ContainingNamespace != null && !namedType.ContainingNamespace.IsGlobalNamespace) { result = namedType.ContainingNamespace.GetFullName() + "."; } result += type.Name; if (namedType.TypeArguments.Count != 0) { result += "<"; result += namedType.TypeArguments.Select(a => GetErrorReportingName(a)).Comma(","); result += ">"; } return(prefix + result); } var typeParameter = type as TypeParameterSymbol; if (typeParameter != null) { return(prefix + type.Name); } Debug.Fail("What case did we miss in type name error reporter?"); return(prefix + type.GetFullName()); }
public static string GetErrorReportingName(TypeSymbol type, RefKind refKind = RefKind.None) { string prefix = ""; switch (refKind) { case RefKind.Ref: prefix = "ref "; break; case RefKind.Out: prefix = "out "; break; } switch (type.GetSpecialTypeSafe()) { case SpecialType.System_Void: case SpecialType.System_SByte: case SpecialType.System_Int16: case SpecialType.System_Int32: case SpecialType.System_Int64: case SpecialType.System_Byte: case SpecialType.System_UInt16: case SpecialType.System_UInt32: case SpecialType.System_UInt64: case SpecialType.System_Single: case SpecialType.System_Double: case SpecialType.System_Decimal: case SpecialType.System_Char: case SpecialType.System_Boolean: case SpecialType.System_String: case SpecialType.System_Object: return prefix + SemanticFacts.GetLanguageName(type.SpecialType); case SpecialType.None: if (type != null && type.IsNullableType() && !ReferenceEquals(type, type.OriginalDefinition)) { TypeSymbol underlyingType = type.GetNullableUnderlyingType(); switch (underlyingType.GetSpecialTypeSafe()) { case SpecialType.System_Boolean: case SpecialType.System_SByte: case SpecialType.System_Int16: case SpecialType.System_Int32: case SpecialType.System_Int64: case SpecialType.System_Byte: case SpecialType.System_UInt16: case SpecialType.System_UInt32: case SpecialType.System_UInt64: case SpecialType.System_Single: case SpecialType.System_Double: case SpecialType.System_Decimal: case SpecialType.System_Char: return prefix + SemanticFacts.GetLanguageName(underlyingType.SpecialType) + "?"; } return prefix + GetErrorReportingName(underlyingType) + "?"; } break; } var dynamicType = type as DynamicTypeSymbol; if (dynamicType != null) { return prefix + "dynamic"; } var arrayType = type as ArrayTypeSymbol; if (arrayType != null) { string suffix = ""; while (true) { var elementType = arrayType.ElementType; suffix += GetSuffix(arrayType.Rank); arrayType = elementType as ArrayTypeSymbol; if (arrayType == null) { return prefix + GetErrorReportingName(elementType) + suffix; } } } var pointerType = type as PointerTypeSymbol; if (pointerType != null) { return prefix + GetErrorReportingName(pointerType.BaseType) + "*"; } var namedType = type as NamedTypeSymbol; if (namedType != null) { string result = ""; if (namedType.ContainingType != null) { result = GetErrorReportingName(namedType.ContainingType) + "."; } else if (namedType.ContainingNamespace != null && !namedType.ContainingNamespace.IsGlobalNamespace) { result = namedType.ContainingNamespace.GetFullName() + "."; } result += type.Name; if (namedType.TypeArguments.Count != 0) { result += "<"; result += namedType.TypeArguments.Select(a => GetErrorReportingName(a)).Comma(","); result += ">"; } return prefix + result; } var typeParameter = type as TypeParameterSymbol; if (typeParameter != null) { return prefix + type.Name; } Debug.Fail("What case did we miss in type name error reporter?"); return prefix + type.GetFullName(); }