/// <summary> /// Adds an appropriate label ID to the trap builder <paramref name="tb"/> /// for the type <paramref name="type"/> belonging to the signature of method /// <paramref name="method"/>. /// /// For methods without type parameters this will always add the key of the /// corresponding type. /// /// For methods with type parameters, this will add the key of the /// corresponding type if the type does *not* contain one of the method /// type parameters, otherwise it will add a textual representation of /// the type. This distinction is required because type parameter IDs /// refer to their declaring methods. /// /// Example: /// /// <code> /// int Count<T>(IEnumerable<T> items) /// </code> /// /// The label definitions for <code>Count</code> (<code>#4</code>) and <code>T</code> /// (<code>#5</code>) will look like: /// /// <code> /// #1=<label for System.Int32> /// #2=<label for type containing Count> /// #3=<label for IEnumerable`1> /// #4=@"{#1} {#2}.Count`2(#3<T>);method" /// #5=@"{#4}T;typeparameter" /// </code> /// /// Note how <code>int</code> is referenced in the label definition <code>#3</code> for /// <code>Count</code>, while <code>T[]</code> is represented textually in order /// to make the reference to <code>#3</code> in the label definition <code>#4</code> for /// <code>T</code> valid. /// </summary> protected static void AddSignatureTypeToId(Context cx, ITrapBuilder tb, IMethodSymbol method, ITypeSymbol type) { if (type.ContainsTypeParameters(cx, method)) { type.BuildTypeId(cx, tb, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0)); } else { tb.Append(Type.Create(cx, type)); } }
/// <summary> /// Adds an appropriate label ID to the trap builder <paramref name="trapFile"/> /// for the type <paramref name="type"/> belonging to the signature of method /// <paramref name="method"/>. /// /// For methods without type parameters this will always add the key of the /// corresponding type. /// /// For methods with type parameters, this will add the key of the /// corresponding type if the type does *not* contain one of the method /// type parameters, otherwise it will add a textual representation of /// the type. This distinction is required because type parameter IDs /// refer to their declaring methods. /// /// Example: /// /// <code> /// int Count<T>(IEnumerable<T> items) /// </code> /// /// The label definitions for <code>Count</code> (<code>#4</code>) and <code>T</code> /// (<code>#5</code>) will look like: /// /// <code> /// #1=<label for System.Int32> /// #2=<label for type containing Count> /// #3=<label for IEnumerable`1> /// #4=@"{#1} {#2}.Count`2(#3<T>);method" /// #5=@"{#4}T;typeparameter" /// </code> /// /// Note how <code>int</code> is referenced in the label definition <code>#3</code> for /// <code>Count</code>, while <code>T[]</code> is represented textually in order /// to make the reference to <code>#3</code> in the label definition <code>#4</code> for /// <code>T</code> valid. /// </summary> protected static void AddSignatureTypeToId(Context cx, TextWriter trapFile, IMethodSymbol method, ITypeSymbol type) { if (type.ContainsTypeParameters(cx, method)) { type.BuildTypeId(cx, trapFile, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0)); } else { trapFile.WriteSubId(Type.Create(cx, type)); } }