コード例 #1
0
ファイル: Method.cs プロジェクト: xcorail/ql
 /// <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&lt;T&gt;(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=&lt;label for System.Int32&gt;
 /// #2=&lt;label for type containing Count&gt;
 /// #3=&lt;label for IEnumerable`1&gt;
 /// #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));
     }
 }
コード例 #2
0
ファイル: Method.cs プロジェクト: Silentsoul04/Semmle.ql
 /// <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&lt;T&gt;(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=&lt;label for System.Int32&gt;
 /// #2=&lt;label for type containing Count&gt;
 /// #3=&lt;label for IEnumerable`1&gt;
 /// #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));
     }
 }