using System;
class A
{
static void Main()
{
new TypedReference().GetType(); // error CS0029: Cannot implicitly convert type 'System.TypedReference' to 'object'
new TypedReference().ToString(); // error CS0029: Cannot implicitly convert type 'System.TypedReference' to 'System.ValueType'
}
}
ECMA-335 (CLI)
8.2.4 Boxing and unboxing of values
A type is
boxable if it is one of the following:
• A value type (including instantiations of generic value types) that does not contain fields that can point into
the CIL evaluation stack
[Rationale: A value type that does contain such fields cannot be boxed, else those embedded pointers
could outlive the entries in the CIL evaluation stack to which they point; e.g.,
System.RuntimeArgumentHandle, System.TypedReference. Value types that contain such pointers are
informally described as "byref-like" value types. end rationale]
Description
ReSharper cannot detect the following errors:
using System;
class A
{
static void Main()
{
new TypedReference().GetType(); // error CS0029: Cannot implicitly convert type 'System.TypedReference' to 'object'
new TypedReference().ToString(); // error CS0029: Cannot implicitly convert type 'System.TypedReference' to 'System.ValueType'
}
}
ECMA-335 (CLI)
8.2.4 Boxing and unboxing of values
A type is
boxable if it is one of the following:
• A value type (including instantiations of generic value types) that does not contain fields that can point into
the CIL evaluation stack
[Rationale: A value type that does contain such fields cannot be boxed, else those embedded pointers
could outlive the entries in the CIL evaluation stack to which they point; e.g.,
System.RuntimeArgumentHandle, System.TypedReference. Value types that contain such pointers are
informally described as "byref-like" value types. end rationale]