File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
lib/semmle/code/csharp/commons
src/utils/model-generator Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ class CollectionType extends RefType {
66
66
}
67
67
}
68
68
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
+
69
80
/** An object creation that creates an empty collection. */
70
81
class EmptyCollectionCreation extends ObjectCreation {
71
82
EmptyCollectionCreation ( ) {
Original file line number Diff line number Diff line change @@ -70,9 +70,14 @@ private predicate isPrimitiveTypeUsedForBulkData(Type t) {
70
70
t .getName ( ) .regexpMatch ( "byte|char|Byte|Char" )
71
71
}
72
72
73
+ private predicate isContainerType ( Type t ) {
74
+ t instanceof CollectionType or
75
+ t instanceof IEnumerableType
76
+ }
77
+
73
78
private string parameterAccess ( Parameter p ) {
74
79
if
75
- p .getType ( ) instanceof CollectionType and
80
+ isContainerType ( p .getType ( ) ) and
76
81
not isPrimitiveTypeUsedForBulkData ( p .getType ( ) .( ArrayType ) .getElementType ( ) )
77
82
then result = "Argument[" + p .getPosition ( ) + "].Element"
78
83
else result = "Argument[" + p .getPosition ( ) + "]"
You can’t perform that action at this time.
0 commit comments