diff --git a/src/core/Microsoft.Scripting/Hosting/CompiledCode.cs b/src/core/Microsoft.Scripting/Hosting/CompiledCode.cs
index 63331493..1f17d98c 100644
--- a/src/core/Microsoft.Scripting/Hosting/CompiledCode.cs
+++ b/src/core/Microsoft.Scripting/Hosting/CompiledCode.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+#nullable enable
+
#if FEATURE_REMOTING
using System.Runtime.Remoting;
#else
@@ -9,6 +11,7 @@
#endif
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.Scripting.Utils;
@@ -19,7 +22,7 @@ namespace Microsoft.Scripting.Hosting {
/// Hosting API counterpart for .
///
public sealed class CompiledCode : MarshalByRefObject {
- private ScriptScope _defaultScope;
+ private ScriptScope? _defaultScope;
internal ScriptCode ScriptCode { get; }
@@ -44,21 +47,21 @@ public ScriptScope DefaultScope {
if (_defaultScope is null) {
Interlocked.CompareExchange(ref _defaultScope, new ScriptScope(Engine, ScriptCode.CreateScope()), null);
}
- return _defaultScope;
+ return _defaultScope;
}
}
///
/// Executes code in a default scope.
///
- public dynamic Execute() {
+ public dynamic? Execute() {
return ScriptCode.Run(DefaultScope.Scope);
}
///
/// Execute code within a given scope and returns the result.
///
- public dynamic Execute(ScriptScope scope) {
+ public dynamic? Execute(ScriptScope scope) {
ContractUtils.RequiresNotNull(scope, nameof(scope));
return ScriptCode.Run(scope.Scope);
}
@@ -66,51 +69,53 @@ public dynamic Execute(ScriptScope scope) {
///
/// Executes code in in a default scope and converts to a given type.
///
+ [return: MaybeNull]
public T Execute() {
- return Engine.Operations.ConvertTo((object)Execute());
+ return Engine.Operations.ConvertTo((object?)Execute());
}
///
/// Execute code within a given scope and converts result to a given type.
///
+ [return: MaybeNull]
public T Execute(ScriptScope scope) {
- return Engine.Operations.ConvertTo((object)Execute(scope));
+ return Engine.Operations.ConvertTo((object?)Execute(scope));
}
#if FEATURE_REMOTING
///
/// Executes the code in an empty scope.
- /// Returns an ObjectHandle wrapping the resulting value of running the code.
+ /// Returns an ObjectHandle wrapping the resulting value of running the code.
///
public ObjectHandle ExecuteAndWrap() {
- return new ObjectHandle((object)Execute());
+ return new ObjectHandle((object?)Execute());
}
///
/// Executes the code in the specified scope.
- /// Returns an ObjectHandle wrapping the resulting value of running the code.
+ /// Returns an ObjectHandle wrapping the resulting value of running the code.
///
public ObjectHandle ExecuteAndWrap(ScriptScope scope) {
- return new ObjectHandle((object)Execute(scope));
+ return new ObjectHandle((object?)Execute(scope));
}
///
/// Executes the code in an empty scope.
- /// Returns an ObjectHandle wrapping the resulting value of running the code.
- ///
+ /// Returns an ObjectHandle wrapping the resulting value of running the code.
+ ///
/// If an exception is thrown the exception is caught and an ObjectHandle to
/// the exception is provided.
///
///
- /// Use this API to handle non-serializable exceptions (exceptions might not be serializable due to security restrictions)
+ /// Use this API to handle non-serializable exceptions (exceptions might not be serializable due to security restrictions)
/// or if an exception serialization loses information.
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public ObjectHandle ExecuteAndWrap(out ObjectHandle exception) {
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public ObjectHandle? ExecuteAndWrap(out ObjectHandle? exception) {
exception = null;
try {
- return new ObjectHandle((object)Execute());
+ return new ObjectHandle((object?)Execute());
} catch (Exception e) {
exception = new ObjectHandle(e);
return null;
@@ -119,28 +124,27 @@ public ObjectHandle ExecuteAndWrap(out ObjectHandle exception) {
///
/// Executes the expression in the specified scope and return a result.
- /// Returns an ObjectHandle wrapping the resulting value of running the code.
- ///
+ /// Returns an ObjectHandle wrapping the resulting value of running the code.
+ ///
/// If an exception is thrown the exception is caught and an ObjectHandle to
/// the exception is provided.
///
///
- /// Use this API to handle non-serializable exceptions (exceptions might not be serializable due to security restrictions)
+ /// Use this API to handle non-serializable exceptions (exceptions might not be serializable due to security restrictions)
/// or if an exception serialization loses information.
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public ObjectHandle ExecuteAndWrap(ScriptScope scope, out ObjectHandle exception) {
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public ObjectHandle? ExecuteAndWrap(ScriptScope scope, out ObjectHandle? exception) {
exception = null;
try{
- return new ObjectHandle((object)Execute(scope));
+ return new ObjectHandle((object?)Execute(scope));
} catch (Exception e) {
exception = new ObjectHandle(e);
return null;
}
}
- // TODO: Figure out what is the right lifetime
- public override object InitializeLifetimeService() {
+ public override object? InitializeLifetimeService() {
return null;
}
#endif
diff --git a/src/core/Microsoft.Scripting/Hosting/Configuration/LanguageElementCollection.cs b/src/core/Microsoft.Scripting/Hosting/Configuration/LanguageElementCollection.cs
index 71610005..1a9abf77 100644
--- a/src/core/Microsoft.Scripting/Hosting/Configuration/LanguageElementCollection.cs
+++ b/src/core/Microsoft.Scripting/Hosting/Configuration/LanguageElementCollection.cs
@@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
-#if FEATURE_CONFIGURATION
-
#nullable enable
+#if FEATURE_CONFIGURATION
+
using System.Configuration;
namespace Microsoft.Scripting.Hosting.Configuration {
diff --git a/src/core/Microsoft.Scripting/Hosting/Configuration/OptionElementCollection.cs b/src/core/Microsoft.Scripting/Hosting/Configuration/OptionElementCollection.cs
index 9421c8a3..363bdbd6 100644
--- a/src/core/Microsoft.Scripting/Hosting/Configuration/OptionElementCollection.cs
+++ b/src/core/Microsoft.Scripting/Hosting/Configuration/OptionElementCollection.cs
@@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
-#if FEATURE_CONFIGURATION
-
#nullable enable
+#if FEATURE_CONFIGURATION
+
using System.Configuration;
namespace Microsoft.Scripting.Hosting.Configuration {
diff --git a/src/core/Microsoft.Scripting/Hosting/Configuration/Section.cs b/src/core/Microsoft.Scripting/Hosting/Configuration/Section.cs
index 24627df4..40c37c9c 100644
--- a/src/core/Microsoft.Scripting/Hosting/Configuration/Section.cs
+++ b/src/core/Microsoft.Scripting/Hosting/Configuration/Section.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+#nullable enable
+
#if FEATURE_CONFIGURATION
using System;
@@ -83,7 +85,7 @@ public IEnumerable GetOptions() {
}
}
- private static Section LoadFromFile(Stream configFileStream) {
+ private static Section? LoadFromFile(Stream configFileStream) {
var result = new Section();
using (var reader = XmlReader.Create(configFileStream)) {
if (reader.ReadToDescendant("configuration") && reader.ReadToDescendant(SectionName)) {
@@ -95,7 +97,7 @@ private static Section LoadFromFile(Stream configFileStream) {
return result;
}
- internal static void LoadRuntimeSetup(ScriptRuntimeSetup setup, Stream configFileStream) {
+ internal static void LoadRuntimeSetup(ScriptRuntimeSetup setup, Stream? configFileStream) {
var config = configFileStream is not null
? LoadFromFile(configFileStream)
: System.Configuration.ConfigurationManager.GetSection(SectionName) as Section;
@@ -112,10 +114,10 @@ internal static void LoadRuntimeSetup(ScriptRuntimeSetup setup, Stream configFil
}
foreach (var languageConfig in config.GetLanguages()) {
- var provider = languageConfig.Type;
- var names = languageConfig.GetNamesArray();
- var extensions = languageConfig.GetExtensionsArray();
- var displayName = languageConfig.DisplayName ?? ((names.Length > 0) ? names[0] : languageConfig.Type);
+ string provider = languageConfig.Type ?? "";
+ string[] names = languageConfig.GetNamesArray();
+ string[] extensions = languageConfig.GetExtensionsArray();
+ string displayName = languageConfig.DisplayName ?? ((names.Length > 0) ? names[0] : provider);
// Honor the latest-wins behavior of the tag for options that were already included in the setup object;
// Keep the options though.
diff --git a/src/core/Microsoft.Scripting/Hosting/DocumentationOperations.cs b/src/core/Microsoft.Scripting/Hosting/DocumentationOperations.cs
index 626abdb8..c52f93e2 100644
--- a/src/core/Microsoft.Scripting/Hosting/DocumentationOperations.cs
+++ b/src/core/Microsoft.Scripting/Hosting/DocumentationOperations.cs
@@ -56,8 +56,8 @@ public ICollection GetOverloads(ObjectHandle value) {
}
// TODO: Figure out what is the right lifetime
- public override object InitializeLifetimeService() {
- return base.InitializeLifetimeService();
+ public override object? InitializeLifetimeService() {
+ return null;
}
#endif
}
diff --git a/src/core/Microsoft.Scripting/Hosting/ErrorListener.cs b/src/core/Microsoft.Scripting/Hosting/ErrorListener.cs
index e97d1bba..1045d022 100644
--- a/src/core/Microsoft.Scripting/Hosting/ErrorListener.cs
+++ b/src/core/Microsoft.Scripting/Hosting/ErrorListener.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+#nullable enable
+
using System;
#if FEATURE_REMOTING
@@ -27,8 +29,7 @@ internal void ReportError(ScriptSource source, string message, in SourceSpan spa
public abstract void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity);
#if FEATURE_REMOTING
- // TODO: Figure out what is the right lifetime
- public override object InitializeLifetimeService() {
+ public override object? InitializeLifetimeService() {
return null;
}
#endif
diff --git a/src/core/Microsoft.Scripting/Hosting/ErrorListenerProxy.cs b/src/core/Microsoft.Scripting/Hosting/ErrorListenerProxy.cs
index 925a0ad7..e2d02bf1 100644
--- a/src/core/Microsoft.Scripting/Hosting/ErrorListenerProxy.cs
+++ b/src/core/Microsoft.Scripting/Hosting/ErrorListenerProxy.cs
@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+#nullable enable
+
namespace Microsoft.Scripting.Hosting {
///
- /// Bridges ErrorSink and ErrorListener.
+ /// Bridges ErrorSink and ErrorListener.
/// Errors reported by language compilers to ErrorSink are forwarded to the ErrorListener provided by the host.
///
///
@@ -18,10 +20,10 @@ namespace Microsoft.Scripting.Hosting {
/// within the context of compilation unit.
///
internal sealed class ErrorListenerProxySink : ErrorSink {
- private readonly ErrorListener _listener;
+ private readonly ErrorListener? _listener;
private readonly ScriptSource _source;
- public ErrorListenerProxySink(ScriptSource source, ErrorListener listener) {
+ public ErrorListenerProxySink(ScriptSource source, ErrorListener? listener) {
_listener = listener;
_source = source;
}
diff --git a/src/core/Microsoft.Scripting/Hosting/ErrorSinkProxyListener.cs b/src/core/Microsoft.Scripting/Hosting/ErrorSinkProxyListener.cs
index 4bb32e68..4d032c29 100644
--- a/src/core/Microsoft.Scripting/Hosting/ErrorSinkProxyListener.cs
+++ b/src/core/Microsoft.Scripting/Hosting/ErrorSinkProxyListener.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
+#nullable enable
+
namespace Microsoft.Scripting.Hosting {
///
/// Bridges ErrorListener and ErrorSink. It provides the reverse functionality as ErrorSinkProxyListener
@@ -14,11 +16,11 @@ public ErrorSinkProxyListener(ErrorSink errorSink) {
}
public override void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity) {
- // Note that we cannot use "source.SourceUnit" since "source" may be a proxy object, and we will not be able to marshall
+ // Note that we cannot use "source.SourceUnit" since "source" may be a proxy object, and we will not be able to marshall
// "source.SourceUnit" to the current AppDomain
- string code = null;
- string line = null;
+ string? code = null;
+ string? line = null;
try {
code = source.GetCode();
line = source.GetCodeLine(span.Start.Line);
diff --git a/src/core/Microsoft.Scripting/Hosting/ExceptionOperations.cs b/src/core/Microsoft.Scripting/Hosting/ExceptionOperations.cs
index e06c6e34..2d32ebce 100644
--- a/src/core/Microsoft.Scripting/Hosting/ExceptionOperations.cs
+++ b/src/core/Microsoft.Scripting/Hosting/ExceptionOperations.cs
@@ -74,8 +74,8 @@ public IList GetStackFrames(ObjectHandle exception) {
return _context.GetStackFrames(exceptionObj!);
}
- public override object InitializeLifetimeService() {
- return base.InitializeLifetimeService();
+ public override object? InitializeLifetimeService() {
+ return null;
}
#endif
}
diff --git a/src/core/Microsoft.Scripting/Hosting/ObjectOperations.cs b/src/core/Microsoft.Scripting/Hosting/ObjectOperations.cs
index 5f829f79..3284045a 100644
--- a/src/core/Microsoft.Scripting/Hosting/ObjectOperations.cs
+++ b/src/core/Microsoft.Scripting/Hosting/ObjectOperations.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
-using System.Linq.Expressions;
+#nullable enable
#if FEATURE_REMOTING
using System.Runtime.Remoting;
@@ -13,21 +13,26 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq.Expressions;
using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
+using NotNull = Microsoft.Scripting.Runtime.NotNullAttribute;
+
namespace Microsoft.Scripting.Hosting {
///
/// ObjectOperations provide a large catalogue of object operations such as member access, conversions,
/// indexing, and things like addition. There are several introspection and tool support services available
- /// for more advanced hosts.
- ///
+ /// for more advanced hosts.
+ ///
+ ///
/// You get ObjectOperation instances from ScriptEngine, and they are bound to their engines for the semantics
/// of the operations. There is a default instance of ObjectOperations you can share across all uses of the
/// engine. However, very advanced hosts can create new instances.
- ///
+ ///
public sealed class ObjectOperations : MarshalByRefObject {
private readonly DynamicOperations _ops;
@@ -46,42 +51,42 @@ internal ObjectOperations(DynamicOperations ops, ScriptEngine engine) {
#region Local Operations
///
- /// Returns true if the object can be called, false if it cannot.
- ///
+ /// Returns true if the object can be called, false if it cannot.
+ ///
/// Even if an object is callable Call may still fail if an incorrect number of arguments or type of arguments are provided.
///
- public bool IsCallable(object obj) {
+ public bool IsCallable(object? obj) {
return _ops.IsCallable(obj);
}
///
/// Invokes the provided object with the given parameters and returns the result.
- ///
- /// The prefered way of calling objects is to convert the object to a strongly typed delegate
+ ///
+ /// The prefered way of calling objects is to convert the object to a strongly typed delegate
/// using the ConvertTo methods and then invoking that delegate.
///
- public dynamic Invoke(object obj, params object[] parameters) {
+ public dynamic? Invoke(object? obj, params object?[] parameters) {
return _ops.Invoke(obj, parameters);
}
///
/// Invokes a member on the provided object with the given parameters and returns the result.
///
- public dynamic InvokeMember(object obj, string memberName, params object[] parameters) {
+ public dynamic? InvokeMember(object? obj, string memberName, params object?[] parameters) {
return _ops.InvokeMember(obj, memberName, parameters);
}
///
/// Creates a new instance from the provided object using the given parameters, and returns the result.
///
- public dynamic CreateInstance(object obj, params object[] parameters) {
+ public dynamic? CreateInstance(object? obj, params object?[] parameters) {
return _ops.CreateInstance(obj, parameters);
}
///
/// Gets the member name from the object obj. Throws an exception if the member does not exist or is write-only.
///
- public dynamic GetMember(object obj, string name) {
+ public dynamic? GetMember(object? obj, string name) {
return _ops.GetMember(obj, name);
}
@@ -89,36 +94,37 @@ public dynamic GetMember(object obj, string name) {
/// Gets the member name from the object obj and converts it to the type T. Throws an exception if the
/// member does not exist, is write-only, or cannot be converted.
///
- public T GetMember(object obj, string name) {
+ [return: MaybeNull]
+ public T GetMember(object? obj, string name) {
return _ops.GetMember(obj, name);
}
///
- /// Gets the member name from the object obj. Returns true if the member is successfully retrieved and
+ /// Gets the member name from the object obj. Returns true if the member is successfully retrieved and
/// stores the value in the value out param.
///
- public bool TryGetMember(object obj, string name, out object value) {
+ public bool TryGetMember(object? obj, string name, out object? value) {
return _ops.TryGetMember(obj, name, out value);
}
///
/// Returns true if the object has a member named name, false if the member does not exist.
///
- public bool ContainsMember(object obj, string name) {
+ public bool ContainsMember(object? obj, string name) {
return _ops.ContainsMember(obj, name);
}
///
- /// Removes the member name from the object obj.
+ /// Removes the member name from the object obj.
///
- public void RemoveMember(object obj, string name) {
+ public void RemoveMember(object? obj, string name) {
_ops.RemoveMember(obj, name);
}
///
/// Sets the member name on object obj to value.
///
- public void SetMember(object obj, string name, object value) {
+ public void SetMember(object? obj, string name, object? value) {
_ops.SetMember(obj, name, value);
}
@@ -126,14 +132,14 @@ public void SetMember(object obj, string name, object value) {
/// Sets the member name on object obj to value. This overload can be used to avoid
/// boxing and casting of strongly typed members.
///
- public void SetMember(object obj, string name, T value) {
+ public void SetMember(object? obj, string name, T value) {
_ops.SetMember(obj, name, value);
}
///
/// Gets the member name from the object obj. Throws an exception if the member does not exist or is write-only.
///
- public dynamic GetMember(object obj, string name, bool ignoreCase) {
+ public dynamic? GetMember(object? obj, string name, bool ignoreCase) {
return _ops.GetMember(obj, name, ignoreCase);
}
@@ -141,36 +147,37 @@ public dynamic GetMember(object obj, string name, bool ignoreCase) {
/// Gets the member name from the object obj and converts it to the type T. Throws an exception if the
/// member does not exist, is write-only, or cannot be converted.
///
- public T GetMember(object obj, string name, bool ignoreCase) {
+ [return: MaybeNull]
+ public T GetMember(object? obj, string name, bool ignoreCase) {
return _ops.GetMember(obj, name, ignoreCase);
}
///
- /// Gets the member name from the object obj. Returns true if the member is successfully retrieved and
+ /// Gets the member name from the object obj. Returns true if the member is successfully retrieved and
/// stores the value in the value out param.
///
- public bool TryGetMember(object obj, string name, bool ignoreCase, out object value) {
+ public bool TryGetMember(object? obj, string name, bool ignoreCase, out object? value) {
return _ops.TryGetMember(obj, name, ignoreCase, out value);
}
///
/// Returns true if the object has a member named name, false if the member does not exist.
///
- public bool ContainsMember(object obj, string name, bool ignoreCase) {
+ public bool ContainsMember(object? obj, string name, bool ignoreCase) {
return _ops.ContainsMember(obj, name, ignoreCase);
}
///
- /// Removes the member name from the object obj.
+ /// Removes the member name from the object obj.
///
- public void RemoveMember(object obj, string name, bool ignoreCase) {
+ public void RemoveMember(object? obj, string name, bool ignoreCase) {
_ops.RemoveMember(obj, name, ignoreCase);
}
///
/// Sets the member name on object obj to value.
///
- public void SetMember(object obj, string name, object value, bool ignoreCase) {
+ public void SetMember(object? obj, string name, object? value, bool ignoreCase) {
_ops.SetMember(obj, name, value, ignoreCase);
}
@@ -178,23 +185,24 @@ public void SetMember(object obj, string name, object value, bool ignoreCase) {
/// Sets the member name on object obj to value. This overload can be used to avoid
/// boxing and casting of strongly typed members.
///
- public void SetMember(object obj, string name, T value, bool ignoreCase) {
+ public void SetMember(object? obj, string name, T value, bool ignoreCase) {
_ops.SetMember(obj, name, value, ignoreCase);
}
///
- /// Converts the object obj to the type T. The conversion will be explicit or implicit depending on
+ /// Converts the object obj to the type T. The conversion will be explicit or implicit depending on
/// what the langauge prefers.
///
- public T ConvertTo(object obj) {
+ [return: MaybeNull]
+ public T ConvertTo(object? obj) {
return _ops.ConvertTo(obj);
}
///
- /// Converts the object obj to the type type. The conversion will be explicit or implicit depending on
+ /// Converts the object obj to the type type. The conversion will be explicit or implicit depending on
/// what the langauge prefers.
///
- public object ConvertTo(object obj, Type type) {
+ public object? ConvertTo(object? obj, Type type) {
ContractUtils.RequiresNotNull(type, nameof(type));
return _ops.ConvertTo(obj, type);
@@ -202,33 +210,34 @@ public object ConvertTo(object obj, Type type) {
///
/// Converts the object obj to the type T. Returns true if the value can be converted, false if it cannot.
- ///
+ ///
/// The conversion will be explicit or implicit depending on what the langauge prefers.
///
- public bool TryConvertTo(object obj, out T result) {
+ public bool TryConvertTo(object? obj, [MaybeNull] out T result) {
return _ops.TryConvertTo(obj, out result);
}
///
/// Converts the object obj to the type type. Returns true if the value can be converted, false if it cannot.
- ///
+ ///
/// The conversion will be explicit or implicit depending on what the langauge prefers.
///
- public bool TryConvertTo(object obj, Type type, out object result) {
+ public bool TryConvertTo(object? obj, Type type, out object? result) {
return _ops.TryConvertTo(obj, type, out result);
}
///
/// Converts the object obj to the type T including explicit conversions which may lose information.
///
- public T ExplicitConvertTo(object obj) {
+ [return: MaybeNull]
+ public T ExplicitConvertTo(object? obj) {
return _ops.ExplicitConvertTo(obj);
}
///
/// Converts the object obj to the type type including explicit conversions which may lose information.
///
- public object ExplicitConvertTo(object obj, Type type) {
+ public object? ExplicitConvertTo(object? obj, Type type) {
ContractUtils.RequiresNotNull(type, nameof(type));
return _ops.ExplicitConvertTo(obj, type);
@@ -236,19 +245,19 @@ public object ExplicitConvertTo(object obj, Type type) {
///
/// Converts the object obj to the type T including explicit conversions which may lose information.
- ///
+ ///
/// Returns true if the value can be converted, false if it cannot.
///
- public bool TryExplicitConvertTo(object obj, out T result) {
+ public bool TryExplicitConvertTo(object? obj, [MaybeNull] out T result) {
return _ops.TryExplicitConvertTo(obj, out result);
}
///
- /// Converts the object obj to the type type including explicit conversions which may lose information.
- ///
+ /// Converts the object obj to the type type including explicit conversions which may lose information.
+ ///
/// Returns true if the value can be converted, false if it cannot.
///
- public bool TryExplicitConvertTo(object obj, Type type, out object result) {
+ public bool TryExplicitConvertTo(object? obj, Type type, out object? result) {
return _ops.TryExplicitConvertTo(obj, type, out result);
}
@@ -256,14 +265,15 @@ public bool TryExplicitConvertTo(object obj, Type type, out object result) {
///
/// Converts the object obj to the type T including implicit conversions.
///
- public T ImplicitConvertTo(object obj) {
+ [return: MaybeNull]
+ public T ImplicitConvertTo(object? obj) {
return _ops.ImplicitConvertTo(obj);
}
///
/// Converts the object obj to the type type including implicit conversions.
///
- public object ImplicitConvertTo(object obj, Type type) {
+ public object? ImplicitConvertTo(object? obj, Type type) {
ContractUtils.RequiresNotNull(type, nameof(type));
return _ops.ImplicitConvertTo(obj, type);
@@ -271,32 +281,33 @@ public object ImplicitConvertTo(object obj, Type type) {
///
/// Converts the object obj to the type T including implicit conversions.
- ///
+ ///
/// Returns true if the value can be converted, false if it cannot.
///
- public bool TryImplicitConvertTo(object obj, out T result) {
+ public bool TryImplicitConvertTo(object? obj, [MaybeNull] out T result) {
return _ops.TryImplicitConvertTo(obj, out result);
}
///
- /// Converts the object obj to the type type including implicit conversions.
- ///
+ /// Converts the object obj to the type type including implicit conversions.
+ ///
/// Returns true if the value can be converted, false if it cannot.
///
- public bool TryImplicitConvertTo(object obj, Type type, out object result) {
+ public bool TryImplicitConvertTo(object? obj, Type type, out object? result) {
return _ops.TryImplicitConvertTo(obj, type, out result);
}
///
/// Performs a generic unary operation on the specified target and returns the result.
///
- public dynamic DoOperation(ExpressionType operation, object target) {
- return _ops.DoOperation