public static string ToString(WellKnownType type) { if (type == WellKnownType.Unknown) { return(null); } return(type.ToString()); }
private static void AssertEnumAndTableInSync() { for (int i = 0; i < s_metadataNames.Length; i++) { string name = s_metadataNames[i]; WellKnownType typeId = (WellKnownType)(i + WellKnownType.First); string typeIdName; switch (typeId) { case WellKnownType.First: typeIdName = "System.Math"; break; case WellKnownType.Microsoft_VisualBasic_CompilerServices_ObjectFlowControl_ForLoopControl: typeIdName = "Microsoft.VisualBasic.CompilerServices.ObjectFlowControl+ForLoopControl"; break; case WellKnownType.CSharp7Sentinel: typeIdName = "System.IFormatProvider"; break; case WellKnownType.ExtSentinel: typeIdName = ""; continue; case (WellKnownType.NextAvailable - 1): typeIdName = "Microsoft.CodeAnalysis.Runtime.Instrumentation"; continue; default: typeIdName = typeId.ToString().Replace("__", "+").Replace('_', '.'); break; } int separator = name.IndexOf('`'); if (separator >= 0) { // Ignore type parameter qualifier for generic types. name = name.Substring(0, separator); typeIdName = typeIdName.Substring(0, separator); } Debug.Assert(name == typeIdName); } Debug.Assert((int)WellKnownType.ExtSentinel == 255); Debug.Assert((int)WellKnownType.NextAvailable <= 512); }