@@ -11,6 +11,7 @@ private import dotnet
1111private import semmle.code.csharp.metrics.Coupling
1212private import TypeRef
1313private import semmle.code.csharp.frameworks.System
14+ private import semmle.code.csharp.frameworks.system.runtime.CompilerServices
1415
1516/**
1617 * A type.
@@ -1008,6 +1009,58 @@ class NullableType extends ValueType, ConstructedType, @nullable_type {
10081009 override string getAPrimaryQlClass ( ) { result = "NullableType" }
10091010}
10101011
1012+ /**
1013+ * An inline array type, for example `MyInlineArray` in
1014+ * ```csharp
1015+ * [System.Runtime.CompilerServices.InlineArray(10)]
1016+ * public struct MyInlineArray
1017+ * {
1018+ * private int _elements0;
1019+ * }
1020+ * ```
1021+ */
1022+ class InlineArrayType extends ValueType , @inline_array_type {
1023+ private SystemRuntimeCompilerServicesInlineArrayAttribute inline_attribute ;
1024+ private Field element_type_field ;
1025+
1026+ InlineArrayType ( ) {
1027+ inline_attribute = this .( Attributable ) .getAnAttribute ( ) and
1028+ element_type_field = this .getAField ( ) and
1029+ not element_type_field .isStatic ( ) and
1030+ not element_type_field .isConst ( )
1031+ }
1032+
1033+ /**
1034+ * Gets the element type of this inline array.
1035+ */
1036+ Type getElementType ( ) { result = element_type_field .getType ( ) }
1037+
1038+ /**
1039+ * Gets the rank of this inline array (inline arrays always have rank 1).
1040+ */
1041+ int getRank ( ) { result = 1 }
1042+
1043+ /**
1044+ * Gets the length of this inline array.
1045+ */
1046+ int getLength ( ) { result = inline_attribute .getLength ( ) }
1047+
1048+ /**
1049+ * Gets the dimension of this inline array.
1050+ */
1051+ int getDimension ( ) {
1052+ exists ( Type elem | elem = this .getElementType ( ) |
1053+ result = elem .( InlineArrayType ) .getDimension ( ) + 1
1054+ or
1055+ result = elem .( ArrayType ) .getDimension ( ) + 1
1056+ or
1057+ not elem instanceof ArrayType and not elem instanceof InlineArrayType and result = 1
1058+ )
1059+ }
1060+
1061+ override string getAPrimaryQlClass ( ) { result = "InlineArrayType" }
1062+ }
1063+
10111064/**
10121065 * An array type, for example `int[]`.
10131066 */
0 commit comments