-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expressions can be typed as open generic types #17121
Comments
Several of them can also be typed as byref and/or pointer types. |
Move existing default tests from SequenceTests.cs to new file and add more. Throw on null type in call to Default(). Fixes #8190. Throw on open generic, byref or pointer type to Default(). Contributes to #8081. # Conflicts: # src/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj
Move existing default tests from SequenceTests.cs to new file and add more. Throw on null type in call to Default(). Fixes #8190. Throw on open generic, byref or pointer type to Default(). Contributes to #8081.
Throw on open generic, byref or pointer type to NewArrayBounds(). Contributes to #8081. Also add further tests beyond this. Note that on byref this already threw TypeLoadException, but ArrayException would be more consistent.
Throw on open generic, byref or pointer type to Constant(). Contributes to #8081.
Contributes to #8081. Also add further tests beyond this. Note that on byref this already threw TypeLoadException, but ArgumentException would be more consistent.
Contributes to #8081. Just tests that it isn't accepted along with null constants (typed as object). Currently it is possible to create a ConditionalExpression that violates this rule, but it requires an other expression type to do so, so when the rest of #8081 is dealt with then coerced null would be the only remaining possibilty that wouldn't have already thrown in creating a child expression.
Contributes to #8081. Only explicit use of the types are corrected here; creating an open generic or byref jump expression through use of a value of such a type will be prohibited by the rest of #8081 preventing such values ever existing.
Contributes to #8081. Only explicit use of the types are corrected here; creating an open generic or byref jump expression through use of a value of such a type will be prohibited by the rest of #8081 preventing such values ever existing.
Contributes to #8081. Only explicit use of the types are corrected here; creating an open generic or byref jump expression through use of a value of such a type will be prohibited by the rest of #8081 preventing such values ever existing.
Also test open generics are prohibited. Contributes to #8081
Should the following be prohibited or allowed (they are currently allowed):
I'm fairly sure the Variable one is a bug (the C# compiler doesn't allow it), but I'm uncertain about Parameter. |
@hughbe Since And as far as open generic types go, I don't see any reason to allow them. |
@svick perf, I'll make a PR once dotnet/corefx#11701 is merged |
I've just found that |
Oh whoops I'm not sure I meant to close this issue. Feel free to reopen if u want |
I can't due to isaacs/github#583 |
Contributes to #8081 Futher test TypeAs validation.
I had been working systematically on this, before I wasn't able to contribute much for a while last summer. Need to track what, if anything remains in this, issue. Shall update the opening comment with a task list. |
Method which matches the required signature, but is declared on an open generic type. Contributes to #8081
Method which matches the required signature, but is declared on an open generic type. Contributes to #8081
Contributes to #8081, but since the current behaviour is to safely always return false, continue to allow pointer type operands. There is already code that examines these expressions for always-false or always-true behaviour, so have pointer types also result in the always-false path being taken.
Contributes to #8081. Also fill other testing gaps in MemberExpression.
Contributes to #8081, but since the current behaviour is to safely always return false, continue to allow pointer type operands. There is already code that examines these expressions for always-false or always-true behaviour, so have pointer types also result in the always-false path being taken.
Contributes to #8081 Block a case of a method from an open generic type.
Method which matches the required signature, but is declared on an open generic type. Contributes to #8081
Marking |
The likes of
Expression.Default(typeof(List<>))
,Expression.Constant(null, typeof(Dictionary<,>))
and some other expressions (though often other rules will get in the way) are allowed.Since these represent a value of an open generic type, they aren't really meaningful.
They can have a value of null which can be used as long as it is converted to
object
and both compilation types acceptExpression.Lambda<Func<object>>(Expression.Default(typeof(List<>)))
as an expression that can be compiled into a delegate that returns null.While they can be pressed into service, it seems more appropriate to prohibit them.
Factory methods that have at least one overload that takes
Type
arguments directly. Will check these off when they're either found to already prohibit such types, or fixed to do so (PRs just adding tests of already-correct behaviour marked immediately, PRs fixing behaviour upon acceptance):Block
(entailed in check that type is reference-assignable from type of last child expression).Break
Call
Test confirming Expression.Call fails with open generic type. corefx#17333Catch
Condition
Constant
Continue
Convert
ConvertChecked
Default
Dynamic
(Entailed in check that arguments match delegate method).Field
Prohibit open generics in Expression.Property and Expression.Field corefx#16231GetActionType
(Exception: Has practical use here)GetDelegateType
(Exception: Has practical use here)GetFuncType
(Exception: Has practical use here)Goto
Label
Throw on byref or pointer types in LabelTarget corefx#16140Lambda
Prohibit open generic delegate types for LambdaExpression corefx#16233MakeCatchBlock
MakeDynamic
(Entailed in check that arguments match delegate method).MakeGoto
MakeTry
(entailed by check that type is void or that body and catch types are reference-assignable)MakeUnary
Waiting on Throw on byref or pointer types in linq Throw expressions. corefx#16141New
NewArrayBounds
NewArrayInit
Parameter
(byref types allowed)Property
Prohibit open generics in Expression.Property and Expression.Field corefx#16231Rethrow
Throw on byref or pointer types in linq Throw expressions. corefx#16141Return
Switch
(Entailed by check that type is void or default and case types are reference-assignable)Throw
Throw on byref or pointer types in linq Throw expressions. corefx#16141TryGetActionType
(Exception: Has practical use here)TryGetFuncType
(Exception: Has practical use here)TypeAs
TypeEqual
Test and optimise TypeEqual and TypeIs behaviour for pointer types. corefx#16150 (pointer types allowed; always results infalse
)TypeIs
Test and optimise TypeEqual and TypeIs behaviour for pointer types. corefx#16150 (pointer types allowed; always results infalse
)Unbox
Test byref, pointer & generic types can't be used with Expression.Unbox corefx#16186Variable
Also the following have overrides that take
MemberInfo
, which could be generic and/or be related to an open generic type. Most will block this with restrictions they place on thoseMemberInfo
arguments relating to other types, but they need to be checked.Add
Add test of binary expression validation against generic methods. corefx#16142AddAsign
Add test of binary expression validation against generic methods. corefx#16142AddAsignChecked
Add test of binary expression validation against generic methods. corefx#16142AddChecked
Add test of binary expression validation against generic methods. corefx#16142And
Add test of binary expression validation against generic methods. corefx#16142AndAlso
Add test of binary expression validation against generic methods. corefx#16142AndAssign
Add test of binary expression validation against generic methods. corefx#16142Bind
Prohibit Expression.Bind with members of open generic types. corefx#18610Call
Convert
Add test of unary expression validation against generic methods. corefx#16437ConvertChecked
Add test of unary expression validation against generic methods. corefx#16437Decrement
Add test of unary expression validation against generic methods. corefx#16437Divide
Add test of binary expression validation against generic methods. corefx#16142DivideAssign
Add test of binary expression validation against generic methods. corefx#16142ElementInit
Equal
Add test of binary expression validation against generic methods. corefx#16142ExclusiveOr
Add test of binary expression validation against generic methods. corefx#16142ExclusiveOrAssign
Add test of binary expression validation against generic methods. corefx#16142Field
Prohibit open generics in Expression.Property and Expression.Field corefx#16231GreaterThan
Add test of binary expression validation against generic methods. corefx#16142GreaterThanOrEqual
Add test of binary expression validation against generic methods. corefx#16142Increment
Add test of unary expression validation against generic methods. corefx#16437IsFalse
Add test of unary expression validation against generic methods. corefx#16437IsTrue
Add test of unary expression validation against generic methods. corefx#16437LeftShift
Add test of binary expression validation against generic methods. corefx#16142LeftShiftAssign
Add test of binary expression validation against generic methods. corefx#16142LessThan
Add test of binary expression validation against generic methods. corefx#16142LessThanOrEqual
Add test of binary expression validation against generic methods. corefx#16142ListBind
Prohibit Expression.ListBind with members of open generic types. corefx#18011ListInit
Add tests of ListInit validation against generic methods. corefx#16624MakeBinary
Add test of binary expression validation against generic methods. corefx#16142MakeIndex
MakeMemberAccess
MakeUnary
Add test of unary expression validation against generic methods. corefx#16437MemberBind
(Covered by validation added in Prohibit Expression.ListBind with members of open generic types. corefx#18011 but also entailed by need of type to match).Modulo
Add test of binary expression validation against generic methods. corefx#16142ModuloAssign
Add test of binary expression validation against generic methods. corefx#16142Multiply
Add test of binary expression validation against generic methods. corefx#16142MultiplyAssign
Add test of binary expression validation against generic methods. corefx#16142MultiplyAssignChecked
Add test of binary expression validation against generic methods. corefx#16142MultiplyChecked
Add test of binary expression validation against generic methods. corefx#16142Negate
Add test of unary expression validation against generic methods. corefx#16437NegateChecked
Add test of unary expression validation against generic methods. corefx#16437New
Not
Add test of unary expression validation against generic methods. corefx#16437NotEqual
Add test of binary expression validation against generic methods. corefx#16142OnesComplement
Add test of unary expression validation against generic methods. corefx#16437Or
Add test of binary expression validation against generic methods. corefx#16142OrAssign
Add test of binary expression validation against generic methods. corefx#16142OrElse
Add test of binary expression validation against generic methods. corefx#16142PostDecrementAssign
Add test of unary expression validation against generic methods. corefx#16437PostIncrementAssign
Add test of unary expression validation against generic methods. corefx#16437Power
Add test of binary expression validation against generic methods. corefx#16142PowerAssign
Add test of binary expression validation against generic methods. corefx#16142PreDecrementAssign
Add test of unary expression validation against generic methods. corefx#16437PreIncrementAssign
Add test of unary expression validation against generic methods. corefx#16437Property
Prohibit open generics in Expression.Property and Expression.Field corefx#16231RightShift
Add test of binary expression validation against generic methods. corefx#16142RightShiftAssign
Add test of binary expression validation against generic methods. corefx#16142Subtract
Add test of binary expression validation against generic methods. corefx#16142SubtractAssign
Add test of binary expression validation against generic methods. corefx#16142SubtractAssignChecked
Add test of binary expression validation against generic methods. corefx#16142SubtractChecked
Add test of binary expression validation against generic methods. corefx#16142Switch
Prohibit open generic comparison methods in SwitchExpression corefx#16344UnaryPlus
Add test of unary expression validation against generic methods. corefx#16437The text was updated successfully, but these errors were encountered: