public static object GetUninitializedObject(Type type) { #if COREFX return(ProfilerInterceptor.GetUninitializedObjectImpl(type)); #else if (typeof(ContextBoundObject).IsAssignableFrom(type)) { throw new MockException("Cannot mock constructors of ContextBoundObject descendants."); } if (type == typeof(string)) { return(string.Empty); } return(FormatterServices.GetUninitializedObject(type)); #endif }
public static object TryGetUninitializedObject(Type type) { #if COREFX return(ProfilerInterceptor.GetUninitializedObjectImpl(type)); #else if (typeof(ContextBoundObject).IsAssignableFrom(type) || type.IsAbstract || type.IsInterface) { return(null); } if (type == typeof(string)) { return(string.Empty); } return(FormatterServices.GetUninitializedObject(type)); #endif }