File tree Expand file tree Collapse file tree
lib/semmle/code/csharp/commons
src/utils/model-generator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ class CollectionType extends RefType {
6666 }
6767}
6868
69+ /** An IEnumerable type. */
70+ class IEnumerableType extends RefType {
71+ IEnumerableType ( ) {
72+ this .hasQualifiedName ( "System.Collections" , "IEnumerable" )
73+ or
74+ this .( ConstructedType )
75+ .getUnboundGeneric ( )
76+ .hasQualifiedName ( "System.Collections.Generic" , "IEnumerable<>" )
77+ }
78+ }
79+
6980/** An object creation that creates an empty collection. */
7081class EmptyCollectionCreation extends ObjectCreation {
7182 EmptyCollectionCreation ( ) {
Original file line number Diff line number Diff line change @@ -70,9 +70,14 @@ private predicate isPrimitiveTypeUsedForBulkData(Type t) {
7070 t .getName ( ) .regexpMatch ( "byte|char|Byte|Char" )
7171}
7272
73+ private predicate isContainerType ( Type t ) {
74+ t instanceof CollectionType or
75+ t instanceof IEnumerableType
76+ }
77+
7378private string parameterAccess ( Parameter p ) {
7479 if
75- p .getType ( ) instanceof CollectionType and
80+ isContainerType ( p .getType ( ) ) and
7681 not isPrimitiveTypeUsedForBulkData ( p .getType ( ) .( ArrayType ) .getElementType ( ) )
7782 then result = "Argument[" + p .getPosition ( ) + "].Element"
7883 else result = "Argument[" + p .getPosition ( ) + "]"
You can’t perform that action at this time.
0 commit comments