diff --git a/src/TestFramework/TestFramework.Extensions/PrivateObject.cs b/src/TestFramework/TestFramework.Extensions/PrivateObject.cs index c08d88371b..a379f5118d 100644 --- a/src/TestFramework/TestFramework.Extensions/PrivateObject.cs +++ b/src/TestFramework/TestFramework.Extensions/PrivateObject.cs @@ -138,7 +138,9 @@ public PrivateObject(Type type, Type[]? parameterTypes, object?[]? args) o = Activator.CreateInstance(type, ConstructorFlags, null, args, null); } - ConstructFrom(o); + _ = o ?? throw new ArgumentNullException(nameof(o)); + _target = o; + _originalType = o.GetType(); } /// @@ -150,7 +152,8 @@ public PrivateObject(Type type, Type[]? parameterTypes, object?[]? args) public PrivateObject(object obj) { _ = obj ?? throw new ArgumentNullException(nameof(obj)); - ConstructFrom(obj); + _target = obj; + _originalType = obj.GetType(); } /// @@ -742,14 +745,6 @@ private static void ValidateAccessString(string access) } } - [MemberNotNull(nameof(_target), nameof(_originalType))] - private void ConstructFrom(object obj) - { - _ = obj ?? throw new ArgumentNullException(nameof(obj)); - _target = obj; - _originalType = obj.GetType(); - } - private void BuildGenericMethodCacheForType(Type t) { DebugEx.Assert(t != null, "type should not be null."); diff --git a/src/TestFramework/TestFramework.Extensions/Properties/AssemblyInfo.cs b/src/TestFramework/TestFramework.Extensions/Properties/AssemblyInfo.cs index 666afde73e..a21ff9d823 100644 --- a/src/TestFramework/TestFramework.Extensions/Properties/AssemblyInfo.cs +++ b/src/TestFramework/TestFramework.Extensions/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: NeutralResourcesLanguage("en")] -[assembly: CLSCompliant(false)] +[assembly: CLSCompliant(true)] // Version information for an assembly consists of the following four values: //