|
Bugzilla – Full Text Bug Listing |
| Summary: | struct constraint should result in default ctor and ValueType base type constraint | ||
|---|---|---|---|
| Product: | [Mono] Mono: Compilers | Reporter: | Gert Driesen <gert.driesen> |
| Component: | C# | Assignee: | Marek Safar <msafar> |
| Status: | RESOLVED FIXED | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | alp, atsushieno |
| Version: | SVN | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
*** Bug 413414 has been marked as a duplicate of this bug. *** *** Bug 324740 has been marked as a duplicate of this bug. *** *** Bug 324741 has been marked as a duplicate of this bug. *** *** Bug 324072 has been marked as a duplicate of this bug. *** *** Bug 324703 has been marked as a duplicate of this bug. *** Fixed in SVN. |
To match csc, using struct as constraint for a generic type argument should implicitly also set the DefaultConstructorConstraint and set System.ValueType as type constraint. To reproduce, compile and run the following code: using System; using System.Reflection; class Program { static int Main () { Type type = typeof (Foo<>); Type [] gargs = type.GetGenericArguments (); if (gargs == null || gargs.Length != 1) { Console.WriteLine ("#1"); return 1; } Type garg = gargs [0]; Type [] csts = garg.GetGenericParameterConstraints (); if (garg.Name != "T") { Console.WriteLine ("#2: " + garg.Name); return 2; } if (garg.GenericParameterAttributes != (GenericParameterAttributes.DefaultConstructorConstraint | GenericParameterAttributes.NotNullableValueTypeConstraint)) { Console.WriteLine ("#3: " + garg.GenericParameterAttributes); return 3; } if (csts == null || csts.Length != 1) { Console.WriteLine ("#4"); return 4; } if (csts [0] != typeof (ValueType)) { Console.WriteLine ("#5: " + csts [0].FullName); return 5; } return 0; } } struct Foo<T> where T : struct { } Actual result: #3: NotNullableValueTypeConstraint and exit code 3. Expected result: No output and exit code 0.