Skip to content

Commit c8e2fa6

Browse files
committed
C#: Do not consider ref struct as being convertible to object, dynamic and valuetype.
1 parent 302bf4f commit c8e2fa6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

csharp/ql/lib/semmle/code/csharp/Conversion.qll

+8-5
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,14 @@ predicate convBoxing(Type fromType, Type toType) {
649649
}
650650

651651
private predicate convBoxingValueType(ValueType fromType, Type toType) {
652-
toType instanceof ObjectType
653-
or
654-
toType instanceof DynamicType
655-
or
656-
toType instanceof SystemValueTypeClass
652+
(
653+
toType instanceof ObjectType
654+
or
655+
toType instanceof DynamicType
656+
or
657+
toType instanceof SystemValueTypeClass
658+
) and
659+
not fromType.(Struct).isRef()
657660
or
658661
toType = fromType.getABaseInterface+()
659662
}

0 commit comments

Comments
 (0)