summaryrefslogtreecommitdiff
path: root/tests/src/Loader/classloader/generics/Constraints
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2016-04-13 10:40:38 -0700
committerFadi Hanna <fadim@microsoft.com>2016-04-13 10:40:38 -0700
commit517207b9d3f2a53c726a8682c1331cf7bdb0360b (patch)
tree0820a51d24dfc90797c64de3097653a213ed47ba /tests/src/Loader/classloader/generics/Constraints
parent8beda3c1561aa7a4b4a18ea98e719fc9fd52a638 (diff)
parentb7e35b9c3d87ba84b859f9f9f795857dfbbda653 (diff)
downloadcoreclr-517207b9d3f2a53c726a8682c1331cf7bdb0360b.tar.gz
coreclr-517207b9d3f2a53c726a8682c1331cf7bdb0360b.tar.bz2
coreclr-517207b9d3f2a53c726a8682c1331cf7bdb0360b.zip
Merge pull request #4295 from fadimounir/typesystemtests
Bulk port of TypeSystem test cases
Diffstat (limited to 'tests/src/Loader/classloader/generics/Constraints')
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj23
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj28
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj23
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj23
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj23
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj23
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config4
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json26
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il2
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj25
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.il171
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.cs158
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.il82
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.il110
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.il134
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.il112
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.il117
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.il87
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.cs187
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.il209
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.il223
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.il178
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.il146
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.il176
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.il189
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.il233
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.il190
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.il165
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.il318
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.il504
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.il484
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.cs208
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.il93
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.cs187
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.il218
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.il181
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.il131
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.il179
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.il87
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.cs181
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.il187
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.il162
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.il123
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.il162
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.cs121
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.csproj43
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.cs123
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.csproj43
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.il117
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.il131
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.il150
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.il166
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.cs151
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.il80
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.il77
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.il104
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.il144
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.il104
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.il68
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.il68
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.il66
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.il86
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.il52
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.il57
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.il57
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.ilproj42
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.il173
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.cs157
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.il83
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.il112
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.il133
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.il108
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.il154
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.cs152
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.csproj48
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.il79
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.il102
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.il124
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.il101
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.il117
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.il131
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.il151
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.ilproj38
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.cs155
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.csproj39
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/General/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/General/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.cs198
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.csproj39
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Recursion/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Recursion/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.cs132
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.csproj39
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/532403/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/532403/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.cs30
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.csproj39
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.cs188
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.csproj39
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/app.config27
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/project.json35
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.cs37
-rw-r--r--tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.csproj39
181 files changed, 14407 insertions, 104 deletions
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il
index 454cdc53f8..1ad189851f 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly extern types{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj
index 7187cb451a..1798e52f10 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_ClassConstraint_Neg.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj
index b8677916bb..dbfebd583d 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,31 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Exe</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
<CLRTestKind>BuildAndRun</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_Constraints_Negative.cs" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
<None Include="project.json" />
</ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
+
<ItemGroup>
<ProjectReference Include="Method_ClassConstraint_Neg.ilproj" />
<ProjectReference Include="Method_DefaultCtorAndClassConstraint_Neg.ilproj" />
@@ -46,7 +40,9 @@
<ProjectReference Include="Method_StructConstraint_Neg.ilproj" />
<ProjectReference Include="types.ilproj" />
</ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il
index fd926bb4fe..ac585b387d 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly extern types{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj
index ec74a8cafe..7d3463cbcf 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_DefaultCtorAndClassConstraint_Neg.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il
index 5214b72882..17b2cfde50 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly extern types{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj
index d5f7e5dc6d..1e49b3a613 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_DefaultCtorAndStructConstraint_Neg.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il
index 9bf744bc72..eaed96b0db 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly extern types{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj
index d0d36a934d..1ba82f71f9 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_DefaultCtorConstraint_Neg.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il
index 570576c59a..315cb05a21 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly extern types{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj
index 3611ac569b..9b799cd78c 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
<Compile Include="Method_StructConstraint_Neg.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config
index 62803f5972..e5622f77ad 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version = "1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@@ -24,4 +24,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
-</configuration> \ No newline at end of file
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json
index cda793f996..a2e84dc340 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json
@@ -1,9 +1,33 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
"System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
"System.Runtime": "4.1.0-rc2-23816",
- "System.Runtime.Extensions": "4.0.10"
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
},
"frameworks": {
"dnxcore50": {}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il
index a43bb72b20..53c0b9e255 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+.assembly extern System.Console { }
+
.assembly extern mscorlib{}
.assembly Types {}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj
index 9fc7db8e42..e90ddd06ea 100644
--- a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
@@ -7,37 +7,32 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
- <OutputType>Library</OutputType>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
<CLRTestKind>BuildOnly</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
+
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
+
<ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="types.il" />
+ <Compile Include="types.il" />
</ItemGroup>
+
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
+
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.il
new file mode 100644
index 0000000000..ec498b24ef
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.il
@@ -0,0 +1,171 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Method_ClassConstraint_Pos {}
+
+
+
+.class public auto ansi beforefieldinit B
+ extends [mscorlib]System.Object
+{
+
+ // Generic method with class() constraint
+ .method public hidebysig instance void
+ method1<class T>() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit M_ClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]ClassWithCtor>()
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]ClassNoCtor>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]Delegate1>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [mscorlib]System.Object>()
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [mscorlib]System.ValueType>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]NonGenInterface>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]ClassWithCtor[]>()
+
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit M_ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]GenClassWithCtor<int32>>()
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]GenClassNoCtor<int32>>()
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B::.ctor()
+ call instance void class B::method1<class [types]GenInterface<int32>>()
+
+ ret
+ }
+
+
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..0dea3bb999
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_ClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_ClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_ClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.cs
new file mode 100644
index 0000000000..9533f0a104
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.cs
@@ -0,0 +1,158 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// POSITIVE TESTS
+/* Test various combinations of constraints on methods
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference tyoe
+default ctor, valuetype
+
+Test each constraint with
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string violatingType, string type)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+
+ Console.WriteLine(" : PASS");
+ return;
+ }
+ catch (TypeLoadException e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected TypeLoadException: " + e);
+ pass = false;
+ return;
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("POSITIVE TESTS");
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+
+ Check(new Case(M_DefaultCtorConstraint.Test1), "Generic argument is a class with default ctor", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorConstraint.Test3), "Generic argument is a struct (valuetypes have public nullary ctors by default)", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "N/A", "N/A");
+
+ // enum is a valueypte and all valuetypes have public nullary ctors.
+ Check(new Case(M_DefaultCtorConstraint.Test8), "Generic argument is an enum", "N/A", "N/A");
+
+
+ Check(new Case(M_DefaultCtorConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorConstraintGenTypes.Test3), "Generic argument is a generic struct", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorConstraintGenTypes.Test6), "Generic argument is Nullable<T>", "N/A", "N/A");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+
+
+ Check(new Case(M_ClassConstraint.Test1), "Generic argument is a class with default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraint.Test2), "Generic argument is a class with no default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraint.Test4), "Generic argument is a delegate", "N/A", "N/A");
+ Check(new Case(M_ClassConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraint.Test7), "Generic argument is an interface", "N/A", "N/A");
+
+
+ Check(new Case(M_ClassConstraint.Test9), "Generic argument is an array of classes with default ctor", "N/A", "N/A");
+
+ Check(new Case(M_ClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "N/A", "N/A");
+ Check(new Case(M_ClassConstraintGenTypes.Test5), "Generic argument is a generic interface", "N/A", "N/A");
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+
+
+ Check(new Case(M_StructConstraint.Test3), "Generic argument is a struct", "N/A", "N/A");
+ Check(new Case(M_StructConstraint.Test8), "Generic argument is an enum", "N/A", "N/A");
+ Check(new Case(M_StructConstraint.Test9), "Generic argument is an mscorlib struct", "N/A", "N/A");
+
+ Check(new Case(M_StructConstraintGenTypes.Test3), "Generic argument is a generic struct", "N/A", "N/A");
+ Check(new Case(M_StructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "N/A", "N/A");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+
+ Check(new Case(M_DefaultCtorAndClassConstraint.Test1), "Generic argument is a class with default ctor", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndClassConstraint.Test5), "Generic argument is a is an mscorlib class with default ctor", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "N/A", "N/A");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+
+
+ Check(new Case(M_DefaultCtorAndStructConstraint.Test3), "Generic argument is a struct", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndStructConstraint.Test9), "Generic argument is an mscorlib struct", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test3), "Generic argument is a generic struct", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "N/A", "N/A");
+ Check(new Case(M_DefaultCtorAndStructConstraint.Test8), "Generic argument is an enum", "N/A", "N/A");
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.csproj
new file mode 100644
index 0000000000..11baa29070
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_Constraints_Positive.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_Constraints_Positive</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_Constraints_Positive.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="Method_ClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="Method_DefaultCtorAndClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="Method_DefaultCtorAndStructConstraint_Pos.ilproj" />
+ <ProjectReference Include="Method_DefaultCtorConstraint_Pos.ilproj" />
+ <ProjectReference Include="Method_StructConstraint_Pos.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.il
new file mode 100644
index 0000000000..bdfe960750
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.il
@@ -0,0 +1,82 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Method_DefaultCtorAndClassConstraint_Pos {}
+
+
+
+.class public auto ansi beforefieldinit D
+ extends [mscorlib]System.Object
+{
+
+ // Generic method with class() and new() constraints
+ .method public hidebysig instance void
+ method1<class .ctor T>() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D::.ctor()
+ call instance void class D::method1<class [types]ClassWithCtor>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D::.ctor()
+ call instance void class D::method1<class [mscorlib]System.Object>()
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D::.ctor()
+ call instance void class D::method1<class [types]GenClassWithCtor<int32>>()
+
+ ret
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..b4ff4c337d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_DefaultCtorAndClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_DefaultCtorAndClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.il
new file mode 100644
index 0000000000..c9b223f097
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.il
@@ -0,0 +1,110 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Method_DefaultCtorAndStructConstraint_Pos {}
+
+
+
+.class public auto ansi beforefieldinit E
+ extends [mscorlib]System.Object
+{
+
+ // Generic method with struct() and new() constraints
+ .method public hidebysig instance void
+ method1<valuetype .ctor T>() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E::.ctor()
+ call instance void class E::method1<valuetype [types]NonGenStruct>()
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E::.ctor()
+ call instance void class E::method1<valuetype [types]Enum1>()
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E::.ctor()
+ call instance void class E::method1<valuetype [mscorlib]System.DateTime>()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E::.ctor()
+ call instance void class E::method1<valuetype [types]GenStruct<int32>>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E::.ctor()
+ call instance void class E::method1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>()
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..958c9f1630
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorAndStructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_DefaultCtorAndStructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_DefaultCtorAndStructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.il
new file mode 100644
index 0000000000..71e7662830
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.il
@@ -0,0 +1,134 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Method_DefaultCtorConstraint_Pos {}
+
+
+.class public auto ansi beforefieldinit A
+ extends [mscorlib]System.Object
+{
+
+ // Generic method with new() constraint
+ .method public hidebysig instance void
+ method1<.ctor T>() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<class [types]ClassWithCtor>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<valuetype [types]NonGenStruct>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<class [mscorlib]System.Object>()
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<valuetype [types]Enum1>()
+ ret
+ }
+
+
+}
+
+.class public auto ansi beforefieldinit M_DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<class [types]GenClassWithCtor<int32>>()
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<valuetype [types]GenStruct<int32>>()
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A::.ctor()
+ call instance void class A::method1<valuetype [mscorlib]System.'Nullable`1'<int32>>()
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.ilproj
new file mode 100644
index 0000000000..12545dfb80
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_DefaultCtorConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_DefaultCtorConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_DefaultCtorConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.il
new file mode 100644
index 0000000000..284d48e0f4
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.il
@@ -0,0 +1,112 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Method_StructConstraint_Pos {}
+
+
+
+.class public auto ansi beforefieldinit C
+ extends [mscorlib]System.Object
+{
+
+ // Generic method with class() constraint
+ .method public hidebysig instance void
+ method1<valuetype T>() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit M_StructConstraint
+ extends [mscorlib]System.Object
+{
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C::.ctor()
+ call instance void class C::method1<valuetype [types]NonGenStruct>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C::.ctor()
+ call instance void class C::method1<valuetype [types]Enum1>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C::.ctor()
+ call instance void class C::method1<valuetype [mscorlib]System.DateTime>()
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit M_StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C::.ctor()
+ call instance void class C::method1<valuetype [types]GenStruct<int32>>()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C::.ctor()
+ call instance void class C::method1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>()
+
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..f16948d7e8
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/Method_StructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Method_StructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Method_StructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/app.config b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/project.json b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.il
new file mode 100644
index 0000000000..53c0b9e255
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.il
@@ -0,0 +1,117 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly Types {}
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.ilproj
new file mode 100644
index 0000000000..e90ddd06ea
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Positive/types.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.il
new file mode 100644
index 0000000000..dfe74b8207
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.il
@@ -0,0 +1,87 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_ClassConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit ClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<valuetype [types]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<valuetype [types]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<valuetype [types]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..cfb4c80e0c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_ClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_ClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_ClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.cs
new file mode 100644
index 0000000000..0166e701e2
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.cs
@@ -0,0 +1,187 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with illegal parameter types by instantiating the types
+
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference type
+default ctor, valuetype
+
+Test each constraint with (whichever applies to negative tests)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+
+
+
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string violatingType, string type)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, e, violatingType, type);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, TypeLoadException e, string violatingType, string type )
+ {
+ if (
+ !e.ToString().Contains("0") ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains("T"))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(DefaultCtorConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "A`1[T]");
+ Check(new Case(DefaultCtorConstraint.Test4), "Generic argument is a delegate", "Delegate1", "A`1[T]");
+ Check(new Case(DefaultCtorConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "A`1[T]");
+ Check(new Case(DefaultCtorConstraint.Test7), "Generic argument is an interface with no default ctor", "NonGenInterface", "A`1[T]");
+ Check(new Case(DefaultCtorConstraint.Test9), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "A`1[T]");
+ Check(new Case(DefaultCtorConstraintGenTypes.Test2), " Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "A`1[T]");
+ Check(new Case(DefaultCtorConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "A`1[T]");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(ClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "B`1[T]");
+ Check(new Case(ClassConstraint.Test8), "Generic argument is an enum", "Enum1", "B`1[T]");
+ Check(new Case(ClassConstraintGenTypes.Test3), "Generic argument is a generic struct with default ctor", "GenStruct[System.Int32]", "B`1[T]");
+ Check(new Case(ClassConstraintGenTypes.Test6), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "B`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(StructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "C`1[T]");
+ Check(new Case(StructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "C`1[T]");
+ Check(new Case(StructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "C`1[T]");
+ Check(new Case(StructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "C`1[T]");
+ Check(new Case(StructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "C`1[T]");
+ Check(new Case(StructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "C`1[T]");
+ Check(new Case(StructConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "C`1[T]");
+ Check(new Case(StructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "C`1[T]");
+ Check(new Case(StructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "C`1[T]");
+ Check(new Case(StructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "C`1[T]");
+ Check(new Case(StructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "C`1[T]");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(DefaultCtorAndClassConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test4), "Generic argument is a delegate", "Delegate1", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test9), "Generic argument is an mscorlib struct", "System.DateTime", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test8), "Generic argument is an enum", "Enum1", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test3), "Generic argument is a generic struct", "GenStruct[System.Int32]", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "System.Collections.Generic.KeyValuePair`2[NonGenStruct,System.Int32]", "D`1[T]");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "D`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(DefaultCtorAndStructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraint.Test10), "Generic argument is an array of classes with default ctor", "NonGenStruct[]", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "E`1[T]");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "E`1[T]");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.csproj
new file mode 100644
index 0000000000..19f8ea1469
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_Constraints_Neg.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_Constraints_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_Constraints_Neg.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="Instantiation_ClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorAndClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorAndStructConstraint_Neg.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorConstraint_Neg.ilproj" />
+ <ProjectReference Include="Instantiation_StructConstraint_Neg.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.il
new file mode 100644
index 0000000000..37f590114a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.il
@@ -0,0 +1,209 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorAndClassConstraint_Neg {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]ClassNoCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ newobj instance void class D`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [mscorlib]System.DateTime>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a generic struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an generic interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..c835970db4
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.il
new file mode 100644
index 0000000000..8cbb4d092c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.il
@@ -0,0 +1,223 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI_extendC {}
+
+.assembly Instantiation_DefaultCtorAndClassTypeConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit F`1<.ctor ([types_implementI_extendC]C) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+
+
+.class public auto ansi beforefieldinit Instantiation_DefaultCtorAndClassTypeConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor that doesn't extend C
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum (has default ctor since it's a valuetype)
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test11() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a generic class with default ctor that implements I but doesn't extend C
+ .method public hidebysig static void Test12() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test13() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test14() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+
+
+
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.ilproj
new file mode 100644
index 0000000000..9d9f4959b9
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndClassTypeConstraint_Neg.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndClassTypeConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndClassTypeConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="types_implementI_extendC.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.il
new file mode 100644
index 0000000000..7edb3d609b
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.il
@@ -0,0 +1,178 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorAndStructConstraint_Neg {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]ClassNoCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ newobj instance void class E`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types]NonGenStruct[]>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..e6068f0920
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorAndStructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndStructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndStructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.il
new file mode 100644
index 0000000000..60da97a375
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.il
@@ -0,0 +1,146 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test10<M>() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<!!M>::.ctor()
+ pop
+
+ ret
+ }
+
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.ilproj
new file mode 100644
index 0000000000..766a567ddc
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_DefaultCtorConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.il
new file mode 100644
index 0000000000..27f71b129b
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.il
@@ -0,0 +1,176 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_StructConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit StructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]ClassNoCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ newobj instance void class C`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<class [types]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..daad12889c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Instantiation_StructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_StructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_StructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.il
new file mode 100644
index 0000000000..6b794e184d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.il
@@ -0,0 +1,189 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorAndClassConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit D`1<class .ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum (has default ctor since it's a valuetype)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types_implementI]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test11() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types_implementI]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test12() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<valuetype [types_implementI]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..40eb841f32
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.il
new file mode 100644
index 0000000000..73f3f7529d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.il
@@ -0,0 +1,233 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI_extendC {}
+
+.assembly Interface_DefaultCtorAndClassTypeConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit F`1<class .ctor ([types_implementI_extendC]C, [types_implementI_extendC]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndClassTypeConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor that implements I but doesn't extend C
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum (has default ctor since it's a valuetype)
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test11() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a generic class with default ctor that implements I but doesn't extend C
+ .method public hidebysig static void Test12() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test13() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test14() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<valuetype [types_implementI_extendC]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor that doesn't implements I but extends C
+ .method public hidebysig static void Test15() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor2>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.ilproj
new file mode 100644
index 0000000000..402afc6280
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndClassTypeConstraint_Neg.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndClassTypeConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndClassTypeConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="types_implementI_extendC.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.il
new file mode 100644
index 0000000000..ea076ff329
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.il
@@ -0,0 +1,190 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorAndStructConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit E`1<valuetype .ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+
+
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum (has default ctor since it's a valuetype)
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types_implementI]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test11() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test12() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<class [types_implementI]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..8804ce1fd6
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorAndStructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndStructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndStructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.il
new file mode 100644
index 0000000000..5e3abe0975
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.il
@@ -0,0 +1,165 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]ClassNoCtor>::.ctor()
+ pop
+
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum (has default ctor since it's a valuetype)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types_implementI]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+
+// NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.ilproj
new file mode 100644
index 0000000000..9e9a1e7422
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Interface_DefaultCtorConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.il
new file mode 100644
index 0000000000..a5c0ab1493
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.il
@@ -0,0 +1,318 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib {}
+.assembly extern TypeParam_Constraints_Neg {}
+.assembly RunTestNeg {}
+
+
+.class public auto ansi beforefieldinit GClass`2<(!U) T,class U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit GStruct`2<(!U) T, valuetype U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class public auto ansi beforefieldinit GNew`2<(!U) T,.ctor U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit GClassType`2<(!U) T,([TypeParam_Constraints_Neg]A) U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit GInterfaceType`2<(!U) T,([TypeParam_Constraints_Neg]I) U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// ===============================================================================
+
+.class public auto ansi beforefieldinit RunGClassTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClass`2<class [TypeParam_Constraints_Neg]A,class [TypeParam_Constraints_Neg]B>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClass`2<class [TypeParam_Constraints_Neg]I,class [TypeParam_Constraints_Neg]C>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClass`2<object,class [TypeParam_Constraints_Neg]A[]>::.ctor()
+ pop
+ ret
+ }
+
+
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClass`2<object,class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClass`2<int32,int32>::.ctor()
+ pop
+ ret
+ }
+}
+
+// ===============================================================================
+
+.class public auto ansi beforefieldinit RunGStructTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<class [TypeParam_Constraints_Neg]A,class [TypeParam_Constraints_Neg]B>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<class [TypeParam_Constraints_Neg]I,class [TypeParam_Constraints_Neg]C>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<object,valuetype [TypeParam_Constraints_Neg]S>::.ctor()
+ pop
+ ret
+ }
+
+
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<valuetype [TypeParam_Constraints_Neg]S,class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<int32,object>::.ctor()
+ pop
+ ret
+ }
+
+}
+
+// ===============================================================================
+
+
+.class public auto ansi beforefieldinit RunGNewTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GNew`2<valuetype [TypeParam_Constraints_Neg]Enum1, class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GNew`2<class [TypeParam_Constraints_Neg]C, class [TypeParam_Constraints_Neg] I>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GNew`2<class [TypeParam_Constraints_Neg]A[],class [TypeParam_Constraints_Neg]A[]>::.ctor()
+ pop
+ ret
+ }
+
+
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GNew`2<object, class [TypeParam_Constraints_Neg]A>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GNew`2<int32,class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+}
+
+// ===============================================================================
+
+.class public auto ansi beforefieldinit RunGClassTypeTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClassType`2<class [mscorlib]System.String, class [mscorlib]System.Object>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClassType`2<class [TypeParam_Constraints_Neg]A, class [mscorlib]System.Object>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClassType`2<class [TypeParam_Constraints_Neg]A[],class [TypeParam_Constraints_Neg]A[]>::.ctor()
+ pop
+ ret
+ }
+
+
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClassType`2<object, class [TypeParam_Constraints_Neg]A>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GClassType`2<int32,int32>::.ctor()
+ pop
+ ret
+ }
+
+}
+
+// ===============================================================================
+
+.class public auto ansi beforefieldinit RunGInterfaceTypeTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GInterfaceType`2<class [mscorlib]System.String, class [mscorlib]System.Object>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GInterfaceType`2<class [TypeParam_Constraints_Neg]I, object>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GInterfaceType`2<class [TypeParam_Constraints_Neg]I[],class [TypeParam_Constraints_Neg]I[]>::.ctor()
+ pop
+ ret
+ }
+
+
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GInterfaceType`2<object, class [TypeParam_Constraints_Neg]I>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GInterfaceType`2<int32,int32>::.ctor()
+ pop
+ ret
+ }
+
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.ilproj
new file mode 100644
index 0000000000..d347a1a2d5
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestNeg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestNeg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="TypeParam_Constraints_Neg.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.il
new file mode 100644
index 0000000000..90f076dfba
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.il
@@ -0,0 +1,504 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+// See test descriptions below
+
+.assembly extern mscorlib {}
+
+.assembly RunTestNeg2 {}
+
+
+.class public auto ansi beforefieldinit A
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public sequential ansi sealed beforefieldinit S
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+
+.class interface public abstract auto ansi I {}
+
+
+
+.class private auto ansi beforefieldinit GClass`1<class T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit GStruct`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class public auto ansi beforefieldinit GNew`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// ============================================================
+
+
+.class private auto ansi beforefieldinit G1`1<valuetype P>
+ extends class GClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G2`1<(I) P>
+ extends class GClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G3`1<([mscorlib]System.Object) P>
+ extends class GClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G4`1<([mscorlib]System.ValueType) P>
+ extends class GClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G5`1<([mscorlib]System.Enum) P>
+ extends class GClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+ // ============================================================
+
+
+.class private auto ansi beforefieldinit G6`1<class P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G7`1<(A) P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G8`1<(I) P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G12`1<(System.ValueType) P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G13`1<(valuetype [mscorlib]System.'Nullable`1'<int32>) P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+ // ============================================================
+
+.class public auto ansi beforefieldinit G9`1<(A) P>
+ extends class GNew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit G10`1<class P>
+ extends class GNew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit G11`1<(I) P>
+ extends class GNew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+ // ============================================================
+
+.class public auto ansi beforefieldinit RunTest
+ extends [mscorlib]System.Object
+{
+
+ // TEST 1
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has 'struct' constraint
+ // use a class as type param
+ .method public hidebysig static void Test1() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G1`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 2
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has 'struct' constraint
+ // use a struct as type param
+ .method public hidebysig static void Test2() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G1`1<valuetype S>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 3
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has interface-type constraint
+ // This is a secondary constraint - this tells us nothing about the eventual instantiation that
+ // we can use here.
+
+ .method public hidebysig static void Test3() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G2`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 4
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.Object constraint
+ .method public hidebysig static void Test4() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G3`1<object>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 5
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.ValueType constraint
+ .method public hidebysig static void Test5() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G4`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 6
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.Enum constraint
+ .method public hidebysig static void Test6() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G5`1<class [mscorlib]System.Enum>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 7
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class' constraint
+ // instantiated with a class
+ .method public hidebysig static void Test7() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G6`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 8
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class' constraint
+ // instantiated with a struct
+ .method public hidebysig static void Test8() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G6`1<valuetype S>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 9
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class-type' constraint
+ .method public hidebysig static void Test9() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G7`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 10
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'interface-type' constraint
+ .method public hidebysig static void Test10() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G8`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 11
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'class-type' constraint
+ // Since constraints are not inherited this is a negative test because P doesn't have new constraint
+ // and since not all reference types have default ctor we do not accept this constraint.
+ .method public hidebysig static void Test11() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G9`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 12
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'class' constraint
+ .method public hidebysig static void Test12() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G10`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 13
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'interface-type' constraint
+ .method public hidebysig static void Test13() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G11`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 14
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'System.ValueType' constraint
+ .method public hidebysig static void Test14() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G12`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 15
+ // NEGATIVE
+ // T has 'struct'Nullable<int>' constraint
+ .method public hidebysig static void Test15() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G12`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+ ret
+ }
+
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.ilproj
new file mode 100644
index 0000000000..c77596dbb6
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg2.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestNeg2</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestNeg2.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.il
new file mode 100644
index 0000000000..403c9f1505
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.il
@@ -0,0 +1,484 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+// See test descriptions below
+
+.assembly extern mscorlib {}
+
+.assembly RunTestNeg3 {}
+
+
+.class public auto ansi beforefieldinit A
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public sequential ansi sealed beforefieldinit S
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+
+.class interface public abstract auto ansi I {}
+
+
+
+.class interface public abstract auto ansi IClass`1<class T> {}
+
+.class interface public abstract auto ansi IStruct`1<valuetype T> {}
+
+.class interface public abstract auto ansi INew`1<.ctor T> {}
+
+// ============================================================
+
+
+.class private auto ansi beforefieldinit G1`1<valuetype P>
+ extends [mscorlib]System.Object
+ implements class IClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G2`1<(I) P>
+ extends [mscorlib]System.Object
+ implements class IClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G3`1<([mscorlib]System.Object) P>
+ extends [mscorlib]System.Object
+ implements class IClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G4`1<([mscorlib]System.ValueType) P>
+ extends [mscorlib]System.Object
+ implements class IClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G5`1<([mscorlib]System.Enum) P>
+ extends [mscorlib]System.Object
+ implements class IClass`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+ // ============================================================
+
+.class private auto ansi beforefieldinit G6`1<class P>
+ extends [mscorlib]System.Object
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G7`1<(A) P>
+ extends [mscorlib]System.Object
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G8`1<(I) P>
+ extends [mscorlib]System.Object
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+.class private auto ansi beforefieldinit G12`1<(System.ValueType) P>
+ extends [mscorlib]System.Object
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class private auto ansi beforefieldinit G13`1<(valuetype [mscorlib]System.'Nullable`1'<int32>) P>
+ extends [mscorlib]System.Object
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+ // ============================================================
+
+.class public auto ansi beforefieldinit G9`1<(A) P>
+ extends [mscorlib]System.Object
+ implements class INew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit G10`1<class P>
+ extends [mscorlib]System.Object
+ implements class INew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit G11`1<(I) P>
+ extends [mscorlib]System.Object
+ implements class INew`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+
+ // ============================================================
+
+.class public auto ansi beforefieldinit RunTest
+ extends [mscorlib]System.Object
+{
+
+ // TEST 1
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has 'struct' constraint
+ // use a class as type param
+ .method public hidebysig static void Test1() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G1`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 2
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has 'struct' constraint
+ // use a struct as type param
+ .method public hidebysig static void Test2() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G1`1<valuetype S>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 3
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has interface-type constraint
+ // This is a secondary constraint - this tells us nothing about the eventual instantiation that
+ // we can use here.
+
+ .method public hidebysig static void Test3() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G2`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 4
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.Object constraint
+ .method public hidebysig static void Test4() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G3`1<object>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 5
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.ValueType constraint
+ .method public hidebysig static void Test5() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G4`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 6
+ // NEGATIVE
+ // T has 'class' constraint BUT
+ // P has System.Enum constraint
+ .method public hidebysig static void Test6() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G5`1<class [mscorlib]System.Enum>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 7
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class' constraint
+ // instantiated with a class
+ .method public hidebysig static void Test7() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G6`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 8
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class' constraint
+ // instantiated with a struct
+ .method public hidebysig static void Test8() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G6`1<valuetype S>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 9
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'class-type' constraint
+ .method public hidebysig static void Test9() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G7`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 10
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'interface-type' constraint
+ .method public hidebysig static void Test10() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G8`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 11
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'class-type' constraint
+ // Since constraints are not inherited this is a negative test because P doesn't have new constraint
+ // and since not all reference types have default ctor we do not accept this constraint.
+ .method public hidebysig static void Test11() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G9`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 12
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'class' constraint
+ .method public hidebysig static void Test12() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G10`1<class A>::.ctor()
+ pop
+ ret
+ }
+
+
+ // =====================================================================
+
+ // TEST 13
+ // NEGATIVE
+ // T has 'new' constraint BUT
+ // P has 'interface-type' constraint
+ .method public hidebysig static void Test13() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G11`1<class I>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 14
+ // NEGATIVE
+ // T has 'struct' constraint BUT
+ // P has 'System.ValueType' constraint
+ .method public hidebysig static void Test14() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G12`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+ // =====================================================================
+
+ // TEST 15
+ // NEGATIVE
+ // T has 'struct'Nullable<int>' constraint
+ .method public hidebysig static void Test15() cil managed
+ {
+
+ .maxstack 1
+ newobj instance void class G12`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+ ret
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.ilproj
new file mode 100644
index 0000000000..c7845e854a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/RunTestNeg3.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestNeg3</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestNeg3.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.cs
new file mode 100644
index 0000000000..769235f9a3
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.cs
@@ -0,0 +1,208 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// NEGATIVE TESTS
+/*
+
+The following constraint combinations are tested:
+
+- Interface-type, New()
+- class, Interface-type, New()
+- struct, Interface-type, New()
+- Class-type, Interface-type, New()
+- Class-type, New()
+
+
+Each is tested with type parameter (whichever is valid in negative tests):
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+*/
+
+using System;
+using System.Security;
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string violatingType, string type)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, e, violatingType, type);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, TypeLoadException e, string violatingType, string type )
+ {
+ if (
+ !e.ToString().Contains("0") ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains("T"))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Console.WriteLine("\nType: A<T> where T : I, new()\n");
+
+
+ Check(new Case(Interface_DefaultCtorConstraint.Test1), "Generic argument is a class with no default ctor", "ClassNoCtor", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint .Test2), "Generic argument is an mscorlib class with default ctor", "System.Object", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint.Test3), "Generic argument is a delegate", "Delegate1", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint .Test4), "Generic argument is an enum", "Enum1", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint.Test5), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint.Test6), "Generic argument is an interface with no default ctor", "NonGenInterface", "A`1[T]");
+
+ Check(new Case(Interface_DefaultCtorConstraint.Test7), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "A`1[T]");
+
+ Check(new Case(Interface_DefaultCtorConstraint.Test8), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint.Test9), "Generic argument is a generic interface", "GenInterface[System.Int32]", "A`1[T]");
+ Check(new Case(Interface_DefaultCtorConstraint.Test10), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "A`1[T]");
+
+ Console.WriteLine("\nType: A<T> where T : class, I, new() \n");
+
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test1), "Generic argument is a class with no default ctor", "ClassNoCtor", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test2), "Generic argument is an mscorlib class with default ctor", "System.Object", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test3), "Generic argument is a delegate", "Delegate1", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test4), "Generic argument is an enum", "Enum1", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test5), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test6), "Generic argument is an interface with no default ctor", "NonGenInterface", "D`1[T]");
+
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test7), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "D`1[T]");
+
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test8), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test9), "Generic argument is a generic interface", "GenInterface[System.Int32]", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test10), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "D`1[T]");
+
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test11), "Generic argument is a struct", "NonGenStruct", "D`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassConstraint.Test12), "Generic argument is a generic struct", "GenStruct[System.Int32]", "D`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct, I, new()\n");
+
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test3), "Generic argument is an mscorlib class with default ctor", "System.Object", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test5), "Generic argument is an enum", "Enum1", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test8), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test9), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test10), "Generic argument is a generic interface", "GenInterface[System.Int32]", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test11), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "E`1[T]");
+ Check(new Case(Interface_DefaultCtorAndStructConstraint.Test12), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "E`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : C, I, new()\n");
+
+
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test1), "Generic argument is a class with default ctor, implements I, doesn't extend C", "ClassWithCtor", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test15), "Generic argument is a class with default ctor, doesn't implement I but extends C", "ClassWithCtor2", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test3), "Generic argument is an mscorlib class with default ctor", "System.Object", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test4), "Generic argument is a delegate", "Delegate1", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test5), "Generic argument is an enum", "Enum1", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test8), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test9), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test10), "Generic argument is a generic interface", "GenInterface[System.Int32]", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test11), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test12), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test13), "Generic argument is a struct", "NonGenStruct", "F`1[T]");
+ Check(new Case(Interface_DefaultCtorAndClassTypeConstraint.Test14), "Generic argument is a generic struct", "GenStruct[System.Int32]", "F`1[T]");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : C, new()\n");
+
+
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test1), "Generic argument is a class with default ctor, implements I, doesn't extend C", "ClassWithCtor", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test3), "Generic argument is an mscorlib class with default ctor", "System.Object", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test4), "Generic argument is a delegate", "Delegate1", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test5), "Generic argument is an enum", "Enum1", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test8), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test9), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test10), "Generic argument is a generic interface", "GenInterface[System.Int32]", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test11), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test12), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test13), "Generic argument is a struct", "NonGenStruct", "F`1[T]");
+ Check(new Case(Instantiation_DefaultCtorAndClassTypeConstraint.Test14), "Generic argument is a generic struct", "GenStruct[System.Int32]", "F`1[T]");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.csproj
new file mode 100644
index 0000000000..40544b9c25
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/Secondary_Ctor_Constraints_Type_Negative.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Secondary_Ctor_Constraints_Type_Negative</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Secondary_Ctor_Constraints_Type_Negative.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="Interface_DefaultCtorAndClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="Interface_DefaultCtorConstraint_Neg.ilproj" />
+ <ProjectReference Include="Interface_DefaultCtorAndStructConstraint_Neg.ilproj" />
+ <ProjectReference Include="Interface_DefaultCtorAndClassTypeConstraint_Neg.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorAndClassTypeConstraint_Neg.ilproj" />
+ <ProjectReference Include="types_implementI.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.il
new file mode 100644
index 0000000000..d7aa60f65f
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.il
@@ -0,0 +1,93 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_ClassConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_ClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<valuetype [types]NonGenStruct>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<valuetype [types]Enum1>::i
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<valuetype [types]GenStruct<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::i
+ pop
+
+ ret
+ }
+}
+
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..45854bf958
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_ClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_ClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_ClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.cs
new file mode 100644
index 0000000000..a873c899f0
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.cs
@@ -0,0 +1,187 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with illegal parameter types accessing static field of the generic type
+
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference tyoe
+default ctor, valuetype
+
+Test each constraint with (whichever applies to negative tests)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string violatingType, string type)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, e, violatingType, type);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, TypeLoadException e, string violatingType, string type )
+ {
+ if (
+ !e.ToString().Contains("0") ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains("T"))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SF_DefaultCtorConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraint.Test4), "Generic argument is a delegate", "Delegate1", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraint.Test7), "Generic argument is an interface with no default ctor", "NonGenInterface", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraint.Test9), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraintGenTypes.Test2), " Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "A`1[T]");
+ Check(new Case(SF_DefaultCtorConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "A`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SF_ClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "B`1[T]");
+ Check(new Case(SF_ClassConstraint.Test8), "Generic argument is an enum", "Enum1", "B`1[T]");
+ Check(new Case(SF_ClassConstraintGenTypes.Test3), "Generic argument is a generic struct with default ctor", "GenStruct[System.Int32]", "B`1[T]");
+ Check(new Case(SF_ClassConstraintGenTypes.Test6), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "B`1[T]");
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SF_StructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "C`1[T]");
+ Check(new Case(SF_StructConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "C`1[T]");
+
+ Check(new Case(SF_StructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "C`1[T]");
+ Check(new Case(SF_StructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "C`1[T]");
+ Check(new Case(SF_StructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "C`1[T]");
+ Check(new Case(SF_StructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "C`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test4), "Generic argument is a delegate", "Delegate1", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test9), "Generic argument is an mscorlib struct", "System.DateTime", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test8), "Generic argument is an enum", "Enum1", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "D`1[T]");
+
+
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test3), "Generic argument is a generic struct", "GenStruct[System.Int32]", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "System.Collections.Generic.KeyValuePair`2[NonGenStruct,System.Int32]", "D`1[T]");
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "D`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "E`1[T]");
+
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test10), "Generic argument is an array of classes with default ctor", "NonGenStruct[]", "E`1[T]");
+
+
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "E`1[T]");
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "E`1[T]");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.csproj
new file mode 100644
index 0000000000..da81447f11
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_Constraints_Neg.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_Constraints_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_Constraints_Neg.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="StaticField_ClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorAndClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorAndStructConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticField_StructConstraint_Neg.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.il
new file mode 100644
index 0000000000..038ca345c6
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.il
@@ -0,0 +1,218 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorAndClassConstraint_Neg {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]ClassNoCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<valuetype [types]NonGenStruct>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]Delegate1>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ ldsfld int32 class D`1<class [mscorlib]System.ValueType>::i
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]NonGenInterface>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<valuetype [types]Enum1>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<valuetype [mscorlib]System.DateTime>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]ClassWithCtor[]>::i
+ pop
+
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]GenClassNoCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a generic struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<valuetype [types]GenStruct<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an generic interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]GenInterface<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ ldsfld int32 class D`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::i
+
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::i
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..f2ad4d0df3
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorAndClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorAndClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.il
new file mode 100644
index 0000000000..8c1743f6c3
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.il
@@ -0,0 +1,181 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorAndStructConstraint_Neg {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]ClassWithCtor>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]ClassNoCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]Delegate1>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [mscorlib]System.Object>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ ldsfld int32 class E`1<class [mscorlib]System.ValueType>::i
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]NonGenInterface>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [types]NonGenStruct[]>::i
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]GenClassWithCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]GenClassNoCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<class [types]GenInterface<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::i
+ pop
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..768aa07c45
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorAndStructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorAndStructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorAndStructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.il
new file mode 100644
index 0000000000..9f801f901a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.il
@@ -0,0 +1,131 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]ClassNoCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]Delegate1>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [mscorlib]System.ValueType>::i
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]NonGenInterface>::i
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]ClassWithCtor[]>::i
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]GenClassNoCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]GenInterface<int32>>::i
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.ilproj
new file mode 100644
index 0000000000..e8b47315cf
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_DefaultCtorConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.il
new file mode 100644
index 0000000000..061256f5bc
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.il
@@ -0,0 +1,179 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_StructConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_StructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]ClassWithCtor>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]ClassNoCtor>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]Delegate1>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [mscorlib]System.Object>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ ldsfld int32 class C`1<class [mscorlib]System.ValueType>::i
+ pop
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]NonGenInterface>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]ClassWithCtor[]>::i
+ pop
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]GenClassWithCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]GenClassNoCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<class [types]GenInterface<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::i
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..c883ffdbb6
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticField_StructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_StructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_StructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.il
new file mode 100644
index 0000000000..e1b19d019a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.il
@@ -0,0 +1,87 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_ClassConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_ClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<valuetype [types]NonGenStruct>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<valuetype [types]Enum1>::method1()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<valuetype [types]GenStruct<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::method1()
+ ret
+ }
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..6a671d9102
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_ClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_ClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_ClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.cs
new file mode 100644
index 0000000000..4bb2c78bb0
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.cs
@@ -0,0 +1,181 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with illegal parameter types by invoking static method on the generic type
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference tyoe
+default ctor, valuetype
+
+Test each constraint with (whichever applies to negative testing)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string violatingType, string type)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, e, violatingType, type);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, TypeLoadException e, string violatingType, string type )
+ {
+ if (
+ !e.ToString().Contains("0") ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains("T"))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraint.Test4), "Generic argument is a delegate", "Delegate1", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraint.Test7), "Generic argument is an interface with no default ctor", "NonGenInterface", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraint.Test9), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraintGenTypes.Test2), " Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "A`1[T]");
+ Check(new Case(SM_DefaultCtorConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "A`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SM_ClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "B`1[T]");
+ Check(new Case(SM_ClassConstraint.Test8), "Generic argument is an enum", "Enum1", "B`1[T]");
+ Check(new Case(SM_ClassConstraintGenTypes.Test3), "Generic argument is a generic struct with default ctor", "GenStruct[System.Int32]", "B`1[T]");
+ Check(new Case(SM_ClassConstraintGenTypes.Test6), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "B`1[T]");
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SM_StructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "C`1[T]");
+ Check(new Case(SM_StructConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "C`1[T]");
+ Check(new Case(SM_StructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "C`1[T]");
+ Check(new Case(SM_StructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "C`1[T]");
+ Check(new Case(SM_StructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "C`1[T]");
+ Check(new Case(SM_StructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "C`1[T]");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test3), "Generic argument is a struct", "NonGenStruct", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test4), "Generic argument is a delegate", "Delegate1", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test9), "Generic argument is an mscorlib struct", "System.DateTime", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test8), "Generic argument is an enum", "Enum1", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test10), "Generic argument is an array of classes with default ctor", "ClassWithCtor[]", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test3), "Generic argument is a generic struct", "GenStruct[System.Int32]", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "System.Collections.Generic.KeyValuePair`2[NonGenStruct,System.Int32]", "D`1[T]");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "D`1[T]");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+ Console.WriteLine("\nNEGATIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test1), "Generic argument is a class with default ctor", "ClassWithCtor", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test2), "Generic argument is a class with no default ctor", "ClassNoCtor", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test4), "Generic argument is a delegate", "Delegate1", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "System.Object", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "System.ValueType", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test7), "Generic argument is an interface", "NonGenInterface", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test10), "Generic argument is an array of classes with default ctor", "NonGenStruct[]", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "GenClassWithCtor[System.Int32]", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "GenClassNoCtor[System.Int32]", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test5), "Generic argument is a generic interface", "GenInterface[System.Int32]", "E`1[T]");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "System.Nullable`1[System.Int32]", "E`1[T]");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.csproj
new file mode 100644
index 0000000000..448eb02af5
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_Constraints_Neg.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_Constraints_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_Constraints_Neg.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="StaticMethod_ClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorAndClassConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorAndStructConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorConstraint_Neg.ilproj" />
+ <ProjectReference Include="StaticMethod_StructConstraint_Neg.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.il
new file mode 100644
index 0000000000..d9240b906e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.il
@@ -0,0 +1,187 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorAndClassConstraint_Neg {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]ClassNoCtor>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<valuetype [types]NonGenStruct>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]Delegate1>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ call void class D`1<class [mscorlib]System.ValueType>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]NonGenInterface>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<valuetype [types]Enum1>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<valuetype [mscorlib]System.DateTime>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]ClassWithCtor[]>::method1()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]GenClassNoCtor<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a generic struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<valuetype [types]GenStruct<int32>>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an generic interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]GenInterface<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ call void class D`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::method1()
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::method1()
+ ret
+ }
+
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.ilproj
new file mode 100644
index 0000000000..d1fbfe1331
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndClassConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorAndClassConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorAndClassConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.il
new file mode 100644
index 0000000000..a09efce3f5
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.il
@@ -0,0 +1,162 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorAndStructConstraint_Neg {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]ClassWithCtor>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]ClassNoCtor>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]Delegate1>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [mscorlib]System.Object>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ call void class E`1<class [mscorlib]System.ValueType>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]NonGenInterface>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [types]NonGenStruct[]>::method1()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]GenClassWithCtor<int32>>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]GenClassNoCtor<int32>>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<class [types]GenInterface<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::method1()
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..75978bb441
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorAndStructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorAndStructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorAndStructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.il
new file mode 100644
index 0000000000..c8adac64cd
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.il
@@ -0,0 +1,123 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorConstraint_Neg {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]ClassNoCtor>::method1()
+
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a delegate (doesn't have public parameterless constructor)
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+ call void class A`1<class [types]Delegate1>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [mscorlib]System.ValueType>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]NonGenInterface>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]ClassWithCtor[]>::method1()
+
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]GenClassNoCtor<int32>>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]GenInterface<int32>>::method1()
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.ilproj
new file mode 100644
index 0000000000..2ebd8251c4
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_DefaultCtorConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.il
new file mode 100644
index 0000000000..675639320d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.il
@@ -0,0 +1,162 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_StructConstraint_Neg {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_StructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]ClassWithCtor>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]ClassNoCtor>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]Delegate1>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [mscorlib]System.Object>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [mscorlib]System.ValueType>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]NonGenInterface>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test10() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]ClassWithCtor[]>::method1()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]GenClassWithCtor<int32>>::method1()
+ ret
+ }
+
+ // NEGATIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]GenClassNoCtor<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<class [types]GenInterface<int32>>::method1()
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::method1()
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.ilproj
new file mode 100644
index 0000000000..e578d8ed7e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/StaticMethod_StructConstraint_Neg.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_StructConstraint_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_StructConstraint_Neg.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.cs
new file mode 100644
index 0000000000..abe962b409
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.cs
@@ -0,0 +1,121 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with illegal parameter types by instantiating the type
+
+*/
+
+using System;
+
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string genArgNumber, string violatingType, string type, string typeParam)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, genArgNumber, e, violatingType, type, typeParam);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, string genArgNumber, TypeLoadException e, string violatingType, string type, string typeParam )
+ {
+ if (
+ !e.ToString().Contains(genArgNumber) ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains(typeParam))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: GClass<T> where T : class\n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+ Check(new Case(RunTest.Test1), "class G1<P> : GClass<P> where P : struct {}, insantiate with class","0", "P", "GClass`1[T]", "T");
+ Check(new Case(RunTest.Test2), "class G1<P> : GClass<P> where P : struct {}, instantiate with valuetype", "0", "P", "GClass`1[T]", "T");
+ Check(new Case(RunTest.Test3), "class G2<P> : GClass<P> where P : I {}", "0", "P", "GClass`1[T]", "T");
+ Check(new Case(RunTest.Test4), "class G3<P> : GClass<P> where P : System.Object {}", "0", "P", "GClass`1[T]", "T");
+ Check(new Case(RunTest.Test5), "class G4<P> : GClass<P> where P : System.ValueType {}", "0", "P", "GClass`1[T]", "T");
+ Check(new Case(RunTest.Test6), "class G5<P> : GClass<P> where P : System.Enum {}", "0", "P", "GClass`1[T]", "T");
+
+
+ Console.WriteLine("\nType: GStruct<T> where T : struct\n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+
+ Check(new Case(RunTest.Test7), "class G6<P> : IStruct<P> where P : class {}, insantiate with class","0", "P", "GStruct`1[T]", "T");
+ Check(new Case(RunTest.Test8), "class G6<P> : IStruct<P> where P : class {}, instantiate with valuetype", "0", "P", "GStruct`1[T]", "T");
+ Check(new Case(RunTest.Test9), "class G7<P> : IStruct<P> where P : A {}", "0", "P", "GStruct`1[T]", "T");
+ Check(new Case(RunTest.Test10), "class G8<P> : IStruct<P> where P : I {}", "0", "P", "GStruct`1[T]", "T");
+
+ Check(new Case(RunTest.Test14), "class G12<P> : IStruct<P> where P : System.ValueType {}", "0", "P", "GStruct`1[T]", "T");
+ Check(new Case(RunTest.Test15), "class G12<P> : IStruct<P> where P : System.Nullable<int> {}", "0", "P", "GStruct`1[T]", "T");
+
+
+ Console.WriteLine("\nType: GNew<T> where T : new() \n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+
+ Check(new Case(RunTest.Test11), "class G9<P> : GNew<P> where P : A {}, insantiate with class","0", "P", "GNew`1[T]", "T");
+ Check(new Case(RunTest.Test12), "class G10<P> : GNew<P> where P : class {}, instantiate with valuetype", "0", "P", "GNew`1[T]", "T");
+ Check(new Case(RunTest.Test13), "class G11<P> : GNew<P> where P : I {}", "0", "P", "GNew`1[T]", "T");
+
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.csproj
new file mode 100644
index 0000000000..eb3a542679
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam2_Constraints_Neg.csproj
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>TypeParam2_Constraints_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="TypeParam2_Constraints_Neg.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="RunTestNeg2.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.cs
new file mode 100644
index 0000000000..275785e70e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.cs
@@ -0,0 +1,123 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with illegal parameter types by instantiating the type
+ These tests are similar to TypeParam2* only here we have a generic interface I<T> with a constraint on T
+ and in TypeParam2* we have a generic class G<T> with a constraint on T.
+*/
+
+using System;
+
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName, string genArgNumber, string violatingType, string type, string typeParam)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException");
+ pass = false;
+ }
+ catch (TypeLoadException e)
+ {
+ // Unhandled Exception: System.TypeLoadException: %0, '%1', on '%2'
+ // violates the constraint of type parameter '%3'.
+
+ Test.CheckTypeLoadExceptionMessage(8310, genArgNumber, e, violatingType, type, typeParam);
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static void CheckTypeLoadExceptionMessage(uint ResourceID, string genArgNumber, TypeLoadException e, string violatingType, string type, string typeParam )
+ {
+ if (
+ !e.ToString().Contains(genArgNumber) ||
+ !e.ToString().Contains(violatingType) ||
+ !e.ToString().Contains(type) ||
+ !e.ToString().Contains(typeParam))
+ {
+ Console.WriteLine("Exception message is incorrect");
+ pass = false;
+ }
+ else
+ {
+ Console.WriteLine("Caught expected exception");
+ }
+ }
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: IClass<T> where T : class\n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+ Check(new Case(RunTest.Test1), "class G1<P> : IClass<P> where P : struct {}, insantiate with class","0", "P", "IClass`1[T]", "T");
+ Check(new Case(RunTest.Test2), "class G1<P> : IClass<P> where P : struct {}, instantiate with valuetype", "0", "P", "IClass`1[T]", "T");
+ Check(new Case(RunTest.Test3), "class G2<P> : IClass<P> where P : I {}", "0", "P", "IClass`1[T]", "T");
+ Check(new Case(RunTest.Test4), "class G3<P> : IClass<P> where P : System.Object {}", "0", "P", "IClass`1[T]", "T");
+ Check(new Case(RunTest.Test5), "class G4<P> : IClass<P> where P : System.ValueType {}", "0", "P", "IClass`1[T]", "T");
+ Check(new Case(RunTest.Test6), "class G5<P> : IClass<P> where P : System.Enum {}", "0", "P", "IClass`1[T]", "T");
+
+
+ Console.WriteLine("\nType: IStruct<T> where T : struct\n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+
+ Check(new Case(RunTest.Test7), "class G6<P> : IStruct<P> where P : class {}, insantiate with class","0", "P", "IStruct`1[T]", "T");
+ Check(new Case(RunTest.Test8), "class G6<P> : IStruct<P> where P : class {}, instantiate with valuetype", "0", "P", "IStruct`1[T]", "T");
+ Check(new Case(RunTest.Test9), "class G7<P> : IStruct<P> where P : A {}", "0", "P", "IStruct`1[T]", "T");
+ Check(new Case(RunTest.Test10), "class G8<P> : IStruct<P> where P : I {}", "0", "P", "IStruct`1[T]", "T");
+
+ Check(new Case(RunTest.Test14), "class G12<P> : IStruct<P> where P : System.ValueType {}", "0", "P", "IStruct`1[T]", "T");
+ Check(new Case(RunTest.Test15), "class G12<P> : IStruct<P> where P : System.Nullable<int> {}", "0", "P", "IStruct`1[T]", "T");
+
+
+
+ Console.WriteLine("\nType: INew<T> where T : new() \n");
+ Console.WriteLine("NEGATIVE TESTS");
+
+
+ Check(new Case(RunTest.Test11), "class G9<P> : INew<P> where P : A {}, insantiate with class","0", "P", "INew`1[T]", "T");
+ Check(new Case(RunTest.Test12), "class G10<P> : INew<P> where P : class {}, instantiate with valuetype", "0", "P", "INew`1[T]", "T");
+ Check(new Case(RunTest.Test13), "class G11<P> : INew<P> where P : I {}", "0", "P", "INew`1[T]", "T");
+
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.csproj
new file mode 100644
index 0000000000..3eeb38e2a9
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/TypeParam3_Constraints_Neg.csproj
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>TypeParam3_Constraints_Neg</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="TypeParam3_Constraints_Neg.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="RunTestNeg3.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/app.config b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/project.json b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.il
new file mode 100644
index 0000000000..53c0b9e255
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.il
@@ -0,0 +1,117 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly Types {}
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.ilproj
new file mode 100644
index 0000000000..e90ddd06ea
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.il
new file mode 100644
index 0000000000..56a463547c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.il
@@ -0,0 +1,131 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly Types_implementI {}
+
+
+.class interface public abstract auto ansi I {}
+
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+ implements I
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+ implements I
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+ implements I
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+ implements I
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.ilproj
new file mode 100644
index 0000000000..56d5b6ed3e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types_implementI</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types_implementI.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.il
new file mode 100644
index 0000000000..68bcbe5c43
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.il
@@ -0,0 +1,150 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly types_implementI_extendC {}
+
+
+.class interface public abstract auto ansi I {}
+
+.class public auto ansi beforefieldinit C
+ extends [mscorlib]System.Object
+{}
+
+// class with public nullary ctor implements I but doesn't extend C
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+ implements I
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// class with public nullary ctor extends C but doesn't implement I
+.class public auto ansi beforefieldinit ClassWithCtor2
+ extends C
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+ implements I
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+ implements I
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+ implements I
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.ilproj
new file mode 100644
index 0000000000..783be27964
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Negative/types_implementI_extendC.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types_implementI_extendC</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types_implementI_extendC.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.il
new file mode 100644
index 0000000000..cb9ea447e3
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.il
@@ -0,0 +1,166 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_ClassConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit ClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]ClassNoCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]Delegate1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ newobj instance void class B`1<class [mscorlib]System.ValueType>::.ctor()
+ pop
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]NonGenInterface>::.ctor()
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]ClassWithCtor[]>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]GenClassNoCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class B`1<class [types]GenInterface<int32>>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..7be25616a1
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_ClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_ClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_ClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.cs
new file mode 100644
index 0000000000..58db02e46d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.cs
@@ -0,0 +1,151 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with legal parameter types by instantiating the types
+
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference type
+default ctor, valuetype
+
+Test each constraint with (whatever applies for positive testing)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+
+
+
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+ static void Check(Case mytest, string testName)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+
+ Console.WriteLine(" : PASS");
+ return;
+ }
+ catch (TypeLoadException e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected TypeLoadException: " + e);
+ pass = false;
+ return;
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+
+ Console.WriteLine("POSITIVE TESTS");
+ Check(new Case(DefaultCtorConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(DefaultCtorConstraint.Test3), "Generic argument is a struct (valuetypes have public nullary ctors by default)");
+ Check(new Case(DefaultCtorConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ Check(new Case(DefaultCtorConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(DefaultCtorConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(DefaultCtorConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(DefaultCtorConstraintGenTypes.Test6), "Generic argument is Nullable<T>");
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+
+ Console.WriteLine("POSITIVE TESTS");
+ Check(new Case(ClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(ClassConstraint.Test2), "Generic argument is a class with no default ctor");
+ Check(new Case(ClassConstraint.Test4), "Generic argument is a delegate");
+ Check(new Case(ClassConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ Check(new Case(ClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor");
+ Check(new Case(ClassConstraint.Test7), "Generic argument is an interface");
+ Check(new Case(ClassConstraint.Test9), "Generic argument is an array of classes with default ctor");
+ Check(new Case(ClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(ClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor");
+ Check(new Case(ClassConstraintGenTypes.Test5), "Generic argument is a generic interface");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+
+ Console.WriteLine("POSITIVE TESTS");
+ Check(new Case(StructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(StructConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(StructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(StructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(StructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+
+ Console.WriteLine("POSITIVE TESTS");
+ Check(new Case(DefaultCtorAndClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(DefaultCtorAndClassConstraint.Test5), "Generic argument is a is an mscorlib class with default ctor");
+ Check(new Case(DefaultCtorAndClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+
+ Console.WriteLine("POSITIVE TESTS");
+ Check(new Case(DefaultCtorAndStructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(DefaultCtorAndStructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(DefaultCtorAndStructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+ Check(new Case(DefaultCtorAndStructConstraint.Test8), "Generic argument is an enum");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.csproj
new file mode 100644
index 0000000000..f11d4b5a2c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_Constraints_Pos.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_Constraints_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_Constraints_Pos.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="Instantiation_ClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorAndClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorAndStructConstraint_Pos.ilproj" />
+ <ProjectReference Include="Instantiation_DefaultCtorConstraint_Pos.ilproj" />
+ <ProjectReference Include="Instantiation_StructConstraint_Pos.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.il
new file mode 100644
index 0000000000..e24a554821
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.il
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorAndClassConstraint_Pos {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..f6c7873c97
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.il
new file mode 100644
index 0000000000..e92f92b8a0
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.il
@@ -0,0 +1,77 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI_extendC{}
+
+.assembly Instantiation_DefaultCtorAndClassTypeConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit F`1<.ctor ([types_implementI_extendC]C) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Instantiation_DefaultCtorAndClassTypeConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor that implements I and extends C
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+ // POSITIVE TEST
+ // generic argument is a generic class with default ctor that implements I and extends C
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a class with default ctor that doesn't implements I but extends C
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor2>::.ctor()
+ pop
+
+ ret
+ }
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.ilproj
new file mode 100644
index 0000000000..e6c72e025a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndClassTypeConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndClassTypeConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndClassTypeConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.il
new file mode 100644
index 0000000000..977aec5d90
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.il
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorAndStructConstraint_Pos {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [mscorlib]System.DateTime>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..ffe14ae58d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorAndStructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorAndStructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorAndStructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.il
new file mode 100644
index 0000000000..307938528d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.il
@@ -0,0 +1,144 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_DefaultCtorConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [mscorlib]System.Object>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test10<M>() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<!!M>::.ctor()
+ pop
+
+ ret
+ }
+
+
+}
+
+.class public auto ansi beforefieldinit DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.ilproj
new file mode 100644
index 0000000000..281b435fef
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_DefaultCtorConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_DefaultCtorConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_DefaultCtorConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.il
new file mode 100644
index 0000000000..bf7a82c3a1
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.il
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly Instantiation_StructConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit StructConstraint
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [types]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [types]Enum1>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [mscorlib]System.DateTime>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [types]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class C`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::.ctor()
+ pop
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..6508369179
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Instantiation_StructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Instantiation_StructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Instantiation_StructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.il
new file mode 100644
index 0000000000..0214f0ac72
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.il
@@ -0,0 +1,68 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorAndClassConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit D`1<class .ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class D`1<class [types_implementI]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..f6541b415d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.il
new file mode 100644
index 0000000000..73b4341d1d
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.il
@@ -0,0 +1,68 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI_extendC{}
+
+.assembly Interface_DefaultCtorAndClassTypeConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit F`1<.ctor ([types_implementI_extendC]C, [types_implementI_extendC]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndClassTypeConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor that implements I and extends C
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+ // POSITIVE TEST
+ // generic argument is a generic class with default ctor that implements I and extends C
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class F`1<class [types_implementI_extendC]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.ilproj
new file mode 100644
index 0000000000..3aa0fd70af
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndClassTypeConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndClassTypeConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndClassTypeConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.il
new file mode 100644
index 0000000000..e3d332530f
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.il
@@ -0,0 +1,66 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorAndStructConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit E`1<valuetype .ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+ // NEGATIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types_implementI]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // NEGATIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class E`1<valuetype [types_implementI]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..d3bebb3289
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorAndStructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorAndStructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorAndStructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.il
new file mode 100644
index 0000000000..f6b7d148fe
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.il
@@ -0,0 +1,86 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types_implementI{}
+
+.assembly Interface_DefaultCtorConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor ([types_implementI]I) T>
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit Interface_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]ClassWithCtor>::.ctor()
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types_implementI]NonGenStruct>::.ctor()
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<class [types_implementI]GenClassWithCtor<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ newobj instance void class A`1<valuetype [types_implementI]GenStruct<int32>>::.ctor()
+ pop
+
+ ret
+ }
+
+}
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.ilproj
new file mode 100644
index 0000000000..4722c83401
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/Interface_DefaultCtorConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>Interface_DefaultCtorConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="Interface_DefaultCtorConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.il
new file mode 100644
index 0000000000..58f9377162
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.il
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+// this file contains positive tests for
+// G<T,U> where T : U where U : struct
+// C# didn't want to compile such type definition so we are using IL.
+
+
+.assembly extern mscorlib {}
+.assembly extern TypeParam_Constraints_Pos {}
+.assembly RunTestPos {}
+
+
+.class public auto ansi beforefieldinit GStruct`2<(!U) T, valuetype U>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+
+.class public auto ansi beforefieldinit RunGStructTest
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<valuetype [TypeParam_Constraints_Pos]S,valuetype [TypeParam_Constraints_Pos]S>::.ctor()
+ pop
+ ret
+ }
+
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+ newobj instance void class GStruct`2<int32,int32>::.ctor()
+ pop
+ ret
+ }
+}
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.ilproj
new file mode 100644
index 0000000000..09852112b4
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestPos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestPos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="TypeParam_Constraints_Pos.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.il
new file mode 100644
index 0000000000..d0ff480f36
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.il
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+// this file contains positive test for
+// GStruct<T> where T : struct
+// G4<P> : GStruct<P> where P : valuetype S
+
+// C# didn't want to compile such type definition so we are using IL.
+
+
+.assembly extern mscorlib {}
+.assembly extern TypeParam2_Constraints_Pos {}
+.assembly RunTestPos2 {}
+
+.class public auto ansi beforefieldinit GStruct`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit G4`1<(valuetype [TypeParam2_Constraints_Pos]S) P>
+ extends class GStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+
+.class public sequential ansi sealed beforefieldinit S_PrivCtor
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+
+
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.ilproj
new file mode 100644
index 0000000000..54739ed81b
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos2.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestPos2</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestPos2.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="TypeParam2_Constraints_Pos.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.il
new file mode 100644
index 0000000000..45afb6d897
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.il
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+// this file contains positive test for
+// interface IStruct<T> where T : struct
+// G4<P> : IStruct<P> where P : valuetype S
+
+// C# didn't want to compile such type definition so we are using IL.
+
+
+.assembly extern mscorlib {}
+.assembly extern TypeParam3_Constraints_Pos {}
+.assembly RunTestPos3 {}
+
+.class interface public abstract auto ansi IStruct`1<valuetype T> {}
+
+
+.class public auto ansi beforefieldinit G4`1<(valuetype [TypeParam3_Constraints_Pos]S) P>
+ implements class IStruct`1<!P>
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+
+.class public sequential ansi sealed beforefieldinit S_PrivCtor
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+
+ .method private hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+
+
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.ilproj
new file mode 100644
index 0000000000..41469c2098
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/RunTestPos3.ilproj
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RunTestPos3</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RunTestPos3.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="TypeParam3_Constraints_Pos.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.il
new file mode 100644
index 0000000000..8e39680aed
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.il
@@ -0,0 +1,173 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_ClassConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_ClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]ClassWithCtor>::i
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]ClassNoCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]Delegate1>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [mscorlib]System.Object>::i
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ ldsfld int32 class B`1<class [mscorlib]System.ValueType>::i
+ pop
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+ ldsfld int32 class B`1<class [types]NonGenInterface>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]ClassWithCtor[]>::i
+ pop
+
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SF_ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]GenClassWithCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]GenClassNoCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class B`1<class [types]GenInterface<int32>>::i
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..864e7cbd71
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_ClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_ClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_ClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.cs
new file mode 100644
index 0000000000..70715d8e44
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.cs
@@ -0,0 +1,157 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with legal parameter types accessing static field of the generic type
+
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference tyoe
+default ctor, valuetype
+
+Test each constraint with (whichever apply for positive tests)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+ static void Check(Case mytest, string testName)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+
+ Console.WriteLine(" : PASS");
+ return;
+ }
+ catch (TypeLoadException e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected TypeLoadException: " + e);
+ pass = false;
+ return;
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SF_DefaultCtorConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(SF_DefaultCtorConstraint.Test3), "Generic argument is a struct (valuetypes have public nullary ctors by default)");
+ Check(new Case(SF_DefaultCtorConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ // enum is a valueypte and all valuetypes have public nullary ctors.
+ Check(new Case(SF_DefaultCtorConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(SF_DefaultCtorConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(SF_DefaultCtorConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SF_DefaultCtorConstraintGenTypes.Test6), "Generic argument is Nullable<T>");
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SF_ClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(SF_ClassConstraint.Test2), "Generic argument is a class with no default ctor");
+ Check(new Case(SF_ClassConstraint.Test4), "Generic argument is a delegate");
+ Check(new Case(SF_ClassConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ Check(new Case(SF_ClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor");
+ Check(new Case(SF_ClassConstraint.Test7), "Generic argument is an interface");
+ Check(new Case(SF_ClassConstraint.Test9), "Generic argument is an array of classes with default ctor");
+ Check(new Case(SF_ClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(SF_ClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor");
+ Check(new Case(SF_ClassConstraintGenTypes.Test5), "Generic argument is a generic interface");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SF_StructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(SF_StructConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(SF_StructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(SF_StructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SF_StructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(SF_DefaultCtorAndClassConstraint.Test5), "Generic argument is a is an mscorlib class with default ctor");
+ Check(new Case(SF_DefaultCtorAndClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SF_DefaultCtorAndStructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+ Check(new Case(SF_DefaultCtorAndStructConstraint.Test8), "Generic argument is an enum");
+
+
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.csproj
new file mode 100644
index 0000000000..f46552f33e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_Constraints_Pos.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_Constraints_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_Constraints_Pos.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="StaticField_ClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorAndClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorAndStructConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticField_DefaultCtorConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticField_StructConstraint_Pos.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.il
new file mode 100644
index 0000000000..078ac97f8c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.il
@@ -0,0 +1,83 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorAndClassConstraint_Pos {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]ClassWithCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [mscorlib]System.Object>::i
+ pop
+
+ ret
+ }
+
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class D`1<class [types]GenClassWithCtor<int32>>::i
+ pop
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..13b68b394b
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorAndClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorAndClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.il
new file mode 100644
index 0000000000..6a649cb0b4
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.il
@@ -0,0 +1,112 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorAndStructConstraint_Pos {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [types]NonGenStruct>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [types]Enum1>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [mscorlib]System.DateTime>::i
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [types]GenStruct<int32>>::i
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class E`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::i
+ pop
+
+ ret
+ }
+
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..435347ac94
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorAndStructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorAndStructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorAndStructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.il
new file mode 100644
index 0000000000..8c76992797
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.il
@@ -0,0 +1,133 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_DefaultCtorConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .field public static int32 i
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]ClassWithCtor>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<valuetype [types]NonGenStruct>::i
+ pop
+
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [mscorlib]System.Object>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<valuetype [types]Enum1>::i
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SF_DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<class [types]GenClassWithCtor<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<valuetype [types]GenStruct<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class A`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::i
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.ilproj
new file mode 100644
index 0000000000..8d4711e466
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_DefaultCtorConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_DefaultCtorConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_DefaultCtorConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.il
new file mode 100644
index 0000000000..b1ab85a5f5
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.il
@@ -0,0 +1,108 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticField_StructConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+ .field public static int32 i
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SF_StructConstraint
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [types]NonGenStruct>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [types]Enum1>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [mscorlib]System.DateTime>::i
+ pop
+
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SF_StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [types]GenStruct<int32>>::i
+ pop
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ ldsfld int32 class C`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::i
+
+ pop
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..5d9d2fad9a
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticField_StructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticField_StructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticField_StructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.il
new file mode 100644
index 0000000000..381742b589
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.il
@@ -0,0 +1,154 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_ClassConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit B`1<class T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_ClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]ClassWithCtor>::method1()
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]ClassNoCtor>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a delegate
+ .method public hidebysig static void Test4() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]Delegate1>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [mscorlib]System.Object>::method1()
+ ret
+ }
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib abstract class with no default ctor
+
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+
+ call void class B`1<class [mscorlib]System.ValueType>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface
+ .method public hidebysig static void Test7() cil managed
+ {
+ .maxstack 1
+ call void class B`1<class [types]NonGenInterface>::method1()
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is an array of classes with default ctor
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]ClassWithCtor[]>::method1()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SM_ClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]GenClassWithCtor<int32>>::method1()
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is a class with no default ctor
+ .method public hidebysig static void Test2() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]GenClassNoCtor<int32>>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an interface with no default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class B`1<class [types]GenInterface<int32>>::method1()
+ ret
+ }
+
+}
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..53f0e0c729
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_ClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_ClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_ClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.cs
new file mode 100644
index 0000000000..869759b590
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.cs
@@ -0,0 +1,152 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* Test various combinations of constraints with legal parameter types by invoking static method on the generic type
+CONSTRAINTS:
+
+default ctor
+reference type
+valuetype
+default ctor, reference tyoe
+default ctor, valuetype
+
+Test each constraint with (whichever apply to positive tests)
+- Class with default nullary ctor (Generic/Non generic)
+- Class with no default nullary ctor (Generic/Non generic)
+- Class from mscorlib with default nullary ctor
+- Abstract Class from mscorlib with no default nullary ctor
+
+- Struct from mscorlib (Generic/Non generic)
+- Struct (Generic/Non generic)
+- Enum (Generic/Non generic)
+
+- Interface (Generic/Non generic)
+
+- Array
+
+- Delegate
+
+- Nullable<T>
+*/
+
+using System;
+
+
+public class Test
+{
+ static bool pass;
+ static int testNumber = 1;
+
+ delegate void Case();
+
+
+
+ static void Check(Case mytest, string testName)
+ {
+
+ Console.Write("Test"+testNumber + ": " + testName);
+ ++testNumber;
+
+
+ try
+ {
+ mytest();
+
+
+ Console.WriteLine(" : PASS");
+ return;
+ }
+ catch (TypeLoadException e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected TypeLoadException: " + e);
+ pass = false;
+ return;
+ }
+
+ catch (Exception e)
+ {
+ Console.WriteLine("\nFAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+
+
+ public static int Main()
+ {
+ pass = true;
+
+ Console.WriteLine("\nType: A<T> where T : new()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorConstraint.Test1), "Generic argument is a class with default ctor" );
+ Check(new Case(SM_DefaultCtorConstraint.Test3), "Generic argument is a struct (valuetypes have public nullary ctors by default)");
+ Check(new Case(SM_DefaultCtorConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ // enum is a valueypte and all valuetypes have public nullary ctors.
+ Check(new Case(SM_DefaultCtorConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(SM_DefaultCtorConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(SM_DefaultCtorConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SM_DefaultCtorConstraintGenTypes.Test6), "Generic argument is Nullable<T>");
+
+
+ Console.WriteLine("\nType: A<T> where T : class()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SM_ClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(SM_ClassConstraint.Test2), "Generic argument is a class with no default ctor");
+ Check(new Case(SM_ClassConstraint.Test4), "Generic argument is a delegate");
+ Check(new Case(SM_ClassConstraint.Test5), "Generic argument is an mscorlib class with default ctor");
+ Check(new Case(SM_ClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor");
+ Check(new Case(SM_ClassConstraint.Test7), "Generic argument is an interface");
+ Check(new Case(SM_ClassConstraint.Test9), "Generic argument is an array of classes with default ctor");
+ Check(new Case(SM_ClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+ Check(new Case(SM_ClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor");
+ Check(new Case(SM_ClassConstraintGenTypes.Test5), "Generic argument is a generic interface");
+
+
+ Console.WriteLine("\nType: A<T> where T : struct()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SM_StructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(SM_StructConstraint.Test8), "Generic argument is an enum");
+ Check(new Case(SM_StructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(SM_StructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SM_StructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : class(), new() \n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test1), "Generic argument is a class with default ctor");
+ Check(new Case(SM_DefaultCtorAndClassConstraint.Test5), "Generic argument is a is an mscorlib class with default ctor");
+ Check(new Case(SM_DefaultCtorAndClassConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor");
+
+
+
+ Console.WriteLine("\nType: A<T> where T : struct(), new()\n");
+ Console.WriteLine("POSITIVE TESTS");
+
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test3), "Generic argument is a struct");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test9), "Generic argument is an mscorlib struct");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test3), "Generic argument is a generic struct");
+ Check(new Case(SM_DefaultCtorAndStructConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct");
+ Check(new Case(SM_DefaultCtorAndStructConstraint.Test8), "Generic argument is an enum");
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.csproj
new file mode 100644
index 0000000000..fa0690db03
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_Constraints_Pos.csproj
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_Constraints_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_Constraints_Pos.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="StaticMethod_ClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorAndClassConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorAndStructConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticMethod_DefaultCtorConstraint_Pos.ilproj" />
+ <ProjectReference Include="StaticMethod_StructConstraint_Pos.ilproj" />
+ <ProjectReference Include="types.ilproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.il
new file mode 100644
index 0000000000..11458e132e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.il
@@ -0,0 +1,79 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorAndClassConstraint_Pos {}
+
+
+// Generic class with class() and new() constraints
+.class public auto ansi beforefieldinit D`1<class .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndClassConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]ClassWithCtor>::method1()
+ ret
+ }
+
+
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [mscorlib]System.Object>::method1()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndClassConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class D`1<class [types]GenClassWithCtor<int32>>::method1()
+ ret
+ }
+
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.ilproj
new file mode 100644
index 0000000000..91d0d6d1c9
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndClassConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorAndClassConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorAndClassConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.il
new file mode 100644
index 0000000000..461387c9c9
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.il
@@ -0,0 +1,102 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorAndStructConstraint_Pos {}
+
+
+// Generic class with struct() and new() constraints
+.class public auto ansi beforefieldinit E`1<valuetype .ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndStructConstraint
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [types]NonGenStruct>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [types]Enum1>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [mscorlib]System.DateTime>::method1()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorAndStructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [types]GenStruct<int32>>::method1()
+ ret
+ }
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class E`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::method1()
+
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..1f17e790fc
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorAndStructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorAndStructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorAndStructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.il
new file mode 100644
index 0000000000..4ebbba6d47
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.il
@@ -0,0 +1,124 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_DefaultCtorConstraint_Pos {}
+
+
+// Generic class with new() constraint
+.class public auto ansi beforefieldinit A`1<.ctor T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorConstraint
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]ClassWithCtor>::method1()
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct (valuetypes have public nullary ctors by default)
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<valuetype [types]NonGenStruct>::method1()
+
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib class with default ctor
+ .method public hidebysig static void Test5() cil managed
+ {
+ .maxstack 1
+ call void class A`1<class [mscorlib]System.Object>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum with no default ctor
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<valuetype [types]Enum1>::method1()
+ ret
+ }
+
+}
+
+.class public auto ansi beforefieldinit SM_DefaultCtorConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+ // POSITIVE TEST
+ // generic argument is a class with default ctor
+ .method public hidebysig static void Test1() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<class [types]GenClassWithCtor<int32>>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<valuetype [types]GenStruct<int32>>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is NUllable<T>
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class A`1<valuetype [mscorlib]System.'Nullable`1'<int32>>::method1()
+ ret
+ }
+
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.ilproj
new file mode 100644
index 0000000000..8d62ad1d96
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_DefaultCtorConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_DefaultCtorConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_DefaultCtorConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.il
new file mode 100644
index 0000000000..ff434d1ef9
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.il
@@ -0,0 +1,101 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+.assembly extern types{}
+
+.assembly StaticMethod_StructConstraint_Pos {}
+
+
+// Generic class with class() constraint
+.class public auto ansi beforefieldinit C`1<valuetype T>
+ extends [mscorlib]System.Object
+{
+
+ .method public static hidebysig void
+ method1() cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_StructConstraint
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [types]NonGenStruct>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an enum
+ .method public hidebysig static void Test8() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [types]Enum1>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib struct
+ .method public hidebysig static void Test9() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [mscorlib]System.DateTime>::method1()
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit SM_StructConstraintGenTypes
+ extends [mscorlib]System.Object
+{
+
+ // POSITIVE TEST
+ // generic argument is a struct
+ .method public hidebysig static void Test3() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [types]GenStruct<int32>>::method1()
+ ret
+ }
+
+
+ // POSITIVE TEST
+ // generic argument is an mscorlib generic struct
+ .method public hidebysig static void Test6() cil managed
+ {
+ .maxstack 1
+
+ call void class C`1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>::method1()
+
+ ret
+ }
+}
+
+
+
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.ilproj
new file mode 100644
index 0000000000..4698beeb5e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/StaticMethod_StructConstraint_Pos.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>StaticMethod_StructConstraint_Pos</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="StaticMethod_StructConstraint_Pos.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/app.config b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/project.json b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.il
new file mode 100644
index 0000000000..53c0b9e255
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.il
@@ -0,0 +1,117 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly Types {}
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.ilproj
new file mode 100644
index 0000000000..e90ddd06ea
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.il
new file mode 100644
index 0000000000..56a463547c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.il
@@ -0,0 +1,131 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly Types_implementI {}
+
+
+.class interface public abstract auto ansi I {}
+
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends [mscorlib]System.Object
+ implements I
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends [mscorlib]System.Object
+ implements I
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+ implements I
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+ implements I
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+ implements I
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.ilproj
new file mode 100644
index 0000000000..56d5b6ed3e
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types_implementI</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types_implementI.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.il
new file mode 100644
index 0000000000..7bbe76e361
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.il
@@ -0,0 +1,151 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Console { }
+
+.assembly extern mscorlib{}
+
+.assembly types_implementI_extendC {}
+
+
+.class interface public abstract auto ansi I {}
+
+.class public auto ansi beforefieldinit C
+ extends [mscorlib]System.Object
+ implements I
+
+{}
+
+// class with public nullary ctor
+.class public auto ansi beforefieldinit ClassWithCtor
+ extends C
+ implements I
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// class with public nullary ctor extends C but doesn't implement I
+.class public auto ansi beforefieldinit ClassWithCtor2
+ extends C
+
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+// generic class with public nullary ctor
+.class public auto ansi beforefieldinit GenClassWithCtor<T>
+ extends C
+ implements I
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+ ret
+ }
+}
+
+
+// class without public nullary ctor
+.class public auto ansi beforefieldinit ClassNoCtor
+ extends C
+ implements I
+{
+}
+
+// generic class without public nullary ctor
+.class public auto ansi beforefieldinit GenClassNoCtor<T>
+ extends C
+ implements I
+{
+}
+
+
+// struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit NonGenStruct
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+
+
+// generic struct (valuetypes have public nullary ctors by default)
+.class public sequential ansi sealed beforefieldinit GenStruct<T>
+ extends [mscorlib]System.ValueType
+ implements I
+{
+ .pack 0
+ .size 1
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit NonGenInterface
+ implements I
+{
+}
+
+// interface without public nullary ctor
+.class public abstract interface auto ansi beforefieldinit GenInterface<T>
+ implements I
+{
+}
+
+
+.class public auto ansi sealed Enum1
+ extends [mscorlib]System.Enum
+{
+ .field public specialname rtspecialname int32 value__
+ .field public static literal valuetype Enum1 One = int32(0x00000000)
+}
+
+
+// doesn't have public parameterless constructor
+.class public auto ansi sealed Delegate1
+ extends [mscorlib]System.MulticastDelegate
+ implements I
+{
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void Invoke() runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ }
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.ilproj
new file mode 100644
index 0000000000..783be27964
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnType/Positive/types_implementI_extendC.ilproj
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>types_implementI_extendC</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <OutputType>Library</OutputType>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="types_implementI_extendC.il" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.cs b/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.cs
new file mode 100644
index 0000000000..983cc508af
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.cs
@@ -0,0 +1,155 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// this test has a generic type with 100 constraints
+// we want to make sure we can load such type.
+
+using System;
+
+public class Test {
+ public static int Main()
+ {
+ bool pass = true;
+
+ try
+ {
+ MyClass<I100> obj = new MyClass<I100>();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ try
+ {
+ // warning CS0219: The variable 'obj' is assigned but its value is never used
+ #pragma warning disable 219
+ MyStruct<I100> obj = new MyStruct<I100>();
+ #pragma warning restore 219
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+
+ if (pass)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+ }
+}
+
+public class MyClass<T> where T : I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32, I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48, I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64, I65, I66, I67, I68, I69, I70, I71, I72, I73, I74, I75, I76, I77, I78, I79, I80, I81, I82, I83, I84, I85, I86, I87, I88, I89, I90, I91, I92, I93, I94, I95, I96, I97, I98, I99, I100{}
+
+public struct MyStruct<T> where T : I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32, I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48, I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64, I65, I66, I67, I68, I69, I70, I71, I72, I73, I74, I75, I76, I77, I78, I79, I80, I81, I82, I83, I84, I85, I86, I87, I88, I89, I90, I91, I92, I93, I94, I95, I96, I97, I98, I99, I100{}
+
+public interface I1 {}
+public interface I2 : I1{}
+public interface I3 : I2{}
+public interface I4 : I3{}
+public interface I5 : I4{}
+public interface I6 : I5{}
+public interface I7 : I6{}
+public interface I8 : I7{}
+public interface I9 : I8{}
+public interface I10 : I9{}
+public interface I11 : I10{}
+public interface I12 : I11{}
+public interface I13 : I12{}
+public interface I14 : I13{}
+public interface I15 : I14{}
+public interface I16 : I15{}
+public interface I17 : I16{}
+public interface I18 : I17{}
+public interface I19 : I18{}
+public interface I20 : I19{}
+public interface I21 : I20{}
+public interface I22 : I21{}
+public interface I23 : I22{}
+public interface I24 : I23{}
+public interface I25 : I24{}
+public interface I26 : I25{}
+public interface I27 : I26{}
+public interface I28 : I27{}
+public interface I29 : I28{}
+public interface I30 : I29{}
+public interface I31 : I30{}
+public interface I32 : I31{}
+public interface I33 : I32{}
+public interface I34 : I33{}
+public interface I35 : I34{}
+public interface I36 : I35{}
+public interface I37 : I36{}
+public interface I38 : I37{}
+public interface I39 : I38{}
+public interface I40 : I39{}
+public interface I41 : I40{}
+public interface I42 : I41{}
+public interface I43 : I42{}
+public interface I44 : I43{}
+public interface I45 : I44{}
+public interface I46 : I45{}
+public interface I47 : I46{}
+public interface I48 : I47{}
+public interface I49 : I48{}
+public interface I50 : I49{}
+public interface I51 : I50{}
+public interface I52 : I51{}
+public interface I53 : I52{}
+public interface I54 : I53{}
+public interface I55 : I54{}
+public interface I56 : I55{}
+public interface I57 : I56{}
+public interface I58 : I57{}
+public interface I59 : I58{}
+public interface I60 : I59{}
+public interface I61 : I60{}
+public interface I62 : I61{}
+public interface I63 : I62{}
+public interface I64 : I63{}
+public interface I65 : I64{}
+public interface I66 : I65{}
+public interface I67 : I66{}
+public interface I68 : I67{}
+public interface I69 : I68{}
+public interface I70 : I69{}
+public interface I71 : I70{}
+public interface I72 : I71{}
+public interface I73 : I72{}
+public interface I74 : I73{}
+public interface I75 : I74{}
+public interface I76 : I75{}
+public interface I77 : I76{}
+public interface I78 : I77{}
+public interface I79 : I78{}
+public interface I80 : I79{}
+public interface I81 : I80{}
+public interface I82 : I81{}
+public interface I83 : I82{}
+public interface I84 : I83{}
+public interface I85 : I84{}
+public interface I86 : I85{}
+public interface I87 : I86{}
+public interface I88 : I87{}
+public interface I89 : I88{}
+public interface I90 : I89{}
+public interface I91 : I90{}
+public interface I92 : I91{}
+public interface I93 : I92{}
+public interface I94 : I93{}
+public interface I95 : I94{}
+public interface I96 : I95{}
+public interface I97 : I96{}
+public interface I98 : I97{}
+public interface I99 : I98{}
+public interface I100 : I99{}
diff --git a/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.csproj b/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.csproj
new file mode 100644
index 0000000000..9976da00e8
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/General/ManyGenConstraints.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>ManyGenConstraints</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="ManyGenConstraints.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/General/app.config b/tests/src/Loader/classloader/generics/Constraints/General/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/General/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/General/project.json b/tests/src/Loader/classloader/generics/Constraints/General/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/General/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.cs b/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.cs
new file mode 100644
index 0000000000..8d6be3fecf
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.cs
@@ -0,0 +1,198 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// this test case contains various types with recursive constraints
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Text;
+
+
+// Test 1: Base class with recursive constraint, derived class
+public class Test1
+{
+ public class Base<T> where T: Base<T>
+ {
+ public List<Base<T>> selfList = new List<Base<T>>();
+ }
+
+
+ public class Derived : Base<Derived> {}
+
+ public static void Test()
+ {
+ Derived d = new Derived();
+ Base<Derived> bd = d;
+ }
+}
+
+// Test 2: Base interface with recursive constraint, derived class
+public class Test2
+{
+ public interface I<T> where T: I<T>{}
+
+ public class Derived : I<Derived> {}
+
+ public static void Test()
+ {
+ Derived d = new Derived();
+ I<Derived> id = d;
+ }
+}
+
+// Test 3: Base interface with recursive constraint, derived struct
+public class Test3
+{
+ public interface I<T> where T: I<T>{}
+
+ public struct Derived : I<Derived> {}
+
+ public static void Test()
+ {
+ #pragma warning disable 219
+ Derived d = new Derived();
+ I<Derived> id = d;
+ #pragma warning restore 219
+ }
+}
+
+
+// Test 4: Base class with recursive constraint, derived generic class
+public class Test4
+{
+ public class Base<T> where T: Base<T>
+ {
+ public List<Base<T>> selfList = new List<Base<T>>();
+ }
+
+
+ public class Derived<T> : Base<Derived<T>> {}
+
+ public static void Test()
+ {
+ Derived<Derived<int>> d = new Derived<Derived<int>>();
+ Base<Derived<Derived<int>>> bdi = d;
+ }
+}
+
+
+// Test 5: Base interface with recursive constraint, derived generic class
+public class Test5
+{
+ public interface I<T> where T: I<T>{}
+
+ public class Derived<T> : I<Derived<T>> {}
+
+ public static void Test()
+ {
+ Derived<Derived<int>> d = new Derived<Derived<int>>();
+ I<Derived<Derived<int>>> idi = d;
+ }
+}
+
+// Test 6: Base interface with recursive constraint, derived generic struct
+public class Test6
+{
+ public interface I<T> where T: I<T>{}
+
+ public struct Derived<T> : I<Derived<T>> {}
+
+ public static void Test()
+ {
+ #pragma warning disable 219
+ Derived<Derived<int>> d = new Derived<Derived<int>>();
+ I<Derived<Derived<int>>> idi = d;
+ #pragma warning restore 219
+ }
+}
+
+
+// Test 7: Base interface with recursive constraint, derived generic interface, derived generic class
+public class Test7
+{
+ public interface I1<T> where T: I1<T>{}
+
+ public interface I2<T>{}
+
+ public class Derived<T> : I2<Derived<T>> {}
+
+ public static void Test()
+ {
+ Derived<Derived<int>> d = new Derived<Derived<int>>();
+ I2<Derived<Derived<int>>> idi = d;
+ }
+}
+
+// Test 8: Base interface with recursive constraint, derived generic interface, derived generic struct
+public class Test8
+{
+ public interface I1<T> where T: I1<T>{}
+
+ public interface I2<T>{}
+
+ public struct Derived<T> : I2<Derived<T>> {}
+
+ public static void Test()
+ {
+ #pragma warning disable 219
+ Derived<Derived<int>> d = new Derived<Derived<int>>();
+ I2<Derived<Derived<int>>> idi = d;
+ #pragma warning restore 219
+ }
+}
+
+
+class RecursiveConstraints
+{
+ static bool pass;
+
+ delegate void Case();
+
+ static void Check(Case mytest, string testName)
+ {
+
+ Console.Write(testName);
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("PASS");
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+ static int Main()
+ {
+ pass = true;
+
+ Check(new Case(Test1.Test), "Test 1: Base class with recursive constraint, derived class : ");
+ Check(new Case(Test2.Test), "Test 2: Base interface with recursive constraint, derived class : ");
+ Check(new Case(Test3.Test), "Test 3: Base interface with recursive constraint, derived struct : ");
+ Check(new Case(Test4.Test), "Test 4: Base class with recursive constraint, derived generic class : ");
+ Check(new Case(Test5.Test), "Test 5: Base interface with recursive constraint, derived generic class : ");
+ Check(new Case(Test6.Test), "Test 6: Base interface with recursive constraint, derived generic struct : ");
+ Check(new Case(Test7.Test), "Test 7: Base interface with recursive constraint, derived generic interface, derived generic class : ");
+ Check(new Case(Test8.Test), "Test 8: Base interface with recursive constraint, derived generic interface, derived generic struct : ");
+
+ if (pass)
+ {
+ Console.WriteLine("All tests passed");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.csproj b/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.csproj
new file mode 100644
index 0000000000..819d134222
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Recursion/RecursiveConstraints.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>RecursiveConstraints</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="RecursiveConstraints.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Recursion/app.config b/tests/src/Loader/classloader/generics/Constraints/Recursion/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Recursion/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Recursion/project.json b/tests/src/Loader/classloader/generics/Constraints/Recursion/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Recursion/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.cs b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.cs
new file mode 100644
index 0000000000..ab51ff89be
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.cs
@@ -0,0 +1,132 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// this test is regression test for VSW 532403.
+// the first test is directly from the bug. The rest of the tests were
+// added to add better coverage for this area where base type has a special
+// constraint and the child has recursion in inheritance.
+
+using System;
+
+public class Test1
+{
+ public class Base<T> where T : new()
+ {
+ }
+ public class Derived<T> : Base<Derived<T>>
+ {
+ }
+
+ public static void Test()
+ {
+ Derived<int> m = new Derived<int>();
+ Base<Derived<int>> m2 = new Derived<int>();
+ }
+}
+
+public class Test2
+{
+ public class Base<T> where T : class
+ {
+ }
+ public class Derived<T> : Base<Derived<T>>
+ {
+ }
+
+ public static void Test()
+ {
+ Derived<int> m = new Derived<int>();
+ Base<Derived<int>> m2 = new Derived<int>();
+ }
+}
+
+public class Test3
+{
+ public interface Base<T> where T : struct
+ {
+ }
+ public struct Derived<T> : Base<Derived<T>>
+ {
+ }
+
+ public static void Test()
+ {
+ #pragma warning disable 219
+ Derived<int> m = new Derived<int>();
+ Base<Derived<int>> m2 = new Derived<int>();
+ #pragma warning restore 219
+ }
+}
+
+public class Test4
+{
+ public class Base<T> where T : class, new()
+ {
+ }
+ public class Derived<T> : Base<Derived<T>>
+ {
+ }
+
+ public static void Test()
+ {
+ Derived<int> m = new Derived<int>();
+ Base<Derived<int>> m2 = new Derived<int>();
+ }
+}
+
+
+
+
+public class RunTests
+{
+
+ static bool pass;
+
+ delegate void Case();
+
+ static void Check(Case mytest, string testName)
+ {
+
+ Console.Write(testName);
+
+ try
+ {
+ mytest();
+
+ Console.WriteLine("PASS");
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAIL: Caught unexpected exception: " + e);
+ pass = false;
+ }
+
+ }
+
+ public static int Main()
+ {
+ pass = true;
+
+ Check(new Case(Test1.Test), "Test 1: Base class with new() constraint : ");
+ Check(new Case(Test2.Test), "Test 2: Base class with class constraint : ");
+ Check(new Case(Test3.Test), "Test 3: Base class with struct constraint : ");
+ Check(new Case(Test4.Test), "Test 4: Base class with class and new() constraints : ");
+
+
+
+ if (pass)
+ {
+ Console.WriteLine("All tests passed");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+
+ }
+}
+
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.csproj b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.csproj
new file mode 100644
index 0000000000..16e91e6995
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/VSW532403.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>VSW532403</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="VSW532403.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/app.config b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/project.json b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/532403/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/app.config b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.cs b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.cs
new file mode 100644
index 0000000000..aefde9b58c
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.cs
@@ -0,0 +1,30 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+
+class TestClass
+{
+ public static void N<U,V>() where U : V { }
+
+ public static void M<U,V>() where U : V
+ {
+ N<U,U>();
+ }
+
+ public static int Main()
+ {
+ try {
+ M<object,object>();
+ Console.WriteLine("PASS");
+ return 100;
+ } catch (Exception e)
+ {
+ Console.WriteLine("CATCH UNEXPECTED EXCEPTION: " + e.ToString());
+ Console.WriteLine("FAIL");
+ return 99;
+ }
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.csproj b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.csproj
new file mode 100644
index 0000000000..fede291648
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/bug62403.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>bug62403</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="bug62403.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/project.json b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/ddb62403/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/app.config b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.cs b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.cs
new file mode 100644
index 0000000000..6b87e6e901
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.cs
@@ -0,0 +1,188 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//Dev10 bug #512868: Invalid context used for generic types during constraint verification leads to BadImageFormatException
+
+using System;
+
+
+public class GenericNode
+{
+ public GenericNode()
+ {
+ }
+}
+
+public interface IFactory<TNode>
+ where TNode : GenericNode
+{
+}
+
+public static class FactoryGenerator<TNode>
+ where TNode : GenericNode
+{
+ public static IFactory<TNode> Instance
+ {
+ get { return null; }
+ }
+}
+
+public class ItemX : InternalItemServices<ContainerX, ItemX>
+{
+ public ItemX()
+ : base()
+ {
+ }
+}
+
+public class ContainerX : InternalContainerServices<ContainerX, ItemX>
+{
+ public ContainerX()
+ : base()
+ {
+ }
+}
+
+public abstract class InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem>
+ where TContainer : GenericNode
+ where TItem : InternalItemServices<TContainer, TItem>
+{
+ protected InternalItemServices()
+ : base(FactoryGenerator<TContainer>.Instance, FactoryGenerator<TItem>.Instance)
+ {
+
+ }
+}
+
+public abstract class ExternalItemServices<TContainer, TItem> : GenericNode
+ where TContainer : GenericNode
+ where TItem : GenericNode
+{
+ protected ExternalItemServices(IFactory<TContainer> containerFactory, IFactory<TItem> itemFactory)
+ : base()
+ {
+ }
+}
+
+public abstract class ExternalContainerServices<TContainer, TItem> : GenericNode
+ where TContainer : GenericNode
+ where TItem : ExternalItemServices<TContainer, TItem>
+{
+ protected ExternalContainerServices(IFactory<TItem> itemFactory)
+ : base()
+ {
+ }
+}
+public abstract class InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem>
+ where TContainer : GenericNode
+ where TItem : ExternalItemServices<TContainer, TItem>
+{
+ protected InternalContainerServices()
+ : base(FactoryGenerator<TItem>.Instance)
+ {
+ }
+}
+
+class Test
+{
+ static int Main(string[] args)
+ {
+ ItemX treeItem = new ItemX();
+
+ Console.WriteLine("Pass");
+ return 100;
+ }
+}
+
+
+// The inheritance relationships here are a little hard to follow, however
+// they are valid and in fact map to conceivable usage models.
+//
+// Consider a tree structure with the following properties:
+//
+// - All tree elements derive from a GenericNode type.
+//
+// - The fundamental tree element is an `item'. The children of an item can
+// be other items or containers.
+//
+// - The children of `containers' can only be items, which can in turn have
+// additional children of item or container type.
+//
+// Say that each tree instance is built using exactly one item type and
+// exactly one corresponding container type. This means the tree structure is
+// parameterized on the <container, item> pair.
+//
+// The hierarchy shape in this testcase could be used to provide services for
+// a <ContainerX, ItemX> instance of the tree.
+// ------------
+//
+// // Generates objects of type TNode.
+// IFactory<TNode>
+// where TNode: GenericNode
+//
+//
+// // Static class exposing a property returning a factory interface for a
+// // specific GenericNode subtype.
+// FactoryGenerator<TNode>
+// where TNode: GenericNode
+//
+// IFactory<TNode> Factory { get; }
+//
+//
+// // Implements this item, inheriting base types parameterized on an arbitrary
+// // <container, item> pair that implement common operations that can be applied
+// // to the specified item in the context of that pair.
+// ItemX : InternalItemServices<ContainerX, ItemX>
+//
+// // Implements one level of item services. The item type is constrained to
+// // be a subclass of this type. This might be useful for various reasons
+// // (e.g., so that routines here can access private InternalItemServices
+// // members in any TItem objects that are passed in).
+// InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem>
+// where TContainer: GenericNode
+// where TItem: InternalItemServices<TContainer, TItem> (i.e., is the type of a subclass)
+//
+// // Pass factories to the base class for both the container and item
+// // types.
+// .ctor() : base(FactoryGenerator<TContainer>.Factory, FactoryGenerator<TItem>.Factory)
+//
+// // Implements the next level of item services, leveraging container
+// // and item factories passed to the .ctor (perhaps to generate child
+// // nodes).
+// ExternalItemServices<TContainer, TItem> : GenericNode
+// where TContainer: GenericNode
+// where TItem: GenericNode
+//
+// .ctor(IFactory<TContainer> useToBuildChildContainers,
+// IFactory<TItem> useToBuildChildItems)
+//
+//
+// // Implements this container, inheriting base types parameterized on an arbitrary
+// // <container, item> pair that implement common operations that can be applied
+// // to the specified container in the context of that pair.
+// ContainerX : InternalContainerServices<ContainerX, ItemX>
+//
+// // Implements one level of container services. The item type is
+// // constrained in a manner forcing it to in fact be an item type that
+// // includes the common item services supplied for this <container, item>
+// // pair.
+// InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem>
+// where TContainer: GenericNode
+// where TItem: ExternalItemServices<TContainer, TItem>
+//
+// // Pass an item factory to the base class.
+// .ctor() : base(FactoryGenerator<TItem>.Factory)
+//
+// // Implements the next level of container services, leveraging an item
+// // factory passed to the .ctor (perhaps to generate child nodes).
+// //
+// // The item type is again constrained in a manner forcing it to in
+// // fact be an item type that includes the common item services
+// // supplied for this <container, item> pair.
+// ExternalContainerServices<TContainer, TItem> : GenericNode
+// where TContainer: GenericNode
+// where TItem: ExternalItemServices<TContainer, TItem>
+//
+// .ctor(IFactory<TItem> useToBuildChildItems)
+//
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.csproj b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.csproj
new file mode 100644
index 0000000000..325527c1d7
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>dev10_512868</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="dev10_512868.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/project.json b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/dev10_512868/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/app.config b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/app.config
new file mode 100644
index 0000000000..e5622f77ad
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/app.config
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/project.json b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/project.json
new file mode 100644
index 0000000000..a2e84dc340
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.cs b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.cs
new file mode 100644
index 0000000000..52dc583df6
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.cs
@@ -0,0 +1,37 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace ConsoleApplication3
+{
+ class Program
+ {
+ static int Main(string[] args)
+ {
+ try{
+ Repro<Program>(null);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Console.WriteLine("FAIL");
+ return 99;
+ }
+ Console.WriteLine("PASS");
+ return 100;
+ }
+
+ static void Repro<T>(B<T> b)
+ where T : Program
+ {
+ }
+
+ }
+
+ class A<T> { }
+ class B<T> where T : class { }
+}
diff --git a/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.csproj b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.csproj
new file mode 100644
index 0000000000..ac3d96b95f
--- /dev/null
+++ b/tests/src/Loader/classloader/generics/Constraints/Regressions/vsw609874/vsw609874.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>vsw609874</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="vsw609874.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>