// object already has the given type code, in which case the object is
// simply returned. Otherwise, the appropriate ToXXX() is invoked on the
// object's implementation of IConvertible.
+ [return: NotNullIfNotNull("value")]
public static object? ChangeType(object? value, TypeCode typeCode)
{
return ChangeType(value, typeCode, CultureInfo.CurrentCulture);
}
+ [return: NotNullIfNotNull("value")]
public static object? ChangeType(object? value, TypeCode typeCode, IFormatProvider? provider)
{
if (value == null && (typeCode == TypeCode.Empty || typeCode == TypeCode.String || typeCode == TypeCode.Object))
throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, value.GetType().FullName, targetType.FullName));
}
+ [return: NotNullIfNotNull("value")]
public static object? ChangeType(object? value, Type conversionType)
{
return ChangeType(value, conversionType, CultureInfo.CurrentCulture);
/// This method takes the given COM object and wraps it in an object
/// of the specified type. The type must be derived from __ComObject.
/// </summary>
+ [return: NotNullIfNotNull("o")]
public static object? CreateWrapperOfType(object? o, Type t)
{
if (t is null)
public static extern double Exchange(ref double location1, double value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [return: NotNullIfNotNull("value")]
+ [return: NotNullIfNotNull("location1")]
public static extern object? Exchange([NotNullIfNotNull("value")] ref object? location1, object? value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// This whole method reduces to a single call to Exchange(ref object, object) but
// the JIT thinks that it will generate more native code than it actually does.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- [return: NotNullIfNotNull("value")]
+ [return: NotNullIfNotNull("location1")]
public static T Exchange<T>([NotNullIfNotNull("value")] ref T location1, T value) where T : class?
{
return Unsafe.As<T>(Exchange(ref Unsafe.As<T, object?>(ref location1), value));