public static string GetSignature(Type type) { var helperType = type.FindHelperType(); if (helperType != null) { var sigMethod = helperType.GetMethod("GetGuidSignature", BindingFlags.Static | BindingFlags.Public); if (sigMethod != null) { return((string)sigMethod.Invoke(null, new Type[] { })); } } if (type == typeof(object)) { return("cinterface(IInspectable)"); } if (type.IsGenericType) { var args = type.GetGenericArguments().Select(t => GetSignature(t)); return("pinterface({" + GetGUID(type) + "};" + String.Join(";", args) + ")"); } if (type.IsValueType) { switch (type.Name) { case "SByte": return("i1"); case "Byte": return("u1"); case "Int16": return("i2"); case "UInt16": return("u2"); case "Int32": return("i4"); case "UInt32": return("u4"); case "Int64": return("i8"); case "UInt64": return("u8"); case "Single": return("f4"); case "Double": return("f8"); case "Boolean": return("b1"); case "Char": return("c2"); case "Guid": return("g16"); default: { if (type.IsEnum) { var isFlags = type.CustomAttributes.Any(cad => cad.AttributeType == typeof(FlagsAttribute)); return("enum(" + TypeExtensions.RemoveNamespacePrefix(type.FullName) + ";" + (isFlags ? "u4" : "i4") + ")"); } if (!type.IsPrimitive) { var args = type.GetFields(BindingFlags.Instance | BindingFlags.Public).Select(fi => GetSignature(fi.FieldType)); return("struct(" + TypeExtensions.RemoveNamespacePrefix(type.FullName) + ";" + String.Join(";", args) + ")"); } throw new InvalidOperationException("unsupported value type"); } } } if (type == typeof(string)) { return("string"); } if (Projections.TryGetDefaultInterfaceTypeForRuntimeClassType(type, out Type iface)) { return("rc(" + TypeExtensions.RemoveNamespacePrefix(type.FullName) + ";" + GetSignature(iface) + ")"); } if (type.IsDelegate()) { return("delegate({" + GetGUID(type) + "})"); } return("{" + type.GUID.ToString() + "}"); }